]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Allow host config to be overriden in backend
authorVishvananda Ishaya <vishvananda@gmail.com>
Thu, 22 May 2014 21:49:20 +0000 (14:49 -0700)
committerVishvananda Ishaya <vishvananda@gmail.com>
Thu, 22 May 2014 21:49:20 +0000 (14:49 -0700)
This allows you to specify host=XXX in your backend configuration
to override the host value that is specified in the DEFAULT section,
allowing for some backends to share a hostname while others can
have unique names.

Change-Id: Ie8894a7cebf350dc2d50567058a765482b9d97d7
Closes-bug: #1322366

bin/cinder-volume

index c8c0c84fad81ecc261e70e2611a8eb9ec0457460..5b8b8a8d9c2fa82af5dc82d44424df6fcf3eb492 100755 (executable)
@@ -50,6 +50,8 @@ from cinder import utils
 from cinder import version
 
 
+host_opt = cfg.StrOpt('host',
+                      help='Backend override of host value.')
 CONF = cfg.CONF
 
 
@@ -61,7 +63,9 @@ if __name__ == '__main__':
     launcher = service.get_launcher()
     if CONF.enabled_backends:
         for backend in CONF.enabled_backends:
-            host = "%s@%s" % (CONF.host, backend)
+            CONF.register_opts([host_opt], group=backend)
+            backend_host = getattr(CONF, backend).host
+            host = "%s@%s" % (backend_host or CONF.host, backend)
             server = service.Service.create(host=host,
                                             service_name=backend)
             launcher.launch_service(server)