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

Python db.fixed_ip_update函数代码示例

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

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



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

示例1: save

 def save(self, context):
     updates = self.obj_get_changes()
     if 'address' in updates:
         raise exception.ObjectActionError(action='save',
                                           reason='address is not mutable')
     db.fixed_ip_update(context, str(self.address), updates)
     self.obj_reset_changes()
开发者ID:csdhome,项目名称:nova,代码行数:7,代码来源:fixed_ip.py


示例2: 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


示例3: test_instance_dns

    def test_instance_dns(self):
        fixedip = '192.168.0.101'
        self.mox.StubOutWithMock(db, 'network_get')
        self.mox.StubOutWithMock(db, 'network_update')
        self.mox.StubOutWithMock(db, 'fixed_ip_associate_pool')
        self.mox.StubOutWithMock(db, 'instance_get')
        self.mox.StubOutWithMock(db,
                              'virtual_interface_get_by_instance_and_network')
        self.mox.StubOutWithMock(db, 'fixed_ip_update')

        db.fixed_ip_update(mox.IgnoreArg(),
                           mox.IgnoreArg(),
                           mox.IgnoreArg())
        db.virtual_interface_get_by_instance_and_network(mox.IgnoreArg(),
                mox.IgnoreArg(), mox.IgnoreArg()).AndReturn({'id': 0})

        db.instance_get(mox.IgnoreArg(),
                        mox.IgnoreArg()).AndReturn({'security_groups':
                                                             [{'id': 0}]})

        db.instance_get(self.context,
                        1).AndReturn({'display_name': HOST})
        db.fixed_ip_associate_pool(mox.IgnoreArg(),
                                   mox.IgnoreArg(),
                                   mox.IgnoreArg()).AndReturn(fixedip)
        db.network_get(mox.IgnoreArg(),
                       mox.IgnoreArg()).AndReturn(networks[0])
        db.network_update(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg())
        self.mox.ReplayAll()
        self.network.add_fixed_ip_to_instance(self.context, 1, HOST,
                                              networks[0]['id'])
        addresses = self.network.instance_dns_manager.get_entries_by_name(HOST)
        self.assertEqual(len(addresses), 1)
        self.assertEqual(addresses[0], fixedip)
开发者ID:swapniltamse,项目名称:nova,代码行数:34,代码来源:test_network.py


示例4: test_add_fixed_ip_instance_without_vpn_requested_networks

    def test_add_fixed_ip_instance_without_vpn_requested_networks(self):
        self.mox.StubOutWithMock(db, 'network_get')
        self.mox.StubOutWithMock(db, 'fixed_ip_associate_pool')
        self.mox.StubOutWithMock(db, 'instance_get')
        self.mox.StubOutWithMock(db,
                              'virtual_interface_get_by_instance_and_network')
        self.mox.StubOutWithMock(db, 'fixed_ip_update')

        db.fixed_ip_update(mox.IgnoreArg(),
                           mox.IgnoreArg(),
                           mox.IgnoreArg())
        db.virtual_interface_get_by_instance_and_network(mox.IgnoreArg(),
                mox.IgnoreArg(), mox.IgnoreArg()).AndReturn({'id': 0})

        db.instance_get(mox.IgnoreArg(),
                        mox.IgnoreArg()).AndReturn({'security_groups':
                                                             [{'id': 0}]})
        db.fixed_ip_associate_pool(mox.IgnoreArg(),
                                   mox.IgnoreArg(),
                                   mox.IgnoreArg()).AndReturn('192.168.0.101')
        db.network_get(mox.IgnoreArg(),
                       mox.IgnoreArg()).AndReturn(networks[0])
        self.mox.ReplayAll()
        self.network.add_fixed_ip_to_instance(self.context, 1, HOST,
                                              networks[0]['id'])
开发者ID:CaptTofu,项目名称:reddwarf,代码行数:25,代码来源:test_network.py


示例5: test_unreserve

 def test_unreserve(self):
     db.fixed_ip_update(context.get_admin_context(), '10.0.0.100',
                        {'reserved': True})
     self.commands.unreserve('10.0.0.100')
     address = db.fixed_ip_get_by_address(context.get_admin_context(),
                                          '10.0.0.100')
     self.assertEqual(address['reserved'], False)
开发者ID:lovocas,项目名称:nova,代码行数:7,代码来源:test_nova_manage.py


示例6: _set_reserved

    def _set_reserved(self, context, address, reserved):
        try:
            fixed_ip = db.fixed_ip_get_by_address(context, address)
            db.fixed_ip_update(context, fixed_ip["address"], {"reserved": reserved})
        except exception.FixedIpNotFoundForAddress:
            msg = _("Fixed IP %s not found") % address
            raise webob.exc.HTTPNotFound(explanation=msg)

        return webob.exc.HTTPAccepted()
开发者ID:sdague,项目名称:nova,代码行数:9,代码来源:fixed_ips.py


示例7: allocate_fixed_ips

 def allocate_fixed_ips(self, context, tenant_id, quantum_net_id, network_tenant_id, vif_rec):
     """Allocates a single fixed IPv4 address for a virtual interface."""
     admin_context = context.elevated()
     network = db.network_get_by_uuid(admin_context, quantum_net_id)
     address = None
     if network["cidr"]:
         address = db.fixed_ip_associate_pool(admin_context, network["id"], vif_rec["instance_id"])
         values = {"allocated": True, "virtual_interface_id": vif_rec["id"]}
         db.fixed_ip_update(admin_context, address, values)
     return [address]
开发者ID:pknouff,项目名称:nova,代码行数:10,代码来源:nova_ipam_lib.py


示例8: 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


示例9: _set_reserved

    def _set_reserved(self, address, reserved):
        ctxt = context.get_admin_context()

        try:
            fixed_ip = db.fixed_ip_get_by_address(ctxt, address)
            if fixed_ip is None:
                raise exception.NotFound("Could not find address")
            db.fixed_ip_update(ctxt, fixed_ip["address"], {"reserved": reserved})
        except exception.NotFound as ex:
            print _("error: %s") % ex
            return 2
开发者ID:comstud,项目名称:nova,代码行数:11,代码来源:manage.py


示例10: allocate_fixed_ip

 def allocate_fixed_ip(self, context, tenant_id, quantum_net_id, vif_rec):
     """Allocates a single fixed IPv4 address for a virtual interface."""
     admin_context = context.elevated()
     network = db.network_get_by_uuid(admin_context, quantum_net_id)
     if network['cidr']:
         address = db.fixed_ip_associate_pool(admin_context,
                                              network['id'],
                                              vif_rec['instance_id'])
         values = {'allocated': True,
                   'virtual_interface_id': vif_rec['id']}
         db.fixed_ip_update(admin_context, address, values)
开发者ID:AsherBond,项目名称:dodai-compute,代码行数:11,代码来源:nova_ipam_lib.py


示例11: _set_reserved

    def _set_reserved(self, address, reserved):
        ctxt = context.get_admin_context()

        try:
            fixed_ip = db.fixed_ip_get_by_address(ctxt, address)
            if fixed_ip is None:
                raise exception.NotFound('Could not find address')
            db.fixed_ip_update(ctxt, fixed_ip['address'],
                                {'reserved': reserved})
        except exception.NotFound as ex:
            print(_("error: %s") % ex)
            return(2)
开发者ID:RibeiroAna,项目名称:nova,代码行数:12,代码来源:manage.py


示例12: 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


示例13: 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.
     """
     try:
         admin_context = context.elevated()
         fixed_ips = db.fixed_ip_get_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})
     except exception.FixedIpNotFoundForInstance:
         LOG.error(_('No fixed IPs to deallocate for vif %s' %
                         vif_ref['id']))
开发者ID:BillTheBest,项目名称:nova,代码行数:15,代码来源:nova_ipam_lib.py


示例14: test_network_delete_safe

 def test_network_delete_safe(self):
     ctxt = context.get_admin_context()
     values = {"host": "localhost", "project_id": "project1"}
     network = db.network_create_safe(ctxt, values)
     db_network = db.network_get(ctxt, network.id)
     values = {"network_id": network["id"], "address": "fake1"}
     address1 = db.fixed_ip_create(ctxt, values)
     values = {"network_id": network["id"], "address": "fake2", "allocated": True}
     address2 = db.fixed_ip_create(ctxt, values)
     self.assertRaises(exception.NetworkInUse, db.network_delete_safe, ctxt, network["id"])
     db.fixed_ip_update(ctxt, address2, {"allocated": False})
     network = db.network_delete_safe(ctxt, network["id"])
     ctxt = ctxt.elevated(read_deleted="yes")
     fixed_ip = db.fixed_ip_get_by_address(ctxt, address1)
     self.assertTrue(fixed_ip["deleted"])
开发者ID:hiteshwadekar,项目名称:nova,代码行数:15,代码来源:test_db_api.py


示例15: test_vpn_allocate_fixed_ip

    def test_vpn_allocate_fixed_ip(self):
        self.mox.StubOutWithMock(db, "fixed_ip_associate")
        self.mox.StubOutWithMock(db, "fixed_ip_update")
        self.mox.StubOutWithMock(db, "virtual_interface_get_by_instance_and_network")

        db.fixed_ip_associate(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg(), reserved=True).AndReturn("192.168.0.1")
        db.fixed_ip_update(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg())
        db.virtual_interface_get_by_instance_and_network(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(
            {"id": 0}
        )
        self.mox.ReplayAll()

        network = dict(networks[0])
        network["vpn_private_address"] = "192.168.0.2"
        self.network.allocate_fixed_ip(None, 0, network, vpn=True)
开发者ID:rlz,项目名称:osc-build-nova,代码行数:15,代码来源:test_network.py


示例16: 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


示例17: test_allocate_fixed_ip

    def test_allocate_fixed_ip(self):
        self.mox.StubOutWithMock(db, "fixed_ip_associate_pool")
        self.mox.StubOutWithMock(db, "fixed_ip_update")
        self.mox.StubOutWithMock(db, "virtual_interface_get_by_instance_and_network")
        self.mox.StubOutWithMock(db, "instance_get")

        db.instance_get(mox.IgnoreArg(), mox.IgnoreArg()).AndReturn({"security_groups": [{"id": 0}]})
        db.fixed_ip_associate_pool(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg()).AndReturn("192.168.0.1")
        db.fixed_ip_update(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg())
        db.virtual_interface_get_by_instance_and_network(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(
            {"id": 0}
        )
        self.mox.ReplayAll()

        network = dict(networks[0])
        network["vpn_private_address"] = "192.168.0.2"
        self.network.allocate_fixed_ip(self.context, 0, network)
开发者ID:nicoleLiu,项目名称:nova,代码行数:17,代码来源:test_network.py


示例18: test_add_fixed_ip_instance_without_vpn_requested_networks

    def test_add_fixed_ip_instance_without_vpn_requested_networks(self):
        self.mox.StubOutWithMock(db, "network_get")
        self.mox.StubOutWithMock(db, "fixed_ip_associate_pool")
        self.mox.StubOutWithMock(db, "instance_get")
        self.mox.StubOutWithMock(db, "virtual_interface_get_by_instance_and_network")
        self.mox.StubOutWithMock(db, "fixed_ip_update")

        db.fixed_ip_update(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg())
        db.virtual_interface_get_by_instance_and_network(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(
            {"id": 0}
        )

        db.instance_get(mox.IgnoreArg(), mox.IgnoreArg()).AndReturn({"security_groups": [{"id": 0}]})
        db.fixed_ip_associate_pool(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg()).AndReturn("192.168.0.101")
        db.network_get(mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(networks[0])
        self.mox.ReplayAll()
        self.network.add_fixed_ip_to_instance(self.context, 1, HOST, networks[0]["id"])
开发者ID:nicoleLiu,项目名称:nova,代码行数:17,代码来源:test_network.py


示例19: test_network_delete_safe

 def test_network_delete_safe(self):
     ctxt = context.get_admin_context()
     values = {'host': 'localhost', 'project_id': 'project1'}
     network = db.network_create_safe(ctxt, values)
     db_network = db.network_get(ctxt, network.id)
     values = {'network_id': network['id'], 'address': 'fake1'}
     address1 = db.fixed_ip_create(ctxt, values)
     values = {'network_id': network['id'],
               'address': 'fake2',
               'allocated': True}
     address2 = db.fixed_ip_create(ctxt, values)
     self.assertRaises(exception.NetworkInUse,
                       db.network_delete_safe, ctxt, network['id'])
     db.fixed_ip_update(ctxt, address2, {'allocated': False})
     network = db.network_delete_safe(ctxt, network['id'])
     ctxt = ctxt.elevated(read_deleted='yes')
     fixed_ip = db.fixed_ip_get_by_address(ctxt, address1)
     self.assertTrue(fixed_ip['deleted'])
开发者ID:AnyBucket,项目名称:OpenStack-Install-and-Understand-Guide,代码行数:18,代码来源:test_db_api.py


示例20: test_allocate_fixed_ip

    def test_allocate_fixed_ip(self):
        self.mox.StubOutWithMock(db, 'fixed_ip_associate_pool')
        self.mox.StubOutWithMock(db, 'fixed_ip_update')
        self.mox.StubOutWithMock(db,
                              'virtual_interface_get_by_instance_and_network')

        db.fixed_ip_associate_pool(mox.IgnoreArg(),
                                   mox.IgnoreArg(),
                                   mox.IgnoreArg()).AndReturn('192.168.0.1')
        db.fixed_ip_update(mox.IgnoreArg(),
                           mox.IgnoreArg(),
                           mox.IgnoreArg())
        db.virtual_interface_get_by_instance_and_network(mox.IgnoreArg(),
                mox.IgnoreArg(), mox.IgnoreArg()).AndReturn({'id': 0})
        self.mox.ReplayAll()

        network = dict(networks[0])
        network['vpn_private_address'] = '192.168.0.2'
        self.network.allocate_fixed_ip(None, 0, network)
开发者ID:lovocas,项目名称:nova,代码行数:19,代码来源:test_network.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python db.fixed_ips_by_virtual_interface函数代码示例发布时间:2022-05-27
下一篇:
Python db.fixed_ip_get_by_address函数代码示例发布时间: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