From: Ann Kamyshnikova Date: Tue, 10 Sep 2013 13:59:15 +0000 (+0400) Subject: Remove dup of LVMISCSIDriver in LVMISERDriver X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=6a3e0fb136856411680c72e6c1e97d00dee6081a;p=openstack-build%2Fcinder-build.git Remove dup of LVMISCSIDriver in LVMISERDriver LVMISERDriver is almost copy of LVMISCSIDriver. Change-Id: I27f03ba19908184e96d05e7f17e581d906fc119a --- diff --git a/cinder/volume/drivers/lvm.py b/cinder/volume/drivers/lvm.py index bb3b71dd4..5e47e1f2c 100644 --- a/cinder/volume/drivers/lvm.py +++ b/cinder/volume/drivers/lvm.py @@ -755,138 +755,3 @@ class LVMISERDriver(LVMISCSIDriver, driver.ISERDriver): self.backend_name =\ self.configuration.safe_get('volume_backend_name') or 'LVM_iSER' self.protocol = 'iSER' - self.tgtadm.set_execute(self._execute) - - def set_execute(self, execute): - LVMVolumeDriver.set_execute(self, execute) - self.tgtadm.set_execute(execute) - - def ensure_export(self, context, volume): - """Synchronously recreates an export for a logical volume.""" - - if not isinstance(self.tgtadm, iscsi.TgtAdm): - try: - iser_target = self.db.volume_get_iscsi_target_num( - context, - volume['id']) - except exception.NotFound: - LOG.info(_("Skipping ensure_export. No iser_target " - "provisioned for volume: %s"), volume['id']) - return - else: - iser_target = 1 # dummy value when using TgtAdm - - chap_auth = None - - # Check for https://bugs.launchpad.net/cinder/+bug/1065702 - old_name = None - volume_name = volume['name'] - if (volume['provider_location'] is not None and - volume['name'] not in volume['provider_location']): - - msg = _('Detected inconsistency in provider_location id') - LOG.debug(msg) - old_name = self._fix_id_migration(context, volume) - if 'in-use' in volume['status']: - volume_name = old_name - old_name = None - - iser_name = "%s%s" % (self.configuration.iscsi_target_prefix, - volume_name) - volume_path = "/dev/%s/%s" % (self.configuration.volume_group, - volume_name) - - self.tgtadm.create_iscsi_target(iser_name, iser_target, - 0, volume_path, chap_auth, - check_exit_code=False, - old_name=old_name) - - def _ensure_iser_targets(self, context, host): - """Ensure that target ids have been created in datastore.""" - if not isinstance(self.tgtadm, iscsi.TgtAdm): - host_iser_targets = self.db.iscsi_target_count_by_host(context, - host) - if host_iser_targets >= self.configuration.iser_num_targets: - return - - # NOTE(vish): Target ids start at 1, not 0. - target_end = self.configuration.iser_num_targets + 1 - for target_num in xrange(1, target_end): - target = {'host': host, 'target_num': target_num} - self.db.iscsi_target_create_safe(context, target) - - def create_export(self, context, volume): - """Creates an export for a logical volume.""" - - iser_name = "%s%s" % (self.configuration.iscsi_target_prefix, - volume['name']) - volume_path = "/dev/%s/%s" % (self.configuration.volume_group, - volume['name']) - model_update = {} - - # TODO(jdg): In the future move all of the dependent stuff into the - # cooresponding target admin class - if not isinstance(self.tgtadm, iscsi.TgtAdm): - lun = 0 - self._ensure_iser_targets(context, volume['host']) - iser_target = self.db.volume_allocate_iscsi_target(context, - volume['id'], - volume['host']) - else: - lun = 1 # For tgtadm the controller is lun 0, dev starts at lun 1 - iser_target = 0 - - # Use the same method to generate the username and the password. - chap_username = utils.generate_username() - chap_password = utils.generate_password() - chap_auth = self._iser_authentication('IncomingUser', chap_username, - chap_password) - tid = self.tgtadm.create_iscsi_target(iser_name, - iser_target, - 0, - volume_path, - chap_auth) - model_update['provider_location'] = self._iser_location( - self.configuration.iscsi_ip_address, tid, iser_name, lun) - model_update['provider_auth'] = self._iser_authentication( - 'CHAP', chap_username, chap_password) - return model_update - - def remove_export(self, context, volume): - """Removes an export for a logical volume.""" - - if not isinstance(self.tgtadm, iscsi.TgtAdm): - try: - iser_target = self.db.volume_get_iscsi_target_num( - context, - volume['id']) - except exception.NotFound: - LOG.info(_("Skipping remove_export. No iser_target " - "provisioned for volume: %s"), volume['id']) - return - else: - iser_target = 0 - - try: - - # NOTE: provider_location may be unset if the volume hasn't - # been exported - location = volume['provider_location'].split(' ') - iqn = location[1] - - self.tgtadm.show_target(iser_target, iqn=iqn) - - except Exception: - LOG.info(_("Skipping remove_export. No iser_target " - "is presently exported for volume: %s"), volume['id']) - return - - self.tgtadm.remove_iscsi_target(iser_target, 0, volume['id'], - volume['name']) - - def _iser_location(self, ip, target, iqn, lun=None): - return "%s:%s,%s %s %s" % (ip, self.configuration.iscsi_port, - target, iqn, lun) - - def _iser_authentication(self, chap, name, password): - return "%s %s %s" % (chap, name, password)