backing up
[vsorcdistro/.git] / ryu / build / lib.linux-armv7l-2.7 / ryu / app / gui_topology / gui_topology.py
1 # Copyright (C) 2014 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 Usage example
18
19 1. Join switches (use your favorite method):
20 $ sudo mn --controller remote --topo tree,depth=3
21
22 2. Run this application:
23 $ PYTHONPATH=. ./bin/ryu run \
24     --observe-links ryu/app/gui_topology/gui_topology.py
25
26 3. Access http://<ip address of ryu host>:8080 with your web browser.
27 """
28
29 import os
30
31 from webob.static import DirectoryApp
32
33 from ryu.app.wsgi import ControllerBase, WSGIApplication, route
34 from ryu.base import app_manager
35
36
37 PATH = os.path.dirname(__file__)
38
39
40 # Serving static files
41 class GUIServerApp(app_manager.RyuApp):
42     _CONTEXTS = {
43         'wsgi': WSGIApplication,
44     }
45
46     def __init__(self, *args, **kwargs):
47         super(GUIServerApp, self).__init__(*args, **kwargs)
48
49         wsgi = kwargs['wsgi']
50         wsgi.register(GUIServerController)
51
52
53 class GUIServerController(ControllerBase):
54     def __init__(self, req, link, data, **config):
55         super(GUIServerController, self).__init__(req, link, data, **config)
56         path = "%s/html/" % PATH
57         self.static_app = DirectoryApp(path)
58  #agregado para buscar otra ruta
59     @route('topology', '/{filename:[^/]*}')
60     def static_handler(self, req, **kwargs):
61         if kwargs['filename']:
62             req.path_info = kwargs['filename']
63         return self.static_app(req)
64
65
66 app_manager.require_app('ryu.app.rest_topology')
67 app_manager.require_app('ryu.app.ws_topology')
68 app_manager.require_app('ryu/app/ofctl_rest.py') ##aqui cambie los puntos por slash/
69 app_manager.require_app('ryu/app/simple_switch_13.py') #Agregue esta linea, Felix