Merge lp:~renukaapte/nova/lp745340 into lp:~citrix-openstack/nova/xenapi

Proposed by Renuka Apte
Status: Merged
Approved by: Armando Migliaccio
Approved revision: 928
Merge reported by: Armando Migliaccio
Merged at revision: not available
Proposed branch: lp:~renukaapte/nova/lp745340
Merge into: lp:~citrix-openstack/nova/xenapi
Diff against target: 78 lines (+23/-21)
2 files modified
Authors (+1/-0)
nova/virt/xenapi/volume_utils.py (+22/-21)
To merge this branch: bzr merge lp:~renukaapte/nova/lp745340
Reviewer Review Type Date Requested Status
Armando Migliaccio (community) Approve
Vish Ishaya (community) Approve
termie (community) Approve
Review via email: mp+57399@code.launchpad.net
To post a comment you must log in.
lp:~renukaapte/nova/lp745340 updated
926. By Renuka Apte

Minor fixes

Revision history for this message
termie (termie) wrote :

You've got a few places with funky indents, looks like you just need to update the indentation of some of the lines around the lines you've changed.

Just a suggestion but my favorite way of dealing with these split up execute calls is:

44 + (r, _e) = utils.execute('sudo', 'iscsiadm', '-m', 'discovery',
45 + '-t', 'sendtargets', '-p', volume_ref['host'])

Is like this:

(r, _e) = utils.execute('sudo', 'iscsiadm',
                        '-m', 'discovery',
                        '-t', 'sendtargets',
                        '-p', volume_ref['host'])

I don't really understand your -vol- -volume-- changes, but I'll take your word for it that -vol- was incorrect.

review: Needs Fixing
lp:~renukaapte/nova/lp745340 updated
927. By Renuka Apte

Fix indentation.

Revision history for this message
Armando Migliaccio (armando-migliaccio) wrote :

lgtm. Maybe add a unit test to cover this part of the code?

review: Approve
Revision history for this message
Armando Migliaccio (armando-migliaccio) wrote :

I have noticed that this patch does not work when dealing with remove volumes (e.g. nova-volume running on a separate host from compute). Have a look at

http://bazaar.launchpad.net/~citrix-openstack/nova/cactus-addons/revision/995

review: Needs Fixing
lp:~renukaapte/nova/lp745340 updated
928. By Renuka Apte

Fix remote volume code

Revision history for this message
termie (termie) wrote :

the code looks fine, but I don't really understand the change, could you explain why the change from -vol- to -volume- is happening?

Revision history for this message
termie (termie) wrote :

(that's technically an approve, btu i'd still love more info)

review: Approve
Revision history for this message
Renuka Apte (renukaapte) wrote :

The function _get_volume_id expects a volume_id or path and returns an integer ID to that volume. The path to a local volume which has been created looks like /dev/mapper/nova--volumes-volume--00000001 for example. The path probably had -vol- in the past, which explains the original code. We simply want to get the numeric part of this path and convert it to an integer.

Revision history for this message
Renuka Apte (renukaapte) wrote :

Moving this merge proposal to nova trunk, instead of citrix-openstack.

Revision history for this message
Vish Ishaya (vishvananda) wrote :

lgtm. Armando can you verify the current changes?

review: Approve
Revision history for this message
Armando Migliaccio (armando-migliaccio) wrote :

I checked the changes and they look fine. We'd be better off by passing the volume id to the compute driver so that we would avoid the string manipulations. This is due to the fact that only dev_path and mountpoint are passed to driver->attach_volume (though dev_path contains the volume_id we are interested in). Changing the attach_volume signature would require a bit of work across the nova code (to make sure that other hypervisors are not affected), but a volume_id=None on the signature would be fine. I guess this could be carried out in another bug fix.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Authors'
2--- Authors 2011-04-07 23:08:15 +0000
3+++ Authors 2011-05-13 02:36:31 +0000
4@@ -58,6 +58,7 @@
5 Naveed Massjouni <naveedm9@gmail.com>
6 Nirmal Ranganathan <nirmal.ranganathan@rackspace.com>
7 Paul Voccio <paul@openstack.org>
8+Renuka Apte <renuka.apte@citrix.com>
9 Ricardo Carrillo Cruz <emaildericky@gmail.com>
10 Rick Clark <rick@openstack.org>
11 Rick Harris <rconradharris@gmail.com>
12
13=== modified file 'nova/virt/xenapi/volume_utils.py'
14--- nova/virt/xenapi/volume_utils.py 2011-03-11 23:48:44 +0000
15+++ nova/virt/xenapi/volume_utils.py 2011-05-13 02:36:31 +0000
16@@ -204,14 +204,17 @@
17 if isinstance(path_or_id, int):
18 return path_or_id
19 # n must contain at least the volume_id
20- # /vol- is for remote volumes
21- # -vol- is for local volumes
22+ # :volume- is for remote volumes
23+ # -volume- is for local volumes
24 # see compute/manager->setup_compute_volume
25- volume_id = path_or_id[path_or_id.find('/vol-') + 1:]
26+ volume_id = path_or_id[path_or_id.find(':volume-') + 1:]
27 if volume_id == path_or_id:
28- volume_id = path_or_id[path_or_id.find('-vol-') + 1:]
29- volume_id = volume_id.replace('--', '-')
30- return volume_id
31+ volume_id = path_or_id[path_or_id.find('-volume--') + 1:]
32+ volume_id = volume_id.replace('volume--', '')
33+ else:
34+ volume_id = volume_id.replace('volume-', '')
35+ volume_id = volume_id[0:volume_id.find('-')]
36+ return int(volume_id)
37
38
39 def _get_target_host(iscsi_string):
40@@ -244,25 +247,23 @@
41 Gets iscsi name and portal from volume name and host.
42 For this method to work the following are needed:
43 1) volume_ref['host'] must resolve to something rather than loopback
44- 2) ietd must bind only to the address as resolved above
45- If any of the two conditions are not met, fall back on Flags.
46 """
47- volume_ref = db.volume_get_by_ec2_id(context.get_admin_context(),
48- volume_id)
49+ volume_ref = db.volume_get(context.get_admin_context(),
50+ volume_id)
51 result = (None, None)
52 try:
53- (r, _e) = utils.execute("sudo iscsiadm -m discovery -t "
54- "sendtargets -p %s" %
55- volume_ref['host'])
56+ (r, _e) = utils.execute('sudo', 'iscsiadm',
57+ '-m', 'discovery',
58+ '-t', 'sendtargets',
59+ '-p', volume_ref['host'])
60 except exception.ProcessExecutionError, exc:
61 LOG.exception(exc)
62 else:
63- targets = r.splitlines()
64- if len(_e) == 0 and len(targets) == 1:
65- for target in targets:
66- if volume_id in target:
67- (location, _sep, iscsi_name) = target.partition(" ")
68- break
69- iscsi_portal = location.split(",")[0]
70- result = (iscsi_name, iscsi_portal)
71+ volume_name = "volume-%08x" % volume_id
72+ for target in r.splitlines():
73+ if FLAGS.iscsi_ip_prefix in target and volume_name in target:
74+ (location, _sep, iscsi_name) = target.partition(" ")
75+ break
76+ iscsi_portal = location.split(",")[0]
77+ result = (iscsi_name, iscsi_portal)
78 return result

Subscribers

People subscribed via source and target branches