Minor fix to handle unconnected ofagent
Change-Id: I9e2b3cce0cb1bdceaf2e5619622401f1badf4d6b
diff --git a/ofagent/agent.py b/ofagent/agent.py
index a60b7f7..73864e0 100644
--- a/ofagent/agent.py
+++ b/ofagent/agent.py
@@ -51,6 +51,7 @@
# TCP connection is lost
self.connected = False
self.exiting = False
+ self.proto_handler = None
def get_device_id(self):
return self.device_id
@@ -119,13 +120,15 @@
reason=reason, connector=connector)
def forward_packet_in(self, ofp_packet_in):
- self.proto_handler.forward_packet_in(ofp_packet_in)
+ if self.proto_handler is not None:
+ self.proto_handler.forward_packet_in(ofp_packet_in)
def forward_change_event(self, event):
# assert isinstance(event, ChangeEvent)
log.info('got-change-event', change_event=event)
if event.HasField("port_status"):
- self.proto_handler.forward_port_status(event.port_status)
+ if self.proto_handler is not None:
+ self.proto_handler.forward_port_status(event.port_status)
else:
log.error('unknown-change-event', change_event=event)