本文整理汇总了Python中nova.compute.instance_types.create函数的典型用法代码示例。如果您正苦于以下问题:Python create函数的具体用法?Python create怎么用?Python create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_duplicate_names_fail
def test_duplicate_names_fail(self):
"""Ensures that name duplicates raise ApiError"""
name = 'some_name'
instance_types.create(name, 256, 1, 120, 'flavor1')
self.assertRaises(exception.ApiError,
instance_types.create,
name, 256, 1, 120, 'flavor2')
开发者ID:BillTheBest,项目名称:nova,代码行数:7,代码来源:test_instance_types.py
示例2: test_duplicate_flavorids_fail
def test_duplicate_flavorids_fail(self):
"""Ensures that flavorid duplicates raise InstanceTypeCreateFailed"""
flavorid = 'flavor1'
instance_types.create('name one', 256, 1, 120, 200, flavorid)
self.assertRaises(exception.InstanceTypeIdExists,
instance_types.create,
'name two', 256, 1, 120, 200, flavorid)
开发者ID:EE-NovRain,项目名称:nova,代码行数:7,代码来源:test_instance_types.py
示例3: test_duplicate_names_fail
def test_duplicate_names_fail(self):
"""Ensures that name duplicates raise InstanceTypeCreateFailed"""
name = 'some_name'
instance_types.create(name, 256, 1, 120, 200, 'flavor1')
self.assertRaises(exception.InstanceTypeExists,
instance_types.create,
name, 256, 1, 120, 200, 'flavor2')
开发者ID:EE-NovRain,项目名称:nova,代码行数:7,代码来源:test_instance_types.py
示例4: test_duplicate_flavorids_fail
def test_duplicate_flavorids_fail(self):
"""Ensures that flavorid duplicates raise ApiError"""
flavorid = 'flavor1'
instance_types.create('name one', 256, 1, 120, flavorid)
self.assertRaises(exception.ApiError,
instance_types.create,
'name two', 256, 1, 120, flavorid)
开发者ID:BillTheBest,项目名称:nova,代码行数:7,代码来源:test_instance_types.py
示例5: test_repeated_inst_types_should_raise_api_error
def test_repeated_inst_types_should_raise_api_error(self):
"""Ensures that instance duplicates raises ApiError"""
new_name = self.name + "dup"
instance_types.create(new_name, 256, 1, 120, self.flavorid + 1)
instance_types.destroy(new_name)
self.assertRaises(
exception.ApiError,
instance_types.create, new_name, 256, 1, 120, self.flavorid)
开发者ID:AsherBond,项目名称:dodai-compute,代码行数:8,代码来源:test_instance_types.py
示例6: create
def create(self, name, memory, vcpus, root_gb, ephemeral_gb=0,
flavorid=None, swap=0, rxtx_factor=1.0, is_public=True):
"""Creates instance types / flavors."""
try:
instance_types.create(name, memory, vcpus, root_gb,
ephemeral_gb, flavorid, swap, rxtx_factor,
is_public)
except exception.InvalidInput, e:
print _("Must supply valid parameters to create instance_type")
print e
return(1)
开发者ID:AnyBucket,项目名称:nova,代码行数:11,代码来源:manage.py
示例7: 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
示例8: test_read_deleted_false_converting_flavorid
def test_read_deleted_false_converting_flavorid(self):
"""
Ensure deleted instance types are not returned when not needed (for
example when creating a server and attempting to translate from
flavorid to instance_type_id.
"""
instance_types.create("instance_type1", 256, 1, 120, 100, "test1")
instance_types.destroy("instance_type1")
instance_types.create("instance_type1_redo", 256, 1, 120, 100, "test1")
instance_type = instance_types.get_instance_type_by_flavor_id("test1", read_deleted="no")
self.assertEqual("instance_type1_redo", instance_type["name"])
开发者ID:jamesbjackson,项目名称:openstack-smartos-nova-grizzly,代码行数:12,代码来源:test_instance_types.py
示例9: 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
示例10: 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
示例11: _create
def _create(self, req, body):
context = req.environ['nova.context']
authorize(context)
vals = body['flavor']
name = vals['name']
flavorid = vals.get('id')
memory_mb = vals.get('ram')
vcpus = vals.get('vcpus')
root_gb = vals.get('disk')
ephemeral_gb = vals.get('OS-FLV-EXT-DATA:ephemeral')
swap = vals.get('swap')
rxtx_factor = vals.get('rxtx_factor')
is_public = vals.get('os-flavor-access:is_public', True)
try:
flavor = instance_types.create(name, memory_mb, vcpus,
root_gb, ephemeral_gb, flavorid,
swap, rxtx_factor, is_public)
req.cache_db_flavor(flavor)
except (exception.InstanceTypeExists,
exception.InstanceTypeIdExists) as err:
raise webob.exc.HTTPConflict(explanation=str(err))
return self._view_builder.show(req, flavor)
开发者ID:Cerberus98,项目名称:nova,代码行数:25,代码来源:flavormanage.py
示例12: test_remove_instance_type_access_doesnt_exists
def test_remove_instance_type_access_doesnt_exists(self):
user_id = "fake"
project_id = "fake"
ctxt = context.RequestContext(user_id, project_id, is_admin=True)
flavor_id = "flavor1"
type_ref = instance_types.create("some flavor", 256, 1, 120, 100, flavorid=flavor_id)
self.assertRaises(
exception.FlavorAccessNotFound, instance_types.remove_instance_type_access, flavor_id, project_id, ctxt=ctxt
)
开发者ID:jamesbjackson,项目名称:openstack-smartos-nova-grizzly,代码行数:9,代码来源:test_instance_types.py
示例13: test_add_instance_type_access
def test_add_instance_type_access(self):
user_id = "fake"
project_id = "fake"
ctxt = context.RequestContext(user_id, project_id, is_admin=True)
flavor_id = "flavor1"
type_ref = instance_types.create("some flavor", 256, 1, 120, 100, flavorid=flavor_id)
access_ref = instance_types.add_instance_type_access(flavor_id, project_id, ctxt=ctxt)
self.assertEqual(access_ref["project_id"], project_id)
self.assertEqual(access_ref["instance_type_id"], type_ref["id"])
开发者ID:jamesbjackson,项目名称:openstack-smartos-nova-grizzly,代码行数:9,代码来源:test_instance_types.py
示例14: test_instance_type_create_with_long_flavor_name
def test_instance_type_create_with_long_flavor_name(self):
# Flavor name with 255 characters or less is valid.
name = "a" * 255
inst_type = instance_types.create(name, 64, 1, 120, flavorid=11)
self.assertEqual(inst_type["name"], name)
# Flavor name which is more than 255 characters will cause error.
name = "a" * 256
self.assertRaises(exception.InvalidInput, instance_types.create, name, 64, 1, 120, flavorid=11)
开发者ID:jamesbjackson,项目名称:openstack-smartos-nova-grizzly,代码行数:9,代码来源:test_instance_types.py
示例15: test_add_instance_type_access_already_exists
def test_add_instance_type_access_already_exists(self):
user_id = "fake"
project_id = "fake"
ctxt = context.RequestContext(user_id, project_id, is_admin=True)
flavor_id = "flavor1"
type_ref = instance_types.create("some flavor", 256, 1, 120, 100, flavorid=flavor_id)
access_ref = instance_types.add_instance_type_access(flavor_id, project_id, ctxt=ctxt)
self.assertRaises(
exception.FlavorAccessExists, instance_types.add_instance_type_access, flavor_id, project_id, ctxt
)
开发者ID:jamesbjackson,项目名称:openstack-smartos-nova-grizzly,代码行数:10,代码来源:test_instance_types.py
示例16: test_instance_type_create_without_flavorid
def test_instance_type_create_without_flavorid(self):
name = "Small Flavor"
inst_type = instance_types.create(name, 256, 1, 120, 100)
self.assertNotEqual(inst_type["flavorid"], None)
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)
开发者ID:jamesbjackson,项目名称:openstack-smartos-nova-grizzly,代码行数:11,代码来源:test_instance_types.py
示例17: test_instance_type_create_with_custom_rxtx_factor
def test_instance_type_create_with_custom_rxtx_factor(self):
name = "Custom RXTX Factor"
inst_type = instance_types.create(name, 256, 1, 120, 100, rxtx_factor=9.9)
self.assertNotEqual(inst_type["flavorid"], None)
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"], 9.9)
开发者ID:jamesbjackson,项目名称:openstack-smartos-nova-grizzly,代码行数:11,代码来源:test_instance_types.py
示例18: test_instance_type_create_without_flavorid
def test_instance_type_create_without_flavorid(self):
name = 'Small Flavor'
inst_type = instance_types.create(name, 256, 1, 120, 100)
self.assertNotEqual(inst_type['flavorid'], None)
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)
开发者ID:EE-NovRain,项目名称:nova,代码行数:11,代码来源:test_instance_types.py
示例19: test_instance_type_create_with_custom_rxtx_factor
def test_instance_type_create_with_custom_rxtx_factor(self):
name = 'Custom RXTX Factor'
inst_type = instance_types.create(name, 256, 1, 120, 100,
rxtx_factor=9.9)
self.assertNotEqual(inst_type['flavorid'], None)
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'], 9.9)
开发者ID:AnyBucket,项目名称:nova,代码行数:12,代码来源:test_instance_types.py
示例20: test_instance_type_create_with_empty_flavorid
def test_instance_type_create_with_empty_flavorid(self):
# Ensure that auto-generated uuid is assigned.
name = 'Empty String ID Flavor'
flavorid = ''
inst_type = instance_types.create(name, 256, 1, 120, 100, flavorid)
self.assertEqual(len(inst_type['flavorid']), 36)
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)
开发者ID:AnyBucket,项目名称:nova,代码行数:13,代码来源:test_instance_types.py
注:本文中的nova.compute.instance_types.create函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论