Exemple #1
0
 def remove(self, network_id, dpid, port_no):
     try:
         self.remove_raw(network_id, dpid, port_no)
     except KeyError:
         raise NetworkNotFound(network_id=network_id)
     except ValueError:
         raise PortNotFound(network_id=network_id, dpid=dpid, port=port_no)
Exemple #2
0
    def _update_port(self, network_id, dpid, port, port_may_exist):
        self.logger.info('processing: %s()', sys._getframe(0).f_code.co_name)

        def _known_nw_id(nw_id):
            return nw_id is not None and nw_id != self.nw_id_unknown

        queue_add_event = False
        self._check_nw_id_unknown(network_id)
        try:
            old_network_id = self.dpids.get_network_safe(dpid, port)
            if (self.networks.has_port(network_id, dpid, port)
                    or _known_nw_id(old_network_id)):
                if not port_may_exist:
                    raise PortAlreadyExist(network_id=network_id,
                                           dpid=dpid,
                                           port=port)

            if old_network_id != network_id:
                queue_add_event = True
                self.networks.add_raw(network_id, dpid, port)
                if _known_nw_id(old_network_id):
                    self.networks.remove_raw(old_network_id, dpid, port)
        except KeyError:
            raise NetworkNotFound(network_id=network_id)

        self.dpids.update_port(dpid, port, network_id)
        if queue_add_event:
            self.networks.add_event(network_id, dpid, port)
Exemple #3
0
 def list_ports(self, network_id):
     try:
         # use list() to keep compatibility for output
         # set() isn't json serializable
         return list(self[network_id])
     except KeyError:
         raise NetworkNotFound(network_id=network_id)
Exemple #4
0
 def remove(self, network_id, dpid, port_no):
     self.logger.info('processing: %s()', sys._getframe(0).f_code.co_name)
     try:
         self.remove_raw(network_id, dpid, port_no)
     except KeyError:
         raise NetworkNotFound(network_id=network_id)
     except ValueError:
         raise PortNotFound(network_id=network_id, dpid=dpid, port=port_no)
Exemple #5
0
 def list_ports(self, network_id):
     self.logger.info('processing: %s()', sys._getframe(0).f_code.co_name)
     try:
         # use list() to keep compatibility for output
         # set() isn't json serializable
         return list(self[network_id])
     except KeyError:
         raise NetworkNotFound(network_id=network_id)
Exemple #6
0
    def remove_network(self, network_id):
        try:
            ports = self[network_id]
        except KeyError:
            raise NetworkNotFound(network_id=network_id)

        while ports:
            (dpid, port_no) = ports.pop()
            self._remove_event(network_id, dpid, port_no)
        if self.pop(network_id, None) is not None:
            self.send_event(EventNetworkDel(network_id))
Exemple #7
0
    def remove_network(self, network_id):
        self.logger.info('processing: %s()', sys._getframe(0).f_code.co_name)
        try:
            ports = self[network_id]
        except KeyError:
            raise NetworkNotFound(network_id=network_id)

        while ports:
            (dpid, port_no) = ports.pop()
            self._remove_event(network_id, dpid, port_no)
        if self.pop(network_id, None) is not None:
            self.send_event(EventNetworkDel(network_id))