Exemplo n.º 1
0
    """
    def __init__(self, dp):
        super(EventOFPStateChange, self).__init__()
        self.datapath = dp


class EventOFPPortStateChange(event.EventBase):
    """
    An event class to notify the port state changes of Dtatapath instance.

    This event performs like EventOFPPortStatus, but OSKen will
    send this event after updating ``ports`` dict of Datapath instances.
    An instance has at least the following attributes.

    ========= =================================================================
    Attribute Description
    ========= =================================================================
    datapath  os_ken.controller.controller.Datapath instance of the switch
    reason    one of OFPPR_*
    port_no   Port number which state was changed
    ========= =================================================================
    """
    def __init__(self, dp, reason, port_no):
        super(EventOFPPortStateChange, self).__init__()
        self.datapath = dp
        self.reason = reason
        self.port_no = port_no


handler.register_service('os_ken.controller.ofp_handler')
Exemplo n.º 2
0
    def __str__(self):
        return '%s<%s>' % (self.__class__.__name__, self.host)


class EventHostAdd(EventHostBase):
    def __init__(self, host):
        super(EventHostAdd, self).__init__(host)


# Note: Currently, EventHostDelete will never be raised, because we have no
# appropriate way to detect the disconnection of hosts. Just defined for
# future use.
class EventHostDelete(EventHostBase):
    def __init__(self, host):
        super(EventHostDelete, self).__init__(host)


class EventHostMove(event.EventBase):
    def __init__(self, src, dst):
        super(EventHostMove, self).__init__()
        self.src = src
        self.dst = dst

    def __str__(self):
        return '%s<src=%s, dst=%s>' % (self.__class__.__name__, self.src,
                                       self.dst)


handler.register_service('os_ken.topology.switches')
Exemplo n.º 3
0
                                                  ev.table,
                                                  ev.old,
                                                  ev.new)


class EventPortInserted(EventRowInsertedBase):
    pass


class EventPortDeleted(EventRowDeletedBase):
    pass


class EventPortUpdated(EventRowUpdatedBase):
    pass


class EventInterfaceInserted(EventRowInsertedBase):
    pass


class EventInterfaceDeleted(EventRowDeletedBase):
    pass


class EventInterfaceUpdated(EventRowUpdatedBase):
    pass


handler.register_service('os_ken.services.protocols.ovsdb.manager')
Exemplo n.º 4
0
                'DPSET: A port was modified.' +
                '(datapath id = %s, port number = %s)',
                dpid_to_str(datapath.id), port.port_no)
            self.port_state[datapath.id].modify(port.port_no, port)
            self.send_event_to_observers(EventPortModify(datapath, port))

    def get_port(self, dpid, port_no):
        """
        This method returns the os_ken.controller.dpset.PortState
        instance for the given Datapath ID and the port number.
        Raises os_ken_exc.PortNotFound if no such a datapath connected to
        this controller or no such a port exists.
        """
        try:
            return self.port_state[dpid][port_no]
        except KeyError:
            raise os_ken_exc.PortNotFound(dpid=dpid,
                                          port=port_no,
                                          network_id=None)

    def get_ports(self, dpid):
        """
        This method returns a list of os_ken.controller.dpset.PortState
        instances for the given Datapath ID.
        Raises KeyError if no such a datapath connected to this controller.
        """
        return list(self.port_state[dpid].values())


handler.register_service('os_ken.controller.dpset')