예제 #1
0
    def actualizar_topology(self, req, **kwargs):

        print 'REST Service: PUT Topology'

        #Separetes HTTP header from HTTP body
        data = getHTTPBody(req)

        #Get topology data from JSON format data
        topo = JSONToListOfNodes(data)

        proxy = self.proxy
        #resul = proxy.update_ls_topology(topo)
        nodes, links = proxy.update_ls_topology(topo)

        #Actualiza los caminos de los servicios
        proxy.update_services_lsps()

        result = True
        if not result:
            return Response(status=404)

        try:
            body = 'Update complete succefully'
            return Response(content_type='application/json',
                            body=body,
                            status=200)
        except Exception as e:
            return Response(status=500)
예제 #2
0
    def actualizar_topology(self, req, **kwargs):
          
        print 'REST Service: PUT Topology'

        #Separetes HTTP header from HTTP body
        data = getHTTPBody(req)

        #Get topology data from JSON format data
        topo = JSONToListOfNodes(data) 

        proxy = self.proxy
        #resul = proxy.update_ls_topology(topo)
        nodes,links = proxy.update_ls_topology(topo)

        #Actualiza los caminos de los servicios
        proxy.update_services_lsps()

        result = True
        if not result:
            return Response(status=404)

        try:    
            body = 'Update complete succefully'
            return Response(content_type='application/json', body=body, status=200)
        except Exception as e:
            return Response(status=500)
예제 #3
0
    def modify_topology_node(self, req, **kwargs):
        
        router_id = kwargs['rid']   
        print 'REST Service: POST Node extra data for router_id ('+router_id+')'

        #Separetes HTTP header from HTTP body
        data = getHTTPBody(req)

        node_data = JSONToDTNodeReduced(data)

        proxy = self.proxy
        result = proxy.modify_topology_node(router_id, node_data)
        if result is None or result is False:
            return Response(status=404)

        try:    
            body = json.dumps({'Result': 'OK'}, 2)
            return Response(content_type='json', body=body, status=200)
        except Exception as e:
            return Response(status=500)
예제 #4
0
    def modify_topology_node(self, req, **kwargs):

        router_id = kwargs['rid']
        print 'REST Service: POST Node extra data for router_id (' + router_id + ')'

        #Separetes HTTP header from HTTP body
        data = getHTTPBody(req)

        node_data = JSONToDTNodeReduced(data)

        proxy = self.proxy
        result = proxy.modify_topology_node(router_id, node_data)
        if result is None or result is False:
            return Response(status=404)

        try:
            body = json.dumps({'Result': 'OK'}, 2)
            return Response(content_type='json', body=body, status=200)
        except Exception as e:
            return Response(status=500)
예제 #5
0
    def update_topology(self, req, **kwargs):
          
        print 'REST Service: PUT Topology'
       
        #Separetes HTTP header from HTTP body
        data = getHTTPBody(req)

        #Get topology data from JSON format data
        topo = JSONToListOfNodes(data) 

        #result = self.main_app.topo_controller.update_ls_topology(topo)
        result = True
        if not result:
            return Response(status=404)

        try:    
            body = 'Update complete succefully'
            return Response(content_type='application/json', body=body)
        except Exception as e:
            return Response(status=500)
예제 #6
0
    def actualizar_service(self, req, **kwargs):
          
        print 'REST Service: PUT Service'

        #Separetes HTTP header from HTTP body
        data = getHTTPBody(req)

        #Get topology data from JSON format data
        service = JSONToDTService(data) 

        proxy = self.proxy
        
        result = proxy.update_service(service)
        if result is None or not result:
            return Response(status=500)

        try:    
            body = json.dumps({'Result': 'OK'}, 2)
            return Response(content_type='json', body=body, status=200)
        except Exception as e:
            return Response(status=500)
예제 #7
0
    def actualizar_service(self, req, **kwargs):

        print 'REST Service: PUT Service'

        #Separetes HTTP header from HTTP body
        data = getHTTPBody(req)

        #Get topology data from JSON format data
        service = JSONToDTService(data)

        proxy = self.proxy

        result = proxy.update_service(service)
        if result is None or not result:
            return Response(status=500)

        try:
            body = json.dumps({'Result': 'OK'}, 2)
            return Response(content_type='json', body=body, status=200)
        except Exception as e:
            return Response(status=500)
예제 #8
0
    def add_service(self, req, **kwargs):

        print 'REST Service: POST Services'
        print "Servicio invocado: " + str(datetime.now().time())

        #Separetes HTTP header from HTTP body
        data = getHTTPBody(req)

        #Get topology data from JSON format data
        service = JSONToDTService(data)

        proxy = self.proxy

        result = proxy.add_service(service)
        if result is None or not result:
            return Response(status=500)

        try:
            body = json.dumps({'Result': 'OK'}, 2)
            print "Servicio creado: " + str(datetime.now().time())
            return Response(content_type='json', body=body, status=200)
        except Exception as e:
            return Response(status=500)
예제 #9
0
    def add_service(self, req, **kwargs):
          
        print 'REST Service: POST Services'
        print "Servicio invocado: " + str(datetime.now().time())

        #Separetes HTTP header from HTTP body
        data = getHTTPBody(req)

        #Get topology data from JSON format data
        service = JSONToDTService(data) 

        proxy = self.proxy
        
        result = proxy.add_service(service)
        if result is None or not result:
            return Response(status=500)

        try:    
            body = json.dumps({'Result': 'OK'}, 2)
            print "Servicio creado: " + str(datetime.now().time())
            return Response(content_type='json', body=body, status=200)
        except Exception as e:
            return Response(status=500)