summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py21
5 files changed, 6 insertions, 92 deletions
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py
index b543f3e0f..cb1ce40c6 100644
--- a/nova/tests/test_xenapi.py
+++ b/nova/tests/test_xenapi.py
@@ -617,30 +617,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")
@@ -1372,7 +1348,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 3bfdd3dbe..397312469 100644
--- a/nova/tests/xenapi/stubs.py
+++ b/nova/tests/xenapi/stubs.py
@@ -178,16 +178,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 a9adb4575..9aee422d0 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 52cb9b17b..9029bf0c2 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:
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py b/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py
index 027d26a67..66f46a839 100644
--- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py
+++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py
@@ -221,6 +221,7 @@ def _validate_sequenced_vhds(staging_path):
if not filename.endswith('.vhd'):
continue
+ # Ignore legacy swap embedded in the image, generated on-the-fly now
if filename == "swap.vhd":
continue
@@ -242,13 +243,11 @@ def import_vhds(sr_path, staging_path, uuid_stack):
Returns: A dict of imported VHDs:
- {'root': {'uuid': 'ffff-aaaa'},
- 'swap': {'uuid': 'ffff-bbbb'}}
+ {'root': {'uuid': 'ffff-aaaa'}}
"""
_handle_old_style_images(staging_path)
_validate_sequenced_vhds(staging_path)
- imported_vhds = {}
files_to_move = []
# Collect sequenced VHDs and assign UUIDs to them
@@ -286,26 +285,12 @@ def import_vhds(sr_path, staging_path, uuid_stack):
_assert_vhd_not_hidden(leaf_vhd_path)
_validate_vdi_chain(leaf_vhd_path)
- imported_vhds["root"] = {"uuid": leaf_vhd_uuid}
-
- # Handle swap file if present
- orig_swap_path = os.path.join(staging_path, "swap.vhd")
- if os.path.exists(orig_swap_path):
- # Rename swap.vhd -> aaaa-bbbb-cccc-dddd.vhd
- vhd_uuid = uuid_stack.pop()
- swap_path = os.path.join(staging_path, "%s.vhd" % vhd_uuid)
- _rename(orig_swap_path, swap_path)
-
- _assert_vhd_not_hidden(swap_path)
-
- imported_vhds["swap"] = {"uuid": vhd_uuid}
- files_to_move.append(swap_path)
-
# Move files into SR
for orig_path in files_to_move:
new_path = os.path.join(sr_path, os.path.basename(orig_path))
_rename(orig_path, new_path)
+ imported_vhds = dict(root=dict(uuid=leaf_vhd_uuid))
return imported_vhds