backing up
[vsorcdistro/.git] / ryu / build / lib.linux-armv7l-2.7 / ryu / services / protocols / zebra / client / sample_dumper.py
1 # Copyright (C) 2017 Nippon Telegraph and Telephone Corporation.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #    http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12 # implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 """
17 Sample Zebra Client application dumping received events.
18 """
19
20 from ryu.controller.handler import set_ev_cls
21 from ryu.lib.packet import zebra
22 from ryu.services.protocols.zebra import event
23 from ryu.services.protocols.zebra.client.zclient import ZClient
24 from ryu.services.protocols.zebra.client import event as zclient_event
25
26
27 class ZClientDumper(ZClient):
28
29     @set_ev_cls(zclient_event.EventZServConnected)
30     def _zserv_connected_handler(self, ev):
31         self.logger.info(
32             'Zebra server connected to %s: %s',
33             ev.zserv.sock.getpeername(), ev.zserv.sock)
34
35     @set_ev_cls(event.EventZebraRouterIDUpdate)
36     def _router_id_update_handler(self, ev):
37         self.logger.info(
38             'ZEBRA_ROUTER_ID_UPDATE received: %s', ev.__dict__)
39
40     @set_ev_cls(event.EventZebraInterfaceAdd)
41     def _interface_add_handler(self, ev):
42         self.logger.info(
43             'ZEBRA_INTERFACE_ADD received: %s', ev.__dict__)
44
45     @set_ev_cls(event.EventZebraInterfaceAddressAdd)
46     def _interface_address_add_handler(self, ev):
47         self.logger.info(
48             'ZEBRA_INTERFACE_ADDRESS_ADD received: %s', ev.__dict__)
49
50     @set_ev_cls(zclient_event.EventZServDisconnected)
51     def _zserv_disconnected_handler(self, ev):
52         self.logger.info(
53             'Zebra server disconnected: %s', ev.zserv.sock)