From d14ac4bf38f23e429572f210f7b0560493968b15 Mon Sep 17 00:00:00 2001 From: Nirmal Ranganathan Date: Tue, 1 May 2012 14:02:16 -0500 Subject: Adding 'host' info to volume-compute connection information. Added a new key 'host' for the initialize/terminate volume connection information. Updated the HpSanISCSIDriver to use teh initialize and terminate methods. Added missing unit tests for the HpSanISCSIDriver. Fixes bug 992729. Change-Id: I09fad6b5328cbfb860ab2c7ae5d206010f3dd45d --- nova/volume/san.py | 89 ++++++++++++++++++++++++------------------------------ 1 file changed, 39 insertions(+), 50 deletions(-) (limited to 'nova/volume') diff --git a/nova/volume/san.py b/nova/volume/san.py index aecb9a0b5..9d83864d0 100644 --- a/nova/volume/san.py +++ b/nova/volume/san.py @@ -582,6 +582,14 @@ class HpSanISCSIDriver(SanISCSIDriver): return model_update + def create_volume_from_snapshot(self, volume, snapshot): + """Creates a volume from a snapshot.""" + raise NotImplementedError() + + def create_snapshot(self, snapshot): + """Creates a snapshot.""" + raise NotImplementedError() + def delete_volume(self, volume): """Deletes a volume.""" cliq_args = {} @@ -594,64 +602,45 @@ class HpSanISCSIDriver(SanISCSIDriver): # TODO(justinsb): Is this needed here? raise exception.Error(_("local_path not supported")) - def ensure_export(self, context, volume): - """Synchronously recreates an export for a logical volume.""" - return self._do_export(context, volume, force_create=False) - - def create_export(self, context, volume): - return self._do_export(context, volume, force_create=True) + def initialize_connection(self, volume, connector): + """Assigns the volume to a server. - def _do_export(self, context, volume, force_create): - """Supports ensure_export and create_export""" - volume_info = self._cliq_get_volume_info(volume['name']) + Assign any created volume to a compute node/host so that it can be + used from that host. HP VSA requires a volume to be assigned + to a server. - is_shared = 'permission.authGroup' in volume_info + This driver returns a driver_volume_type of 'iscsi'. + The format of the driver data is defined in _get_iscsi_properties. + Example return value:: - model_update = {} + { + 'driver_volume_type': 'iscsi' + 'data': { + 'target_discovered': True, + 'target_iqn': 'iqn.2010-10.org.openstack:volume-00000001', + 'target_portal': '127.0.0.0.1:3260', + 'volume_id': 1, + } + } - should_export = False - - if force_create or not is_shared: - should_export = True - # Check that we have a project_id - project_id = volume['project_id'] - if not project_id: - project_id = context.project_id - - if project_id: - #TODO(justinsb): Use a real per-project password here - chap_username = 'proj_' + project_id - # HP/Lefthand requires that the password be >= 12 characters - chap_password = 'project_secret_' + project_id - else: - msg = (_("Could not determine project for volume %s, " - "can't export") % - (volume['name'])) - if force_create: - raise exception.Error(msg) - else: - LOG.warn(msg) - should_export = False - - if should_export: - cliq_args = {} - cliq_args['volumeName'] = volume['name'] - cliq_args['chapName'] = chap_username - cliq_args['targetSecret'] = chap_password - - self._cliq_run_xml("assignVolumeChap", cliq_args) - - model_update['provider_auth'] = ("CHAP %s %s" % - (chap_username, chap_password)) + """ + cliq_args = {} + cliq_args['volumeName'] = volume['name'] + cliq_args['serverName'] = connector['host'] + self._cliq_run_xml("assignVolumeToServer", cliq_args) - return model_update + iscsi_properties = self._get_iscsi_properties(volume) + return { + 'driver_volume_type': 'iscsi', + 'data': iscsi_properties + } - def remove_export(self, context, volume): - """Removes an export for a logical volume.""" + def terminate_connection(self, volume, connector): + """Unassign the volume from the host.""" cliq_args = {} cliq_args['volumeName'] = volume['name'] - - self._cliq_run_xml("unassignVolume", cliq_args) + cliq_args['serverName'] = connector['host'] + self._cliq_run_xml("unassignVolumeToServer", cliq_args) class SolidFireSanISCSIDriver(SanISCSIDriver): -- cgit