Skip to content

Commit

Permalink
Merge "Handle missing 'provider_location' in rm_export."
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Sep 10, 2012
2 parents 2e4c232 + ff3b994 commit 641223d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions nova/tests/api/ec2/test_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ def setUp(self):
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,
Expand Down Expand Up @@ -163,6 +165,9 @@ def tearDown(self):
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)

Expand Down
12 changes: 6 additions & 6 deletions nova/volume/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,6 @@ def create_export(self, context, volume):

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
Expand All @@ -378,6 +372,12 @@ def remove_export(self, context, volume):
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)
Expand Down

0 comments on commit 641223d

Please sign in to comment.