Merge lp:~billy-olsen/charms/trusty/openstack-dashboard/multi-region-dashboard into lp:~openstack-charmers-archive/charms/trusty/openstack-dashboard/next

Proposed by Billy Olsen
Status: Merged
Merged at revision: 45
Proposed branch: lp:~billy-olsen/charms/trusty/openstack-dashboard/multi-region-dashboard
Merge into: lp:~openstack-charmers-archive/charms/trusty/openstack-dashboard/next
Diff against target: 127 lines (+68/-5)
4 files modified
hooks/horizon_contexts.py (+24/-5)
templates/icehouse/local_settings.py (+7/-0)
templates/juno/local_settings.py (+7/-0)
unit_tests/test_horizon_contexts.py (+30/-0)
To merge this branch: bzr merge lp:~billy-olsen/charms/trusty/openstack-dashboard/multi-region-dashboard
Reviewer Review Type Date Requested Status
OpenStack Charmers Pending
Review via email: mp+243356@code.launchpad.net

Commit message

[wolsen,r=]
Add support for handling multiple regions in the openstack-dashboard, either via multiple keystone services and/or multiple regions within a single keystone service.

Description of the change

Add support for handling multiple regions in the openstack-dashboard, either via multiple keystone services and/or multiple regions within a single keystone service.

To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

UOSCI bot says:
charm_lint_check #1301 openstack-dashboard-next for billy-olsen mp243356
    LINT OK: passed

LINT Results (max last 5 lines):
  I: config.yaml: option profile has no default value
  I: config.yaml: option ssl_key has no default value
  I: config.yaml: option vip has no default value
  I: config.yaml: option ssl_cert has no default value
  I: config.yaml: option secret has no default value

Full lint test output: http://paste.ubuntu.com/9340357/
Build: http://10.98.191.181:8080/job/charm_lint_check/1301/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

UOSCI bot says:
charm_unit_test #1135 openstack-dashboard-next for billy-olsen mp243356
    UNIT OK: passed

UNIT Results (max last 5 lines):
  hooks/horizon_hooks 86 8 91% 73-74, 122-124, 149-150, 169
  hooks/horizon_utils 73 8 89% 135, 190-202
  TOTAL 232 17 93%
  Ran 41 tests in 1.569s
  OK

Full unit test output: http://paste.ubuntu.com/9340358/
Build: http://10.98.191.181:8080/job/charm_unit_test/1135/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

UOSCI bot says:
charm_amulet_test #567 openstack-dashboard-next for billy-olsen mp243356
    AMULET FAIL: amulet-test missing

AMULET Results (max last 5 lines):
INFO:root:Workspace dir: /var/lib/jenkins/workspace/charm_amulet_test
INFO:root:Reading file: Makefile
INFO:root:Searching for: ['@juju test']
INFO:root:Search string not found in makefile target commands.
ERROR:root:No make target was executed.

Full amulet test output: http://paste.ubuntu.com/9340359/
Build: http://10.98.191.181:8080/job/charm_amulet_test/567/

Revision history for this message
Liang Chen (cbjchen) wrote :

Since the mutilple region support is handled by this patch, the following comments right above the changes in both local_setting can probably be removed.

# For multiple regions uncomment this configuration, and add (endpoint, title).
# AVAILABLE_REGIONS = [
# ('http://cluster1.example.com:5000/v2.0', 'cluster1'),
# ('http://cluster2.example.com:5000/v2.0', 'cluster2'),
# ]

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/horizon_contexts.py'
2--- hooks/horizon_contexts.py 2014-10-15 19:47:09 +0000
3+++ hooks/horizon_contexts.py 2014-12-02 05:22:54 +0000
4@@ -69,22 +69,41 @@
5 def __call__(self):
6 log('Generating template context for identity-service')
7 ctxt = {}
8+ regions = set()
9
10 for rid in relation_ids('identity-service'):
11 for unit in related_units(rid):
12 rdata = relation_get(rid=rid, unit=unit)
13 serv_host = rdata.get('service_host')
14 serv_host = format_ipv6_addr(serv_host) or serv_host
15+ region = rdata.get('region')
16
17- ctxt = {
18+ local_ctxt = {
19 'service_port': rdata.get('service_port'),
20 'service_host': serv_host,
21 'service_protocol':
22- rdata.get('service_protocol') or 'http',
23+ rdata.get('service_protocol') or 'http'
24 }
25- if context_complete(ctxt):
26- return ctxt
27- return {}
28+
29+ if not context_complete(local_ctxt):
30+ continue
31+
32+ # Update the service endpoint and title for each available
33+ # region in order to support multi-region deployments
34+ if region is not None:
35+ endpoint = ("%(service_protocol)s://%(service_host)s"
36+ ":%(service_port)s/v2.0") % local_ctxt
37+ for reg in region.split():
38+ regions.add((endpoint, reg))
39+
40+ if len(ctxt) == 0:
41+ ctxt = local_ctxt
42+
43+ if len(regions) > 1:
44+ avail_regions = map(lambda r: {'endpoint': r[0], 'title': r[1]},
45+ regions)
46+ ctxt['regions'] = sorted(avail_regions)
47+ return ctxt
48
49
50 class HorizonContext(OSContextGenerator):
51
52=== modified file 'templates/icehouse/local_settings.py'
53--- templates/icehouse/local_settings.py 2014-08-21 00:36:43 +0000
54+++ templates/icehouse/local_settings.py 2014-12-02 05:22:54 +0000
55@@ -120,6 +120,13 @@
56 # ('http://cluster1.example.com:5000/v2.0', 'cluster1'),
57 # ('http://cluster2.example.com:5000/v2.0', 'cluster2'),
58 # ]
59+{% if regions|length > 1 -%}
60+AVAILABLE_REGIONS = [
61+{% for region in regions -%}
62+ ('{{ region.endpoint }}', '{{ region.title }}'),
63+{% endfor -%}
64+]
65+{% endif -%}
66
67 OPENSTACK_HOST = "{{ service_host }}"
68 OPENSTACK_KEYSTONE_URL = "{{ service_protocol }}://%s:{{ service_port }}/v2.0" % OPENSTACK_HOST
69
70=== modified file 'templates/juno/local_settings.py'
71--- templates/juno/local_settings.py 2014-10-06 14:47:17 +0000
72+++ templates/juno/local_settings.py 2014-12-02 05:22:54 +0000
73@@ -132,6 +132,13 @@
74 # ('http://cluster1.example.com:5000/v2.0', 'cluster1'),
75 # ('http://cluster2.example.com:5000/v2.0', 'cluster2'),
76 # ]
77+{% if regions|length > 1 -%}
78+AVAILABLE_REGIONS = [
79+{% for region in regions -%}
80+ ('{{ region.endpoint }}', '{{ region.title }}'),
81+{% endfor -%}
82+]
83+{% endif -%}
84
85 OPENSTACK_HOST = "{{ service_host }}"
86 OPENSTACK_KEYSTONE_URL = "{{ service_protocol }}://%s:{{ service_port }}/v2.0" % OPENSTACK_HOST
87
88=== modified file 'unit_tests/test_horizon_contexts.py'
89--- unit_tests/test_horizon_contexts.py 2014-10-15 19:47:09 +0000
90+++ unit_tests/test_horizon_contexts.py 2014-12-02 05:22:54 +0000
91@@ -180,6 +180,36 @@
92 {'service_host': 'foo', 'service_port': 5000,
93 'service_protocol': 'http'})
94
95+ @patch("horizon_contexts.format_ipv6_addr")
96+ def test_IdentityServiceContext_single_region(self, mock_format_ipv6_addr):
97+ mock_format_ipv6_addr.return_value = "foo"
98+ self.relation_ids.return_value = ['foo']
99+ self.related_units.return_value = ['bar', 'baz']
100+ self.relation_get.side_effect = self.test_relation.get
101+ self.test_relation.set({'service_host': 'foo', 'service_port': 5000,
102+ 'region': 'regionOne'})
103+ self.context_complete.return_value = True
104+ self.assertEquals(horizon_contexts.IdentityServiceContext()(),
105+ {'service_host': 'foo', 'service_port': 5000,
106+ 'service_protocol': 'http'})
107+
108+ @patch("horizon_contexts.format_ipv6_addr")
109+ def test_IdentityServiceContext_multi_region(self, mock_format_ipv6_addr):
110+ mock_format_ipv6_addr.return_value = "foo"
111+ self.relation_ids.return_value = ['foo']
112+ self.related_units.return_value = ['bar', 'baz']
113+ self.relation_get.side_effect = self.test_relation.get
114+ self.test_relation.set({'service_host': 'foo', 'service_port': 5000,
115+ 'region': 'regionOne regionTwo'})
116+ self.context_complete.return_value = True
117+ self.assertEqual(horizon_contexts.IdentityServiceContext()(),
118+ {'service_host': 'foo', 'service_port': 5000,
119+ 'service_protocol': 'http',
120+ 'regions': [{'endpoint': 'http://foo:5000/v2.0',
121+ 'title': 'regionOne'},
122+ {'endpoint': 'http://foo:5000/v2.0',
123+ 'title': 'regionTwo'}]})
124+
125 def test_HorizonHAProxyContext_no_cluster(self):
126 self.relation_ids.return_value = []
127 self.local_unit.return_value = 'openstack-dashboard/0'

Subscribers

People subscribed via source and target branches