topology: Enable to detect migrations of hosts
Currently, the topology library does not update the position of a host which was detected before even if the host migrated to another port. This patch enables to detect the migrations of the hosts when the host is detected on another port. Reported-by: Mahmoud Elzoghbi <mahmoud.said.elzoghbi@gmail.com> Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
63f81837fd
commit
7e6f3f00ed
@ -170,4 +170,24 @@ 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('ryu.topology.switches')
|
||||
|
@ -868,6 +868,11 @@ class Switches(app_manager.RyuApp):
|
||||
self.hosts.add(host)
|
||||
ev = event.EventHostAdd(host)
|
||||
self.send_event_to_observers(ev)
|
||||
elif self.hosts[host_mac].port != port:
|
||||
# assumes the host is moved to another port
|
||||
ev = event.EventHostMove(src=self.hosts[host_mac], dst=host)
|
||||
self.hosts[host_mac] = host
|
||||
self.send_event_to_observers(ev)
|
||||
|
||||
# arp packet, update ip address
|
||||
if eth.ethertype == ether_types.ETH_TYPE_ARP:
|
||||
|
Loading…
Reference in New Issue
Block a user