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

Python db.flavor_get函数代码示例

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

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



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

示例1: test_instance_type_get_with_extra_specs

 def test_instance_type_get_with_extra_specs(self):
     instance_type = db.flavor_get(
                         self.context,
                         self.instance_type_id)
     self.assertEqual(instance_type['extra_specs'],
                      self.specs)
     instance_type = db.flavor_get(
                         self.context,
                         5)
     self.assertEqual(instance_type['extra_specs'], {})
开发者ID:dlq84,项目名称:nova,代码行数:10,代码来源:test_instance_types_extra_specs.py


示例2: test_instance_type_get_with_extra_specs

 def test_instance_type_get_with_extra_specs(self):
     instance_type = db.flavor_get(
                         self.context,
                         self.instance_type_id)
     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(
                         self.context,
                         5)
     self.assertEquals(instance_type['extra_specs'], {})
开发者ID:Brocade-OpenSource,项目名称:OpenStack-DNRM-Nova,代码行数:14,代码来源:test_instance_types_extra_specs.py


示例3: get_by_id

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


示例4: get_flavor

def get_flavor(instance_type_id, ctxt=None, inactive=False):
    """Retrieves single flavor by id."""
    if instance_type_id is None:
        return get_default_flavor()

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

    if inactive:
        ctxt = ctxt.elevated(read_deleted="yes")

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


示例5: create_instance

def create_instance(testcase):
    fake.stub_out_image_service(testcase.stubs)
    ctxt = context.get_admin_context()
    instance_type = db.flavor_get(ctxt, 1)
    sys_meta = flavors.save_flavor_info({}, instance_type)
    return db.instance_create(ctxt,
                    {'user_id': 'fake',
                     'project_id': 'fake',
                     'instance_type_id': 1,
                     'memory_mb': 1024,
                     'vcpus': 2,
                     'image_ref': '155d900f-4e14-4e4c-a73d-069cbf4541e6',
                     'system_metadata': sys_meta})
开发者ID:adesso-mobile,项目名称:nova,代码行数:13,代码来源:test_powervm.py


示例6: test_create_instances_here

    def test_create_instances_here(self):
        # Just grab the first instance type
        inst_type = db.flavor_get(self.ctxt, 1)
        image = {'properties': {}}
        instance_uuids = self.instance_uuids
        instance_props = {'id': 'removed',
                          'security_groups': 'removed',
                          'info_cache': 'removed',
                          'name': 'instance-00000001',
                          'hostname': 'meow',
                          'display_name': 'moo',
                          'image_ref': 'fake_image_ref',
                          'user_id': self.ctxt.user_id,
                          # Test these as lists
                          'metadata': [{'key': 'moo', 'value': 'cow'}],
                          'system_metadata': [{'key': 'meow', 'value': 'cat'}],
                          'project_id': self.ctxt.project_id}

        call_info = {'uuids': []}
        block_device_mapping = [block_device.create_image_bdm(
            'fake_image_ref')]

        def _fake_instance_update_at_top(_ctxt, instance):
            call_info['uuids'].append(instance['uuid'])

        self.stubs.Set(self.msg_runner, 'instance_update_at_top',
                       _fake_instance_update_at_top)

        self.scheduler._create_instances_here(self.ctxt, instance_uuids,
                instance_props, inst_type, image,
                ['default'], block_device_mapping)
        self.assertEqual(instance_uuids, call_info['uuids'])

        for instance_uuid in instance_uuids:
            instance = db.instance_get_by_uuid(self.ctxt, instance_uuid)
            meta = utils.instance_meta(instance)
            self.assertEqual('cow', meta['moo'])
            sys_meta = utils.instance_sys_meta(instance)
            self.assertEqual('cat', sys_meta['meow'])
            self.assertEqual('meow', instance['hostname'])
            self.assertEqual('moo-%s' % instance['uuid'],
                             instance['display_name'])
            self.assertEqual('fake_image_ref', instance['image_ref'])
开发者ID:674009287,项目名称:nova,代码行数:43,代码来源:test_cells_scheduler.py


示例7: test_create_instances_here

    def test_create_instances_here(self):
        # Just grab the first instance type
        inst_type = db.flavor_get(self.ctxt, 1)
        image = {"properties": {}}
        instance_uuids = self.instance_uuids
        instance_props = {
            "id": "removed",
            "security_groups": "removed",
            "info_cache": "removed",
            "name": "instance-00000001",
            "hostname": "meow",
            "display_name": "moo",
            "image_ref": "fake_image_ref",
            "user_id": self.ctxt.user_id,
            # Test these as lists
            "metadata": [{"key": "moo", "value": "cow"}],
            "system_metadata": [{"key": "meow", "value": "cat"}],
            "project_id": self.ctxt.project_id,
        }

        call_info = {"uuids": []}
        block_device_mapping = [block_device.create_image_bdm("fake_image_ref")]

        def _fake_instance_update_at_top(_ctxt, instance):
            call_info["uuids"].append(instance["uuid"])

        self.stubs.Set(self.msg_runner, "instance_update_at_top", _fake_instance_update_at_top)

        self.scheduler._create_instances_here(
            self.ctxt, instance_uuids, instance_props, inst_type, image, ["default"], block_device_mapping
        )
        self.assertEqual(instance_uuids, call_info["uuids"])

        for instance_uuid in instance_uuids:
            instance = db.instance_get_by_uuid(self.ctxt, instance_uuid)
            meta = utils.instance_meta(instance)
            self.assertEqual("cow", meta["moo"])
            sys_meta = utils.instance_sys_meta(instance)
            self.assertEqual("cat", sys_meta["meow"])
            self.assertEqual("meow", instance["hostname"])
            self.assertEqual("moo-%s" % instance["uuid"], instance["display_name"])
            self.assertEqual("fake_image_ref", instance["image_ref"])
开发者ID:niuzhenguo,项目名称:nova,代码行数:42,代码来源:test_cells_scheduler.py


示例8: _prep_instance

    def _prep_instance(self, instance_ref, **kwargs):
        type_id = 5  # m1.small
        flavor = db.flavor_get(self.context, type_id)
        sys_meta = flavors.save_flavor_info({}, flavor)

        instance_ref.update(
            uuid='1e4fa700-a506-11e3-a1fc-7071bc7738b5',
            power_state=power_state.SHUTDOWN,
            user_id=self.user_id,
            project_id=self.project_id,
            instance_type_id=str(type_id),
            system_metadata=sys_meta,
            extra_specs={},
        )

        for key, val in kwargs.items():
            instance_ref[key] = val

        instance = instance_obj.Instance(self.context, **instance_ref)
        instance.create()
        return instance
开发者ID:ILMostro,项目名称:pcs-nova-driver,代码行数:21,代码来源:test_driver.py


示例9: setUp

    def setUp(self):
        super(LibvirtBlockInfoTest, self).setUp()

        self.user_id = 'fake'
        self.project_id = 'fake'
        self.context = context.get_admin_context()
        flavor = db.flavor_get(self.context, 2)
        sys_meta = flavors.save_flavor_info({}, flavor)
        nova.tests.image.fake.stub_out_image_service(self.stubs)
        self.test_instance = {
                'uuid': '32dfcb37-5af1-552b-357c-be8c3aa38310',
                'memory_kb': '1024000',
                'basepath': '/some/path',
                'bridge_name': 'br100',
                'vcpus': 2,
                'project_id': 'fake',
                'bridge': 'br101',
                'image_ref': '155d900f-4e14-4e4c-a73d-069cbf4541e6',
                'root_gb': 10,
                'ephemeral_gb': 20,
                'instance_type_id': 2,  # m1.tiny
                'system_metadata': sys_meta}
开发者ID:Cisco-OCPChina,项目名称:nova,代码行数:22,代码来源:test_libvirt_blockinfo.py


示例10: setUp

    def setUp(self):
        super(GraniteDriverTestCase, self).setUp()
        self.flags(instances_path=self.useFixture(fixtures.TempDir()).path)
        self.lxc_connection = lxc_connection.LXCDriver(None)

        instance_type = db.flavor_get(context.get_admin_context(), 5)
        sys_meta = flavors.save_flavor_info({}, instance_type)

        self.instance = {
            'uuid': '32dfcb37-5af1-552b-357c-be8c3aa38310',
            'memory_kb': '1024000',
            'basepath': '/some/path',
            'bridge_name': 'br100',
            'vcpus': 2,
            'project_id': 'fake',
            'bridge': 'br101',
            'image_ref': '155d900f-4e14-4e4c-a73d-069cbf4541e6',
            'root_gb': 10,
            'ephemeral_gb': 20,
            'instance_type_id': '5',  # m1.small
            'extra_specs': {},
            'system_metadata': sys_meta}
开发者ID:javacruft,项目名称:nova-compute-flex,代码行数:22,代码来源:test_driver.py


示例11: setUp

    def setUp(self):
        super(LibvirtBlockInfoTest, self).setUp()

        self.user_id = "fake"
        self.project_id = "fake"
        self.context = context.get_admin_context()
        flavor = db.flavor_get(self.context, 2)
        sys_meta = flavors.save_flavor_info({}, flavor)
        nova.tests.image.fake.stub_out_image_service(self.stubs)
        self.test_instance = {
            "uuid": "32dfcb37-5af1-552b-357c-be8c3aa38310",
            "memory_kb": "1024000",
            "basepath": "/some/path",
            "bridge_name": "br100",
            "vcpus": 2,
            "project_id": "fake",
            "bridge": "br101",
            "image_ref": "155d900f-4e14-4e4c-a73d-069cbf4541e6",
            "root_gb": 10,
            "ephemeral_gb": 20,
            "instance_type_id": 2,  # m1.tiny
            "system_metadata": sys_meta,
        }
开发者ID:holzman,项目名称:nova,代码行数:23,代码来源:test_blockinfo.py


示例12: get_by_id

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


示例13: flavor_get

 def flavor_get(self, context, flavor_id):
     return db.flavor_get(context, flavor_id)
开发者ID:Cisco-OCPChina,项目名称:nova,代码行数:2,代码来源:fake.py


示例14: instance_type_get

 def instance_type_get(self, context, instance_type_id):
     return db.flavor_get(context, instance_type_id)
开发者ID:ashw7n,项目名称:nova,代码行数:2,代码来源:fake.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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