示例#1
0
    def index(self, format='html'):
        """GET /policy: All items in the collection"""
        if sourceLRNode.isServiceAvailable(
                NodeServiceModel.ADMINISTRATIVE) == False:
            return "Administrative service is not available"

        return json.dumps(sourceLRNode.networkPolicyDescription.specData)
示例#2
0
 def index(self, format='html'):
     """GET /description: All items in the collection"""
     if sourceLRNode.isServiceAvailable(NodeServiceModel.ADMINISTRATIVE) == False:
         return "Administrative service is not available"
         
     data = {}
     data['timestamp'] = str(datetime.utcnow())
     data.update(sourceLRNode.config)
         
     return json.dumps(data)
示例#3
0
 def index(self, format='html'):
     """GET /distribute: All items in the collection"""
     # url('distribute')
     distributeInfo = {'OK': True}
     
     if sourceLRNode.isServiceAvailable(NodeServiceModel.DISTRIBUTE) == False:
         distributeInfo['OK'] = False
     else:
         distributeInfo['node_config'] = sourceLRNode.config
         distributeInfo['distribute_sink_url'] = urlparse.urljoin(request.url,self.resource_data)
     log.info("received distribute request...returning: \n"+json.dumps(distributeInfo))
     return json.dumps(distributeInfo)
 def index(self, format='html'):
     """GET /services: All items in the collection"""
     if sourceLRNode.isServiceAvailable('Network Node Services') == False:  
         return "Administrative service is not available"
         
     data = {}
     data['timestamp'] = str(datetime.datetime.utcnow())
     data['node_id'] = sourceLRNode.nodeDescription.node_id
     data['active'] =  sourceLRNode.nodeDescription.active
     data['node_name'] = sourceLRNode.nodeDescription.node_name
     data['services'] = []
     for s in sourceLRNode.nodeServices:
         data['services'].append(s.specData)
         
     return json.dumps(data)
示例#5
0
    def index(self, format='html'):
        """GET /services: All items in the collection"""
        if sourceLRNode.isServiceAvailable('Network Node Services') == False:
            return "Administrative service is not available"

        data = {}
        data['timestamp'] = str(datetime.datetime.utcnow())
        data['node_id'] = sourceLRNode.nodeDescription.node_id
        data['active'] = sourceLRNode.nodeDescription.active
        data['node_name'] = sourceLRNode.nodeDescription.node_name
        data['services'] = []
        for s in sourceLRNode.nodeServices:
            data['services'].append(s.specData)

        return json.dumps(data)
示例#6
0
    def create(self):
        """POST / distribute start distribution"""
        
        def doDistribution(destinationNode, server, sourceUrl, destinationUrl):
            
            filterFunction = (ResourceDataModel._defaultDB.name+"/" + 
                                          ResourceDataModel.DEFAULT_FILTER)
            # We want to always use the default filter function to filter
            # out design document on replication. But we don't have any
            # query arguments until we test if there is any filter.
            replicationOptions={'filter':filterFunction, 
                                             'query_params': None}
            # If the destination node is using an filter and is not custom use it
            # as the query params for the filter function
            if ((destinationNode.filterDescription is not None) and 
                 (destinationNode.filterDescription.custom_filter == False)):
                     replicationOptions['query_params'] = destinationNode.filterDescription.specData
            
            log.info("\n\nReplication started\nSource:{0}\nDestionation:{1}\nArgs:{2}".format(
                            sourceUrl, destinationUrl, str(replicationOptions)))
            if replicationOptions['query_params'] is  None: 
                del replicationOptions['query_params']
                
            results = server.replicate(sourceUrl, destinationUrl, **replicationOptions)
            log.debug("Replication results: "+str(results))
        
        log.info("Distribute.......\n")
        #Check if the distribte service is available on the node.
        if(sourceLRNode.isServiceAvailable(NodeServiceModel.DISTRIBUTE) == False):
            log.info("Distribute not available on node ")
            return
        if((sourceLRNode.connections is None) or 
            (len(sourceLRNode.connections) ==0)):
            log.info("No connection present for distribution")
            return
        log.info("Connections: "+str(sourceLRNode.connections)+"\n")

        for connectionInfo in self._getDistributeDestinations():
            replicationArgs = (connectionInfo['destinationNode'], 
                                         defaultCouchServer, 
                                         self.resource_data, 
                                         connectionInfo['distributeInfo']['distribute_sink_url'])
                                         
            # Use a thread to do the actual replication.                             
            replicationThread = threading.Thread(target=doDistribution, 
                                                                        args=replicationArgs)
            replicationThread.start()
示例#7
0
    def index(self, format="html"):
        """GET /status: All items in the collection"""
        if sourceLRNode.isServiceAvailable(NodeServiceModel.ADMINISTRATIVE) == False:
            return "Administrative service not is available"

        return json.dumps(sourceLRNode.status)
示例#8
0
 def index(self, format='html'):
     """GET /policy: All items in the collection"""
     if sourceLRNode.isServiceAvailable(NodeServiceModel.ADMINISTRATIVE) == False:
         return "Administrative service is not available"
         
     return json.dumps(sourceLRNode.networkPolicyDescription.specData)