summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-10-01 21:56:20 +0000
committerGerrit Code Review <review@openstack.org>2012-10-01 21:56:20 +0000
commitd399c755688c5c4d7f7aa5cb5fa8a55b4319f9ff (patch)
tree2f9a13bc50847ec240f291934cf6ec3863cc495e /nova
parent14cfc19381b7f923b9c0e174038810a1a1aec5dc (diff)
parenta36288351af519ef62ad4f52b3e3e38601ba3f58 (diff)
downloadnova-d399c755688c5c4d7f7aa5cb5fa8a55b4319f9ff.tar.gz
nova-d399c755688c5c4d7f7aa5cb5fa8a55b4319f9ff.tar.xz
nova-d399c755688c5c4d7f7aa5cb5fa8a55b4319f9ff.zip
Merge "xenapi: Removing legacy swap-in-image."
Diffstat (limited to 'nova')
-rw-r--r--nova/tests/test_xenapi.py25
-rw-r--r--nova/tests/xenapi/stubs.py10
-rw-r--r--nova/virt/xenapi/vm_utils.py19
-rw-r--r--nova/virt/xenapi/vmops.py23
4 files changed, 3 insertions, 74 deletions
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py
index 0449f3daf..ed76c72aa 100644
--- a/nova/tests/test_xenapi.py
+++ b/nova/tests/test_xenapi.py
@@ -618,30 +618,6 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
os_type="linux", architecture="x86-64")
self.check_vm_params_for_linux()
- def test_spawn_vhd_glance_swapdisk(self):
- # Change the default host_call_plugin to one that'll return
- # a swap disk
- orig_func = stubs.FakeSessionForVMTests.host_call_plugin
- _host_call_plugin = stubs.FakeSessionForVMTests.host_call_plugin_swap
- stubs.FakeSessionForVMTests.host_call_plugin = _host_call_plugin
- # Stubbing out firewall driver as previous stub sets a particular
- # stub for async plugin calls
- stubs.stubout_firewall_driver(self.stubs, self.conn)
- try:
- # We'll steal the above glance linux test
- self.test_spawn_vhd_glance_linux()
- finally:
- # Make sure to put this back
- stubs.FakeSessionForVMTests.host_call_plugin = orig_func
-
- # We should have 2 VBDs.
- self.assertEqual(len(self.vm['VBDs']), 2)
- # Now test that we have 1.
- self.tearDown()
- self.setUp()
- self.test_spawn_vhd_glance_linux()
- self.assertEqual(len(self.vm['VBDs']), 1)
-
def test_spawn_vhd_glance_windows(self):
self._test_spawn(IMAGE_VHD, None, None,
os_type="windows", architecture="i386")
@@ -1410,7 +1386,6 @@ class XenAPIGenerateLocal(stubs.XenAPITestBase):
super(XenAPIGenerateLocal, self).setUp()
self.flags(xenapi_connection_url='test_url',
xenapi_connection_password='test_pass',
- xenapi_generate_swap=True,
firewall_driver='nova.virt.xenapi.firewall.'
'Dom0IptablesFirewallDriver')
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
diff --git a/nova/tests/xenapi/stubs.py b/nova/tests/xenapi/stubs.py
index fa1108175..35aa8e4aa 100644
--- a/nova/tests/xenapi/stubs.py
+++ b/nova/tests/xenapi/stubs.py
@@ -175,16 +175,6 @@ class FakeSessionForVMTests(fake.SessionBase):
return (super(FakeSessionForVMTests, self).
host_call_plugin(_1, _2, plugin, method, _5))
- def host_call_plugin_swap(self, _1, _2, plugin, method, _5):
- if (plugin, method) == ('glance', 'download_vhd'):
- root_uuid = _make_fake_vdi()
- swap_uuid = _make_fake_vdi()
- return pickle.dumps(dict(root=dict(uuid=root_uuid),
- swap=dict(uuid=swap_uuid)))
- else:
- return (super(FakeSessionForVMTests, self).
- host_call_plugin(_1, _2, plugin, method, _5))
-
def VM_start(self, _1, ref, _2, _3):
vm = fake.get_record('VM', ref)
if vm['power_state'] != 'Halted':
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py
index 2dc358f0f..47cbba6c4 100644
--- a/nova/virt/xenapi/vm_utils.py
+++ b/nova/virt/xenapi/vm_utils.py
@@ -848,12 +848,6 @@ def _create_cached_image(context, session, instance, name_label,
session.call_xenapi('VDI.add_to_other_config',
root_vdi_ref, 'image-id', str(image_id))
- swap_vdi = vdis.get('swap')
- if swap_vdi:
- session.call_xenapi(
- 'VDI.add_to_other_config', root_vdi_ref, 'swap-disk',
- str(swap_vdi['uuid']))
-
if FLAGS.use_cow_images and sr_type == 'ext':
new_vdi_ref = _clone_vdi(session, root_vdi_ref)
else:
@@ -868,19 +862,6 @@ def _create_cached_image(context, session, instance, name_label,
else ImageType.to_string(image_type))
vdi_uuid = session.call_xenapi('VDI.get_uuid', new_vdi_ref)
vdis[vdi_type] = dict(uuid=vdi_uuid, file=None)
-
- # Create a swap disk if the glance image had one associated with it.
- vdi_rec = session.call_xenapi('VDI.get_record', root_vdi_ref)
- if 'swap-disk' in vdi_rec['other_config']:
- swap_disk_uuid = vdi_rec['other_config']['swap-disk']
- swap_vdi_ref = session.call_xenapi('VDI.get_by_uuid',
- swap_disk_uuid)
- new_swap_vdi_ref = _safe_copy_vdi(
- session, sr_ref, instance, swap_vdi_ref)
- new_swap_vdi_uuid = session.call_xenapi('VDI.get_uuid',
- new_swap_vdi_ref)
- vdis['swap'] = dict(uuid=new_swap_vdi_uuid, file=None)
-
return vdis
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index cea5485ab..ae8efc5f3 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -57,11 +57,7 @@ xenapi_vmops_opts = [
'to go to running state'),
cfg.StrOpt('xenapi_vif_driver',
default='nova.virt.xenapi.vif.XenAPIBridgeDriver',
- help='The XenAPI VIF driver using XenServer Network APIs.'),
- cfg.BoolOpt('xenapi_generate_swap',
- default=False,
- help='Whether to generate swap '
- '(False means fetching it from OVA)'),
+ help='The XenAPI VIF driver using XenServer Network APIs.')
]
FLAGS = flags.FLAGS
@@ -425,6 +421,7 @@ class VMOps(object):
def _attach_disks(self, instance, vm_ref, name_label, disk_image_type,
vdis):
ctx = nova_context.get_admin_context()
+ instance_type = db.instance_type_get(ctx, instance['instance_type_id'])
# DISK_ISO needs two VBDs: the ISO disk and a blank RW disk
if disk_image_type == vm_utils.ImageType.DISK_ISO:
@@ -447,8 +444,6 @@ class VMOps(object):
if instance['auto_disk_config']:
LOG.debug(_("Auto configuring disk, attempting to "
"resize partition..."), instance=instance)
- instance_type = db.instance_type_get(ctx,
- instance['instance_type_id'])
vm_utils.auto_configure_disk(self._session,
root_vdi['ref'],
instance_type['root_gb'])
@@ -457,23 +452,11 @@ class VMOps(object):
DEVICE_ROOT, bootable=True)
# Attach (optional) swap disk
- swap_vdi = vdis.get('swap')
-
- instance_type = db.instance_type_get(ctx, instance['instance_type_id'])
swap_mb = instance_type['swap']
- generate_swap = swap_mb and FLAGS.xenapi_generate_swap
- if generate_swap:
+ if swap_mb:
vm_utils.generate_swap(self._session, instance, vm_ref,
DEVICE_SWAP, name_label, swap_mb)
- if swap_vdi:
- # We won't be using packaged swap VDI, so destroy it
- vm_utils.destroy_vdi(self._session, swap_vdi['ref'])
- elif swap_vdi:
- # Attach packaged swap VDI to VM
- vm_utils.create_vbd(self._session, vm_ref, swap_vdi['ref'],
- DEVICE_SWAP, bootable=False)
-
# Attach (optional) ephemeral disk
ephemeral_gb = instance_type['ephemeral_gb']
if ephemeral_gb: