From fe23b04d4e0e05d5a9e0733152a24ede24f67d93 Mon Sep 17 00:00:00 2001 From: Brad Crittenden Date: Thu, 3 Sep 2015 15:18:51 -0400 Subject: [PATCH 1/3] Add dashboard-plugin relation --- hooks/dashboard-plugin-relation-joined | 1 + hooks/horizon_hooks.py | 15 ++++++++++++++- hooks/horizon_utils.py | 1 + unit_tests/test_horizon_hooks.py | 24 ++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 120000 hooks/dashboard-plugin-relation-joined diff --git a/hooks/dashboard-plugin-relation-joined b/hooks/dashboard-plugin-relation-joined new file mode 120000 index 00000000..3195386e --- /dev/null +++ b/hooks/dashboard-plugin-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 e529a5ae..e3ffeda4 100755 --- a/hooks/horizon_hooks.py +++ b/hooks/horizon_hooks.py @@ -24,6 +24,7 @@ from charmhelpers.contrib.openstack.utils import ( config_value_changed, configure_installation_source, git_install_requested, + git_pip_venv_dir, openstack_upgrade_available, os_release, save_script_rc @@ -38,7 +39,8 @@ from horizon_utils import ( do_openstack_upgrade, git_install, git_post_install_late, - setup_ipv6 + setup_ipv6, + INSTALL_DIR ) from charmhelpers.contrib.network.ip import ( get_iface_for_address, @@ -244,6 +246,17 @@ def update_nrpe_config(): nrpe_setup.write() +@hooks.hook('dashboard-plugin-relation-joined') +def update_dashboard_plugin(rel_id=None): + if git_install_requested(): + bin_path = git_pip_venv_dir(config('openstack-origin-git')) + else: + bin_path = '/usr/bin' + relation_set(relation_id=rel_id, + bin_path=bin_path, + openstack_dir=INSTALL_DIR) + + def main(): try: hooks.execute(sys.argv) diff --git a/hooks/horizon_utils.py b/hooks/horizon_utils.py index 63bfd2be..f7237c18 100644 --- a/hooks/horizon_utils.py +++ b/hooks/horizon_utils.py @@ -91,6 +91,7 @@ APACHE_24_SSL = "%s/sites-available/default-ssl.conf" % (APACHE_CONF_DIR) APACHE_24_DEFAULT = "%s/sites-available/000-default.conf" % (APACHE_CONF_DIR) APACHE_SSL = "%s/sites-available/default-ssl" % (APACHE_CONF_DIR) APACHE_DEFAULT = "%s/sites-available/default" % (APACHE_CONF_DIR) +INSTALL_DIR = "/usr/share/openstack-dashboard" ROUTER_SETTING = \ "/usr/share/openstack-dashboard/openstack_dashboard/enabled/_40_router.py" diff --git a/unit_tests/test_horizon_hooks.py b/unit_tests/test_horizon_hooks.py index e73f852d..08d7ba75 100644 --- a/unit_tests/test_horizon_hooks.py +++ b/unit_tests/test_horizon_hooks.py @@ -308,6 +308,29 @@ class TestHorizonHooks(CharmTestCase): self._call_hook('website-relation-joined') self.relation_set.assert_called_with(port=70, hostname='192.168.1.1') + @patch.object(hooks, 'git_install_requested') + def test_dashboard_config_joined_not_git(self, _git_requested): + _git_requested.return_value = False + self._call_hook('dashboard-plugin-relation-joined') + self.relation_set.assert_called_with( + bin_path='/usr/bin', + openstack_dir='/usr/share/openstack-dashboard', + relation_id=None + ) + + @patch.object(hooks, 'git_pip_venv_dir') + @patch.object(hooks, 'git_install_requested') + def test_dashboard_config_joined_git(self, _git_requested, _git_pip_venv_dir): + expected_bin_path = '/mnt/fuji/venv' + _git_requested.return_value = True + _git_pip_venv_dir.return_value = expected_bin_path + self._call_hook('dashboard-plugin-relation-joined') + self.relation_set.assert_called_with( + bin_path=expected_bin_path, + openstack_dir='/usr/share/openstack-dashboard', + relation_id=None + ) + @patch('sys.argv') @patch.object(hooks, 'install') def test_main_hook_exists(self, _install, _argv): @@ -320,3 +343,4 @@ class TestHorizonHooks(CharmTestCase): _argv = ['hooks/start'] # NOQA hooks.main() self.log.assert_called() + From 290a78f21ae2fdbb311a1384c92fea8ad3fae0be Mon Sep 17 00:00:00 2001 From: Brad Crittenden Date: Thu, 3 Sep 2015 15:52:15 -0400 Subject: [PATCH 2/3] Add dashboard-plugin relation to metadata.yaml --- metadata.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/metadata.yaml b/metadata.yaml index 4ee536a8..41b945c0 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -11,6 +11,8 @@ provides: scope: container website: interface: http + dashboard-plugin: + interface: dashboard-plugin requires: identity-service: interface: keystone From 6b4090e92bcff32e5845b77140a8efedd35061b8 Mon Sep 17 00:00:00 2001 From: Brad Crittenden Date: Fri, 4 Sep 2015 11:16:58 -0400 Subject: [PATCH 3/3] Fix lint --- unit_tests/test_horizon_hooks.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/unit_tests/test_horizon_hooks.py b/unit_tests/test_horizon_hooks.py index 08d7ba75..00193d76 100644 --- a/unit_tests/test_horizon_hooks.py +++ b/unit_tests/test_horizon_hooks.py @@ -313,14 +313,15 @@ class TestHorizonHooks(CharmTestCase): _git_requested.return_value = False self._call_hook('dashboard-plugin-relation-joined') self.relation_set.assert_called_with( - bin_path='/usr/bin', + bin_path='/usr/bin', openstack_dir='/usr/share/openstack-dashboard', relation_id=None ) @patch.object(hooks, 'git_pip_venv_dir') @patch.object(hooks, 'git_install_requested') - def test_dashboard_config_joined_git(self, _git_requested, _git_pip_venv_dir): + def test_dashboard_config_joined_git(self, _git_requested, + _git_pip_venv_dir): expected_bin_path = '/mnt/fuji/venv' _git_requested.return_value = True _git_pip_venv_dir.return_value = expected_bin_path @@ -343,4 +344,3 @@ class TestHorizonHooks(CharmTestCase): _argv = ['hooks/start'] # NOQA hooks.main() self.log.assert_called() -