Exemplo n.º 1
0
    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,
            })
Exemplo n.º 2
0
Arquivo: link.py Projeto: lamr14/KNet
    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,
            })