]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Add the api config opts in groups to deal with the single heat.conf
authorAngus Salkeld <asalkeld@redhat.com>
Tue, 27 Aug 2013 00:26:53 +0000 (10:26 +1000)
committerAngus Salkeld <asalkeld@redhat.com>
Tue, 27 Aug 2013 00:26:53 +0000 (10:26 +1000)
So first off, I also don't like the replicating of the api_opts in wsgi.py
but if I don't do that the sample generator doesn't work:(

We add the wsgi options into a group for each of the api servers with
the deprecated group of "DEFAULT" so it still deals with the flat layout.

The behaviour is as follows (assuming heat-api):
1) if you have both (/etc/heat/{heat.conf, heat-api.conf}
   the value in heat-api.conf wins over heat.conf
2) if you have just one of the config files but a value in both the
   [DEFAULT] section and the [heat-api] section then the value in heat-api
   wins.

bug #1209141
Change-Id: I66ddb3dca91d13b28e68dfb4306e94eb4e537fa7

bin/heat-api
bin/heat-api-cfn
bin/heat-api-cloudwatch
etc/heat/heat.conf.sample
heat/common/wsgi.py

index 8f58c0944e82c745146721fceff13825aaccc638..7286334de6d9b06d8d10a474020842b3148fac03 100755 (executable)
@@ -56,11 +56,11 @@ if __name__ == '__main__':
 
         app = config.load_paste_app()
 
-        port = cfg.CONF.bind_port
-        host = cfg.CONF.bind_host
+        port = cfg.CONF.heat_api.bind_port
+        host = cfg.CONF.heat_api.bind_host
         LOG.info('Starting Heat ReST API on %s:%s' % (host, port))
         server = wsgi.Server()
-        server.start(app, cfg.CONF, default_port=port)
+        server.start(app, cfg.CONF.heat_api, default_port=port)
         server.wait()
     except RuntimeError as e:
         sys.exit("ERROR: %s" % e)
index 95a946ca874d1f422c57a45570679d244fbfda07..71a97a5fb3a1becc24c6aade0a6bac8980932a6c 100755 (executable)
@@ -58,11 +58,11 @@ if __name__ == '__main__':
 
         app = config.load_paste_app()
 
-        port = cfg.CONF.bind_port
-        host = cfg.CONF.bind_host
+        port = cfg.CONF.heat_api_cfn.bind_port
+        host = cfg.CONF.heat_api_cfn.bind_host
         LOG.info('Starting Heat API on %s:%s' % (host, port))
         server = wsgi.Server()
-        server.start(app, cfg.CONF, default_port=port)
+        server.start(app, cfg.CONF.heat_api_cfn, default_port=port)
         server.wait()
     except RuntimeError as e:
         sys.exit("ERROR: %s" % e)
index 6a53a43c578899dd207140e8da182b465282c3e7..b01db22e4cdd26535e1c8f8c8b2d89d7181d7b29 100755 (executable)
@@ -58,11 +58,11 @@ if __name__ == '__main__':
 
         app = config.load_paste_app()
 
-        port = cfg.CONF.bind_port
-        host = cfg.CONF.bind_host
+        port = cfg.CONF.heat_api_cloudwatch.bind_port
+        host = cfg.CONF.heat_api_cloudwatch.bind_host
         LOG.info('Starting Heat CloudWatch API on %s:%s' % (host, port))
         server = wsgi.Server()
-        server.start(app, cfg.CONF, default_port=port)
+        server.start(app, cfg.CONF.heat_api_cloudwatch, default_port=port)
         server.wait()
     except RuntimeError as e:
         sys.exit("ERROR: %s" % e)
index 5bf734ed39ca954c40574f20631b5ca0afbcadb8..1432a36efb1582a6cc412d1bc6f3b9ccf010648a 100644 (file)
 #auth_encryption_key=notgood but just long enough i think
 
 
-#
-# Options defined in heat.common.wsgi
-#
-
-# Address to bind the server.  Useful when selecting a
-# particular network interface. (string value)
-#bind_host=0.0.0.0
-
-# The port on which the server will listen. (integer value)
-#bind_port=<None>
-
-# Number of backlog requests to configure the socket with
-# (integer value)
-#backlog=4096
-
-# Location of the SSL Certificate File to use for SSL mode
-# (string value)
-#cert_file=<None>
-
-# Location of the SSL Key File to use for enabling SSL mode
-# (string value)
-#key_file=<None>
-
-# Number of workers for Heat service (integer value)
-#workers=0
-
-
 #
 # Options defined in heat.db.api
 #
 #auth_uri=<None>
 
 
-[matchmaker_redis]
+[heat_api_cloudwatch]
 
 #
-# Options defined in heat.openstack.common.rpc.matchmaker_redis
+# Options defined in heat.common.wsgi
 #
 
-# Host to locate redis (string value)
-#host=127.0.0.1
+# Address to bind the server.  Useful when selecting a
+# particular network interface. (string value)
+#bind_host=0.0.0.0
 
-# Use this port to connect to redis host. (integer value)
-#port=6379
+# The port on which the server will listen. (integer value)
+#bind_port=8003
 
-# Password for Redis server. (optional) (string value)
-#password=<None>
+# Number of backlog requests to configure the socket with
+# (integer value)
+#backlog=4096
+
+# Location of the SSL Certificate File to use for SSL mode
+# (string value)
+#cert_file=<None>
+
+# Location of the SSL Key File to use for enabling SSL mode
+# (string value)
+#key_file=<None>
+
+# Number of workers for Heat service (integer value)
+#workers=0
+
+
+[heat_api]
+
+#
+# Options defined in heat.common.wsgi
+#
+
+# Address to bind the server.  Useful when selecting a
+# particular network interface. (string value)
+#bind_host=0.0.0.0
+
+# The port on which the server will listen. (integer value)
+#bind_port=8004
+
+# Number of backlog requests to configure the socket with
+# (integer value)
+#backlog=4096
+
+# Location of the SSL Certificate File to use for SSL mode
+# (string value)
+#cert_file=<None>
+
+# Location of the SSL Key File to use for enabling SSL mode
+# (string value)
+#key_file=<None>
+
+# Number of workers for Heat service (integer value)
+#workers=0
+
+
+[heat_api_cfn]
+
+#
+# Options defined in heat.common.wsgi
+#
+
+# Address to bind the server.  Useful when selecting a
+# particular network interface. (string value)
+#bind_host=0.0.0.0
+
+# The port on which the server will listen. (integer value)
+#bind_port=8000
+
+# Number of backlog requests to configure the socket with
+# (integer value)
+#backlog=4096
+
+# Location of the SSL Certificate File to use for SSL mode
+# (string value)
+#cert_file=<None>
+
+# Location of the SSL Key File to use for enabling SSL mode
+# (string value)
+#key_file=<None>
+
+# Number of workers for Heat service (integer value)
+#workers=0
 
 
 [auth_password]
 #ringfile=/etc/oslo/matchmaker_ring.json
 
 
+[matchmaker_redis]
+
+#
+# Options defined in heat.openstack.common.rpc.matchmaker_redis
+#
+
+# Host to locate redis (string value)
+#host=127.0.0.1
+
+# Use this port to connect to redis host. (integer value)
+#port=6379
+
+# Password for Redis server. (optional) (string value)
+#password=<None>
+
+
index b1c04fdbded11d7a831f227a4286f1ee8186157c..f50c521d83aec310d77cd442bb7b0c856fba3821 100644 (file)
@@ -50,34 +50,92 @@ from heat.openstack.common import importutils
 
 URL_LENGTH_LIMIT = 50000
 
-bind_opts = [
+api_opts = [
     cfg.StrOpt('bind_host', default='0.0.0.0',
                help=_('Address to bind the server.  Useful when '
-                      'selecting a particular network interface.')),
-    cfg.IntOpt('bind_port',
-               help=_('The port on which the server will listen.'))
+                      'selecting a particular network interface.'),
+               deprecated_group='DEFAULT'),
+    cfg.IntOpt('bind_port', default=8004,
+               help=_('The port on which the server will listen.'),
+               deprecated_group='DEFAULT'),
+    cfg.IntOpt('backlog', default=4096,
+               help=_("Number of backlog requests "
+                      "to configure the socket with"),
+               deprecated_group='DEFAULT'),
+    cfg.StrOpt('cert_file', default=None,
+               help=_("Location of the SSL Certificate File "
+                      "to use for SSL mode"),
+               deprecated_group='DEFAULT'),
+    cfg.StrOpt('key_file', default=None,
+               help=_("Location of the SSL Key File to use "
+                      "for enabling SSL mode"),
+               deprecated_group='DEFAULT'),
+    cfg.IntOpt('workers', default=0,
+               help=_("Number of workers for Heat service"),
+               deprecated_group='DEFAULT'),
 ]
+api_group = cfg.OptGroup('heat_api')
+cfg.CONF.register_group(api_group)
+cfg.CONF.register_opts(api_opts,
+                       group=api_group)
 
-cfg.CONF.register_opts(bind_opts)
-
-socket_opts = [
+api_cfn_opts = [
+    cfg.StrOpt('bind_host', default='0.0.0.0',
+               help=_('Address to bind the server.  Useful when '
+                      'selecting a particular network interface.'),
+               deprecated_group='DEFAULT'),
+    cfg.IntOpt('bind_port', default=8000,
+               help=_('The port on which the server will listen.'),
+               deprecated_group='DEFAULT'),
     cfg.IntOpt('backlog', default=4096,
                help=_("Number of backlog requests "
-                      "to configure the socket with")),
+                      "to configure the socket with"),
+               deprecated_group='DEFAULT'),
     cfg.StrOpt('cert_file', default=None,
                help=_("Location of the SSL Certificate File "
-                      "to use for SSL mode")),
+                      "to use for SSL mode"),
+               deprecated_group='DEFAULT'),
     cfg.StrOpt('key_file', default=None,
                help=_("Location of the SSL Key File to use "
-                      "for enabling SSL mode")),
+                      "for enabling SSL mode"),
+               deprecated_group='DEFAULT'),
+    cfg.IntOpt('workers', default=0,
+               help=_("Number of workers for Heat service"),
+               deprecated_group='DEFAULT'),
 ]
+api_cfn_group = cfg.OptGroup('heat_api_cfn')
+cfg.CONF.register_group(api_cfn_group)
+cfg.CONF.register_opts(api_cfn_opts,
+                       group=api_cfn_group)
 
-cfg.CONF.register_opts(socket_opts)
-
-workers_opts = cfg.IntOpt('workers', default=0,
-                          help=_("Number of workers for Heat service"))
-
-cfg.CONF.register_opt(workers_opts)
+api_cw_opts = [
+    cfg.StrOpt('bind_host', default='0.0.0.0',
+               help=_('Address to bind the server.  Useful when '
+                      'selecting a particular network interface.'),
+               deprecated_group='DEFAULT'),
+    cfg.IntOpt('bind_port', default=8003,
+               help=_('The port on which the server will listen.'),
+               deprecated_group='DEFAULT'),
+    cfg.IntOpt('backlog', default=4096,
+               help=_("Number of backlog requests "
+                      "to configure the socket with"),
+               deprecated_group='DEFAULT'),
+    cfg.StrOpt('cert_file', default=None,
+               help=_("Location of the SSL Certificate File "
+                      "to use for SSL mode"),
+               deprecated_group='DEFAULT'),
+    cfg.StrOpt('key_file', default=None,
+               help=_("Location of the SSL Key File to use "
+                      "for enabling SSL mode"),
+               deprecated_group='DEFAULT'),
+    cfg.IntOpt('workers', default=0,
+               help=_("Number of workers for Heat service"),
+               deprecated_group='DEFAULT'),
+]
+api_cw_group = cfg.OptGroup('heat_api_cloudwatch')
+cfg.CONF.register_group(api_cw_group)
+cfg.CONF.register_opts(api_cw_opts,
+                       group=api_cw_group)
 
 
 class WritableLogger(object):
@@ -93,9 +151,6 @@ class WritableLogger(object):
 
 def get_bind_addr(conf, default_port=None):
     """Return the host and port to bind to."""
-    for opt in bind_opts:
-        if opt.name not in conf:
-            conf.register_opt(opt)
     return (conf.bind_host, conf.bind_port or default_port)
 
 
@@ -120,8 +175,6 @@ def get_socket(conf, default_port):
                       bind_addr[1], socket.AF_UNSPEC, socket.SOCK_STREAM)
                       if addr[0] in (socket.AF_INET, socket.AF_INET6)][0]
 
-    conf.register_opts(socket_opts)
-
     cert_file = conf.cert_file
     key_file = conf.key_file
     use_ssl = cert_file or key_file