1 # Copyright (C) 2013 Nippon Telegraph and Telephone Corporation.
2 # Copyright (C) 2013 Isaku Yamahata <yamahata at private email ne jp>
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 from ryu.base import app_manager
18 from ryu.services.protocols.vrrp import event as vrrp_event
21 def vrrp_config(app, interface, config):
22 """create an instance.
23 returns EventVRRPConfigReply(instance.name, interface, config)
25 returns EventVRRPConfigReply(None, interface, config)
28 config_request = vrrp_event.EventVRRPConfigRequest(interface, config)
29 config_request.sync = True
30 return app.send_request(config_request)
33 def vrrp_shutdown(app, instance_name):
34 """shutdown the instance.
36 shutdown_request = vrrp_event.EventVRRPShutdownRequest(instance_name)
37 app.send_event(vrrp_event.VRRP_MANAGER_NAME, shutdown_request)
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.
44 transmit_request = vrrp_event.EventVRRPTransmitRequest(data)
45 app.send_event(monitor_name, transmit_request)
48 def vrrp_list(app, instance_name=None):
50 returns EventVRRPListReply([VRRPInstance]).
52 list_request = vrrp_event.EventVRRPListRequest(instance_name)
53 list_request.dst = vrrp_event.VRRP_MANAGER_NAME
54 return app.send_request(list_request)
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.
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)
69 app_manager.require_app('ryu.services.protocols.vrrp.manager', api_style=True)