本文整理汇总了Python中nova.compute.instance_types.get_all_types函数的典型用法代码示例。如果您正苦于以下问题:Python get_all_types函数的具体用法?Python get_all_types怎么用?Python get_all_types使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_all_types函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_instance_type_create_then_delete
def test_instance_type_create_then_delete(self):
# Ensure instance types can be created.
name = "Small Flavor"
flavorid = "flavor1"
original_list = instance_types.get_all_types()
# create new type and make sure values stick
inst_type = instance_types.create(name, 256, 1, 120, 100, flavorid)
inst_type_id = inst_type["id"]
self.assertEqual(inst_type["flavorid"], flavorid)
self.assertEqual(inst_type["name"], name)
self.assertEqual(inst_type["memory_mb"], 256)
self.assertEqual(inst_type["vcpus"], 1)
self.assertEqual(inst_type["root_gb"], 120)
self.assertEqual(inst_type["ephemeral_gb"], 100)
self.assertEqual(inst_type["swap"], 0)
self.assertEqual(inst_type["rxtx_factor"], 1.0)
# make sure new type shows up in list
new_list = instance_types.get_all_types()
self.assertNotEqual(len(original_list), len(new_list), "instance type was not created")
instance_types.destroy(name)
self.assertRaises(exception.InstanceTypeNotFound, instance_types.get_instance_type, inst_type_id)
# deleted instance should not be in list anymoer
new_list = instance_types.get_all_types()
self.assertEqual(original_list, new_list)
开发者ID:jamesbjackson,项目名称:openstack-smartos-nova-grizzly,代码行数:29,代码来源:test_instance_types.py
示例2: test_instance_type_create_then_delete
def test_instance_type_create_then_delete(self):
"""Ensure instance types can be created"""
name = 'Small Flavor'
flavorid = 'flavor1'
original_list = instance_types.get_all_types()
# create new type and make sure values stick
inst_type = instance_types.create(name, 256, 1, 120, 100, flavorid)
inst_type_id = inst_type['id']
self.assertEqual(inst_type['flavorid'], flavorid)
self.assertEqual(inst_type['name'], name)
self.assertEqual(inst_type['memory_mb'], 256)
self.assertEqual(inst_type['vcpus'], 1)
self.assertEqual(inst_type['root_gb'], 120)
self.assertEqual(inst_type['ephemeral_gb'], 100)
self.assertEqual(inst_type['swap'], 0)
self.assertEqual(inst_type['rxtx_factor'], 1)
# make sure new type shows up in list
new_list = instance_types.get_all_types()
self.assertNotEqual(len(original_list), len(new_list),
'instance type was not created')
instance_types.destroy(name)
self.assertRaises(exception.InstanceTypeNotFound,
instance_types.get_instance_type, inst_type_id)
# deleted instance should not be in list anymoer
new_list = instance_types.get_all_types()
self.assertEqual(original_list, new_list)
开发者ID:EE-NovRain,项目名称:nova,代码行数:31,代码来源:test_instance_types.py
示例3: test_instance_type_create_then_delete
def test_instance_type_create_then_delete(self):
"""Ensure instance types can be created"""
starting_inst_list = instance_types.get_all_types()
instance_types.create(self.name, 256, 1, 120, self.flavorid)
new = instance_types.get_all_types()
self.assertNotEqual(len(starting_inst_list), len(new), "instance type was not created")
instance_types.destroy(self.name)
self.assertEqual(1, instance_types.get_instance_type(self.id)["deleted"])
self.assertEqual(starting_inst_list, instance_types.get_all_types())
instance_types.purge(self.name)
self.assertEqual(len(starting_inst_list), len(instance_types.get_all_types()), "instance type not purged")
开发者ID:rajarammallya,项目名称:openstack-nova,代码行数:11,代码来源:test_instance_types.py
示例4: _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._get_is_public(req)
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)
flavors = instance_types.get_all_types(context, filters=filters)
flavors_list = 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:AnyBucket,项目名称:nova,代码行数:32,代码来源:flavors.py
示例5: test_get_all_instance_types
def test_get_all_instance_types(self):
"""Ensures that all instance types can be retrieved"""
session = get_session()
total_instance_types = session.query(models.InstanceTypes).\
count()
inst_types = instance_types.get_all_types()
self.assertEqual(total_instance_types, len(inst_types))
开发者ID:pombredanne,项目名称:nova,代码行数:7,代码来源:test_instance_types.py
示例6: _get_flavor_refs
def _get_flavor_refs(self):
"""Return a dictionary mapping flavorid to flavor_ref."""
flavor_refs = instance_types.get_all_types(True)
rval = {}
for name, obj in flavor_refs.iteritems():
rval[obj['flavorid']] = obj
return rval
开发者ID:AnyBucket,项目名称:OpenStack-Install-and-Understand-Guide,代码行数:7,代码来源:flavorextradata.py
示例7: _generate_name
def _generate_name(self):
"""return a name not in the DB"""
nonexistent_flavor = str(int(time.time()))
flavors = instance_types.get_all_types()
while nonexistent_flavor in flavors:
nonexistent_flavor += "z"
else:
return nonexistent_flavor
开发者ID:EE-NovRain,项目名称:nova,代码行数:8,代码来源:test_instance_types.py
示例8: _nonexistent_flavor_name
def _nonexistent_flavor_name(self):
"""return an instance type name not in the DB"""
nonexistent_flavor = "sdfsfsdf"
flavors = instance_types.get_all_types()
while nonexistent_flavor in flavors:
nonexistent_flavor += "z"
else:
return nonexistent_flavor
开发者ID:AsherBond,项目名称:dodai-compute,代码行数:8,代码来源:test_instance_types.py
示例9: _generate_flavorid
def _generate_flavorid(self):
"""return a flavorid not in the DB."""
nonexistent_flavor = 2700
flavor_ids = [value["id"] for key, value in instance_types.get_all_types().iteritems()]
while nonexistent_flavor in flavor_ids:
nonexistent_flavor += 1
else:
return nonexistent_flavor
开发者ID:jamesbjackson,项目名称:openstack-smartos-nova-grizzly,代码行数:8,代码来源:test_instance_types.py
示例10: list
def list(self, name=None):
"""Lists all active or specific instance types / flavors."""
try:
if name is None:
inst_types = instance_types.get_all_types()
else:
inst_types = instance_types.get_instance_type_by_name(name)
except db_exc.DBError, e:
_db_error(e)
开发者ID:AnyBucket,项目名称:nova,代码行数:9,代码来源:manage.py
示例11: test_instance_type_create
def test_instance_type_create(self):
# Ensure instance types can be created.
name = "Instance create test"
flavor_id = "512"
original_list = instance_types.get_all_types()
# create new type and make sure values stick
inst_type = instance_types.create(name, 256, 1, 120, flavorid=flavor_id)
self.assertEqual(inst_type["flavorid"], flavor_id)
self.assertEqual(inst_type["name"], name)
self.assertEqual(inst_type["memory_mb"], 256)
self.assertEqual(inst_type["vcpus"], 1)
self.assertEqual(inst_type["root_gb"], 120)
self.assertEqual(inst_type["ephemeral_gb"], 0)
self.assertEqual(inst_type["swap"], 0)
self.assertEqual(inst_type["rxtx_factor"], 1.0)
# make sure new type shows up in list
new_list = instance_types.get_all_types()
self.assertNotEqual(len(original_list), len(new_list), "instance type was not created")
开发者ID:jamesbjackson,项目名称:openstack-smartos-nova-grizzly,代码行数:21,代码来源:test_instance_types.py
示例12: test_instance_type_create_then_delete
def test_instance_type_create_then_delete(self):
"""Ensure instance types can be created"""
name = 'Small Flavor'
flavorid = 'flavor1'
original_list = instance_types.get_all_types()
# create new type and make sure values stick
inst_type = instance_types.create(name, 256, 1, 120, flavorid)
inst_type_id = inst_type['id']
self.assertEqual(inst_type['flavorid'], flavorid)
self.assertEqual(inst_type['name'], name)
self.assertEqual(inst_type['memory_mb'], 256)
self.assertEqual(inst_type['vcpus'], 1)
self.assertEqual(inst_type['local_gb'], 120)
self.assertEqual(inst_type['swap'], 0)
self.assertEqual(inst_type['rxtx_quota'], 0)
self.assertEqual(inst_type['rxtx_cap'], 0)
# make sure new type shows up in list
new_list = instance_types.get_all_types()
self.assertNotEqual(len(original_list), len(new_list),
'instance type was not created')
# destroy instance and make sure deleted flag is set to True
instance_types.destroy(name)
inst_type = instance_types.get_instance_type(inst_type_id)
self.assertEqual(1, inst_type["deleted"])
# deleted instance should not be in list anymoer
new_list = instance_types.get_all_types()
self.assertEqual(original_list, new_list)
# ensure instances are gone after purge
instance_types.purge(name)
new_list = instance_types.get_all_types()
self.assertEqual(original_list, new_list,
'instance type not purged')
开发者ID:BillTheBest,项目名称:nova,代码行数:38,代码来源:test_instance_types.py
示例13: test_instance_type_create
def test_instance_type_create(self):
"""Ensure instance types can be created"""
name = 'Instance create test'
flavor_id = '512'
original_list = instance_types.get_all_types()
# create new type and make sure values stick
inst_type = instance_types.create(name, 256, 1, 120,
flavorid=flavor_id)
self.assertEqual(inst_type['flavorid'], flavor_id)
self.assertEqual(inst_type['name'], name)
self.assertEqual(inst_type['memory_mb'], 256)
self.assertEqual(inst_type['vcpus'], 1)
self.assertEqual(inst_type['root_gb'], 120)
self.assertEqual(inst_type['ephemeral_gb'], 0)
self.assertEqual(inst_type['swap'], 0)
self.assertEqual(inst_type['rxtx_factor'], 1)
# make sure new type shows up in list
new_list = instance_types.get_all_types()
self.assertNotEqual(len(original_list), len(new_list),
'instance type was not created')
开发者ID:EE-NovRain,项目名称:nova,代码行数:23,代码来源:test_instance_types.py
示例14: list
def list(self, name=None):
"""Lists all active or specific instance types / flavors."""
try:
if name is None:
inst_types = instance_types.get_all_types()
else:
inst_types = instance_types.get_instance_type_by_name(name)
except db_exc.DBError as e:
_db_error(e)
if isinstance(inst_types.values()[0], dict):
for k, v in inst_types.iteritems():
self._print_instance_types(k, v)
else:
self._print_instance_types(name, inst_types)
开发者ID:CiscoAS,项目名称:nova,代码行数:14,代码来源:manage.py
示例15: _get_flavors
def _get_flavors(self, req):
"""Helper function that returns a list of flavor dicts."""
filters = {}
if 'minRam' in req.params:
try:
filters['min_memory_mb'] = int(req.params['minRam'])
except ValueError:
pass # ignore bogus values per spec
if 'minDisk' in req.params:
try:
filters['min_local_gb'] = int(req.params['minDisk'])
except ValueError:
pass # ignore bogus values per spec
return instance_types.get_all_types(filters=filters)
开发者ID:CorCornelisse,项目名称:nova,代码行数:16,代码来源:flavors.py
示例16: _get_flavors
def _get_flavors(self, req, is_detail=True):
"""Helper function that returns a list of flavor dicts."""
filters = {}
if 'minRam' in req.params:
try:
filters['min_memory_mb'] = int(req.params['minRam'])
except ValueError:
pass # ignore bogus values per spec
if 'minDisk' in req.params:
try:
filters['min_local_gb'] = int(req.params['minDisk'])
except ValueError:
pass # ignore bogus values per spec
ctxt = req.environ['nova.context']
inst_types = instance_types.get_all_types(filters=filters)
builder = self._get_view_builder(req)
items = [builder.build(inst_type, is_detail=is_detail)
for inst_type in inst_types.values()]
return items
开发者ID:dragonetail,项目名称:nova,代码行数:21,代码来源:flavors.py
示例17: _get_flavors
def _get_flavors(self, req):
"""Helper function that returns a list of flavor dicts."""
filters = {}
if 'minRam' in req.params:
try:
filters['min_memory_mb'] = int(req.params['minRam'])
except ValueError:
pass # ignore bogus values per spec
if 'minDisk' in req.params:
try:
filters['min_root_gb'] = int(req.params['minDisk'])
except ValueError:
pass # ignore bogus values per spec
flavors = instance_types.get_all_types(filters=filters)
flavors_list = 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:HolySparky,项目名称:Openstack-NetworkAPI,代码行数:21,代码来源:networks.py
示例18: _get_flavors
def _get_flavors(self, req):
"""Helper function that returns a list of flavor dicts."""
filters = {}
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)
flavors = instance_types.get_all_types(filters=filters)
flavors_list = 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:nimbis,项目名称:nova,代码行数:22,代码来源:flavors.py
示例19: _refresh_resource_mixins
def _refresh_resource_mixins(self, extras):
"""
Register the flavors as ResourceTemplates to which the user has access.
"""
template_schema = 'http://schemas.openstack.org/template/resource#'
os_flavours = instance_types.get_all_types()
for itype in os_flavours:
resource_template = templates.ResourceTemplate(
term=itype,
scheme=template_schema,
related=[templates.RES_TEMPLATE],
attributes=get_resource_attributes(os_flavours[itype]),
title='This is an openstack ' + itype + ' flavor.',
location='/' + itype + '/')
msg = ('Registering an OpenStack flavour/instance type: %s') % \
str(resource_template)
LOG.debug(msg)
try:
self.registry.get_backend(resource_template, extras)
except AttributeError:
self.register_backend(resource_template, MIXIN_BACKEND)
开发者ID:dizz,项目名称:occi-os,代码行数:23,代码来源:wsgi.py
示例20: _refresh_resource_mixins
def _refresh_resource_mixins(self, extras):
"""
Register the flavors as ResourceTemplates to which the user has access.
"""
template_schema = 'http://schemas.openstack.org/template/resource#'
os_flavours = instance_types.get_all_types()
for itype in os_flavours.values():
ctg_term = occify_terms(itype['name'])
resource_template = os_mixins.ResourceTemplate(
term=quote(ctg_term),
flavor_id=itype['flavorid'],
scheme=template_schema,
related=[infrastructure.RESOURCE_TEMPLATE],
title='This is an openstack ' + itype['name'] + ' flavor.',
location='/' + quote(ctg_term) + '/')
try:
self.registry.get_backend(resource_template, extras)
except AttributeError:
msg = 'Registering an OpenStack flavour/instance type: %s' % \
str(resource_template)
LOG.debug(msg)
self.register_backend(resource_template, MIXIN_BACKEND)
开发者ID:Acidburn0zzz,项目名称:occi-os,代码行数:24,代码来源:wsgi.py
注:本文中的nova.compute.instance_types.get_all_types函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论