From ff3b994f12edf28d187bb1987aa7094b7897b015 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Fri, 7 Sep 2012 11:52:03 -0400 Subject: Handle missing 'provider_location' in rm_export. Updates the remove_export function in the ISCSIDriver so that it handles the case where provider_location isn't set on a volume. This can occur if a volume is created but not exported. This was a regression from a previous commit (66f6a9edce3ccd624aba5d2a6bf3362901ed57f7) which changed the way iscsi targets are created/deleted. With this commit the Nova Smoke Test volume tests should once again pass. Fixes LP Bug #1046484. Change-Id: I4539d73691a058d8fdc6c864dee06c0d4e4813f7 --- nova/tests/api/ec2/test_cloud.py | 5 +++++ nova/volume/driver.py | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/nova/tests/api/ec2/test_cloud.py b/nova/tests/api/ec2/test_cloud.py index ff84def77..6301ce180 100644 --- a/nova/tests/api/ec2/test_cloud.py +++ b/nova/tests/api/ec2/test_cloud.py @@ -99,6 +99,8 @@ class CloudTestCase(test.TestCase): self.flags(compute_driver='nova.virt.fake.FakeDriver', volumes_dir=vol_tmpdir) self.stubs.Set(iscsi.TgtAdm, '_get_target', self.fake_get_target) + self.stubs.Set(iscsi.TgtAdm, 'remove_iscsi_target', + self.fake_remove_iscsi_target) def fake_show(meh, context, id): return {'id': id, @@ -163,6 +165,9 @@ class CloudTestCase(test.TestCase): def fake_get_target(obj, iqn): return 1 + def fake_remove_iscsi_target(obj, tid, lun, vol_id, **kwargs): + pass + def _stub_instance_get_with_fixed_ips(self, func_name): orig_func = getattr(self.cloud.compute_api, func_name) diff --git a/nova/volume/driver.py b/nova/volume/driver.py index d03ad7cdc..3e974a915 100644 --- a/nova/volume/driver.py +++ b/nova/volume/driver.py @@ -347,12 +347,6 @@ class ISCSIDriver(VolumeDriver): def remove_export(self, context, volume): """Removes an export for a logical volume.""" - #BOOKMARK jdg - location = volume['provider_location'].split(' ') - iqn = location[1] - if 'iqn' not in iqn: - LOG.warning(_("Jacked... didn't get an iqn")) - return # NOTE(jdg): tgtadm doesn't use the iscsi_targets table # TODO(jdg): In the future move all of the dependent stuff into the @@ -369,6 +363,12 @@ class ISCSIDriver(VolumeDriver): iscsi_target = 0 try: + + # NOTE: provider_location may be unset if the volume hasn't + # been exported + location = volume['provider_location'].split(' ') + iqn = location[1] + # ietadm show will exit with an error # this export has already been removed self.tgtadm.show_target(iscsi_target, iqn=iqn) -- cgit