本文整理汇总了Python中nova.compute.flavors.create函数的典型用法代码示例。如果您正苦于以下问题:Python create函数的具体用法?Python create怎么用?Python create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_create_flavor_ephemeral_error
def test_create_flavor_ephemeral_error(self):
args = ("ephemeral_test", "1024", "1", "10", "9999999999")
try:
flavors.create(*args)
self.fail("Be sure this will never be executed.")
except exception.InvalidInput as e:
self.assertIn("ephemeral", e.message)
开发者ID:375670450,项目名称:nova,代码行数:7,代码来源:test_flavors.py
示例2: test_ephemeral_gb_must_be_nonnegative_db_integer
def test_ephemeral_gb_must_be_nonnegative_db_integer(self):
self.assertInvalidInput('flavor1', 64, 1, 120, ephemeral_gb='foo')
self.assertInvalidInput('flavor1', 64, 1, 120, ephemeral_gb=-1)
self.assertInvalidInput('flavor1', 64, 1, 120,
ephemeral_gb=db.MAX_INT + 1)
flavors.create('flavor1', 64, 1, 120, ephemeral_gb=0)
flavors.create('flavor2', 64, 1, 120, ephemeral_gb=120)
开发者ID:mahak,项目名称:nova,代码行数:7,代码来源:test_flavors.py
示例3: test_swap_must_be_nonnegative_db_integer
def test_swap_must_be_nonnegative_db_integer(self):
self.assertInvalidInput('flavor1', 64, 1, 120, swap='foo')
self.assertInvalidInput('flavor1', 64, 1, 120, swap=-1)
self.assertInvalidInput('flavor1', 64, 1, 120,
swap=db.MAX_INT + 1)
flavors.create('flavor1', 64, 1, 120, swap=0)
flavors.create('flavor2', 64, 1, 120, swap=1)
开发者ID:mahak,项目名称:nova,代码行数:7,代码来源:test_flavors.py
示例4: test_add_flavor_access_already_exists
def test_add_flavor_access_already_exists(self):
user_id = "fake"
project_id = "fake"
ctxt = context.RequestContext(user_id, project_id, is_admin=True)
flavor_id = "flavor1"
flavors.create("some flavor", 256, 1, 120, 100, flavorid=flavor_id)
flavors.add_flavor_access(flavor_id, project_id, ctxt=ctxt)
self.assertRaises(exception.FlavorAccessExists, flavors.add_flavor_access, flavor_id, project_id, ctxt)
开发者ID:newgoliath,项目名称:nova,代码行数:8,代码来源:test_flavors.py
示例5: test_flavorid_populated
def test_flavorid_populated(self):
flavor1 = flavors.create('flavor1', 64, 1, 120)
self.assertIsNot(None, flavor1['flavorid'])
flavor2 = flavors.create('flavor2', 64, 1, 120, flavorid='')
self.assertIsNot(None, flavor2['flavorid'])
flavor3 = flavors.create('flavor3', 64, 1, 120, flavorid='foo')
self.assertEqual('foo', flavor3['flavorid'])
开发者ID:MasterZ40,项目名称:nova,代码行数:9,代码来源:test_flavors.py
示例6: test_remove_flavor_access_doesnt_exists
def test_remove_flavor_access_doesnt_exists(self):
user_id = 'fake'
project_id = 'fake'
ctxt = context.RequestContext(user_id, project_id, is_admin=True)
flavor_id = 'flavor1'
flavors.create('some flavor', 256, 1, 120, 100, flavorid=flavor_id)
self.assertRaises(exception.FlavorAccessNotFound,
flavors.remove_flavor_access,
flavor_id, project_id, ctxt=ctxt)
开发者ID:Charu-Sharma,项目名称:nova,代码行数:9,代码来源:test_flavors.py
示例7: test_flavorid_populated
def test_flavorid_populated(self):
flavor1 = flavors.create("flavor1", 64, 1, 120)
self.assertIsNot(None, flavor1["flavorid"])
flavor2 = flavors.create("flavor2", 64, 1, 120, flavorid="")
self.assertIsNot(None, flavor2["flavorid"])
flavor3 = flavors.create("flavor3", 64, 1, 120, flavorid="foo")
self.assertEqual("foo", flavor3["flavorid"])
开发者ID:sdague,项目名称:nova,代码行数:9,代码来源:test_instance_types.py
示例8: test_flavorid_populated
def test_flavorid_populated(self):
flavor1 = flavors.create('flavor1', 64, 1, 120)
self.assertIsNotNone(flavor1.flavorid)
flavor2 = flavors.create('flavor2', 64, 1, 120, flavorid='')
self.assertIsNotNone(flavor2.flavorid)
flavor3 = flavors.create('flavor3', 64, 1, 120, flavorid='foo')
self.assertEqual('foo', flavor3.flavorid)
开发者ID:mahak,项目名称:nova,代码行数:9,代码来源:test_flavors.py
示例9: test_rxtx_factor_must_be_positive_float
def test_rxtx_factor_must_be_positive_float(self):
self.assertInvalidInput("flavor1", 64, 1, 120, rxtx_factor="foo")
self.assertInvalidInput("flavor1", 64, 1, 120, rxtx_factor=-1.0)
self.assertInvalidInput("flavor1", 64, 1, 120, rxtx_factor=0.0)
flavor = flavors.create("flavor1", 64, 1, 120, rxtx_factor=1.0)
self.assertEqual(1.0, flavor["rxtx_factor"])
flavor = flavors.create("flavor2", 64, 1, 120, rxtx_factor=1.1)
self.assertEqual(1.1, flavor["rxtx_factor"])
开发者ID:sdague,项目名称:nova,代码行数:10,代码来源:test_instance_types.py
示例10: test_rxtx_factor_must_be_positive_float
def test_rxtx_factor_must_be_positive_float(self):
self.assertInvalidInput('flavor1', 64, 1, 120, rxtx_factor='foo')
self.assertInvalidInput('flavor1', 64, 1, 120, rxtx_factor=-1.0)
self.assertInvalidInput('flavor1', 64, 1, 120, rxtx_factor=0.0)
flavor = flavors.create('flavor1', 64, 1, 120, rxtx_factor=1.0)
self.assertEqual(1.0, flavor.rxtx_factor)
flavor = flavors.create('flavor2', 64, 1, 120, rxtx_factor=1.1)
self.assertEqual(1.1, flavor.rxtx_factor)
开发者ID:mahak,项目名称:nova,代码行数:10,代码来源:test_flavors.py
示例11: test_read_deleted_false_converting_flavorid
def test_read_deleted_false_converting_flavorid(self):
"""Ensure deleted flavors are not returned when not needed (for
example when creating a server and attempting to translate from
flavorid to instance_type_id.
"""
flavors.create("instance_type1", 256, 1, 120, 100, "test1")
flavors.destroy("instance_type1")
flavors.create("instance_type1_redo", 256, 1, 120, 100, "test1")
instance_type = flavors.get_flavor_by_flavor_id("test1", read_deleted="no")
self.assertEqual("instance_type1_redo", instance_type.name)
开发者ID:isyippee,项目名称:nova,代码行数:11,代码来源:test_flavors.py
示例12: test_name_length_checks
def test_name_length_checks(self):
MAX_LEN = 255
# Flavor name with 255 characters or less is valid.
flavors.create('a' * MAX_LEN, 64, 1, 120)
# Flavor name which is more than 255 characters will cause error.
self.assertInvalidInput('a' * (MAX_LEN + 1), 64, 1, 120)
# Flavor name which is empty should cause an error
self.assertInvalidInput('', 64, 1, 120)
开发者ID:MasterZ40,项目名称:nova,代码行数:11,代码来源:test_flavors.py
示例13: test_remove_flavor_access
def test_remove_flavor_access(self):
user_id = "fake"
project_id = "fake"
ctxt = context.RequestContext(user_id, project_id, is_admin=True)
flavor_id = "flavor1"
flavors.create("some flavor", 256, 1, 120, 100, flavorid=flavor_id)
flavors.add_flavor_access(flavor_id, project_id, ctxt)
flavors.remove_flavor_access(flavor_id, project_id, ctxt)
projects = flavors.get_flavor_access_by_flavor_id(flavor_id, ctxt)
self.assertEqual([], projects)
开发者ID:newgoliath,项目名称:nova,代码行数:11,代码来源:test_flavors.py
示例14: 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:Acidburn0zzz,项目名称:nova,代码行数:12,代码来源:test_flavors.py
示例15: 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
示例16: 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
示例17: 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
示例18: _create_flavor
def _create_flavor(self, context, flavor):
""" Create and insert the flavor """
flavor_dict = flavor.__dict__
name = self.prefix + flavor.name
flavorid = self.prefix + flavor.id
memory = flavor.ram
vcpus = flavor.vcpus
root_gb = flavor.disk
ephemeral_gb = flavor_dict.get('OS-FLV-EXT-DATA:ephemeral', 0)
u_swap = flavor_dict.get('swap', 0)
rxtx_factor = flavor_dict.get('rxtx_factor', 1.0)
is_public = flavor_dict.get('os-flavor-access:is_public', True)
if u_swap == "":
swap = 0
else:
swap = int(u_swap)
try:
return flavors.create(name, memory, vcpus, root_gb,
ephemeral_gb=ephemeral_gb,
flavorid=flavorid, swap=swap,
rxtx_factor=rxtx_factor,
is_public=is_public)
except exception.InstanceExists as err:
raise err
开发者ID:gpanda,项目名称:powervc-driver,代码行数:25,代码来源:flavorsync.py
示例19: _create
def _create(self, req, body):
context = req.environ['nova.context']
authorize(context)
vals = body['flavor']
name = vals['name']
flavorid = vals.get('id')
memory = vals['ram']
vcpus = vals['vcpus']
root_gb = vals['disk']
ephemeral_gb = vals.get('ephemeral', 0)
swap = vals.get('swap', 0)
rxtx_factor = vals.get('os-flavor-rxtx:rxtx_factor', 1.0)
is_public = vals.get('flavor-access:is_public', True)
try:
flavor = flavors.create(name, memory, vcpus, root_gb,
ephemeral_gb=ephemeral_gb,
flavorid=flavorid, swap=swap,
rxtx_factor=rxtx_factor,
is_public=is_public)
if not flavor['is_public']:
flavors.add_flavor_access(flavor['flavorid'],
context.project_id, context)
req.cache_db_flavor(flavor)
except (exception.FlavorExists,
exception.FlavorIdExists) as err:
raise webob.exc.HTTPConflict(explanation=err.format_message())
return self._view_builder.show(req, flavor)
开发者ID:AsherBond,项目名称:nova,代码行数:31,代码来源:flavor_manage.py
示例20: test_default_values
def test_default_values(self):
flavor1 = flavors.create('flavor1', 64, 1, 120)
self.assertIsNot(None, flavor1['flavorid'])
self.assertEqual(flavor1['ephemeral_gb'], 0)
self.assertEqual(flavor1['swap'], 0)
self.assertEqual(flavor1['rxtx_factor'], 1.0)
开发者ID:MasterZ40,项目名称:nova,代码行数:7,代码来源:test_flavors.py
注:本文中的nova.compute.flavors.create函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论