def get_routers_from_openstack(): logger.info("Get list servers with ip addresses ... ") ops_server = ops.Servers(name=cmd_args.name, dbg=logging.INFO) if cmd_args.ansible: ops_server.create_ansible_hosts(cmd_args.netid) if cmd_args.list: ops_server.create_dynamic_inventory(cmd_args.netid) # logger.info(srv_ips) return ops_server.get_srv_nets(cmd_args.netid)
def get_routers_from_openstack(name_lab, netid_lab): logger.debug("Get list servers with ip addresses ... ") ops_server = ops.Servers(name=name_lab, dbg=logging.ERROR) rt = ops_server.get_srv_nets(netid_lab) hosts = list() for r in rt: if re.search(r'[^R]*(R\d+)', r): hosts.append(rt[r]['ipv4']) # logger.info(srv_ips) return hosts
def main(): logger.info("Get list servers with ip addresses ... ") file_config = "oslabs.yml" lab_routers = "" wan = "wan0" lab = "labv22" if cmd_args.host: print("{}") exit(0) if os.path.exists(file_config): with open(file_config) as file: param_list = yaml.load(file, Loader=yaml.FullLoader) wan = param_list["wan"] lab = param_list["lab"] # print(param_list) ops_server = ops.Servers(name=lab, dbg=logging.ERROR) ops_server.create_dynamic_inventory(wan)
def main(): lab_host = cmd_args.name host_intrf = f"net{int(cmd_args.interface)-1}" logger.info(f"host: {lab_host} interface: {host_intrf}") ops_server = ops.Servers(name=lab_host, dbg=logging.WARNING, name_underline=False) # print(f'srv: {ops_server}') if len(ops_server.servers) > 1: logging.error("Exist few elements but need one") exit(1) else: srv = ops_server.servers[0] logger.info(f"{srv.name} : {srv.instance}") logger.info(f"Interface: {srv.kvminfo.interfaces[host_intrf].dev}") os_name = f"root@{srv.host}" logger.info(f'os_name: {os_name}') p_ssh = Popen([ "ssh", os_name, "tcpdump", "-U", "-i", str(srv.kvminfo.interfaces[host_intrf].dev), "-s", "0", "-w", "-" ], stdout=PIPE) p_wireshark = Popen(["wireshark", "-k", "-i", "-"], stdin=p_ssh.stdout)