def create(self): # add port # set port type as patch # set port peer mapping self.src_patchif = "patch" + str(SwitchLink.patchif_index) SwitchLink.patchif_index += 1 self.dst_patchif = "patch" + str(SwitchLink.patchif_index) SwitchLink.patchif_index += 1 ovs.addport(self.src_switch, self.src_patchif) ovs.addport(self.dst_switch, self.dst_patchif) ovs.config_port_as_patch(self.src_patchif) ovs.config_port_as_patch(self.dst_patchif) ovs.peer_patch_ports(self.src_patchif, self.dst_patchif) ovs.peer_patch_ports(self.dst_patchif, self.src_patchif) # link - source node id s = utils.get_switch_data(self.src_switch) sourceid = s["id"] # link -target node id t = utils.get_switch_data(self.dst_switch) targetid = t["id"] # store the link endpoints in array (for UI drawing) self.links.append({ "source": sourceid, "target": targetid, "source-name": self.src_switch, "target-name": self.dst_switch }) # update in DB self.docid = utils.link_t.insert({ 'id': self.id, 'source': self.src_switch, 'target': self.dst_switch, 'source-id': sourceid, 'target-id': targetid, 'if1': self.src_patchif, 'if2': self.dst_patchif, 'qos': None, })
def create(self): for router in self.routers: log.debug("Creating RouterLink" + str(router)) r = utils.get_router_data(router['name']) log.debug(r) # get IP from the router data r for the interface ip, mac = self.__getip(r['interfaces'], router["interface"]) log.debug(ip) log.debug(mac) # create a link node to switch ovs.create_link(self.switch, router["interface"], router['name'], ip, mac) # get the tap interface name tapif = ovs.get_port_name(router["name"], router["interface"]) # apply the Qos to the interface if "qos" in router: qos = self.getqos(router["qos"]) tc.config_qos(tapif, qos) sourceid = r["id"] # link -target node id s = utils.get_switch_data(self.switch) targetid = s["id"] # get the tap interface name tapif = ovs.get_port_name(router["name"], router["interface"]) # store the link endpoints in array (for UI drawing) self.links.append({ "source": sourceid, "target": targetid, "source-name": router["name"], "target-name": self.switch }) # update in DB self.docid = utils.link_t.insert({ 'id': utils.generate_id(), 'source': router["name"], 'target': self.switch, 'source-id': sourceid, 'target-id': targetid, 'if1': router["interface"], 'if2': tapif, 'qos': None, })
def create(self): for node in self.nodes: # print node node_interface = "eth1" qos = None #mac = None #if "mac" in node: # mac = node["mac"] #ip = self.network.getip() n = utils.get_node_data(node["name"]) # create a link node to switch ovs.create_link(self.switch, node_interface, node["name"], n['ip'], n['mac']) # get the tap interface name tapif = ovs.get_port_name(node["name"], node_interface) # link - source node id # sourceid = utils.get_node_data(node["name"]) sourceid = n["id"] # link -target node id s = utils.get_switch_data(self.switch) targetid = s["id"] # apply the Qos to the interface if "qos" in node: qos = self.getqos(node["qos"]) tc.config_qos(tapif, qos) # store the link endpoints in array (for UI drawing) self.links.append({ "source": sourceid, "target": targetid, "source-name": node["name"], "target-name": self.switch }) # update in DB self.docid = utils.link_t.insert({ 'id': utils.generate_id(), 'source': node["name"], 'target': self.switch, 'source-id': sourceid, 'target-id': targetid, 'if1': node_interface, 'if2': tapif, 'qos': qos, })