• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python db.fixed_ips_by_virtual_interface函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中nova.db.fixed_ips_by_virtual_interface函数的典型用法代码示例。如果您正苦于以下问题:Python fixed_ips_by_virtual_interface函数的具体用法?Python fixed_ips_by_virtual_interface怎么用?Python fixed_ips_by_virtual_interface使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了fixed_ips_by_virtual_interface函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: deallocate_ips_by_vif

 def deallocate_ips_by_vif(self, context, tenant_id, net_id, vif_ref):
     """Deallocate all fixed IPs associated with the specified
        virtual interface.
     """
     admin_context = context.elevated()
     fixed_ips = db.fixed_ips_by_virtual_interface(admin_context,
                                                      vif_ref['id'])
     # NOTE(s0mik): Sets fixed-ip to deallocated, but leaves the entry
     # associated with the instance-id.  This prevents us from handing it
     # out again immediately, as allocating it to a new instance before
     # a DHCP lease has timed-out is bad.  Instead, the fixed-ip will
     # be disassociated with the instance-id by a call to one of two
     # methods inherited from FlatManager:
     # - if DHCP is in use, a lease expiring in dnsmasq triggers
     #   a call to release_fixed_ip in the network manager.
     # - otherwise, _disassociate_stale_fixed_ips is called periodically
     #   to disassociate all fixed ips that are unallocated
     #   but still associated with an instance-id.
     for fixed_ip in fixed_ips:
         db.fixed_ip_update(admin_context, fixed_ip['address'],
                            {'allocated': False,
                             'virtual_interface_id': None})
     if len(fixed_ips) == 0:
         LOG.error(_('No fixed IPs to deallocate for vif %s') %
                   vif_ref['id'])
开发者ID:usc-isi,项目名称:essex-baremetal-support,代码行数:25,代码来源:nova_ipam_lib.py


示例2: _from_bm_node

def _from_bm_node(instance_id, tenant_id):
    LOG.debug('_from_bm_node(instance_id=%s,tenant_id=%s)',
              instance_id, tenant_id)
    ctx = context.get_admin_context()
    info = []
    for vif in db.virtual_interface_get_by_instance(ctx, instance_id):
        LOG.debug('vif=%s', vif.__dict__)
        mac = vif.address
        network_ref = None
        if vif['network_id']:
            network_ref = db.network_get(ctx, vif['network_id'])
        if not network_ref:
            LOG.warn('vif.network is None')
            continue
        LOG.debug('vif.network=%s', network_ref.__dict__)
        network_uuid = network_ref.uuid
        if not network_uuid:
            LOG.warn('network_uuid is None')
            continue
        vifinfo_uuid = _get_vifinfo_uuid(tenant_id, network_uuid, vif.uuid)
        LOG.debug('vifinfo_uuid=%s', vifinfo_uuid)
        if not vifinfo_uuid:
            continue
        fixed_ips = db.fixed_ips_by_virtual_interface(ctx, vif.id)
        if not fixed_ips:
            LOG.warn('fixed_ip is None')
            continue
        addrs = [fip.address for fip in fixed_ips]
        info.append((vifinfo_uuid, network_uuid, mac, addrs))
    LOG.debug('_from_bm_node(instance_id=%s,tenant_id=%s) end: info=%s',
              instance_id, tenant_id, info)
    return info
开发者ID:chinmaynaik,项目名称:nova,代码行数:32,代码来源:firewall2.py


示例3: get_v4_ips_by_interface

 def get_v4_ips_by_interface(self, context, net_id, vif_id, project_id):
     """Returns a list of IPv4 address strings associated with
        the specified virtual interface, based on the fixed_ips table.
     """
     vif_rec = db.virtual_interface_get_by_uuid(context, vif_id)
     fixed_ips = db.fixed_ips_by_virtual_interface(context, vif_rec["id"])
     return [fixed_ip["address"] for fixed_ip in fixed_ips]
开发者ID:bgh,项目名称:nova,代码行数:7,代码来源:nova_ipam_lib.py


示例4: get_v4_ips_by_interface

 def get_v4_ips_by_interface(self, context, net_id, vif_id, project_id):
     """Returns a list of IPv4 address strings associated with
        the specified virtual interface, based on the fixed_ips table.
     """
     # TODO(tr3buchet): link fixed_ips to vif by uuid so only 1 db call
     vif_rec = db.virtual_interface_get_by_uuid(context, vif_id)
     fixed_ips = db.fixed_ips_by_virtual_interface(context,
                                                   vif_rec['id'])
     return [fixed_ip['address'] for fixed_ip in fixed_ips]
开发者ID:A7Zulu,项目名称:nova,代码行数:9,代码来源:nova_ipam_lib.py


示例5: deallocate_ips_by_vif

 def deallocate_ips_by_vif(self, context, tenant_id, net_id, vif_ref):
     """Deallocate all fixed IPs associated with the specified
        virtual interface.
     """
     admin_context = context.elevated()
     fixed_ips = db.fixed_ips_by_virtual_interface(admin_context, vif_ref["id"])
     for fixed_ip in fixed_ips:
         db.fixed_ip_update(admin_context, fixed_ip["address"], {"allocated": False, "virtual_interface_id": None})
     if len(fixed_ips) == 0:
         LOG.error(_("No fixed IPs to deallocate for vif %s" % vif_ref["id"]))
开发者ID:pknouff,项目名称:nova,代码行数:10,代码来源:nova_ipam_lib.py


示例6: deallocate_ips_by_vif

 def deallocate_ips_by_vif(self, context, tenant_id, net_id, vif_ref):
     """Deallocate all fixed IPs associated with the specified
        virtual interface.
     """
     admin_context = context.elevated()
     fixed_ips = db.fixed_ips_by_virtual_interface(admin_context,
                                                      vif_ref['id'])
     for fixed_ip in fixed_ips:
         db.fixed_ip_update(admin_context, fixed_ip['address'],
                            {'allocated': False,
                             'virtual_interface_id': None})
     if len(fixed_ips) == 0:
         LOG.error(_('No fixed IPs to deallocate for vif %s'),
                   vif_ref['id'])
开发者ID:Cygnet,项目名称:nova,代码行数:14,代码来源:nova_ipam_lib.py


示例7: deallocate_ips_by_vif

    def deallocate_ips_by_vif(self, context, tenant_id, net_id, vif_ref):
        """Deallocate all fixed IPs associated with the specified
           virtual interface.
        """
        admin_context = context.elevated()
        fixed_ips = db.fixed_ips_by_virtual_interface(admin_context,
                                                         vif_ref['id'])
        # NOTE(s0mik): Sets fixed-ip to deallocated, but leaves the entry
        # associated with the instance-id.  This prevents us from handing it
        # out again immediately, as allocating it to a new instance before
        # a DHCP lease has timed-out is bad.  Instead, the fixed-ip will
        # be disassociated with the instance-id by a call to one of two
        # methods inherited from FlatManager:
        # - if DHCP is in use, a lease expiring in dnsmasq triggers
        #   a call to release_fixed_ip in the network manager, or it will
        #   be timed out periodically if the lease fails.
        # - otherwise, we release the ip immediately

        read_deleted_context = admin_context.elevated(read_deleted='yes')
        for fixed_ip in fixed_ips:
            fixed_id = fixed_ip['id']
            floating_ips = self.net_manager.db.floating_ip_get_by_fixed_ip_id(
                                admin_context,
                                fixed_id)
            # disassociate floating ips related to fixed_ip
            for floating_ip in floating_ips:
                address = floating_ip['address']
                manager.FloatingIP.disassociate_floating_ip(
                    self.net_manager,
                    read_deleted_context,
                    address,
                    affect_auto_assigned=True)
                # deallocate if auto_assigned
                if floating_ip['auto_assigned']:
                    manager.FloatingIP.deallocate_floating_ip(
                        read_deleted_context,
                        address,
                        affect_auto_assigned=True)
            db.fixed_ip_update(admin_context, fixed_ip['address'],
                               {'allocated': False,
                                'virtual_interface_id': None})
            if not self.net_manager.DHCP:
                db.fixed_ip_disassociate(admin_context, fixed_ip['address'])

        if len(fixed_ips) == 0:
            LOG.error(_('No fixed IPs to deallocate for vif %s'),
                      vif_ref['id'])
开发者ID:A7Zulu,项目名称:nova,代码行数:47,代码来源:nova_ipam_lib.py


示例8: get_by_virtual_interface_id

 def get_by_virtual_interface_id(cls, context, vif_id):
     db_fixedips = db.fixed_ips_by_virtual_interface(context, vif_id)
     return obj_base.obj_make_list(context, cls(context),
                                   objects.FixedIP, db_fixedips)
开发者ID:csdhome,项目名称:nova,代码行数:4,代码来源:fixed_ip.py


示例9: get_by_virtual_interface_id

 def get_by_virtual_interface_id(cls, context, vif_id):
     expected_attrs = ['network', 'floating_ips']
     db_fixedips = db.fixed_ips_by_virtual_interface(context, vif_id)
     return obj_base.obj_make_list(context, cls(context),
                                   objects.FixedIP, db_fixedips,
                                   expected_attrs=expected_attrs)
开发者ID:375670450,项目名称:nova,代码行数:6,代码来源:fixed_ip.py



注:本文中的nova.db.fixed_ips_by_virtual_interface函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python db.flavor_create函数代码示例发布时间:2022-05-27
下一篇:
Python db.fixed_ip_update函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap