]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Multi storage backend support for Nexenta driver
authorVictor Rodionov <vito.ordaz@gmail.com>
Fri, 23 Aug 2013 18:25:36 +0000 (22:25 +0400)
committerVictor Rodionov <vito.ordaz@gmail.com>
Thu, 29 Aug 2013 21:04:28 +0000 (01:04 +0400)
Recover nexenta prefix for host, user, password and iscsi_port
config options.

Change-Id: I8bdc54f391145193b7813e0e411afa39d07d9aad

cinder/tests/test_nexenta.py
cinder/volume/drivers/nexenta/options.py
cinder/volume/drivers/nexenta/volume.py
etc/cinder/cinder.conf.sample

index 48758db8d0b1d25f8b18201f037acd82dbcf76a1..208a45da614fcb8c296cb0516dec49efcf1e49fb 100644 (file)
@@ -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):
index d0720e6524f66347aeb987fc64be85d418905e3a..6c8dc17516b787127d1e3ac4825731fd7a7e6f18 100644 (file)
 
 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'),
index 5d86841d3a649b57fd4828fdfbe6a293a320dda7..586856fe14a6b5664e25fdcdc016bb42af070bc7 100644 (file)
@@ -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.
index 2214d0104211fa7ad4d09ac4656675e56535e874..bcc1f3bf2ad293240218db8832c1e0f02026f1a8 100644 (file)
 # 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
 # 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
 
 #volume_dd_blocksize=1M
 
 
-# Total option count: 342
+# Total option count: 346