summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenuka Apte <renuka.apte@citrix.com>2011-04-08 14:46:26 -0700
committerRenuka Apte <renuka.apte@citrix.com>2011-04-08 14:46:26 -0700
commitd3de6cd1b2997e495a000b998b321346e2a75306 (patch)
treed1a2ec70feb51adfd005f3aee501f7e6e6aaa11d
parent11eb77870630dca9399070cd8c3d16f6e2bbce53 (diff)
downloadnova-d3de6cd1b2997e495a000b998b321346e2a75306.tar.gz
nova-d3de6cd1b2997e495a000b998b321346e2a75306.tar.xz
nova-d3de6cd1b2997e495a000b998b321346e2a75306.zip
Fixes euca-attach-volume for iscsi using Xenserver
Minor changes required to xenapi functions to get correct format for volume-id, iscsi-host, etc.
-rw-r--r--nova/virt/xenapi/volume_utils.py26
1 files changed, 11 insertions, 15 deletions
diff --git a/nova/virt/xenapi/volume_utils.py b/nova/virt/xenapi/volume_utils.py
index 72284ac02..27964cac0 100644
--- a/nova/virt/xenapi/volume_utils.py
+++ b/nova/virt/xenapi/volume_utils.py
@@ -209,9 +209,9 @@ def _get_volume_id(path_or_id):
# see compute/manager->setup_compute_volume
volume_id = path_or_id[path_or_id.find('/vol-') + 1:]
if volume_id == path_or_id:
- volume_id = path_or_id[path_or_id.find('-vol-') + 1:]
- volume_id = volume_id.replace('--', '-')
- return volume_id
+ volume_id = path_or_id[path_or_id.find('-volume--') + 1:]
+ volume_id = volume_id.replace('volume--', '')
+ return int(volume_id)
def _get_target_host(iscsi_string):
@@ -244,25 +244,21 @@ def _get_target(volume_id):
Gets iscsi name and portal from volume name and host.
For this method to work the following are needed:
1) volume_ref['host'] must resolve to something rather than loopback
- 2) ietd must bind only to the address as resolved above
- If any of the two conditions are not met, fall back on Flags.
"""
- volume_ref = db.volume_get_by_ec2_id(context.get_admin_context(),
+ volume_ref = db.volume_get(context.get_admin_context(),
volume_id)
result = (None, None)
try:
- (r, _e) = utils.execute("sudo iscsiadm -m discovery -t "
- "sendtargets -p %s" %
- volume_ref['host'])
+ (r, _e) = utils.execute('sudo', 'iscsiadm', '-m', 'discovery',
+ '-t', 'sendtargets', '-p', volume_ref['host'])
except exception.ProcessExecutionError, exc:
LOG.exception(exc)
else:
- targets = r.splitlines()
- if len(_e) == 0 and len(targets) == 1:
- for target in targets:
- if volume_id in target:
+ volume_name = "volume-%08x" % volume_id
+ for target in r.splitlines():
+ if FLAGS.iscsi_ip_prefix in target and volume_name in target:
(location, _sep, iscsi_name) = target.partition(" ")
break
- iscsi_portal = location.split(",")[0]
- result = (iscsi_name, iscsi_portal)
+ iscsi_portal = location.split(",")[0]
+ result = (iscsi_name, iscsi_portal)
return result