def reinstall(switch_address, interface, port): with open(reinstall_file, "w+") as f: switch_ip_parts = switch_address.split(".") pi_addr = ".".join([ switch_ip_parts[0], switch_ip_parts[1], str(private_number), str(port) ]) f.write(pi_addr) power_cycle.power_cycle(switch_address, interface, port)
def restart(host_ips): ip_mac_map = {ip: None for ip in host_ips} with open('{}/{}'.format(direc, hosts_file), 'r') as fd: for line in fd: mac, ip = line.split(';')[:2] ip_mac_map[ip] = mac for ip in host_ips: mac = ip_mac_map[ip] if mac: switch_port = findport.find_port(mac, switch_ip, community) if switch_port: power_cycle.power_cycle(switch_port, switch_ip, community)
def reinstall(host_ip): host_ip = host_ip[ 0] # change later. func should take a list rather than string with open(direc + '/' + hosts_file, 'r') as fd: for line in fd: if host_ip == line.split(';')[1]: mac = line.split(';')[0] switch_port = findport.find_port(mac, switch_ip, community) if switch_port: with open(direc + '/reinstall.txt', 'w') as f: f.write(host_ip) power_cycle.power_cycle(switch_port, switch_ip, community) else: print('Switch port not found')
def remshell(pi_address, port_on_localhost): with open(direc + '/' + hosts_file, 'r') as fd: for line in fd: if pi_address == line.split(';')[1]: mac = line.split(';')[0] switch_port = findport.find_port(mac, switch_ip, community) if switch_port: with open(direc + '/remshell.txt', 'w') as fd: pi_addr = piaddress + ',' + str(port_on_localhost) fd.write(pi_addr) power_cycle.power_cycle(switch_port, switch_ip, community) else: print('Switch port not found') else: print(pi_address + ' not found')
def mapper(switch_address,interface, port, file): for portNum in port: power_cycle.power_cycle(switch_address,interface, portNum) time.sleep(30) mac_mapper.mac_mapper(file)
def reinstall(switch_address, interface, port): with open("reinstall.txt", "w") as f: network_addr = ip[:7] + str(interface) + "." + str(port) f.write(network_addr) power_cycle.power_cycle(switch_address, interface, port)
def restart(switch_address, interface, ports): for port in ports: power_cycle.power_cycle(switch_address, interface, port)
def powercycle(switch_ports): for switch_port in switch_ports: power_cycle.power_cycle(switch_port, switch_ip, community)