def remove_plugin_config(): """Called when a dashboard plugin is leaving. This is necessary so that the packages that the plugin asked to install are removed and any conflicting packages are restored and the config updated. This ensures that when changing plugins the system isn't left in a broken state. """ resolve_CONFIGS() rid = juju_relation_id() runit = juju_remote_unit() pkg_data = get_plugin_packages_from_kv(rid, runit) changed = False if pkg_data['install_packages']: remove_packages = filter_missing_packages(pkg_data['install_packages']) if remove_packages: status_set('maintenance', 'Removing packages') apt_purge(remove_packages, fatal=True) apt_autoremove(purge=True, fatal=True) changed = True if pkg_data['conflicting_packages']: install_packages = filter_installed_packages( pkg_data['conflicting_packages']) if install_packages: status_set('maintenance', 'Installing packages') apt_install(install_packages, fatal=True) changed = True if changed: log("Package installation/purge detected, restarting services", "INFO") for s in services(): service_restart(s) CONFIGS.write(LOCAL_SETTINGS)
def upgrade_charm(): execd_preinstall() apt_install(filter_installed_packages(determine_packages()), fatal=True) packages_removed = remove_old_packages() update_nrpe_config() CONFIGS.write_all() if packages_removed: log("Package purge detected, restarting services", "INFO") for s in services(): service_restart(s) check_custom_theme()
def update_nrpe_config(): # python-dbus is used by check_upstart_job apt_install('python-dbus') hostname = nrpe.get_nagios_hostname() current_unit = nrpe.get_nagios_unit_name() nrpe_setup = nrpe.NRPE(hostname=hostname) nrpe.copy_nrpe_checks() nrpe.add_init_service_checks(nrpe_setup, services(), current_unit) nrpe.add_haproxy_checks(nrpe_setup, current_unit) conf = nrpe_setup.config check_http_params = conf.get('nagios_check_http_params') if check_http_params: nrpe_setup.add_check(shortname='vhost', description='Check Virtual Host {%s}' % current_unit, check_cmd='check_http %s' % check_http_params) nrpe_setup.write()
def update_nrpe_config(): # python-dbus is used by check_upstart_job apt_install('python-dbus') hostname = nrpe.get_nagios_hostname() current_unit = nrpe.get_nagios_unit_name() nrpe_setup = nrpe.NRPE(hostname=hostname) nrpe.copy_nrpe_checks() nrpe.add_init_service_checks(nrpe_setup, services(), current_unit) nrpe.add_haproxy_checks(nrpe_setup, current_unit) conf = nrpe_setup.config check_http_params = conf.get('nagios_check_http_params') if check_http_params: nrpe_setup.add_check( shortname='vhost', description='Check Virtual Host {%s}' % current_unit, check_cmd='check_http %s' % check_http_params ) nrpe_setup.write()
def update_plugin_config(): resolve_CONFIGS() # NOTE(ajkavanagh) - plugins can indicate that they have packages to # install and purge. Grab them from the relation and install/update as # needed. rid = juju_relation_id() runit = juju_remote_unit() (add_packages, remove_packages) = update_plugin_packages_in_kv(rid, runit) remove_packages = filter_missing_packages(remove_packages) if remove_packages: status_set('maintenance', 'Removing packages') apt_purge(remove_packages, fatal=True) apt_autoremove(purge=True, fatal=True) add_packages = filter_installed_packages(add_packages) if add_packages: status_set('maintenance', 'Installing packages') apt_install(add_packages, fatal=True) if remove_packages or add_packages: log("Package installation/purge detected, restarting services", "INFO") for s in services(): service_restart(s) CONFIGS.write(LOCAL_SETTINGS)