backing up
[vsorcdistro/.git] / ryu / build / lib.linux-armv7l-2.7 / ryu / topology / api.py
1 # Copyright (C) 2013 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 from ryu.base import app_manager
17 from ryu.topology import event
18
19
20 def get_switch(app, dpid=None):
21     rep = app.send_request(event.EventSwitchRequest(dpid))
22     return rep.switches
23
24
25 def get_all_switch(app):
26     return get_switch(app)
27
28
29 def get_link(app, dpid=None):
30     rep = app.send_request(event.EventLinkRequest(dpid))
31     return rep.links
32
33
34 def get_all_link(app):
35     return get_link(app)
36
37
38 def get_host(app, dpid=None):
39     rep = app.send_request(event.EventHostRequest(dpid))
40     return rep.hosts
41
42
43 def get_all_host(app):
44     return get_host(app)
45
46
47 app_manager.require_app('ryu.topology.switches', api_style=True)