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

Python db.flavor_get_by_name函数代码示例

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

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



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

示例1: _sync_flavor

 def _sync_flavor(self, ctx, flavor, extra_specs):
     """
     Insert the flavor with extra specs if not in local database
     """
     flavor_name = self.prefix + flavor.name
     try:
         db.flavor_get_by_name(ctx, flavor_name)
     except exception.FlavorNotFoundByName:
         self._insert_pvc_flavor_extraspecs(ctx, flavor, extra_specs)
开发者ID:gpanda,项目名称:powervc-driver,代码行数:9,代码来源:flavorsync.py


示例2: test_instance_type_get_by_name_with_extra_specs

 def test_instance_type_get_by_name_with_extra_specs(self):
     instance_type = db.flavor_get_by_name(
                         self.context,
                         "cg1.4xlarge")
     self.assertEqual(instance_type['extra_specs'],
                      self.specs)
     instance_type = db.flavor_get_by_name(
                         self.context,
                         "m1.small")
     self.assertEqual(instance_type['extra_specs'], {})
开发者ID:dlq84,项目名称:nova,代码行数:10,代码来源:test_instance_types_extra_specs.py


示例3: test_instance_type_get_by_name_with_extra_specs

    def test_instance_type_get_by_name_with_extra_specs(self):
        instance_type = db.flavor_get_by_name(
                            self.context,
                            "cg1.4xlarge")
        self.assertEquals(instance_type['extra_specs'],
                          dict(cpu_arch="x86_64",
                               cpu_model="Nehalem",
                               xpu_arch="fermi",
                               xpus="2",
                               xpu_model="Tesla 2050"))

        instance_type = db.flavor_get_by_name(
                            self.context,
                            "m1.small")
        self.assertEquals(instance_type['extra_specs'], {})
开发者ID:Brocade-OpenSource,项目名称:OpenStack-DNRM-Nova,代码行数:15,代码来源:test_instance_types_extra_specs.py


示例4: test_spawn_attach_volume_vmdk

 def test_spawn_attach_volume_vmdk(self):
     self._create_instance_in_the_db()
     self.type_data = db.flavor_get_by_name(None, 'm1.large')
     self.mox.StubOutWithMock(block_device, 'volume_in_mapping')
     self.mox.StubOutWithMock(v_driver, 'block_device_info_get_mapping')
     ebs_root = 'fake_root'
     block_device.volume_in_mapping(mox.IgnoreArg(),
             mox.IgnoreArg()).AndReturn(ebs_root)
     connection_info = self._test_vmdk_connection_info('vmdk')
     root_disk = [{'connection_info': connection_info}]
     v_driver.block_device_info_get_mapping(
             mox.IgnoreArg()).AndReturn(root_disk)
     mount_point = '/dev/vdc'
     self.mox.StubOutWithMock(volumeops.VMwareVolumeOps,
                              '_get_res_pool_of_vm')
     volumeops.VMwareVolumeOps._get_res_pool_of_vm(
              mox.IgnoreArg()).AndReturn('fake_res_pool')
     self.mox.StubOutWithMock(volumeops.VMwareVolumeOps,
                              '_relocate_vmdk_volume')
     volumeops.VMwareVolumeOps._relocate_vmdk_volume(mox.IgnoreArg(),
              'fake_res_pool', mox.IgnoreArg())
     self.mox.StubOutWithMock(volumeops.VMwareVolumeOps,
                              'attach_volume')
     volumeops.VMwareVolumeOps.attach_volume(connection_info,
             self.instance, mox.IgnoreArg())
     self.mox.ReplayAll()
     self.conn.spawn(self.context, self.instance, self.image,
                     injected_files=[], admin_password=None,
                     network_info=self.network_info,
                     block_device_info=None)
开发者ID:qingw,项目名称:nova,代码行数:30,代码来源:test_vmwareapi.py


示例5: get_by_name

 def get_by_name(cls, context, name):
     try:
         db_flavor = cls._flavor_get_by_name_from_db(context, name)
     except exception.FlavorNotFoundByName:
         db_flavor = db.flavor_get_by_name(context, name)
     return cls._from_db_object(context, cls(context), db_flavor,
                                expected_attrs=['extra_specs'])
开发者ID:sapcc,项目名称:nova,代码行数:7,代码来源:flavor.py


示例6: test_spawn_attach_volume_vmdk

 def test_spawn_attach_volume_vmdk(self):
     self._create_instance_in_the_db()
     self.type_data = db.flavor_get_by_name(None, "m1.large")
     self.mox.StubOutWithMock(block_device, "volume_in_mapping")
     self.mox.StubOutWithMock(v_driver, "block_device_info_get_mapping")
     ebs_root = "fake_root"
     block_device.volume_in_mapping(mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(ebs_root)
     connection_info = self._test_vmdk_connection_info("vmdk")
     root_disk = [{"connection_info": connection_info}]
     v_driver.block_device_info_get_mapping(mox.IgnoreArg()).AndReturn(root_disk)
     mount_point = "/dev/vdc"
     self.mox.StubOutWithMock(volumeops.VMwareVolumeOps, "_get_volume_uuid")
     volumeops.VMwareVolumeOps._get_volume_uuid(mox.IgnoreArg(), "volume-fake-id").AndReturn("fake_disk_uuid")
     self.mox.StubOutWithMock(vm_util, "get_vmdk_backed_disk_device")
     vm_util.get_vmdk_backed_disk_device(mox.IgnoreArg(), "fake_disk_uuid").AndReturn("fake_device")
     self.mox.StubOutWithMock(volumeops.VMwareVolumeOps, "_consolidate_vmdk_volume")
     volumeops.VMwareVolumeOps._consolidate_vmdk_volume(
         self.instance, mox.IgnoreArg(), "fake_device", mox.IgnoreArg()
     )
     self.mox.StubOutWithMock(volumeops.VMwareVolumeOps, "attach_volume")
     volumeops.VMwareVolumeOps.attach_volume(connection_info, self.instance, mox.IgnoreArg())
     self.mox.ReplayAll()
     self.conn.spawn(
         self.context,
         self.instance,
         self.image,
         injected_files=[],
         admin_password=None,
         network_info=self.network_info,
         block_device_info=None,
     )
开发者ID:slagle,项目名称:nova,代码行数:31,代码来源:test_vmwareapi.py


示例7: get_flavor_by_name

def get_flavor_by_name(name, ctxt=None):
    """Retrieves single flavor by name."""
    if name is None:
        return get_default_flavor()

    if ctxt is None:
        ctxt = context.get_admin_context()

    return db.flavor_get_by_name(ctxt, name)
开发者ID:LeoDuo,项目名称:nova,代码行数:9,代码来源:flavors.py


示例8: _create_vm

 def _create_vm(self):
     """Create and spawn the VM."""
     self._create_instance_in_the_db()
     self.type_data = db.flavor_get_by_name(None, 'm1.large')
     self.conn.spawn(self.context, self.instance, self.image,
                     injected_files=[], admin_password=None,
                     network_info=self.network_info,
                     block_device_info=None)
     self._check_vm_record()
开发者ID:abhirajbutala,项目名称:nova,代码行数:9,代码来源:test_vmwareapi.py


示例9: _create_vm

 def _create_vm(self, node=None, num_instances=1):
     """Create and spawn the VM."""
     if not node:
         node = self.node_name
     self._create_instance_in_the_db(node=node)
     self.type_data = db.flavor_get_by_name(None, "m1.large")
     self.conn.spawn(
         self.context,
         self.instance,
         self.image,
         injected_files=[],
         admin_password=None,
         network_info=self.network_info,
         block_device_info=None,
     )
     self._check_vm_record(num_instances=num_instances)
开发者ID:slagle,项目名称:nova,代码行数:16,代码来源:test_vmwareapi.py


示例10: test_spawn_attach_volume_iscsi

 def test_spawn_attach_volume_iscsi(self):
     self._create_instance_in_the_db()
     self.type_data = db.flavor_get_by_name(None, 'm1.large')
     self.mox.StubOutWithMock(block_device, 'volume_in_mapping')
     self.mox.StubOutWithMock(v_driver, 'block_device_info_get_mapping')
     connection_info = self._test_vmdk_connection_info('iscsi')
     root_disk = [{'connection_info': connection_info}]
     v_driver.block_device_info_get_mapping(
             mox.IgnoreArg()).AndReturn(root_disk)
     self.mox.StubOutWithMock(volumeops.VMwareVolumeOps,
                              'attach_volume')
     volumeops.VMwareVolumeOps.attach_volume(connection_info,
             self.instance, mox.IgnoreArg())
     self.mox.ReplayAll()
     block_device_info = {'mount_device': 'vda'}
     self.conn.spawn(self.context, self.instance, self.image,
                     injected_files=[], admin_password=None,
                     network_info=self.network_info,
                     block_device_info=block_device_info)
开发者ID:Acidburn0zzz,项目名称:nova,代码行数:19,代码来源:test_vmwareapi.py


示例11: _sync_flavor

    def _sync_flavor(self, ctx, flavor, extra_specs):
        """
        Insert the flavor with extra specs if not in local database
        """
        flavor_in_local_db = None
        flavor_name = self.prefix + flavor.name
        try:
            flavor_in_local_db = db.flavor_get_by_name(ctx, flavor_name)
        except exception.FlavorNotFoundByName:
            self._insert_pvc_flavor_extraspecs(ctx, flavor, extra_specs)

        # Update the extra_speces of the flavor
        if flavor_in_local_db is not None:
            flavor_id = flavor_in_local_db.get('flavorid', '')
            if (flavor_id is not ''
                    and extra_specs):
                self._update_flavor_extraspecs(ctx,
                                               flavor_id,
                                               extra_specs)
开发者ID:openstack,项目名称:powervc-driver,代码行数:19,代码来源:flavorsync.py


示例12: test_spawn_attach_volume_iscsi

 def test_spawn_attach_volume_iscsi(self):
     self._create_instance_in_the_db()
     self.type_data = db.flavor_get_by_name(None, "m1.large")
     self.mox.StubOutWithMock(block_device, "volume_in_mapping")
     self.mox.StubOutWithMock(v_driver, "block_device_info_get_mapping")
     ebs_root = "fake_root"
     block_device.volume_in_mapping(mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(ebs_root)
     connection_info = self._test_vmdk_connection_info("iscsi")
     root_disk = [{"connection_info": connection_info}]
     v_driver.block_device_info_get_mapping(mox.IgnoreArg()).AndReturn(root_disk)
     self.mox.StubOutWithMock(volumeops.VMwareVolumeOps, "attach_volume")
     volumeops.VMwareVolumeOps.attach_volume(connection_info, self.instance, mox.IgnoreArg())
     self.mox.ReplayAll()
     self.conn.spawn(
         self.context,
         self.instance,
         self.image,
         injected_files=[],
         admin_password=None,
         network_info=self.network_info,
         block_device_info=None,
     )
开发者ID:slagle,项目名称:nova,代码行数:22,代码来源:test_vmwareapi.py


示例13: get_by_name

 def get_by_name(cls, context, name):
     db_flavor = db.flavor_get_by_name(context, name)
     return cls._from_db_object(context, cls(), db_flavor,
                                expected_attrs=['extra_specs'])
开发者ID:B-Rich,项目名称:nova-1,代码行数:4,代码来源:flavor.py


示例14: _setup_test_migrate_disk_and_power_off_mocks

    def _setup_test_migrate_disk_and_power_off_mocks(self, same_host=False, copy_exception=False, size_exception=False):
        self._instance_data = self._get_instance_data()
        instance = db.instance_create(self._context, self._instance_data)
        network_info = fake_network.fake_get_instance_nw_info(self.stubs, spectacular=True)

        instance["root_gb"] = 10

        fake_local_ip = "10.0.0.1"
        if same_host:
            fake_dest_ip = fake_local_ip
        else:
            fake_dest_ip = "10.0.0.2"

        if size_exception:
            flavor = "m1.tiny"
        else:
            flavor = "m1.small"

        instance_type = db.flavor_get_by_name(self._context, flavor)

        if not size_exception:
            fake_root_vhd_path = "C:\\FakePath\\root.vhd"
            fake_revert_path = os.path.join(self._test_instance_dir, "_revert")

            func = mox.Func(self._check_instance_name)
            vmutils.VMUtils.set_vm_state(func, constants.HYPERV_VM_STATE_DISABLED)

            m = vmutils.VMUtils.get_vm_storage_paths(func)
            m.AndReturn(([fake_root_vhd_path], []))

            m = hostutils.HostUtils.get_local_ips()
            m.AndReturn([fake_local_ip])

            m = fake.PathUtils.get_instance_dir(mox.IsA(str))
            m.AndReturn(self._test_instance_dir)

            m = pathutils.PathUtils.get_instance_migr_revert_dir(instance["name"], remove_dir=True)
            m.AndReturn(fake_revert_path)

            if same_host:
                fake.PathUtils.makedirs(mox.IsA(str))

            m = fake.PathUtils.copy(fake_root_vhd_path, mox.IsA(str))
            if copy_exception:
                m.AndRaise(shutil.Error("Simulated copy error"))
                m = fake.PathUtils.get_instance_dir(mox.IsA(str), mox.IsA(str), remove_dir=True)
                m.AndReturn(self._test_instance_dir)
            else:
                fake.PathUtils.rename(mox.IsA(str), mox.IsA(str))
                destroy_disks = True
                if same_host:
                    fake.PathUtils.rename(mox.IsA(str), mox.IsA(str))
                    destroy_disks = False

                self._setup_destroy_mocks(False)

                if destroy_disks:
                    m = fake.PathUtils.get_instance_dir(mox.IsA(str), mox.IsA(str), remove_dir=True)
                    m.AndReturn(self._test_instance_dir)

        return (instance, fake_dest_ip, network_info, instance_type)
开发者ID:polettix,项目名称:nova,代码行数:61,代码来源:test_hypervapi.py


示例15: _setup_test_migrate_disk_and_power_off_mocks

    def _setup_test_migrate_disk_and_power_off_mocks(self, same_host=False,
                                                     copy_exception=False,
                                                     size_exception=False):
        self._instance = self._get_instance()
        network_info = fake_network.fake_get_instance_nw_info(self.stubs)

        self._instance['root_gb'] = 10

        fake_local_ip = '10.0.0.1'
        if same_host:
            fake_dest_ip = fake_local_ip
        else:
            fake_dest_ip = '10.0.0.2'

        if size_exception:
            flavor = 'm1.tiny'
        else:
            flavor = 'm1.small'

        flavor = db.flavor_get_by_name(self._context, flavor)
        flavor = fake_flavor.fake_flavor_obj(self._context, **flavor)

        if not size_exception:
            fake_root_vhd_path = 'C:\\FakePath\\root.vhd'
            fake_revert_path = os.path.join(self._test_instance_dir, '_revert')

            func = mox.Func(self._check_instance_name)
            vmutils.VMUtils.set_vm_state(func,
                                         constants.HYPERV_VM_STATE_DISABLED)

            self._setup_delete_vm_log_mocks()

            m = vmutils.VMUtils.get_vm_storage_paths(func)
            m.AndReturn(([fake_root_vhd_path], []))

            m = hostutils.HostUtils.get_local_ips()
            m.AndReturn([fake_local_ip])

            m = fake.PathUtils.get_instance_dir(mox.IsA(str))
            m.AndReturn(self._test_instance_dir)

            m = pathutils.PathUtils.get_instance_migr_revert_dir(
                self._instance.name, remove_dir=True, create_dir=True)
            m.AndReturn(fake_revert_path)

            if same_host:
                fake.PathUtils.makedirs(mox.IsA(str))

            m = fake.PathUtils.copy(fake_root_vhd_path, mox.IsA(str))
            if copy_exception:
                m.AndRaise(shutil.Error('Simulated copy error'))
                m = fake.PathUtils.get_instance_dir(mox.IsA(str),
                                                    mox.IsA(str),
                                                    remove_dir=True)
                m.AndReturn(self._test_instance_dir)
            else:
                fake.PathUtils.move_folder_files(mox.IsA(str),
                                                 mox.IsA(str))
                destroy_disks = True
                if same_host:
                    fake.PathUtils.move_folder_files(mox.IsA(str),
                                                     mox.IsA(str))
                    destroy_disks = False

                self._setup_destroy_mocks(False)

                if destroy_disks:
                    m = fake.PathUtils.get_instance_dir(mox.IsA(str),
                                                        mox.IsA(str),
                                                        remove_dir=True)
                    m.AndReturn(self._test_instance_dir)

        return (self._instance, fake_dest_ip, network_info, flavor)
开发者ID:BenoitKnecht,项目名称:nova,代码行数:73,代码来源:test_hypervapi.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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