def __init__(self, ip='', user='', pwd='', lab_name=''): self.ip, self.user, self.pwd, self.lab_name = ip, user, pwd, lab_name if os.environ.get('UNL_IP'): self.ip = os.environ.get('UNL_IP') self.unl = UnlServer(self.ip) self.unl.login(self.user, self.pwd) self.lab = None self.nodes = dict()
def app_1(): unl = UnlServer('192.168.247.20') unl.login('admin', 'unl') print("*** CONNECTED TO UNL") lab = unl.create_lab(LAB_NAME) print("*** CREATED LAB") node_1 = lab.create_node(Router('R1')) print("*** CREATED NODE")
def app(): try: unl = UnlServer('10.14.10.153') unl.login('admin', 'eve') print("*** CONNECTED TO UNL") lab = unl.create_lab(LAB_NAME) lab.cleanup() print("*** CREATED LAB") # Creating topology in UnetLab nodes = dict() for (a_name, a_intf), (b_name, b_intf) in TOPOLOGY.items(): # Create a mapping between a Node's name and an object if not a_name in nodes: nodes[a_name] = lab.create_node(Router(a_name)) print("*** NODE {} CREATED".format(a_name)) if not b_name in nodes: nodes[b_name] = lab.create_node(Router(b_name)) print("*** NODE {} CREATED".format(b_name)) # Extract Node objects using their names and connect them node_a = nodes[a_name] node_b = nodes[b_name] node_a.connect_node(a_intf, node_b, b_intf) print("*** NODES {0} and {1} ARE CONNECTED".format(a_name, b_name)) print("*** TOPOLOGY IS BUILT") lab.start_all_nodes() print("*** NODES STARTED") # Reading and pushing configuration for node_name in nodes: conf = read_file('..\\config\\{}.txt'.format(node_name)) nodes[node_name].configure(conf) print("*** NODE {} CONFIGURED".format(node_name)) input('PRESS ANY KEY TO STOP THE LAB') except Exception as e: print("*** APP FAILED : {}".format(e)) finally: print("*** CLEANING UP THE LAB")
def __init__(self, ip='', user='', pwd='', lab_name=''): self.ip, self.user, self.pwd, self.lab_name = ip, user, pwd, lab_name self.unl = UnlServer(self.ip) self.unl.login(self.user, self.pwd) self.lab = None self.nodes = dict()