本文整理汇总了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'], {})
示例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'], {})
示例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'])
示例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)
示例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})
示例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'])
示例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"])
示例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
示例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}
示例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}
示例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,
}
示例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'])
示例13: flavor_get
def flavor_get(self, context, flavor_id):
return db.flavor_get(context, flavor_id)
示例14: instance_type_get
def instance_type_get(self, context, instance_type_id):
return db.flavor_get(context, instance_type_id)