本文整理汇总了Python中nova.db.instance_destroy函数的典型用法代码示例。如果您正苦于以下问题:Python instance_destroy函数的具体用法?Python instance_destroy怎么用?Python instance_destroy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了instance_destroy函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_live_migration_common_check_service_different_hypervisor
def test_live_migration_common_check_service_different_hypervisor(self):
"""Original host and dest host has different hypervisor type."""
dest = "dummydest"
instance_id = self._create_instance()
i_ref = db.instance_get(self.context, instance_id)
# compute service for destination
s_ref = self._create_compute_service(host=i_ref["host"])
# compute service for original host
s_ref2 = self._create_compute_service(host=dest, hypervisor_type="xen")
# mocks
driver = self.scheduler.driver
self.mox.StubOutWithMock(driver, "mounted_on_same_shared_storage")
driver.mounted_on_same_shared_storage(mox.IgnoreArg(), i_ref, dest)
self.mox.ReplayAll()
self.assertRaises(
exception.InvalidHypervisorType,
self.scheduler.driver._live_migration_common_check,
self.context,
i_ref,
dest,
)
db.instance_destroy(self.context, instance_id)
db.service_destroy(self.context, s_ref["id"])
db.service_destroy(self.context, s_ref2["id"])
开发者ID:rajarammallya,项目名称:openstack-nova,代码行数:28,代码来源:test_scheduler.py
示例2: test_unfilter_instance_undefines_nwfilters
def test_unfilter_instance_undefines_nwfilters(self):
admin_ctxt = context.get_admin_context()
fakefilter = NWFilterFakes()
self.fw._conn.nwfilterDefineXML = fakefilter.filterDefineXMLMock
self.fw._conn.nwfilterLookupByName = fakefilter.nwfilterLookupByName
instance_ref = self._create_instance()
inst_id = instance_ref['id']
inst_uuid = instance_ref['uuid']
self.security_group = self.setup_and_return_security_group()
db.instance_add_security_group(self.context, inst_uuid,
self.security_group['id'])
instance = db.instance_get(self.context, inst_id)
network_info = _fake_network_info(self.stubs, 1)
self.fw.setup_basic_filtering(instance, network_info)
original_filter_count = len(fakefilter.filters)
self.fw.unfilter_instance(instance, network_info)
self.assertEqual(original_filter_count - len(fakefilter.filters), 1)
db.instance_destroy(admin_ctxt, instance_ref['uuid'])
开发者ID:RibeiroAna,项目名称:nova,代码行数:25,代码来源:test_firewall.py
示例3: test_shelve
def test_shelve(self):
# Ensure instance can be shelved.
fake_instance = self._create_fake_instance_obj(
{'display_name': 'vm01'})
instance = fake_instance
self.assertIsNone(instance['task_state'])
def fake_init(self2):
# In original _FakeImageService.__init__(), some fake images are
# created. To verify the snapshot name of this test only, here
# sets a fake method.
self2.images = {}
def fake_create(self2, ctxt, metadata, data=None):
self.assertEqual(metadata['name'], 'vm01-shelved')
metadata['id'] = '8b24ed3f-ee57-43bc-bc2e-fb2e9482bc42'
return metadata
fake_image.stub_out_image_service(self)
self.stubs.Set(fake_image._FakeImageService, '__init__', fake_init)
self.stubs.Set(fake_image._FakeImageService, 'create', fake_create)
self.compute_api.shelve(self.context, instance)
self.assertEqual(instance.task_state, task_states.SHELVING)
db.instance_destroy(self.context, instance['uuid'])
开发者ID:amadev,项目名称:nova,代码行数:28,代码来源:test_shelve.py
示例4: test_add_console_does_not_duplicate
def test_add_console_does_not_duplicate(self, mock_get):
mock_get.return_value = self.pool_info
instance = self._create_instance()
cons1 = self.console.add_console(self.context, instance['id'])
cons2 = self.console.add_console(self.context, instance['id'])
self.assertEqual(cons1, cons2)
db.instance_destroy(self.context, instance['uuid'])
开发者ID:BeyondTheClouds,项目名称:nova,代码行数:7,代码来源:test_console.py
示例5: test_delete_fast_if_host_not_set
def test_delete_fast_if_host_not_set(self):
inst = self._create_instance_obj()
inst.host = ''
updates = {'progress': 0, 'task_state': task_states.DELETING}
self.mox.StubOutWithMock(inst, 'save')
self.mox.StubOutWithMock(db,
'block_device_mapping_get_all_by_instance')
self.mox.StubOutWithMock(db, 'constraint')
self.mox.StubOutWithMock(db, 'instance_destroy')
self.mox.StubOutWithMock(self.compute_api, '_create_reservations')
db.block_device_mapping_get_all_by_instance(self.context,
inst.uuid).AndReturn([])
inst.save()
self.compute_api._create_reservations(self.context,
inst, inst.instance_type_id,
inst.project_id, inst.user_id
).AndReturn(None)
db.constraint(host=mox.IgnoreArg()).AndReturn('constraint')
db.instance_destroy(self.context, inst.uuid, 'constraint')
self.mox.ReplayAll()
self.compute_api.delete(self.context, inst)
for k, v in updates.items():
self.assertEqual(inst[k], v)
开发者ID:raidwang,项目名称:nova,代码行数:28,代码来源:test_compute_api.py
示例6: test_too_many_cores
def test_too_many_cores(self):
"""Ensures we don't go over max cores"""
compute1 = self.start_service('compute', host='host1')
compute2 = self.start_service('compute', host='host2')
instance_ids1 = []
instance_ids2 = []
for index in xrange(FLAGS.max_cores):
instance_id = self._create_instance()
compute1.run_instance(self.context, instance_id)
instance_ids1.append(instance_id)
instance_id = self._create_instance()
compute2.run_instance(self.context, instance_id)
instance_ids2.append(instance_id)
instance_id = self._create_instance()
self.assertRaises(driver.NoValidHost,
self.scheduler.driver.schedule_run_instance,
self.context,
instance_id)
db.instance_destroy(self.context, instance_id)
for instance_id in instance_ids1:
compute1.terminate_instance(self.context, instance_id)
for instance_id in instance_ids2:
compute2.terminate_instance(self.context, instance_id)
compute1.kill()
compute2.kill()
开发者ID:pombredanne,项目名称:nova,代码行数:25,代码来源:test_scheduler.py
示例7: test_destroy_with_not_equal_constraint_met
def test_destroy_with_not_equal_constraint_met(self):
ctx = context.get_admin_context()
instance = db.instance_create(ctx, {'task_state': 'deleting'})
constraint = db.constraint(task_state=db.not_equal('error', 'resize'))
db.instance_destroy(ctx, instance['uuid'], constraint)
self.assertRaises(exception.InstanceNotFound, db.instance_get_by_uuid,
ctx, instance['uuid'])
开发者ID:matiu2,项目名称:nova,代码行数:7,代码来源:test_db_api.py
示例8: test_update_of_instance_wont_update_private_fields
def test_update_of_instance_wont_update_private_fields(self):
inst = db.instance_create(self.context, {})
self.cloud.update_instance(self.context, inst['id'],
mac_address='DE:AD:BE:EF')
inst = db.instance_get(self.context, inst['id'])
self.assertEqual(None, inst['mac_address'])
db.instance_destroy(self.context, inst['id'])
开发者ID:yosh,项目名称:nova,代码行数:7,代码来源:test_cloud.py
示例9: test_describe_instances
def test_describe_instances(self):
"""Makes sure describe_instances works and filters results."""
inst1 = db.instance_create(self.context, {'reservation_id': 'a',
'host': 'host1'})
inst2 = db.instance_create(self.context, {'reservation_id': 'a',
'host': 'host2'})
comp1 = db.service_create(self.context, {'host': 'host1',
'availability_zone': 'zone1',
'topic': "compute"})
comp2 = db.service_create(self.context, {'host': 'host2',
'availability_zone': 'zone2',
'topic': "compute"})
result = self.cloud.describe_instances(self.context)
result = result['reservationSet'][0]
self.assertEqual(len(result['instancesSet']), 2)
instance_id = cloud.id_to_ec2_id(inst2['id'])
result = self.cloud.describe_instances(self.context,
instance_id=[instance_id])
result = result['reservationSet'][0]
self.assertEqual(len(result['instancesSet']), 1)
self.assertEqual(result['instancesSet'][0]['instanceId'],
instance_id)
self.assertEqual(result['instancesSet'][0]
['placement']['availabilityZone'], 'zone2')
db.instance_destroy(self.context, inst1['id'])
db.instance_destroy(self.context, inst2['id'])
db.service_destroy(self.context, comp1['id'])
db.service_destroy(self.context, comp2['id'])
开发者ID:yosh,项目名称:nova,代码行数:28,代码来源:test_cloud.py
示例10: tearDown
def tearDown(self):
try:
shutil.rmtree(FLAGS.volumes_dir)
except OSError:
pass
db.instance_destroy(self.context, self.instance_uuid)
super(VolumeTestCase, self).tearDown()
开发者ID:xww,项目名称:nova-old,代码行数:7,代码来源:test_volume.py
示例11: test_remove_console
def test_remove_console(self):
instance = self._create_instance()
console_id = self.console.add_console(self.context, instance["id"])
self.console.remove_console(self.context, console_id)
self.assertRaises(exception.NotFound, db.console_get, self.context, console_id)
db.instance_destroy(self.context, instance["uuid"])
开发者ID:tr3buchet,项目名称:nova,代码行数:7,代码来源:test_console.py
示例12: test_live_migration_common_check_service_orig_not_exists
def test_live_migration_common_check_service_orig_not_exists(self):
"""Destination host does not exist."""
dest = 'dummydest'
# mocks for live_migration_common_check()
instance_id = self._create_instance()
i_ref = db.instance_get(self.context, instance_id)
t1 = utils.utcnow() - datetime.timedelta(10)
s_ref = self._create_compute_service(created_at=t1, updated_at=t1,
host=dest)
# mocks for mounted_on_same_shared_storage()
fpath = '/test/20110127120000'
self.mox.StubOutWithMock(driver, 'rpc', use_mock_anything=True)
topic = FLAGS.compute_topic
driver.rpc.call(mox.IgnoreArg(),
db.queue_get_for(self.context, topic, dest),
{"method": 'create_shared_storage_test_file'}).AndReturn(fpath)
driver.rpc.call(mox.IgnoreArg(),
db.queue_get_for(mox.IgnoreArg(), topic, i_ref['host']),
{"method": 'check_shared_storage_test_file',
"args": {'filename': fpath}})
driver.rpc.call(mox.IgnoreArg(),
db.queue_get_for(mox.IgnoreArg(), topic, dest),
{"method": 'cleanup_shared_storage_test_file',
"args": {'filename': fpath}})
self.mox.ReplayAll()
self.assertRaises(exception.SourceHostUnavailable,
self.scheduler.driver._live_migration_common_check,
self.context, i_ref, dest)
db.instance_destroy(self.context, instance_id)
db.service_destroy(self.context, s_ref['id'])
开发者ID:cp16net,项目名称:reddwarf,代码行数:34,代码来源:test_scheduler.py
示例13: test_live_migration_common_check_service_different_version
def test_live_migration_common_check_service_different_version(self):
"""Original host and dest host has different hypervisor version."""
dest = 'dummydest'
instance_id = self._create_instance()
i_ref = db.instance_get(self.context, instance_id)
# compute service for destination
s_ref = self._create_compute_service(host=i_ref['host'])
# compute service for original host
s_ref2 = self._create_compute_service(host=dest,
hypervisor_version=12002)
# mocks
driver = self.scheduler.driver
self.mox.StubOutWithMock(driver, 'mounted_on_same_shared_storage')
driver.mounted_on_same_shared_storage(mox.IgnoreArg(), i_ref, dest)
self.mox.ReplayAll()
self.assertRaises(exception.DestinationHypervisorTooOld,
self.scheduler.driver._live_migration_common_check,
self.context, i_ref, dest)
db.instance_destroy(self.context, instance_id)
db.service_destroy(self.context, s_ref['id'])
db.service_destroy(self.context, s_ref2['id'])
开发者ID:cp16net,项目名称:reddwarf,代码行数:25,代码来源:test_scheduler.py
示例14: test_shelve
def test_shelve(self):
# Ensure instance can be shelved.
fake_instance = self._create_fake_instance({'display_name': 'vm01'})
instance = jsonutils.to_primitive(fake_instance)
instance_uuid = instance['uuid']
self.compute.run_instance(self.context, instance, {}, {}, [], None,
None, True, None, False)
self.assertIsNone(instance['task_state'])
def fake_init(self2):
# In original _FakeImageService.__init__(), some fake images are
# created. To verify the snapshot name of this test only, here
# sets a fake method.
self2.images = {}
def fake_create(self2, ctxt, metadata):
self.assertEqual(metadata['name'], 'vm01-shelved')
metadata['id'] = '8b24ed3f-ee57-43bc-bc2e-fb2e9482bc42'
return metadata
fake_image.stub_out_image_service(self.stubs)
self.stubs.Set(fake_image._FakeImageService, '__init__', fake_init)
self.stubs.Set(fake_image._FakeImageService, 'create', fake_create)
inst_obj = instance_obj.Instance.get_by_uuid(self.context,
instance_uuid)
self.compute_api.shelve(self.context, inst_obj)
inst_obj.refresh()
self.assertEqual(inst_obj.task_state, task_states.SHELVING)
db.instance_destroy(self.context, instance['uuid'])
开发者ID:BATYD-Turksat,项目名称:nova_servo,代码行数:33,代码来源:test_shelve.py
示例15: test_shelve
def test_shelve(self):
# Ensure instance can be shelved.
fake_instance = self._create_fake_instance({"display_name": "vm01"})
instance = jsonutils.to_primitive(fake_instance)
instance_uuid = instance["uuid"]
self.assertIsNone(instance["task_state"])
def fake_init(self2):
# In original _FakeImageService.__init__(), some fake images are
# created. To verify the snapshot name of this test only, here
# sets a fake method.
self2.images = {}
def fake_create(self2, ctxt, metadata, data=None):
self.assertEqual(metadata["name"], "vm01-shelved")
metadata["id"] = "8b24ed3f-ee57-43bc-bc2e-fb2e9482bc42"
return metadata
fake_image.stub_out_image_service(self.stubs)
self.stubs.Set(fake_image._FakeImageService, "__init__", fake_init)
self.stubs.Set(fake_image._FakeImageService, "create", fake_create)
inst_obj = objects.Instance.get_by_uuid(self.context, instance_uuid)
self.compute_api.shelve(self.context, inst_obj)
inst_obj.refresh()
self.assertEqual(inst_obj.task_state, task_states.SHELVING)
db.instance_destroy(self.context, instance["uuid"])
开发者ID:AsherBond,项目名称:nova,代码行数:30,代码来源:test_shelve.py
示例16: test_show_works_correctly
def test_show_works_correctly(self):
"""show() works correctly as expected."""
ctxt = context.get_admin_context()
s_ref = self._create_compute_service()
i_ref1 = _create_instance(project_id='p-01', host=s_ref['host'])
i_ref2 = _create_instance(project_id='p-02', vcpus=3,
host=s_ref['host'])
result = self.controller.show(self.req, s_ref['host'])
c1 = ('resource' in result['host'] and
'usage' in result['host'])
compute_node = s_ref['compute_node'][0]
c2 = self._dic_is_equal(result['host']['resource'],
compute_node)
c3 = result['host']['usage'].keys() == ['p-01', 'p-02']
keys = ['vcpus', 'memory_mb']
c4 = self._dic_is_equal(
result['host']['usage']['p-01'], i_ref1, keys)
disk = i_ref2['root_gb'] + i_ref2['ephemeral_gb']
if result['host']['usage']['p-01']['local_gb'] == disk:
c6 = True
else:
c6 = False
c5 = self._dic_is_equal(
result['host']['usage']['p-02'], i_ref2, keys)
if result['host']['usage']['p-02']['local_gb'] == disk:
c7 = True
else:
c7 = False
self.assertTrue(c1 and c2 and c3 and c4 and c5 and c6 and c7)
db.service_destroy(ctxt, s_ref['id'])
db.instance_destroy(ctxt, i_ref1['id'])
db.instance_destroy(ctxt, i_ref2['id'])
开发者ID:Jaesang,项目名称:nova,代码行数:35,代码来源:test_hosts.py
示例17: test_too_many_addresses
def test_too_many_addresses(self):
"""Test for a NoMoreAddresses exception when all fixed ips are used.
"""
admin_context = context.get_admin_context()
network = db.project_get_network(admin_context, self.projects[0].id)
num_available_ips = db.network_count_available_ips(admin_context,
network['id'])
addresses = []
instance_ids = []
for i in range(num_available_ips):
instance_ref = self._create_instance(0)
instance_ids.append(instance_ref['id'])
address = self._create_address(0, instance_ref['id'])
addresses.append(address)
lease_ip(address)
ip_count = db.network_count_available_ips(context.get_admin_context(),
network['id'])
self.assertEqual(ip_count, 0)
self.assertRaises(db.NoMoreAddresses,
self.network.allocate_fixed_ip,
self.context,
'foo')
for i in range(num_available_ips):
self.network.deallocate_fixed_ip(self.context, addresses[i])
release_ip(addresses[i])
db.instance_destroy(context.get_admin_context(), instance_ids[i])
ip_count = db.network_count_available_ips(context.get_admin_context(),
network['id'])
self.assertEqual(ip_count, num_available_ips)
开发者ID:anotherjesse,项目名称:nova,代码行数:31,代码来源:test_network.py
示例18: test_delete_fast_if_host_not_set
def test_delete_fast_if_host_not_set(self):
inst = self._create_instance_obj()
inst.host = ''
db_inst = obj_base.obj_to_primitive(inst)
updates = {'progress': 0, 'task_state': task_states.DELETING}
new_inst = dict(db_inst, **updates)
self.mox.StubOutWithMock(db,
'block_device_mapping_get_all_by_instance')
self.mox.StubOutWithMock(db,
'instance_update_and_get_original')
self.mox.StubOutWithMock(db, 'constraint')
self.mox.StubOutWithMock(db, 'instance_destroy')
self.mox.StubOutWithMock(self.compute_api, '_create_reservations')
db.block_device_mapping_get_all_by_instance(self.context,
inst.uuid).AndReturn([])
db.instance_update_and_get_original(
self.context, inst.uuid, updates).AndReturn((db_inst, new_inst))
self.compute_api._create_reservations(self.context,
db_inst, new_inst,
inst.project_id,
inst.user_id).AndReturn(None)
db.constraint(host=mox.IgnoreArg()).AndReturn('constraint')
db.instance_destroy(self.context, inst.uuid, 'constraint')
if self.is_cells:
self.mox.StubOutWithMock(self.compute_api, '_cast_to_cells')
self.compute_api._cast_to_cells(
self.context, db_inst, 'delete')
self.mox.ReplayAll()
self.compute_api.delete(self.context, db_inst)
开发者ID:xqueralt,项目名称:nova,代码行数:34,代码来源:test_compute_api.py
示例19: init_host
def init_host(self, host=socket.gethostname()):
"""
Initialize anything that is necessary for the driver to function,
including catching up with currently running VE's on the given host.
"""
ctxt = context.get_admin_context()
LOG.debug("Hostname: %s" % (host,))
LOG.debug("Instances: %s" % (db.instance_get_all_by_host(ctxt, host)))
for instance in db.instance_get_all_by_host(ctxt, host):
try:
LOG.debug("Checking state of %s" % instance["name"])
state = self.get_info(instance["name"])["state"]
except exception.NotFound:
state = power_state.SHUTOFF
LOG.debug("Current state of %s was %s." % (instance["name"], state))
db.instance_set_state(ctxt, instance["id"], state)
if state == power_state.SHUTOFF:
db.instance_destroy(ctxt, instance["id"])
if state != power_state.RUNNING:
continue
开发者ID:ed-,项目名称:reddwarf,代码行数:25,代码来源:openvz_conn.py
示例20: _tearDownBlockDeviceMapping
def _tearDownBlockDeviceMapping(self, inst1, inst2, volumes):
for vol in volumes:
self.volume_api.delete(self.context, vol)
for uuid in (inst1["uuid"], inst2["uuid"]):
for bdm in db.block_device_mapping_get_all_by_instance(self.context, uuid):
db.block_device_mapping_destroy(self.context, bdm["id"])
db.instance_destroy(self.context, inst2["uuid"])
db.instance_destroy(self.context, inst1["uuid"])
开发者ID:99cloud,项目名称:nova,代码行数:8,代码来源:test_cinder_cloud.py
注:本文中的nova.db.instance_destroy函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论