Exemplo n.º 1
0
    def create(self, cfg):
        """
        Create Tables from config.
        """
        for dpath in cfg.dpaths:
            msg = fibcdbm.create_dp(dpath)
            evt = fibcevt.EventFIBCPortMap(msg, "add", "dp")
            self.on_port_map(evt)

        for router in cfg.routers:
            msg = fibcdbm.create_idmap(router)
            evt = fibcevt.EventFIBCPortMap(msg, "add", "idmap")
            self.on_port_map(evt)

            for port in fibcdbm.create_ports(router):
                evt = fibcevt.EventFIBCPortMap(port, "add", "port")
                self.on_port_map(evt)
Exemplo n.º 2
0
    def mod_portmap(self, req, table, cmd, **kwargs):
        """
        modify portmap
        """
        dic = json.loads(req.body)
        if table == "dp":
            evt = fibcevt.EventFIBCPortMap(dic, cmd, "dp")
            self.app.send_event_to_observers(evt)

        elif table == "re":
            msg = fibcdbm.create_idmap(dic)
            evt = fibcevt.EventFIBCPortMap(msg, cmd, "idmap")
            self.app.send_event_to_observers(evt)

        elif table == "port":
            for port in fibcdbm.create_ports(dic):
                evt = fibcevt.EventFIBCPortMap(port, cmd, "port")
                self.app.send_event_to_observers(evt)

        else:
            pass
Exemplo n.º 3
0
    def mod_portmap(self, req, table, cmd, **kwargs):
        """
        modify portmap
        """
        dic = json.loads(req.body)
        if table == "dp":
            evt = fibcevt.EventFIBCPortMap(dic, cmd, "dp")
            self.app.send_event_to_observers(evt)

        elif table == "re":
            msg = dict(re_id=dic["re_id"], dp_id=dic["dp_id"])
            evt = fibcevt.EventFIBCPortMap(msg, cmd, "idmap")
            self.app.send_event_to_observers(evt)

        elif table == "port":
            for port in dic["ports"]:
                entry = FIBCPortEntry.new(re_id=dic["re_id"],
                                          dp_id=dic["dp_id"],
                                          **port)
                evt = fibcevt.EventFIBCPortMap(entry, cmd, "port")
                self.app.send_event_to_observers(evt)

        else:
            pass