def remove_kraken_vip(name): """ Delete a given instance vip and associated pool """ pool_name = vip_name(name) vs_name = pool_name connection = load_balancer._adc_connection() print(blue("Delete virtual server %s" % vs_name)) connection.LocalLB.VirtualServer.delete_virtual_server([vs_name]) print(blue("Delete pool %s" % pool_name)) connection.LocalLB.Pool.delete_pool([pool_name])
def upgrade_all(up_tyr=True, up_confs=True, check_version=True, send_mail='no', manual_lb=False, check_dead=True, check_bina=True): """Upgrade all navitia packages, databases and launch rebinarisation of all instances """ up_tyr = get_bool_from_cli(up_tyr) up_confs = get_bool_from_cli(up_confs) check_version = get_bool_from_cli(check_version) check_dead = get_bool_from_cli(check_dead) check_bina = get_bool_from_cli(check_bina) if check_version: execute(compare_version_candidate_installed, host_name='tyr') if env.use_load_balancer: if manual_lb: print(yellow("WARNING : you are in MANUAL mode :\n" "Check frequently for message asking you to switch nodes manually")) else: # check credential NOW _adc_connection(check=True) execute(check_last_dataset) if send_mail in ('start', 'all'): broadcast_email('start') time_dict = TimeCollector() time_dict.register_start('total_deploy') if up_tyr: execute(update_tyr_step, time_dict, only_bina=False, check_bina=check_bina) if check_version: execute(compare_version_candidate_installed) execute(kraken.swap_all_data_nav) if env.use_load_balancer: # Upgrade kraken/jormun on first hosts set env.roledefs['eng'] = env.eng_hosts_1 env.roledefs['ws'] = env.ws_hosts_1 if manual_lb: raw_input(yellow("Please disable ENG1,3/WS1,5,6 and enable ENG2,4/WS2-4")) else: execute(switch_to_first_phase, env.eng_hosts_1, env.ws_hosts_1, env.ws_hosts_2) time_dict.register_start('kraken') execute(upgrade_kraken, wait=env.KRAKEN_RESTART_SCHEME, up_confs=up_confs, supervision=True) if check_dead: execute(check_dead_instances) execute(upgrade_jormungandr, reload=False, up_confs=up_confs) # check first hosts set before upgrading the second one for server in env.roledefs['ws']: instance = random.choice(env.instances.values()) execute(jormungandr.test_jormungandr, get_host_addr(server), instance=instance.name) # Upgrade kraken/jormun on remaining hosts env.roledefs['eng'] = env.eng_hosts_2 env.roledefs['ws'] = env.ws_hosts_2 if manual_lb: raw_input(yellow("Please enable ENG1,3/WS1,5,6 and disable ENG2,4/WS2-4")) else: execute(switch_to_second_phase, env.eng_hosts_1, env.eng_hosts_2, env.ws_hosts_1, env.ws_hosts_2) execute(upgrade_jormungandr, reload=False, up_confs=up_confs) if manual_lb: raw_input(yellow("Please enable WS1-6")) else: execute(switch_to_third_phase, env.ws_hosts_2) env.roledefs['ws'] = env.ws_hosts execute(upgrade_kraken, wait=env.KRAKEN_RESTART_SCHEME, up_confs=up_confs) time_dict.register_end('kraken') if not manual_lb: execute(enable_all_nodes, env.eng_hosts, env.ws_hosts_1, env.ws_hosts_2) env.roledefs['eng'] = env.eng_hosts else: time_dict.register_start('kraken') execute(upgrade_kraken, wait=env.KRAKEN_RESTART_SCHEME, up_confs=up_confs, supervision=True) time_dict.register_end('kraken') execute(upgrade_jormungandr, up_confs=up_confs) # check deployment OK for server in env.roledefs['ws']: instance = random.choice(env.instances.values()) execute(jormungandr.test_jormungandr, get_host_addr(server), instance=instance.name) # start tyr_beat even if up_tyr is False execute(tyr.start_tyr_beat) time_dict.register_end('total_deploy') if send_mail in ('end', 'all'): warn_dict = jormungandr.check_kraken_jormun_after_deploy() status = show_dead_kraken_status(warn_dict, show=True) status += show_time_deploy(time_dict) broadcast_email('end', status) if env.use_load_balancer and manual_lb: print(yellow("Please enable ENG1-4/WS1-4"))
def upgrade_all(up_tyr=True, up_confs=True, kraken_wait=True, check_version=True, send_mail='no', manual_lb=False, check_dead=True): """Upgrade all navitia packages, databases and launch rebinarisation of all instances """ check_version = get_bool_from_cli(check_version) up_tyr = get_bool_from_cli(up_tyr) up_confs = get_bool_from_cli(up_confs) kraken_wait = get_bool_from_cli(kraken_wait) if check_version: execute(compare_version_candidate_installed, host_name='tyr') if env.use_load_balancer: if manual_lb: print(yellow("WARNING : you are in MANUAL mode :\n" "Check frequently for message asking you to switch nodes manually")) else: # check credential NOW _adc_connection(check=True) execute(check_last_dataset) if send_mail in ('start', 'all'): broadcast_email('start') time_dict = TimeCollector() time_dict.register_start('total_deploy') if up_tyr: execute(tyr.stop_tyr_beat) execute(upgrade_tyr, up_confs=up_confs, pilot_tyr_beat=False) time_dict.register_start('bina') execute(tyr.launch_rebinarization_upgrade, pilot_tyr_beat=False) time_dict.register_end('bina') if check_version: execute(compare_version_candidate_installed) execute(kraken.swap_all_data_nav) if env.use_load_balancer: # Upgrade kraken/jormun on first hosts set env.roledefs['eng'] = env.eng_hosts_1 env.roledefs['ws'] = env.ws_hosts_1 if manual_lb: raw_input(yellow("Please disable ENG1/WS1 and enable ENG2-4/WS2-4")) else: execute(switch_to_first_phase, env.eng_hosts_1, env.ws_hosts_1, env.ws_hosts_2) time_dict.register_start('kraken') execute(upgrade_kraken, kraken_wait=kraken_wait, up_confs=up_confs, supervision=True) if check_dead: execute(check_dead_instances) execute(upgrade_jormungandr, reload=False, up_confs=up_confs) # Upgrade kraken/jormun on remaining hosts env.roledefs['eng'] = env.eng_hosts_2 env.roledefs['ws'] = env.ws_hosts_2 if manual_lb: raw_input(yellow("Please enable ENG1/WS1 and disable ENG2-4/WS2-4")) else: execute(switch_to_second_phase, env.eng_hosts_1, env.eng_hosts_2, env.ws_hosts_1, env.ws_hosts_2) execute(upgrade_kraken, kraken_wait=kraken_wait, up_confs=up_confs) time_dict.register_end('kraken') execute(upgrade_jormungandr, reload=False, up_confs=up_confs) if not manual_lb: execute(enable_all_nodes, env.eng_hosts, env.ws_hosts_1, env.ws_hosts_2) env.roledefs['eng'] = env.eng_hosts env.roledefs['ws'] = env.ws_hosts else: time_dict.register_start('kraken') execute(upgrade_kraken, kraken_wait=kraken_wait, up_confs=up_confs, supervision=True) time_dict.register_end('kraken') execute(upgrade_jormungandr, up_confs=up_confs) if up_tyr: execute(tyr.start_tyr_beat) time_dict.register_end('total_deploy') if send_mail in ('end', 'all'): warn_dict = jormungandr.check_kraken_jormun_after_deploy() status = show_dead_kraken_status(warn_dict, show=True) status += show_time_deploy(time_dict) broadcast_email('end', status) if env.use_load_balancer and manual_lb: print(yellow("Please enable ENG1-4/WS1-4"))