backing up
[vsorcdistro/.git] / ryu / build / lib.linux-armv7l-2.7 / ryu / services / protocols / vrrp / api.py
1 # Copyright (C) 2013 Nippon Telegraph and Telephone Corporation.
2 # Copyright (C) 2013 Isaku Yamahata <yamahata at private email ne jp>
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #    http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13 # implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 from ryu.base import app_manager
18 from ryu.services.protocols.vrrp import event as vrrp_event
19
20
21 def vrrp_config(app, interface, config):
22     """create an instance.
23     returns EventVRRPConfigReply(instance.name, interface, config)
24     on success.
25     returns EventVRRPConfigReply(None, interface, config)
26     on failure.
27     """
28     config_request = vrrp_event.EventVRRPConfigRequest(interface, config)
29     config_request.sync = True
30     return app.send_request(config_request)
31
32
33 def vrrp_shutdown(app, instance_name):
34     """shutdown the instance.
35     """
36     shutdown_request = vrrp_event.EventVRRPShutdownRequest(instance_name)
37     app.send_event(vrrp_event.VRRP_MANAGER_NAME, shutdown_request)
38
39
40 def vrrp_transmit(app, monitor_name, data):
41     """transmit a packet from the switch.  this is internal use only.
42     data is str-like, a packet to send.
43     """
44     transmit_request = vrrp_event.EventVRRPTransmitRequest(data)
45     app.send_event(monitor_name, transmit_request)
46
47
48 def vrrp_list(app, instance_name=None):
49     """list instances.
50     returns EventVRRPListReply([VRRPInstance]).
51     """
52     list_request = vrrp_event.EventVRRPListRequest(instance_name)
53     list_request.dst = vrrp_event.VRRP_MANAGER_NAME
54     return app.send_request(list_request)
55
56
57 def vrrp_config_change(app, instance_name,
58                        priority=None, advertisement_interval=None,
59                        preempt_mode=None, accept_mode=None):
60     """change configuration of an instance.
61     None means no change.
62     """
63     config_change = vrrp_event.EventVRRPConfigChangeRequest(
64         instance_name, priority, advertisement_interval,
65         preempt_mode, accept_mode)
66     return app.send_event(vrrp_event.VRRP_MANAGER_NAME, config_change)
67
68
69 app_manager.require_app('ryu.services.protocols.vrrp.manager', api_style=True)