summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Verboso <fverboso@unime.it>2018-12-10 17:22:59 +0100
committerFabio Verboso <fverboso@unime.it>2018-12-10 17:22:59 +0100
commitd1ebff90342e2dfee677b68b60e503109edb7b03 (patch)
tree527d8920785e87e0796a7eaabe0db85146168837
parent5a373e7941328679483ea344fe93ce4a7d8fbe13 (diff)
Fix Dns zone.
It is not necessary to specify the zone into the config file Change-Id: I049a4039aab817024ab40e1b6c5b2b383100653f
Notes
Notes (review): Code-Review+2: Fabio Verboso <fverboso@unime.it> Workflow+1: Fabio Verboso <fverboso@unime.it> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Mon, 10 Dec 2018 16:48:22 +0000 Reviewed-on: https://review.openstack.org/624121 Project: openstack/iotronic Branch: refs/heads/master
-rw-r--r--etc/iotronic/iotronic.conf2
-rw-r--r--iotronic/conductor/endpoints.py2
-rw-r--r--iotronic/wamp/proxies/nginx.py20
3 files changed, 9 insertions, 15 deletions
diff --git a/etc/iotronic/iotronic.conf b/etc/iotronic/iotronic.conf
index 7dd9b46..66256a9 100644
--- a/etc/iotronic/iotronic.conf
+++ b/etc/iotronic/iotronic.conf
@@ -3,8 +3,6 @@ transport_url=rabbit://<user>:<password>@<host>:5672/
3 3
4debug=True 4debug=True
5proxy=nginx 5proxy=nginx
6# dns_zone=openstack.iotronic
7
8 6
9# Authentication strategy used by iotronic-api: one of 7# Authentication strategy used by iotronic-api: one of
10# "keystone" or "noauth". "noauth" should not be used in a 8# "keystone" or "noauth". "noauth" should not be used in a
diff --git a/iotronic/conductor/endpoints.py b/iotronic/conductor/endpoints.py
index 763b8e2..8602dab 100644
--- a/iotronic/conductor/endpoints.py
+++ b/iotronic/conductor/endpoints.py
@@ -713,7 +713,7 @@ class ConductorEndpoint(object):
713 713
714 cctx = self.wamp_agent_client.prepare(server=board.agent) 714 cctx = self.wamp_agent_client.prepare(server=board.agent)
715 cctx.call(ctx, 'enable_webservice', board=dns, 715 cctx.call(ctx, 'enable_webservice', board=dns,
716 https_port=https_port, http_port=http_port) 716 https_port=https_port, http_port=http_port, zone=zone)
717 cctx.call(ctx, 'reload_proxy') 717 cctx.call(ctx, 'reload_proxy')
718 718
719 LOG.debug('Configure Web Proxy on Board %s with dns %s (email: %s) ', 719 LOG.debug('Configure Web Proxy on Board %s with dns %s (email: %s) ',
diff --git a/iotronic/wamp/proxies/nginx.py b/iotronic/wamp/proxies/nginx.py
index 6ec71bf..b8ac651 100644
--- a/iotronic/wamp/proxies/nginx.py
+++ b/iotronic/wamp/proxies/nginx.py
@@ -23,20 +23,17 @@ LOG = logging.getLogger(__name__)
23nginx_opts = [ 23nginx_opts = [
24 cfg.StrOpt('nginx_path', 24 cfg.StrOpt('nginx_path',
25 default='/etc/nginx/conf.d/iotronic', 25 default='/etc/nginx/conf.d/iotronic',
26 help=('Default Nginx Path')), 26 help=('Default Nginx Path'))
27 cfg.StrOpt('dns_zone',
28 default='openstack.iotronic',
29 help=('Default zone')),
30] 27]
31 28
32CONF = cfg.CONF 29CONF = cfg.CONF
33CONF.register_opts(nginx_opts, 'nginx') 30CONF.register_opts(nginx_opts, 'nginx')
34 31
35 32
36def save_map(board, dns): 33def save_map(board, zone):
37 fp = CONF.nginx.nginx_path + "/maps/map_" + board 34 fp = CONF.nginx.nginx_path + "/maps/map_" + board
38 with open(fp, "w") as text_file: 35 with open(fp, "w") as text_file:
39 text_file.write("~" + board + "." + dns + " " + board + ";") 36 text_file.write("~" + board + "." + zone + " " + board + ";")
40 37
41 38
42def save_upstream(board, https_port): 39def save_upstream(board, https_port):
@@ -50,7 +47,7 @@ def save_upstream(board, https_port):
50 text_file.write("%s" % string) 47 text_file.write("%s" % string)
51 48
52 49
53def save_server(board, http_port, dns): 50def save_server(board, http_port, zone):
54 fp = CONF.nginx.nginx_path + "/servers/" + board 51 fp = CONF.nginx.nginx_path + "/servers/" + board
55 string = '''server {{ 52 string = '''server {{
56 listen 80; 53 listen 80;
@@ -60,7 +57,7 @@ def save_server(board, http_port, dns):
60 proxy_pass http://localhost:{1}; 57 proxy_pass http://localhost:{1};
61 }} 58 }}
62 }} 59 }}
63 '''.format(board, http_port, dns) 60 '''.format(board, http_port, zone)
64 61
65 with open(fp, "w") as text_file: 62 with open(fp, "w") as text_file:
66 text_file.write("%s" % string) 63 text_file.write("%s" % string)
@@ -77,19 +74,18 @@ def remove(board):
77class ProxyManager(Proxy): 74class ProxyManager(Proxy):
78 75
79 def __init__(self): 76 def __init__(self):
80 self.dns = CONF.nginx.dns_zone
81 super(ProxyManager, self).__init__("nginx") 77 super(ProxyManager, self).__init__("nginx")
82 78
83 def reload_proxy(self, ctx): 79 def reload_proxy(self, ctx):
84 call(["nginx", "-s", "reload"]) 80 call(["nginx", "-s", "reload"])
85 81
86 def enable_webservice(self, ctx, board, https_port, http_port): 82 def enable_webservice(self, ctx, board, https_port, http_port, zone):
87 LOG.debug( 83 LOG.debug(
88 'Enabling WebService with ports %s for http and %s for https ' 84 'Enabling WebService with ports %s for http and %s for https '
89 'on board %s', http_port, https_port, board) 85 'on board %s', http_port, https_port, board)
90 save_map(board, self.dns) 86 save_map(board, zone)
91 save_upstream(board, https_port) 87 save_upstream(board, https_port)
92 save_server(board, http_port, self.dns) 88 save_server(board, http_port, zone)
93 89
94 def disable_webservice(self, ctx, board): 90 def disable_webservice(self, ctx, board):
95 LOG.debug('Disabling WebService on board %s', 91 LOG.debug('Disabling WebService on board %s',