diff --git a/hooks/dashboard-relation-changed b/hooks/dashboard-relation-changed new file mode 120000 index 00000000..3195386e --- /dev/null +++ b/hooks/dashboard-relation-changed @@ -0,0 +1 @@ +horizon_hooks.py \ No newline at end of file diff --git a/hooks/dashboard-relation-joined b/hooks/dashboard-relation-joined new file mode 120000 index 00000000..3195386e --- /dev/null +++ b/hooks/dashboard-relation-joined @@ -0,0 +1 @@ +horizon_hooks.py \ No newline at end of file diff --git a/hooks/horizon_hooks.py b/hooks/horizon_hooks.py index 097b5136..edbb13e5 100755 --- a/hooks/horizon_hooks.py +++ b/hooks/horizon_hooks.py @@ -225,6 +225,7 @@ def config_changed(): websso_trusted_dashboard_changed() application_dashboard_relation_changed() + dashboard_relation_changed() @hooks.hook('identity-service-relation-joined') @@ -464,6 +465,25 @@ def websso_trusted_dashboard_changed(): }) +@hooks.hook('dashboard-relation-joined', + 'dashboard-relation-changed') +def dashboard_relation_changed(): + """ + Provide dashboard information. + """ + relations = relation_ids('dashboard') + if not relations: + return + + relation_settings = { + 'os-public-hostname': config('os-public-hostname'), + 'vip': config('vip'), + } + + for rel_id in relations: + relation_set(rel_id, relation_settings=relation_settings, app=True) + + def main(): try: hooks.execute(sys.argv) diff --git a/metadata.yaml b/metadata.yaml index 21eeacc5..1ba0c420 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -24,6 +24,8 @@ provides: scope: container websso-trusted-dashboard: interface: websso-trusted-dashboard + dashboard: + interface: dashboard requires: identity-service: interface: keystone diff --git a/unit_tests/test_horizon_hooks.py b/unit_tests/test_horizon_hooks.py index 09795d35..fac20090 100644 --- a/unit_tests/test_horizon_hooks.py +++ b/unit_tests/test_horizon_hooks.py @@ -252,6 +252,7 @@ class TestHorizonHooks(CharmTestCase): ], 'certificates': [], 'ha': [], + 'dashboard': [], }[rname] self.relation_ids.side_effect = relation_ids_side_effect @@ -525,3 +526,19 @@ class TestHorizonHooks(CharmTestCase): "group": "[local] OpenStack" }) ]) + + def test_dashboard_relation_changed(self): + self.relation_ids.return_value = None + hooks.dashboard_relation_changed() + + self.test_config.set('os-public-hostname', 'mydashboard.local') + self.test_config.set('vip', '1.2.3.4') + self.relation_ids.return_value = ['dashboard:0'] + hooks.dashboard_relation_changed() + + self.relation_set.assert_called_with( + 'dashboard:0', + relation_settings={'os-public-hostname': 'mydashboard.local', + 'vip': '1.2.3.4'}, + app=True, + )