def post_series_upgrade():
    log("Running complete series upgrade hook", "INFO")
    openstack.clear_unit_paused()
    openstack.clear_unit_upgrading()
    if not openstack.is_unit_paused_set():
        for service in services():
            started = service_start(service)
            if not started:
                raise Exception("{} didn't start cleanly.".format(service))
def pre_series_upgrade():
    log("Running prepare series upgrade hook", "INFO")
    if not openstack.is_unit_paused_set():
        for service in services():
            stopped = service_stop(service)
            if not stopped:
                raise Exception("{} didn't stop cleanly.".format(service))
        openstack.set_unit_paused()
    openstack.set_unit_upgrading()
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)
    nrpe_setup.write()
def post_series_upgrade():
    log("Running complete series upgrade hook", "INFO")
    openstack.clear_unit_paused()
    openstack.clear_unit_upgrading()
    _services, _ = get_managed_services_and_ports(services(), [])
    if not openstack.is_unit_paused_set():
        for service in _services:
            service_resume(service)
            started = service_start(service)
            if not started:
                raise Exception("{} didn't start cleanly.".format(service))
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)
    api_port = determine_api_port(config('bind-port'), singlenode_mode=True)
    nrpe_setup.add_check(shortname="swift-proxy-healthcheck",
                         description="Check Swift Proxy Healthcheck",
                         check_cmd="/usr/lib/nagios/plugins/check_http \
                  -I localhost -u /healthcheck -p {} \
                  -e \"OK\"".format(api_port))
    nrpe_setup.write()