def main(): args = get_args() general.preliminary_checks([ "BILLBOARD_API_TOKEN", "NETBOX_TOKEN", ]) # device_name = args.device_name.lower() action = args.action.lower() path_filters = args.path_filter.split(",") all_path_types = ["prod_global", "monitor", "site_local", "int_local"] # Check path filter if path_filters == ["all"]: path_filters = all_path_types local_mode = args.local_mode prod_mode = args.prod_mode device_name, site_name = general.get_server_site(args.device_name) # Perform withdraw or announce action if action == "announce": command_list = announce(site_name=site_name, device=device_name, path_filters=path_filters) elif action == "withdraw": command_list = withdraw(device=device_name, path_filters=path_filters) # Check for prod_mode before processing commands for i in command_list: if local_mode: local_flags = ["--host", "localhost", "--port", "55010"] i.extend(local_flags) print(" ".join(i)) p = subprocess.Popen( i, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, ) p.communicate(input="y\n") elif prod_mode: print(" ".join(i)) print("WE'LL DO IT LIVE!") p = subprocess.Popen( i, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, ) p.communicate(input="y\n") else: print(" ".join(i))
def main(): general.preliminary_checks(["AWX_API_TOKEN"]) a = awx.AWX() output = a.sync_invenstory() job_id = output.get("workflow_job", None) if job_id: print("To see the output of the job: (will take around 1m45)") print( f"Job ID: {job_id}\thttps://awx.global.ftlprod.net/#/jobs/workflow/{job_id}/output" ) else: print("Didn't receive the job_id, verify manually.") pprint(output) sys.exit(1)
def main(): general.preliminary_checks(["AWX_API_TOKEN"]) a = awx.AWX() output = a.update_dns(server) job_id = output.get("job", None) if job_id: print("To see the output of the job:") print( f"Job ID: {job_id}\thttps://awx.global.ftlprod.net/#/jobs/playbook/{job_id}/output" ) else: print("Didn't receive the job_id, verify manually.") pprint(output) sys.exit(1)
def main(): general.preliminary_checks(["AWX_API_TOKEN"]) a = awx.AWX() run_phase = { "phase2": a.phase2_single_slice, "phase3": a.phase3_single_slice, } output = run_phase[phase](server) job_id = output.get("job", None) if job_id: webbrowser.open_new_tab( f"https://awx.global.ftlprod.net/#/jobs/playbook/{job_id}/output") print("Job ID:", job_id) else: print("Didn't receive the job_id, verify manually.") pprint(output) sys.exit(1)
"""Get a colorized string to represent the IP""" tag = next(t.slug for t in nb_ip.tags) if nb_ip.tags else "no-tag" color = COLORS[tag] if tag is not None else "" return f"{color}{nb_ip.address}{COLORS['reset']}" if __name__ == "__main__": parser = argparse.ArgumentParser( description= "Print out a data server's interface configuration according to " "Netbox. Includes the type and status of connected circuits.") parser.add_argument("server", help="Server name") args = parser.parse_args() srv_name = args.server.lower() general.preliminary_checks(["NETBOX_TOKEN"]) nb = netbox.Netbox() nb_server = nb.get_server(srv_name) if nb_server is None: raise ValueError(f"No server {srv_name} in Netbox") print( f"\nNETBOX data for: {COLORS['site-local-ip']}{nb_server.name}{COLORS['reset']}" f" ({nb_server.device_type.display_name})\n") print( f"{'Name':16}" f"{'Type':6}" f"{'Lacp':6}" f"{'Status':14}" f"{'Provider':15}"
def main(): general.preliminary_checks(["AWX_API_TOKEN"]) a = awx.AWX() print(a.get_job_status(job_id))
def main() -> None: general.preliminary_checks(["BILLBOARD_API_TOKEN"]) bb_path_parsed = extract_parse_paths() execute_new_com(bb_path_parsed)