本文整理汇总了Python中nova.compute.flavors.get_all_flavors函数的典型用法代码示例。如果您正苦于以下问题:Python get_all_flavors函数的具体用法?Python get_all_flavors怎么用?Python get_all_flavors使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_all_flavors函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_inactive_flavors_with_same_name
def test_get_inactive_flavors_with_same_name(self):
flav1 = flavors.create('flavor', 256, 1, 120)
flavors.destroy('flavor')
flav2 = flavors.create('flavor', 512, 4, 250)
returned_flavors_ids = flavors.get_all_flavors().keys()
self.assertNotIn(flav1.id, returned_flavors_ids)
self.assertIn(flav2.id, returned_flavors_ids)
returned_flavors_ids = flavors.get_all_flavors(inactive=True).keys()
self.assertIn(flav1.id, returned_flavors_ids)
self.assertIn(flav2.id, returned_flavors_ids)
示例2: test_get_inactive_flavors
def test_get_inactive_flavors(self):
flav1 = flavors.create("flavor1", 256, 1, 120)
flav2 = flavors.create("flavor2", 512, 4, 250)
flavors.destroy("flavor1")
returned_flavors_ids = flavors.get_all_flavors().keys()
self.assertNotIn(flav1["id"], returned_flavors_ids)
self.assertIn(flav2["id"], returned_flavors_ids)
returned_flavors_ids = flavors.get_all_flavors(inactive=True).keys()
self.assertIn(flav1["id"], returned_flavors_ids)
self.assertIn(flav2["id"], returned_flavors_ids)
示例3: test_get_inactive_flavors_with_same_flavorid
def test_get_inactive_flavors_with_same_flavorid(self):
flav1 = flavors.create('flavor', 256, 1, 120, 100, "flavid")
flavors.destroy('flavor')
flav2 = flavors.create('flavor', 512, 4, 250, 100, "flavid")
returned_flavors_ids = flavors.get_all_flavors().keys()
self.assertNotIn(flav1['id'], returned_flavors_ids)
self.assertIn(flav2['id'], returned_flavors_ids)
returned_flavors_ids = flavors.get_all_flavors(inactive=True).keys()
self.assertIn(flav1['id'], returned_flavors_ids)
self.assertIn(flav2['id'], returned_flavors_ids)
示例4: test_get_inactive_flavors_with_same_name
def test_get_inactive_flavors_with_same_name(self):
flavors.create('flavor1', 256, 1, 120, 100, "test_id1")
flavors.destroy('flavor1')
flavors.create('flavor1', 512, 4, 250, 100, "test_id2")
returned_flavors_ids = flavors.get_all_flavors().keys()
self.assertNotIn('test_id1', returned_flavors_ids)
self.assertIn('test_id2', returned_flavors_ids)
returned_flavors_ids = flavors.get_all_flavors(inactive=True).keys()
self.assertIn('test_id1', returned_flavors_ids)
self.assertIn('test_id2', returned_flavors_ids)
示例5: test_basic_create
def test_basic_create(self):
# Ensure instance types can be created.
original_list = flavors.get_all_flavors()
# Create new type and make sure values stick
flavor = flavors.create("flavor", 64, 1, 120)
self.assertEqual(flavor["name"], "flavor")
self.assertEqual(flavor["memory_mb"], 64)
self.assertEqual(flavor["vcpus"], 1)
self.assertEqual(flavor["root_gb"], 120)
# Ensure new type shows up in list
new_list = flavors.get_all_flavors()
self.assertNotEqual(len(original_list), len(new_list), "flavor was not created")
示例6: test_create_then_delete
def test_create_then_delete(self):
original_list = flavors.get_all_flavors()
flavor = flavors.create("flavor", 64, 1, 120)
# Ensure new type shows up in list
new_list = flavors.get_all_flavors()
self.assertNotEqual(len(original_list), len(new_list), "instance type was not created")
flavors.destroy("flavor")
self.assertRaises(exception.InstanceTypeNotFound, flavors.get_flavor, flavor["id"])
# Deleted instance should not be in list anymore
new_list = flavors.get_all_flavors()
self.assertEqual(original_list, new_list)
示例7: test_basic_create
def test_basic_create(self):
# Ensure instance types can be created.
original_list = flavors.get_all_flavors()
# Create new type and make sure values stick
flavor = flavors.create('flavor', 64, 1, 120)
self.assertEqual(flavor['name'], 'flavor')
self.assertEqual(flavor['memory_mb'], 64)
self.assertEqual(flavor['vcpus'], 1)
self.assertEqual(flavor['root_gb'], 120)
# Ensure new type shows up in list
new_list = flavors.get_all_flavors()
self.assertNotEqual(len(original_list), len(new_list),
'flavor was not created')
示例8: _get_flavors
def _get_flavors(self, req):
"""Helper function that returns a list of flavor dicts."""
filters = {}
context = req.environ['nova.context']
if context.is_admin:
# Only admin has query access to all flavor types
filters['is_public'] = self._parse_is_public(
req.params.get('is_public', None))
else:
filters['is_public'] = True
filters['disabled'] = False
if 'minRam' in req.params:
try:
filters['min_memory_mb'] = int(req.params['minRam'])
except ValueError:
msg = _('Invalid minRam filter [%s]') % req.params['minRam']
raise webob.exc.HTTPBadRequest(explanation=msg)
if 'minDisk' in req.params:
try:
filters['min_root_gb'] = int(req.params['minDisk'])
except ValueError:
msg = _('Invalid minDisk filter [%s]') % req.params['minDisk']
raise webob.exc.HTTPBadRequest(explanation=msg)
limited_flavors = flavors.get_all_flavors(context, filters=filters)
flavors_list = limited_flavors.values()
sorted_flavors = sorted(flavors_list,
key=lambda item: item['flavorid'])
limited_flavors = common.limited_by_marker(sorted_flavors, req)
return limited_flavors
示例9: _generate_name
def _generate_name(self):
"""return a name not in the DB."""
nonexistent_flavor = str(int(time.time()))
all_flavors = flavors.get_all_flavors()
while nonexistent_flavor in all_flavors:
nonexistent_flavor += "z"
else:
return nonexistent_flavor
示例10: _generate_flavorid
def _generate_flavorid(self):
"""return a flavorid not in the DB."""
nonexistent_flavor = 2700
flavor_ids = [value["id"] for key, value in flavors.get_all_flavors().iteritems()]
while nonexistent_flavor in flavor_ids:
nonexistent_flavor += 1
else:
return nonexistent_flavor
示例11: _get_flavor_refs
def _get_flavor_refs(self, context):
"""Return a dictionary mapping flavorid to flavor_ref."""
flavor_refs = flavors.get_all_flavors(context)
rval = {}
for name, obj in flavor_refs.iteritems():
rval[obj['flavorid']] = obj
return rval
示例12: test_create_then_delete
def test_create_then_delete(self):
original_list = flavors.get_all_flavors()
flavor = flavors.create("flavor", 64, 1, 120)
# Ensure new type shows up in list
new_list = flavors.get_all_flavors()
self.assertNotEqual(len(original_list), len(new_list), "instance type was not created")
flavors.destroy("flavor")
self.assertRaises(exception.FlavorNotFound, flavors.get_flavor, flavor.id)
# Deleted instance should not be in list anymore
new_list = flavors.get_all_flavors()
self.assertEqual(len(original_list), len(new_list))
for k in original_list.keys():
f = original_list[k]
self.assertIsInstance(f, objects.Flavor)
self.assertEqual(f.flavorid, new_list[k].flavorid)
示例13: get_items
def get_items(self, context, zone_id=None):
flavors = instance_types.get_all_flavors(context, filters={})
return flavors.values()
示例14: _existing_flavor
def _existing_flavor(self):
"""return first flavor name."""
return flavors.get_all_flavors().keys()[0]
示例15: test_get_all_instance_types
def test_get_all_instance_types(self):
# Ensures that all flavors can be retrieved.
session = sql_session.get_session()
total_instance_types = session.query(models.InstanceTypes).count()
inst_types = flavors.get_all_flavors()
self.assertEqual(total_instance_types, len(inst_types))