本文整理汇总了Python中nova.compute.flavors.get_all_flavors函数的典型用法代码示例。如果您正苦于以下问题:Python get_all_flavors函数的具体用法?Python get_all_flavors怎么用?Python get_all_flavors使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_all_flavors函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:Milstein,项目名称:nova,代码行数:12,代码来源:test_flavors.py
示例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)
开发者ID:newgoliath,项目名称:nova,代码行数:12,代码来源:test_flavors.py
示例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)
开发者ID:Acidburn0zzz,项目名称:nova,代码行数:12,代码来源:test_flavors.py
示例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)
开发者ID:aspiers,项目名称:nova,代码行数:12,代码来源:test_flavors.py
示例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")
开发者ID:newgoliath,项目名称:nova,代码行数:14,代码来源:test_flavors.py
示例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)
开发者ID:newgoliath,项目名称:nova,代码行数:15,代码来源:test_flavors.py
示例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')
开发者ID:MasterZ40,项目名称:nova,代码行数:15,代码来源:test_flavors.py
示例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
开发者ID:Brocade-OpenSource,项目名称:OpenStack-DNRM-Nova,代码行数:33,代码来源:flavors.py
示例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
开发者ID:MasterZ40,项目名称:nova,代码行数:8,代码来源:test_flavors.py
示例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
开发者ID:newgoliath,项目名称:nova,代码行数:8,代码来源:test_flavors.py
示例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
开发者ID:Ivan-Zhu,项目名称:nova-v3-api-doc,代码行数:8,代码来源:flavor_access.py
示例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)
开发者ID:isyippee,项目名称:nova,代码行数:19,代码来源:test_flavors.py
示例13: get_items
def get_items(self, context, zone_id=None):
flavors = instance_types.get_all_flavors(context, filters={})
return flavors.values()
开发者ID:pombredanne,项目名称:gce,代码行数:3,代码来源:machine_type_api.py
示例14: _existing_flavor
def _existing_flavor(self):
"""return first flavor name."""
return flavors.get_all_flavors().keys()[0]
开发者ID:MasterZ40,项目名称:nova,代码行数:3,代码来源:test_flavors.py
示例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))
开发者ID:MasterZ40,项目名称:nova,代码行数:6,代码来源:test_flavors.py
示例16: retrieve_flavors
def retrieve_flavors(context):
return flavors.get_all_flavors(context)
开发者ID:ic-hep,项目名称:occi-os,代码行数:2,代码来源:vm.py
示例17: retrieve_flavors
def retrieve_flavors(context):
"""
Retrieve list of flavors.
"""
return flavors.get_all_flavors(context)
开发者ID:enolfc,项目名称:occi-os,代码行数:5,代码来源:vm.py
示例18: retrieve_flavors
def retrieve_flavors():
return flavors.get_all_flavors()
开发者ID:verdurin,项目名称:occi-os,代码行数:2,代码来源:vm.py
注:本文中的nova.compute.flavors.get_all_flavors函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论