From fc68571c51d81fd3e9786faebce3946564920ab5 Mon Sep 17 00:00:00 2001 From: Sahid Orentino Ferdjaoui Date: Fri, 25 Jan 2019 15:20:57 +0100 Subject: [PATCH] context: extend HAProxyContext for placement API Since we will have to generate a HAProxyContext for nova-compute-os-api, this change add new class PlacementAPIHAProxyContext which extends HAProxyContext. Partial-Bug: #1812672 Change-Id: I56920e3d9c5216cdd5a8ea8b83714e65b777a78b Signed-off-by: Sahid Orentino Ferdjaoui --- hooks/nova_cc_context.py | 10 +++++++++- hooks/nova_cc_utils.py | 7 +++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/hooks/nova_cc_context.py b/hooks/nova_cc_context.py index e2bb2e3a..62f0c347 100644 --- a/hooks/nova_cc_context.py +++ b/hooks/nova_cc_context.py @@ -207,7 +207,15 @@ class HAProxyContext(ch_context.HAProxyContext): ctxt['service_ports'] = port_mapping # for nova.conf ctxt['listen_ports'] = listen_ports - ctxt['port'] = placement_api + return ctxt + + +class PlacementAPIHAProxyContext(HAProxyContext): + """Context for the nova placement api service.""" + + def __call__(self): + ctxt = super(PlacementAPIHAProxyContext, self).__call__() + ctxt['port'] = ctxt['listen_ports']['placement_listen_port'] return ctxt diff --git a/hooks/nova_cc_utils.py b/hooks/nova_cc_utils.py index 87322c12..753c703d 100644 --- a/hooks/nova_cc_utils.py +++ b/hooks/nova_cc_utils.py @@ -284,8 +284,11 @@ def resource_map(actual_services=True): _resource_map[WSGI_NOVA_PLACEMENT_API_CONF] = { 'contexts': [ ch_context.WSGIWorkerConfigContext( - name="nova", script=wsgi_script), - nova_cc_context.HAProxyContext()], + name="nova_placement", + user="nova", + group="nova", + script=wsgi_script), + nova_cc_context.PlacementAPIHAProxyContext()], 'services': ['apache2'] } elif not placement_api_enabled():