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
=== modified file 'Authors'
--- Authors 2011-04-07 23:08:15 +0000
+++ Authors 2011-05-13 02:36:31 +0000
@@ -58,6 +58,7 @@
58Naveed Massjouni <naveedm9@gmail.com>58Naveed Massjouni <naveedm9@gmail.com>
59Nirmal Ranganathan <nirmal.ranganathan@rackspace.com>59Nirmal Ranganathan <nirmal.ranganathan@rackspace.com>
60Paul Voccio <paul@openstack.org>60Paul Voccio <paul@openstack.org>
61Renuka Apte <renuka.apte@citrix.com>
61Ricardo Carrillo Cruz <emaildericky@gmail.com>62Ricardo Carrillo Cruz <emaildericky@gmail.com>
62Rick Clark <rick@openstack.org>63Rick Clark <rick@openstack.org>
63Rick Harris <rconradharris@gmail.com>64Rick Harris <rconradharris@gmail.com>
6465
=== modified file 'nova/virt/xenapi/volume_utils.py'
--- nova/virt/xenapi/volume_utils.py 2011-03-11 23:48:44 +0000
+++ nova/virt/xenapi/volume_utils.py 2011-05-13 02:36:31 +0000
@@ -204,14 +204,17 @@
204 if isinstance(path_or_id, int):204 if isinstance(path_or_id, int):
205 return path_or_id205 return path_or_id
206 # n must contain at least the volume_id206 # n must contain at least the volume_id
207 # /vol- is for remote volumes207 # :volume- is for remote volumes
208 # -vol- is for local volumes208 # -volume- is for local volumes
209 # see compute/manager->setup_compute_volume209 # see compute/manager->setup_compute_volume
210 volume_id = path_or_id[path_or_id.find('/vol-') + 1:]210 volume_id = path_or_id[path_or_id.find(':volume-') + 1:]
211 if volume_id == path_or_id:211 if volume_id == path_or_id:
212 volume_id = path_or_id[path_or_id.find('-vol-') + 1:]212 volume_id = path_or_id[path_or_id.find('-volume--') + 1:]
213 volume_id = volume_id.replace('--', '-')213 volume_id = volume_id.replace('volume--', '')
214 return volume_id214 else:
215 volume_id = volume_id.replace('volume-', '')
216 volume_id = volume_id[0:volume_id.find('-')]
217 return int(volume_id)
215218
216219
217def _get_target_host(iscsi_string):220def _get_target_host(iscsi_string):
@@ -244,25 +247,23 @@
244 Gets iscsi name and portal from volume name and host.247 Gets iscsi name and portal from volume name and host.
245 For this method to work the following are needed:248 For this method to work the following are needed:
246 1) volume_ref['host'] must resolve to something rather than loopback249 1) volume_ref['host'] must resolve to something rather than loopback
247 2) ietd must bind only to the address as resolved above
248 If any of the two conditions are not met, fall back on Flags.
249 """250 """
250 volume_ref = db.volume_get_by_ec2_id(context.get_admin_context(),251 volume_ref = db.volume_get(context.get_admin_context(),
251 volume_id)252 volume_id)
252 result = (None, None)253 result = (None, None)
253 try:254 try:
254 (r, _e) = utils.execute("sudo iscsiadm -m discovery -t "255 (r, _e) = utils.execute('sudo', 'iscsiadm',
255 "sendtargets -p %s" %256 '-m', 'discovery',
256 volume_ref['host'])257 '-t', 'sendtargets',
258 '-p', volume_ref['host'])
257 except exception.ProcessExecutionError, exc:259 except exception.ProcessExecutionError, exc:
258 LOG.exception(exc)260 LOG.exception(exc)
259 else:261 else:
260 targets = r.splitlines()262 volume_name = "volume-%08x" % volume_id
261 if len(_e) == 0 and len(targets) == 1:263 for target in r.splitlines():
262 for target in targets:264 if FLAGS.iscsi_ip_prefix in target and volume_name in target:
263 if volume_id in target:265 (location, _sep, iscsi_name) = target.partition(" ")
264 (location, _sep, iscsi_name) = target.partition(" ")266 break
265 break267 iscsi_portal = location.split(",")[0]
266 iscsi_portal = location.split(",")[0]268 result = (iscsi_name, iscsi_portal)
267 result = (iscsi_name, iscsi_portal)
268 return result269 return result

Subscribers

People subscribed via source and target branches