本文整理汇总了Python中nova.compute.flavors.get_default_flavor函数的典型用法代码示例。如果您正苦于以下问题:Python get_default_flavor函数的具体用法?Python get_default_flavor怎么用?Python get_default_flavor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_default_flavor函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_count_members_by_user
def test_count_members_by_user(self):
instance1 = tests_utils.get_test_instance(self.context,
flavor=flavors.get_default_flavor(), obj=True)
instance1.user_id = 'user1'
instance1.save()
instance2 = tests_utils.get_test_instance(self.context,
flavor=flavors.get_default_flavor(), obj=True)
instance2.user_id = 'user2'
instance2.save()
instance3 = tests_utils.get_test_instance(self.context,
flavor=flavors.get_default_flavor(), obj=True)
instance3.user_id = 'user2'
instance3.save()
instance_ids = [instance1.uuid, instance2.uuid, instance3.uuid]
values = self._get_default_values()
group = self._create_instance_group(self.context, values)
instance_group.InstanceGroup.add_members(self.context, group.uuid,
instance_ids)
group = instance_group.InstanceGroup.get_by_uuid(self.context,
group.uuid)
count_user1 = group.count_members_by_user(self.context, 'user1')
count_user2 = group.count_members_by_user(self.context, 'user2')
count_user3 = group.count_members_by_user(self.context, 'user3')
self.assertEqual(1, count_user1)
self.assertEqual(2, count_user2)
self.assertEqual(0, count_user3)
开发者ID:andrey01,项目名称:openstack-nova,代码行数:28,代码来源:test_instance_group.py
示例2: test_get_hosts
def test_get_hosts(self):
instance1 = tests_utils.get_test_instance(self.context,
flavor=flavors.get_default_flavor(), obj=True)
instance1.host = 'hostA'
instance1.save()
instance2 = tests_utils.get_test_instance(self.context,
flavor=flavors.get_default_flavor(), obj=True)
instance2.host = 'hostB'
instance2.save()
instance3 = tests_utils.get_test_instance(self.context,
flavor=flavors.get_default_flavor(), obj=True)
instance3.host = 'hostB'
instance3.save()
instance_ids = [instance1.uuid, instance2.uuid, instance3.uuid]
values = self._get_default_values()
group = self._create_instance_group(self.context, values)
instance_group.InstanceGroup.add_members(self.context, group.uuid,
instance_ids)
group = instance_group.InstanceGroup.get_by_uuid(self.context,
group.uuid)
hosts = group.get_hosts(self.context)
self.assertEqual(2, len(hosts))
self.assertIn('hostA', hosts)
self.assertIn('hostB', hosts)
hosts = group.get_hosts(self.context, exclude=[instance1.uuid])
self.assertEqual(1, len(hosts))
self.assertIn('hostB', hosts)
开发者ID:andrey01,项目名称:openstack-nova,代码行数:29,代码来源:test_instance_group.py
示例3: test_allocate_for_instance_handles_macs_passed
def test_allocate_for_instance_handles_macs_passed(self):
# If a macs argument is supplied to the 'nova-network' API, it is just
# ignored. This test checks that the call down to the rpcapi layer
# doesn't pass macs down: nova-network doesn't support hypervisor
# mac address limits (today anyhow).
macs = set(["ab:cd:ef:01:23:34"])
with mock.patch.object(self.network_api.network_rpcapi, "allocate_for_instance") as mock_alloc:
kwargs = dict(
zip(
[
"host",
"instance_id",
"project_id",
"requested_networks",
"rxtx_factor",
"vpn",
"macs",
"dhcp_options",
],
itertools.repeat(mock.ANY),
)
)
mock_alloc.return_value = []
flavor = flavors.get_default_flavor()
flavor["rxtx_factor"] = 0
instance = objects.Instance(
id=1, uuid=uuids.instance, project_id="project_id", host="host", system_metadata={}, flavor=flavor
)
self.network_api.allocate_for_instance(self.context, instance, "vpn", requested_networks=None, macs=macs)
mock_alloc.assert_called_once_with(self.context, **kwargs)
开发者ID:sebrandon1,项目名称:nova,代码行数:30,代码来源:test_api.py
示例4: fake_instance_create
def fake_instance_create(context, inst_, session=None):
inst = fake_instance.fake_db_instance(
**{
"id": 1,
"uuid": AUTO_INSTANCE_UUID,
"created_at": datetime.datetime(2010, 10, 10, 12, 0, 0),
"updated_at": datetime.datetime(2010, 10, 10, 12, 0, 0),
"progress": 0,
"name": "instance-1", # this is a property
"task_state": "",
"vm_state": "",
"auto_disk_config": inst_["auto_disk_config"],
"security_groups": inst_["security_groups"],
"instance_type": flavors.get_default_flavor(),
}
)
def fake_instance_get_for_create(context, id_, *args, **kwargs):
return (inst, inst)
self.stubs.Set(db, "instance_update_and_get_original", fake_instance_get_for_create)
def fake_instance_get_all_for_create(context, *args, **kwargs):
return [inst]
self.stubs.Set(db, "instance_get_all", fake_instance_get_all_for_create)
self.stubs.Set(db, "instance_get_all_by_filters", fake_instance_get_all_for_create)
def fake_instance_add_security_group(context, instance_id, security_group_id):
pass
self.stubs.Set(db, "instance_add_security_group", fake_instance_add_security_group)
return inst
开发者ID:siriusxh,项目名称:nova,代码行数:34,代码来源:test_disk_config.py
示例5: test_flavor_get_by_None_name_returns_default
def test_flavor_get_by_None_name_returns_default(self):
# Ensure get by name returns default flavor with no name.
default = flavors.get_default_flavor()
actual = flavors.get_flavor_by_name(None)
self.assertIsInstance(default, objects.Flavor)
self.assertIsInstance(actual, objects.Flavor)
self.assertEqual(default.flavorid, actual.flavorid)
开发者ID:Juniper,项目名称:nova,代码行数:7,代码来源:test_flavors.py
示例6: setUp
def setUp(self):
super(SimpleTenantUsageControllerTest, self).setUp()
self.controller = simple_tenant_usage.SimpleTenantUsageController()
class FakeComputeAPI:
def get_instance_type(self, context, flavor_type):
if flavor_type == 1:
return flavors.get_default_flavor()
else:
raise exception.InstanceTypeNotFound(flavor_type)
self.compute_api = FakeComputeAPI()
self.context = None
now = timeutils.utcnow()
self.baseinst = dict(display_name='foo',
launched_at=now - datetime.timedelta(1),
terminated_at=now,
instance_type_id=1,
vm_state='deleted',
deleted=0)
basetype = flavors.get_default_flavor()
sys_meta = utils.dict_to_metadata(
flavors.save_flavor_info({}, basetype))
self.baseinst['system_metadata'] = sys_meta
self.basetype = flavors.extract_flavor(self.baseinst)
开发者ID:Acidburn0zzz,项目名称:nova,代码行数:26,代码来源:test_simple_tenant_usage.py
示例7: fake_inst_obj
def fake_inst_obj(context):
inst = objects.Instance(
context=context,
id=1,
user_id="fake_user",
uuid="b65cee2f-8c69-4aeb-be2f-f79742548fc2",
project_id="test",
key_name="key",
key_data="ssh-rsa AAAAB3Nzai....N3NtHw== [email protected]",
host="test",
launch_index=1,
reservation_id="r-xxxxxxxx",
user_data=ENCODE_USER_DATA_STRING,
image_ref=7,
vcpus=1,
fixed_ips=[],
root_device_name="/dev/sda1",
hostname="test.novadomain",
display_name="my_displayname",
metadata={},
default_ephemeral_device=None,
default_swap_device=None,
system_metadata={},
)
nwinfo = network_model.NetworkInfo([])
inst.info_cache = objects.InstanceInfoCache(context=context, instance_uuid=inst.uuid, network_info=nwinfo)
with mock.patch.object(inst, "save"):
inst.set_flavor(flavors.get_default_flavor())
return inst
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:29,代码来源:test_metadata.py
示例8: test_delete_flavor_info
def test_delete_flavor_info(self):
instance_type = flavors.get_default_flavor()
metadata = {}
flavors.save_flavor_info(metadata, instance_type)
flavors.save_flavor_info(metadata, instance_type, '_')
flavors.delete_flavor_info(metadata, '', '_')
self.assertEqual(metadata, {})
开发者ID:MasterZ40,项目名称:nova,代码行数:7,代码来源:test_flavors.py
示例9: test_allocate_for_instance_handles_macs_passed
def test_allocate_for_instance_handles_macs_passed(self):
# If a macs argument is supplied to the 'nova-network' API, it is just
# ignored. This test checks that the call down to the rpcapi layer
# doesn't pass macs down: nova-network doesn't support hypervisor
# mac address limits (today anyhow).
macs = set(['ab:cd:ef:01:23:34'])
self.mox.StubOutWithMock(self.network_api.network_rpcapi,
"allocate_for_instance")
kwargs = dict(
zip([
'host', 'instance_id', 'project_id', 'requested_networks',
'rxtx_factor', 'vpn', 'macs', 'dhcp_options'
], itertools.repeat(mox.IgnoreArg())))
self.network_api.network_rpcapi.allocate_for_instance(
mox.IgnoreArg(), **kwargs).AndReturn([])
self.mox.ReplayAll()
flavor = flavors.get_default_flavor()
flavor['rxtx_factor'] = 0
instance = objects.Instance(
id=1,
uuid='uuid',
project_id='project_id',
host='host',
system_metadata={},
flavor=flavor)
self.network_api.allocate_for_instance(
self.context, instance, 'vpn', 'requested_networks', macs=macs)
开发者ID:anantk,项目名称:nova,代码行数:27,代码来源:test_api.py
示例10: test_allocate_for_instance_handles_macs_passed
def test_allocate_for_instance_handles_macs_passed(self):
# If a macs argument is supplied to the 'nova-network' API, it is just
# ignored. This test checks that the call down to the rpcapi layer
# doesn't pass macs down: nova-network doesn't support hypervisor
# mac address limits (today anyhow).
macs = set(["ab:cd:ef:01:23:34"])
self.mox.StubOutWithMock(self.network_api.network_rpcapi, "allocate_for_instance")
kwargs = dict(
zip(
[
"host",
"instance_id",
"project_id",
"requested_networks",
"rxtx_factor",
"vpn",
"macs",
"dhcp_options",
],
itertools.repeat(mox.IgnoreArg()),
)
)
self.network_api.network_rpcapi.allocate_for_instance(mox.IgnoreArg(), **kwargs).AndReturn([])
self.mox.ReplayAll()
flavor = flavors.get_default_flavor()
flavor["rxtx_factor"] = 0
sys_meta = flavors.save_flavor_info({}, flavor)
instance = dict(
id="id", uuid="uuid", project_id="project_id", host="host", system_metadata=utils.dict_to_metadata(sys_meta)
)
self.network_api.allocate_for_instance(self.context, instance, "vpn", "requested_networks", macs=macs)
开发者ID:Thingee,项目名称:nova,代码行数:31,代码来源:test_api.py
示例11: _stub_migrate_instance_calls
def _stub_migrate_instance_calls(self, method, multi_host, info):
fake_flavor = flavors.get_default_flavor()
fake_flavor['rxtx_factor'] = 1.21
fake_instance = objects.Instance(
uuid=uuid.uuid4().hex,
project_id='fake_project_id',
instance_type_id=fake_flavor['id'],
flavor=fake_flavor,
system_metadata={})
fake_migration = {
'source_compute': 'fake_compute_source',
'dest_compute': 'fake_compute_dest'
}
def fake_mig_inst_method(*args, **kwargs):
info['kwargs'] = kwargs
def fake_get_multi_addresses(*args, **kwargs):
return multi_host, ['fake_float1', 'fake_float2']
self.stubs.Set(network_rpcapi.NetworkAPI, method, fake_mig_inst_method)
self.stubs.Set(self.network_api, '_get_multi_addresses',
fake_get_multi_addresses)
expected = {
'instance_uuid': fake_instance.uuid,
'source_compute': 'fake_compute_source',
'dest_compute': 'fake_compute_dest',
'rxtx_factor': 1.21,
'project_id': 'fake_project_id',
'floating_addresses': None
}
if multi_host:
expected['floating_addresses'] = ['fake_float1', 'fake_float2']
return fake_instance, fake_migration, expected
开发者ID:anantk,项目名称:nova,代码行数:35,代码来源:test_api.py
示例12: _stub_migrate_instance_calls
def _stub_migrate_instance_calls(self, method, multi_host, info):
fake_flavor = flavors.get_default_flavor()
fake_flavor["rxtx_factor"] = 1.21
fake_instance = objects.Instance(
uuid=uuid.uuid4().hex,
project_id="fake_project_id",
instance_type_id=fake_flavor["id"],
flavor=fake_flavor,
system_metadata={},
)
fake_migration = {"source_compute": "fake_compute_source", "dest_compute": "fake_compute_dest"}
def fake_mig_inst_method(*args, **kwargs):
info["kwargs"] = kwargs
def fake_get_multi_addresses(*args, **kwargs):
return multi_host, ["fake_float1", "fake_float2"]
self.stub_out("nova.network.rpcapi.NetworkAPI." + method, fake_mig_inst_method)
self.stub_out("nova.network.api.API._get_multi_addresses", fake_get_multi_addresses)
expected = {
"instance_uuid": fake_instance.uuid,
"source_compute": "fake_compute_source",
"dest_compute": "fake_compute_dest",
"rxtx_factor": 1.21,
"project_id": "fake_project_id",
"floating_addresses": None,
}
if multi_host:
expected["floating_addresses"] = ["fake_float1", "fake_float2"]
return fake_instance, fake_migration, expected
开发者ID:sebrandon1,项目名称:nova,代码行数:32,代码来源:test_api.py
示例13: test_get_flavor_from_deleted_with_id
def test_get_flavor_from_deleted_with_id(self):
# Deleted instances may not have type info in system_metadata,
# so verify that they get their type from a lookup of their
# instance_type_id
inst_without_sys_meta = dict(self.baseinst, system_metadata=[], deleted=1)
flavor = self.controller._get_flavor(self.context, self.compute_api, inst_without_sys_meta, {})
self.assertEqual(flavor, flavors.get_default_flavor())
开发者ID:imsplitbit,项目名称:nova,代码行数:7,代码来源:test_simple_tenant_usage.py
示例14: _stub_migrate_instance_calls
def _stub_migrate_instance_calls(self, method, multi_host, info):
fake_flavor = flavors.get_default_flavor()
fake_flavor['rxtx_factor'] = 1.21
sys_meta = utils.dict_to_metadata(
flavors.save_flavor_info({}, fake_flavor))
fake_instance = {'uuid': 'fake_uuid',
'instance_type_id': fake_flavor['id'],
'project_id': 'fake_project_id',
'system_metadata': sys_meta}
fake_migration = {'source_compute': 'fake_compute_source',
'dest_compute': 'fake_compute_dest'}
def fake_mig_inst_method(*args, **kwargs):
info['kwargs'] = kwargs
def fake_get_multi_addresses(*args, **kwargs):
return multi_host, ['fake_float1', 'fake_float2']
self.stubs.Set(network_rpcapi.NetworkAPI, method,
fake_mig_inst_method)
self.stubs.Set(self.network_api, '_get_multi_addresses',
fake_get_multi_addresses)
expected = {'instance_uuid': 'fake_uuid',
'source_compute': 'fake_compute_source',
'dest_compute': 'fake_compute_dest',
'rxtx_factor': 1.21,
'project_id': 'fake_project_id',
'floating_addresses': None}
if multi_host:
expected['floating_addresses'] = ['fake_float1', 'fake_float2']
return fake_instance, fake_migration, expected
开发者ID:Krylon360,项目名称:nova,代码行数:32,代码来源:test_api.py
示例15: fake_inst_obj
def fake_inst_obj(context):
inst = objects.Instance(
context=context,
id=1,
user_id='fake_user',
uuid='b65cee2f-8c69-4aeb-be2f-f79742548fc2',
project_id='test',
key_name="key",
key_data="ssh-rsa AAAAB3Nzai....N3NtHw== [email protected]",
host='test',
launch_index=1,
reservation_id='r-xxxxxxxx',
user_data=ENCODE_USER_DATA_STRING,
image_ref=7,
kernel_id=None,
ramdisk_id=None,
vcpus=1,
fixed_ips=[],
root_device_name='/dev/sda1',
hostname='test.novadomain',
display_name='my_displayname',
metadata={},
default_ephemeral_device=None,
default_swap_device=None,
system_metadata={},
availability_zone=None)
nwinfo = network_model.NetworkInfo([])
inst.info_cache = objects.InstanceInfoCache(context=context,
instance_uuid=inst.uuid,
network_info=nwinfo)
with mock.patch.object(inst, 'save'):
inst.set_flavor(flavors.get_default_flavor())
return inst
开发者ID:apporc,项目名称:nova,代码行数:33,代码来源:test_metadata.py
示例16: test_get_hosts_with_some_none
def test_get_hosts_with_some_none(self):
instance1 = tests_utils.get_test_instance(self.context, flavor=flavors.get_default_flavor(), obj=True)
instance1.host = None
instance1.save()
instance2 = tests_utils.get_test_instance(self.context, flavor=flavors.get_default_flavor(), obj=True)
instance2.host = "hostB"
instance2.save()
instance_ids = [instance1.uuid, instance2.uuid]
values = self._get_default_values()
group = self._create_instance_group(self.context, values)
instance_group.InstanceGroup.add_members(self.context, group.uuid, instance_ids)
group = instance_group.InstanceGroup.get_by_uuid(self.context, group.uuid)
hosts = group.get_hosts(self.context)
self.assertEqual(1, len(hosts))
self.assertIn("hostB", hosts)
开发者ID:dlq84,项目名称:nova,代码行数:17,代码来源:test_instance_group.py
示例17: test_set_default_ephemeral_device
def test_set_default_ephemeral_device(self):
instance = objects.Instance(context=self.context)
instance.system_metadata = flavors.save_flavor_info(
{}, flavors.get_default_flavor())
instance.system_metadata['instance_type_ephemeral_gb'] = 1
with mock.patch.object(instance, 'save') as mock_save:
self.driver._set_default_ephemeral_device(instance)
mock_save.assert_called_once_with()
self.assertEqual('/dev/sda1', instance.default_ephemeral_device)
开发者ID:AsherBond,项目名称:nova,代码行数:9,代码来源:test_driver.py
示例18: _get_instance_xml
def _get_instance_xml(self, driver, vif, image_meta=None):
default_inst_type = flavors.get_default_flavor()
extra_specs = default_inst_type["extra_specs"].items()
quota_bandwidth = self.bandwidth.items()
default_inst_type["extra_specs"] = dict(extra_specs + quota_bandwidth)
conf = self._get_conf()
nic = driver.get_config(self.instance, vif, image_meta, default_inst_type)
conf.add_device(nic)
return conf.to_xml()
开发者ID:nagyist,项目名称:openstack-nova,代码行数:9,代码来源:test_vif.py
示例19: _test_set_flavor
def _test_set_flavor(self, namespace):
prefix = "%s_" % namespace if namespace is not None else ""
db_inst = db.instance_create(
self.context, {"user_id": self.context.user_id, "project_id": self.context.project_id}
)
inst = instance.Instance.get_by_uuid(self.context, db_inst["uuid"])
db_flavor = flavors.get_default_flavor()
inst.set_flavor(db_flavor, namespace)
db_inst = db.instance_get(self.context, db_inst["id"])
self.assertEqual(db_flavor["flavorid"], flavors.extract_flavor(db_inst, prefix)["flavorid"])
开发者ID:VinceOnGit,项目名称:nova,代码行数:10,代码来源:test_instance.py
示例20: _test_get_flavor
def _test_get_flavor(self, namespace):
prefix = '%s_' % namespace if namespace is not None else ''
db_inst = db.instance_create(self.context, {
'user_id': self.context.user_id,
'project_id': self.context.project_id,
'system_metadata': flavors.save_flavor_info(
{}, flavors.get_default_flavor(), prefix)})
db_flavor = flavors.extract_flavor(db_inst, prefix)
inst = instance.Instance.get_by_uuid(self.context, db_inst['uuid'])
flavor = inst.get_flavor(namespace)
self.assertEqual(db_flavor['flavorid'], flavor.flavorid)
开发者ID:chengxiayan,项目名称:nova,代码行数:11,代码来源:test_instance.py
注:本文中的nova.compute.flavors.get_default_flavor函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论