]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
solidfire: Add ability to override account prefix
authorMathieu Gagné <mgagne@iweb.com>
Mon, 13 May 2013 21:05:21 +0000 (17:05 -0400)
committerMathieu Gagné <mgagne@iweb.com>
Mon, 13 May 2013 23:40:24 +0000 (19:40 -0400)
The SolidFire account is created with a prefix based on the hostname
of the host running cinder-volume. This prevents cinder-volume from
being run in an active/active setup.

This patch introduces a new configuration option sf_account_prefix
to override the prefix used when a SolidFire account is created.

If sf_account_prefix is empty, no prefix will be added to
the SolidFire account name when created.

The default value is still the hostname.

Change-Id: I3b974789ea3e749cc8696b69754023ad76155179
Fixes: bug #1179671
cinder/tests/test_solidfire.py
cinder/volume/drivers/solidfire.py

index 40dfa419a72b7c6b27daa3394af36f75c838e96b..8679f4142debd394aafd18b57002dd30650cad1c 100644 (file)
@@ -44,6 +44,7 @@ class SolidFireVolumeTestCase(test.TestCase):
         self.configuration.sf_allow_tenant_qos = True
         self.configuration.san_is_local = True
         self.configuration.sf_emulate_512 = True
+        self.configuration.sf_account_prefix = 'cinder'
 
         super(SolidFireVolumeTestCase, self).setUp()
         self.stubs.Set(SolidFire, '_issue_api_request',
index 85aba46e80f742d458cd0cd948d1e8da5baa8d73..602da4d8a2590c5be8fabb0c77c8465c1a894c41 100644 (file)
@@ -43,7 +43,11 @@ sf_opts = [
 
     cfg.BoolOpt('sf_allow_tenant_qos',
                 default=False,
-                help='Allow tenants to specify QOS on create'), ]
+                help='Allow tenants to specify QOS on create'),
+
+    cfg.StrOpt('sf_account_prefix',
+               default=socket.gethostname(),
+               help='Create SolidFire accounts with this prefix'), ]
 
 
 class SolidFire(SanISCSIDriver):
@@ -190,7 +194,9 @@ class SolidFire(SanISCSIDriver):
 
     def _get_sf_account_name(self, project_id):
         """Build the SolidFire account name to use."""
-        return ('%s-%s' % (socket.gethostname(), project_id))
+        return '%s%s%s' % (self.configuration.sf_account_prefix,
+                           '-' if self.configuration.sf_account_prefix else '',
+                           project_id)
 
     def _get_sfaccount(self, project_id):
         sf_account_name = self._get_sf_account_name(project_id)