From 1cb1cc617f4638d80da6c2acc457c72a59e6346b Mon Sep 17 00:00:00 2001 From: Bilal Baqar Date: Sun, 9 Aug 2015 08:53:26 -0700 Subject: [PATCH] Changing hook to symlink --- hooks/plumgrid-plugin-relation-changed | 95 +------------------------- 1 file changed, 1 insertion(+), 94 deletions(-) mode change 100755 => 120000 hooks/plumgrid-plugin-relation-changed diff --git a/hooks/plumgrid-plugin-relation-changed b/hooks/plumgrid-plugin-relation-changed deleted file mode 100755 index 57a7c2f..0000000 --- a/hooks/plumgrid-plugin-relation-changed +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2015, PLUMgrid Inc, http://plumgrid.com - -# The hooks of this charm have been symlinked to functions -# in this file. - -import sys - -from charmhelpers.core.hookenv import ( - Hooks, - UnregisteredHookError, - log, -) - -from charmhelpers.core.host import ( - restart_on_change, -) - -from charmhelpers.fetch import ( - apt_install, - apt_update, - configure_sources, - apt_purge, -) - -from neutron_plumgrid_utils import ( - determine_packages, - register_configs, - restart_map, - ensure_files, -) - -hooks = Hooks() -CONFIGS = register_configs() - - -@hooks.hook() -def install(): - ''' - Install hook is run when the charm is first deployed on a node. - ''' - configure_sources() - apt_update() - apt_install(determine_packages(), options=['--force-yes'], fatal=True) - ensure_files() - - -@hooks.hook('config-changed') -def config_changed(): - ''' - This hook is run when a config parameter is changed. - It also runs on node reboot. - ''' - stop() - configure_sources() - apt_update() - apt_install(determine_packages(), options=['--force-yes'], fatal=True) - ensure_files() - CONFIGS.write_all() - - -@hooks.hook('neutron-plugin-api-relation-joined') -@hooks.hook('plumgrid-plugin-relation-changed') -@hooks.hook('container-relation-changed') -@restart_on_change(restart_map()) -def relation_changed(): - ''' - This hook is run when relation between neutron-api-plumgrid and - neutron-api or plumgrid-edge is made. - ''' - ensure_files() - CONFIGS.write_all() - - -@hooks.hook('stop') -def stop(): - ''' - This hook is run when the charm is destroyed. - ''' - pkgs = determine_packages() - for pkg in pkgs: - apt_purge(pkg, fatal=False) - - -def main(): - try: - hooks.execute(sys.argv) - except UnregisteredHookError as e: - log('Unknown hook {} - skipping.'.format(e)) - - -if __name__ == '__main__': - main() diff --git a/hooks/plumgrid-plugin-relation-changed b/hooks/plumgrid-plugin-relation-changed new file mode 120000 index 0000000..4dc4326 --- /dev/null +++ b/hooks/plumgrid-plugin-relation-changed @@ -0,0 +1 @@ +neutron_plumgrid_hooks.py \ No newline at end of file