def cluster_changed(): CONFIGS.write_all() if hookenv.relation_ids('cluster'): ch_peerstorage.peer_echo(includes=['dbsync_state']) dbsync_state = ch_peerstorage.peer_retrieve('dbsync_state') if dbsync_state == 'complete': if not ch_utils.is_unit_paused_set(): for svc in ncc_utils.services(): ch_host.service_resume(svc) else: hookenv.log('Unit is in paused state, not issuing ' 'start/resume to all services') else: if not ch_utils.is_unit_paused_set(): hookenv.log('Database sync not ready. Shutting down services') for svc in ncc_utils.services(): ch_host.service_pause(svc) else: hookenv.log( 'Database sync not ready. Would shut down services but ' 'unit is in paused state, not issuing stop/pause to all ' 'services') # The shared metadata secret is stored in the leader-db and if its changed # the gateway needs to know. for rid in hookenv.relation_ids('quantum-network-service'): quantum_joined(rid=rid, remote_restart=False)
def install(): hookenv.status_set('maintenance', 'Executing pre-install') execd.execd_preinstall() ch_utils.configure_installation_source(hookenv.config('openstack-origin')) hookenv.status_set('maintenance', 'Installing apt packages') ch_fetch.apt_update() ch_fetch.apt_install(ncc_utils.determine_packages(), fatal=True) ncc_utils.disable_package_apache_site() ncc_utils.stop_deprecated_services() _files = os.path.join(hookenv.charm_dir(), 'files') if os.path.isdir(_files): for f in os.listdir(_files): f = os.path.join(_files, f) if os.path.isfile(f): hookenv.log('Installing %s to /usr/bin' % f) shutil.copy2(f, '/usr/bin') for port in ncc_utils.determine_ports(): hookenv.open_port(port) msg = 'Disabling services into db relation joined' hookenv.log(msg) hookenv.status_set('maintenance', msg) if not ch_utils.is_unit_paused_set(): for svc in ncc_utils.services(): ch_host.service_pause(svc) else: hookenv.log('Unit is in paused state, not issuing stop/pause ' 'to all services')
def upgrade_charm(): ch_fetch.apt_install( ch_fetch.filter_installed_packages( ncc_utils.determine_packages()), fatal=True) packages_removed = ncc_utils.remove_old_packages() if packages_removed: hookenv.log("Package purge detected, restarting services", "INFO") for s in ncc_utils.services(): ch_host.service_restart(s) # For users already using bionic-rocky which are upgrading their # charm only we need ensure to not end-up with the old # 'wsgi-openstack-api' and the new 'wsgi-placement-api' apache # configurations installed at the same time. ncc_utils.stop_deprecated_services() ncc_utils.disable_package_apache_site(service_reload=True) for r_id in hookenv.relation_ids('amqp'): amqp_joined(relation_id=r_id) for r_id in hookenv.relation_ids('identity-service'): identity_joined(rid=r_id) for r_id in hookenv.relation_ids('cloud-compute'): set_region_on_relation_from_config(r_id) for unit in hookenv.related_units(r_id): update_ssh_keys_and_notify_compute_units(r_id, unit) for r_id in hookenv.relation_ids('shared-db'): db_joined(relation_id=r_id) add_hosts_to_cell_when_ready() leader_init_db_if_ready_allowed_units() update_nrpe_config()
def upgrade_charm(): ch_fetch.apt_install( ch_fetch.filter_installed_packages( ncc_utils.determine_packages()), fatal=True) packages_removed = ncc_utils.remove_old_packages() if packages_removed: hookenv.log("Package purge detected, restarting services", "INFO") for s in ncc_utils.services(): ch_host.service_restart(s) # For users already using bionic-rocky which are upgrading their # charm only we need ensure to not end-up with the old # 'wsgi-openstack-api' and the new 'wsgi-placement-api' apache # configurations installed at the same time. ncc_utils.stop_deprecated_services() ncc_utils.disable_package_apache_site(service_reload=True) for r_id in hookenv.relation_ids('amqp'): amqp_joined(relation_id=r_id) for r_id in hookenv.relation_ids('identity-service'): identity_joined(rid=r_id) for r_id in hookenv.relation_ids('cloud-compute'): for unit in hookenv.related_units(r_id): compute_changed(r_id, unit) for r_id in hookenv.relation_ids('shared-db'): db_joined(relation_id=r_id) leader_init_db_if_ready_allowed_units() update_nrpe_config()
def db_departed(): CONFIGS.write_all() update_cell_db_if_ready(skip_acl_check=True) for r_id in hookenv.relation_ids('cluster'): hookenv.relation_set(relation_id=r_id, dbsync_state='incomplete') if not ch_utils.is_unit_paused_set(): for svc in ncc_utils.services(): ch_host.service_pause(svc) else: hookenv.log('Unit is in paused state, not issuing stop/pause to all ' 'services')
def update_nrpe_config(): # python-dbus is used by check_upstart_job ch_fetch.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, ncc_utils.services(), current_unit) nrpe.add_haproxy_checks(nrpe_setup, current_unit) nrpe_setup.write()
def upgrade_charm(): ch_fetch.apt_install(ch_fetch.filter_installed_packages( ncc_utils.determine_packages()), fatal=True) packages_removed = ncc_utils.remove_old_packages() if packages_removed: hookenv.log("Package purge detected, restarting services", "INFO") for s in ncc_utils.services(): ch_host.service_restart(s) for r_id in hookenv.relation_ids('amqp'): amqp_joined(relation_id=r_id) for r_id in hookenv.relation_ids('identity-service'): identity_joined(rid=r_id) for r_id in hookenv.relation_ids('cloud-compute'): for unit in hookenv.related_units(r_id): compute_changed(r_id, unit) for r_id in hookenv.relation_ids('shared-db'): db_joined(relation_id=r_id) leader_init_db_if_ready_allowed_units() update_nrpe_config() update_nova_consoleauth_config()