From 5274c00d4f60e08f535275f3a136f011dfaa40e6 Mon Sep 17 00:00:00 2001 From: Victor Rodionov Date: Fri, 23 Aug 2013 22:25:36 +0400 Subject: [PATCH] Multi storage backend support for Nexenta driver Recover nexenta prefix for host, user, password and iscsi_port config options. Change-Id: I8bdc54f391145193b7813e0e411afa39d07d9aad --- cinder/tests/test_nexenta.py | 22 +++++++-------- cinder/volume/drivers/nexenta/options.py | 14 ++++++++++ cinder/volume/drivers/nexenta/volume.py | 35 ++++++++++++++---------- etc/cinder/cinder.conf.sample | 14 +++++++++- 4 files changed, 58 insertions(+), 27 deletions(-) diff --git a/cinder/tests/test_nexenta.py b/cinder/tests/test_nexenta.py index 48758db8d..208a45da6 100644 --- a/cinder/tests/test_nexenta.py +++ b/cinder/tests/test_nexenta.py @@ -56,13 +56,13 @@ class TestNexentaDriver(test.TestCase): def setUp(self): super(TestNexentaDriver, self).setUp() self.configuration = mox_lib.MockObject(conf.Configuration) - self.configuration.san_ip = '1.1.1.1' - self.configuration.san_login = 'admin' - self.configuration.san_password = 'nexenta' + self.configuration.nexenta_host = '1.1.1.1' + self.configuration.nexenta_user = 'admin' + self.configuration.nexenta_password = 'nexenta' self.configuration.nexenta_volume = 'cinder' self.configuration.nexenta_rest_port = 2000 self.configuration.nexenta_rest_protocol = 'http' - self.configuration.iscsi_port = 3260 + self.configuration.nexenta_iscsi_target_portal_port = 3260 self.configuration.nexenta_target_prefix = 'iqn:' self.configuration.nexenta_target_group_prefix = 'cinder/' self.configuration.nexenta_blocksize = '8K' @@ -173,13 +173,13 @@ class TestNexentaDriver(test.TestCase): self._stub_all_export_methods() self.mox.ReplayAll() retval = self.drv.create_export({}, self.TEST_VOLUME_REF) - self.assertEquals( - retval, - {'provider_location': - '%s:%s,1 %s%s 0' % (self.configuration.san_ip, - self.configuration.iscsi_port, - self.configuration.nexenta_target_prefix, - self.TEST_VOLUME_NAME)}) + location = '%(host)s:%(port)s,1 %(prefix)s%(volume)s 0' % { + 'host': self.configuration.nexenta_host, + 'port': self.configuration.nexenta_iscsi_target_portal_port, + 'prefix': self.configuration.nexenta_target_prefix, + 'volume': self.TEST_VOLUME_NAME + } + self.assertEquals(retval, {'provider_location': location}) def __get_test(i): def _test_create_export_fail(self): diff --git a/cinder/volume/drivers/nexenta/options.py b/cinder/volume/drivers/nexenta/options.py index d0720e652..6c8dc1751 100644 --- a/cinder/volume/drivers/nexenta/options.py +++ b/cinder/volume/drivers/nexenta/options.py @@ -25,16 +25,30 @@ from oslo.config import cfg + NEXENTA_CONNECTION_OPTIONS = [ + cfg.StrOpt('nexenta_host', + default='', + help='IP address of Nexenta SA'), cfg.IntOpt('nexenta_rest_port', default=2000, help='HTTP port to connect to Nexenta REST API server'), cfg.StrOpt('nexenta_rest_protocol', default='auto', help='Use http or https for REST connection (default auto)'), + cfg.StrOpt('nexenta_user', + default='admin', + help='User name to connect to Nexenta SA'), + cfg.StrOpt('nexenta_password', + default='nexenta', + help='Password to connect to Nexenta SA', + secret=True), ] NEXENTA_ISCSI_OPTIONS = [ + cfg.IntOpt('nexenta_iscsi_target_portal_port', + default=3260, + help='Nexenta target portal port'), cfg.StrOpt('nexenta_volume', default='cinder', help='pool on SA that will hold all volumes'), diff --git a/cinder/volume/drivers/nexenta/volume.py b/cinder/volume/drivers/nexenta/volume.py index 5d86841d3..586856fe1 100644 --- a/cinder/volume/drivers/nexenta/volume.py +++ b/cinder/volume/drivers/nexenta/volume.py @@ -63,11 +63,12 @@ class NexentaDriver(driver.ISCSIDriver): # pylint: disable=R0921 auto = protocol == 'auto' if auto: protocol = 'http' + url = '%s://%s:%s/rest/nms/' % (protocol, + self.configuration.nexenta_host, + self.configuration.nexenta_rest_port) self.nms = jsonrpc.NexentaJSONProxy( - '%s://%s:%s/rest/nms/' % (protocol, self.configuration.san_ip, - self.configuration.nexenta_rest_port), - self.configuration.san_login, self.configuration.san_password, - auto=auto) + url, self.configuration.nexenta_user, + self.configuration.nexenta_password, auto=auto) def check_for_setup_error(self): """Verify that the volume for our zvols exists. @@ -237,8 +238,8 @@ class NexentaDriver(driver.ISCSIDriver): # pylint: disable=R0921 except nexenta.NexentaException as exc: if ensure and 'already configured' in exc.args[0]: target_already_configured = True - LOG.exception(_('Ignored target creation error while ensuring ' - 'export')) + LOG.info(_('Ignored target creation error "%s" while ensuring ' + 'export'), exc) else: raise try: @@ -247,8 +248,8 @@ class NexentaDriver(driver.ISCSIDriver): # pylint: disable=R0921 if ((ensure and 'already exists' in exc.args[0]) or (target_already_configured and 'target must be offline' in exc.args[0])): - LOG.exception(_('Ignored target group creation error while ' - 'ensuring export')) + LOG.info(_('Ignored target group creation error "%s" while ' + 'ensuring export'), exc) else: raise try: @@ -257,8 +258,8 @@ class NexentaDriver(driver.ISCSIDriver): # pylint: disable=R0921 except nexenta.NexentaException as exc: if ensure and ('already exists' in exc.args[0] or 'target must be offline' in exc.args[0]): - LOG.exception(_('Ignored target group member addition error ' - 'while ensuring export')) + LOG.info(_('Ignored target group member addition error "%s" ' + 'while ensuring export'), exc) else: raise try: @@ -266,7 +267,8 @@ class NexentaDriver(driver.ISCSIDriver): # pylint: disable=R0921 except nexenta.NexentaException as exc: if not ensure or 'in use' not in exc.args[0]: raise - LOG.exception(_('Ignored LU creation error while ensuring export')) + LOG.info(_('Ignored LU creation error "%s" while ensuring export'), + exc) try: self.nms.scsidisk.add_lun_mapping_entry(zvol_name, { 'target_group': target_group_name, @@ -275,10 +277,13 @@ class NexentaDriver(driver.ISCSIDriver): # pylint: disable=R0921 except nexenta.NexentaException as exc: if not ensure or 'view entry exists' not in exc.args[0]: raise - LOG.exception(_('Ignored LUN mapping entry addition error while ' - 'ensuring export')) - return '%s:%s,1 %s 0' % (self.configuration.san_ip, - self.configuration.iscsi_port, target_name) + LOG.info(_('Ignored LUN mapping entry addition error "%s" while ' + 'ensuring export'), exc) + return '%(host)s:%(port)s,1 %(name)s 0' % { + 'host': self.configuration.nexenta_host, + 'port': self.configuration.nexenta_iscsi_target_portal_port, + 'name': target_name + } def create_export(self, _ctx, volume): """Create new export for zvol. diff --git a/etc/cinder/cinder.conf.sample b/etc/cinder/cinder.conf.sample index 2214d0104..bcc1f3bf2 100644 --- a/etc/cinder/cinder.conf.sample +++ b/etc/cinder/cinder.conf.sample @@ -1235,6 +1235,9 @@ # Options defined in cinder.volume.drivers.nexenta.options # +# IP address of Nexenta SA (string value) +#nexenta_host= + # HTTP port to connect to Nexenta REST API server (integer # value) #nexenta_rest_port=2000 @@ -1243,6 +1246,15 @@ # value) #nexenta_rest_protocol=auto +# User name to connect to Nexenta SA (string value) +#nexenta_user=admin + +# Password to connect to Nexenta SA (string value) +#nexenta_password=nexenta + +# Nexenta target portal port (integer value) +#nexenta_iscsi_target_portal_port=3260 + # pool on SA that will hold all volumes (string value) #nexenta_volume=cinder @@ -1600,4 +1612,4 @@ #volume_dd_blocksize=1M -# Total option count: 342 +# Total option count: 346 -- 2.45.2