本文整理汇总了Python中nova.db.flavor_extra_specs_get函数的典型用法代码示例。如果您正苦于以下问题:Python flavor_extra_specs_get函数的具体用法?Python flavor_extra_specs_get怎么用?Python flavor_extra_specs_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了flavor_extra_specs_get函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_build_request_spec_without_image
def test_build_request_spec_without_image(self):
image = None
instance = {'uuid': 'fake-uuid'}
instance_type = {'flavorid': 'fake-id'}
self.mox.StubOutWithMock(flavors, 'extract_flavor')
self.mox.StubOutWithMock(db, 'flavor_extra_specs_get')
flavors.extract_flavor(mox.IgnoreArg()).AndReturn(instance_type)
db.flavor_extra_specs_get(self.context, mox.IgnoreArg()).AndReturn([])
self.mox.ReplayAll()
request_spec = scheduler_utils.build_request_spec(self.context, image,
[instance])
self.assertEqual({}, request_spec['image'])
示例2: build_request_spec
def build_request_spec(ctxt, image, instances, instance_type=None):
"""Build a request_spec for the scheduler.
The request_spec assumes that all instances to be scheduled are the same
type.
"""
instance = instances[0]
if isinstance(instance, obj_base.NovaObject):
instance = obj_base.obj_to_primitive(instance)
if instance_type is None:
instance_type = flavors.extract_flavor(instance)
# NOTE(comstud): This is a bit ugly, but will get cleaned up when
# we're passing an InstanceType internal object.
extra_specs = db.flavor_extra_specs_get(ctxt, instance_type['flavorid'])
instance_type['extra_specs'] = extra_specs
request_spec = {
'image': image or {},
'instance_properties': instance,
'instance_type': instance_type,
'num_instances': len(instances),
# NOTE(alaski): This should be removed as logic moves from the
# scheduler to conductor. Provides backwards compatibility now.
'instance_uuids': [inst['uuid'] for inst in instances]}
return jsonutils.to_primitive(request_spec)
示例3: test_flavor_extra_specs_delete
def test_flavor_extra_specs_delete(self):
del self.specs["xpu_model"]
db.flavor_extra_specs_delete(self.context,
self.flavorid,
"xpu_model")
actual_specs = db.flavor_extra_specs_get(
self.context,
self.flavorid)
self.assertEqual(self.specs, actual_specs)
示例4: test_extra_specs_update
def test_extra_specs_update(self):
expected_specs = {'k1': 'v1'}
updated_specs = {'k1': 'v2'}
self._test_extra_specs_empty()
self.set_key(self.instance_type_name, "k1", "v1")
actual_specs = db.flavor_extra_specs_get(
context.get_admin_context(),
self.instance_type_flavorid)
self.assertEquals(expected_specs, actual_specs)
self.set_key(self.instance_type_name, "k1", "v2")
actual_specs = db.flavor_extra_specs_get(
context.get_admin_context(),
self.instance_type_flavorid)
self.assertEquals(updated_specs, actual_specs)
self.unset_key(self.instance_type_name, "k1")
示例5: test_instance_type_extra_specs_update
def test_instance_type_extra_specs_update(self):
self.specs["cpu_model"] = "Sandy Bridge"
db.flavor_extra_specs_update_or_create(
self.context,
self.flavorid,
dict(cpu_model="Sandy Bridge"))
actual_specs = db.flavor_extra_specs_get(
self.context,
self.flavorid)
self.assertEqual(self.specs, actual_specs)
示例6: test_instance_type_specs_get
def test_instance_type_specs_get(self):
expected_specs = dict(cpu_arch="x86_64",
cpu_model="Nehalem",
xpu_arch="fermi",
xpus="2",
xpu_model="Tesla 2050")
actual_specs = db.flavor_extra_specs_get(
self.context,
self.flavorid)
self.assertEquals(expected_specs, actual_specs)
示例7: test_instance_type_extra_specs_create
def test_instance_type_extra_specs_create(self):
net_attrs = {
"net_arch": "ethernet",
"net_mbps": "10000"
}
self.specs.update(net_attrs)
db.flavor_extra_specs_update_or_create(
self.context,
self.flavorid,
net_attrs)
actual_specs = db.flavor_extra_specs_get(
self.context,
self.flavorid)
self.assertEqual(self.specs, actual_specs)
示例8: test_instance_type_extra_specs_update
def test_instance_type_extra_specs_update(self):
expected_specs = dict(cpu_arch="x86_64",
cpu_model="Sandy Bridge",
xpu_arch="fermi",
xpus="2",
xpu_model="Tesla 2050")
db.flavor_extra_specs_update_or_create(
self.context,
self.flavorid,
dict(cpu_model="Sandy Bridge"))
actual_specs = db.flavor_extra_specs_get(
self.context,
self.flavorid)
self.assertEquals(expected_specs, actual_specs)
示例9: test_extra_specs_multiple
def test_extra_specs_multiple(self):
two_items_extra_specs = {'k1': 'v1',
'k3': 'v3'}
self._test_extra_specs_empty()
self.set_key(self.instance_type_name, "k1", "v1")
self.set_key(self.instance_type_name, "k3", "v3")
actual_specs = db.flavor_extra_specs_get(
context.get_admin_context(),
self.instance_type_flavorid)
self.assertEquals(two_items_extra_specs, actual_specs)
self.unset_key(self.instance_type_name, "k1")
self.unset_key(self.instance_type_name, "k3")
示例10: test_instance_type_extra_specs_create
def test_instance_type_extra_specs_create(self):
expected_specs = dict(cpu_arch="x86_64",
cpu_model="Nehalem",
xpu_arch="fermi",
xpus="2",
xpu_model="Tesla 2050",
net_arch="ethernet",
net_mbps="10000")
db.flavor_extra_specs_update_or_create(
self.context,
self.flavorid,
dict(net_arch="ethernet",
net_mbps=10000))
actual_specs = db.flavor_extra_specs_get(
self.context,
self.flavorid)
self.assertEquals(expected_specs, actual_specs)
示例11: _get_extra_specs
def _get_extra_specs(self, context, flavor_id):
extra_specs = db.flavor_extra_specs_get(context, flavor_id)
return dict(extra_specs=extra_specs)
示例12: _test_extra_specs_empty
def _test_extra_specs_empty(self):
empty_specs = {}
actual_specs = db.flavor_extra_specs_get(
context.get_admin_context(),
self.instance_type_id)
self.assertEquals(empty_specs, actual_specs)
示例13: test_instance_type_specs_get
def test_instance_type_specs_get(self):
actual_specs = db.flavor_extra_specs_get(
self.context,
self.flavorid)
self.assertEqual(self.specs, actual_specs)