summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2017-02-13 15:43:56 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-02-22 12:22:30 +0900
commitfd3bfb55dea8e45b07b7ca488476497fc7e8e817 (patch)
treef8c5ab5c114910fd3126f05ad817f4bdd4b461a4
parente5a0974508b2279e84d57149f844a2a098c7fef8 (diff)
zebra: Add sample application for Zebra client service
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/services/protocols/zebra/client/sample_dumper.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/ryu/services/protocols/zebra/client/sample_dumper.py b/ryu/services/protocols/zebra/client/sample_dumper.py
new file mode 100644
index 00000000..395620e7
--- /dev/null
+++ b/ryu/services/protocols/zebra/client/sample_dumper.py
@@ -0,0 +1,53 @@
+# Copyright (C) 2017 Nippon Telegraph and Telephone Corporation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""
+Sample Zebra Client application dumping received events.
+"""
+
+from ryu.controller.handler import set_ev_cls
+from ryu.lib.packet import zebra
+from ryu.services.protocols.zebra import event
+from ryu.services.protocols.zebra.client.zclient import ZClient
+from ryu.services.protocols.zebra.client import event as zclient_event
+
+
+class ZClientDumper(ZClient):
+
+ @set_ev_cls(zclient_event.EventZServConnected)
+ def _zserv_connected_handler(self, ev):
+ self.logger.info(
+ 'Zebra server connected to %s: %s',
+ ev.zserv.sock.getpeername(), ev.zserv.sock)
+
+ @set_ev_cls(event.EventZebraRouterIDUpdate)
+ def _router_id_update_handler(self, ev):
+ self.logger.info(
+ 'ZEBRA_ROUTER_ID_UPDATE received: %s', ev.__dict__)
+
+ @set_ev_cls(event.EventZebraInterfaceAdd)
+ def _interface_add_handler(self, ev):
+ self.logger.info(
+ 'ZEBRA_INTERFACE_ADD received: %s', ev.__dict__)
+
+ @set_ev_cls(event.EventZebraInterfaceAddressAdd)
+ def _interface_address_add_handler(self, ev):
+ self.logger.info(
+ 'ZEBRA_INTERFACE_ADDRESS_ADD received: %s', ev.__dict__)
+
+ @set_ev_cls(zclient_event.EventZServDisconnected)
+ def _zserv_disconnected_handler(self, ev):
+ self.logger.info(
+ 'Zebra server disconnected: %s', ev.zserv.sock)