コード例 #1
0
    def __persistConnection(self, direction, headers=dict()):
        headers['persistent-connection'] = direction
        #message body is actually irrellevant and is not read on the other
        # side.
        #we just need to conform to the http protocol
        fields = []
        fields.append(Input('cmd', "persist-connection"))

        #sending along the connection parameters for this server
        conf = ServerConf()
        connectionParams = dict()
        connectionParams['serverId'] = conf.getServerId()
        connectionParams['hostname'] = conf.getHostName()
        connectionParams['fqdn'] = conf.getFqdn()
        connectionParams['client_secure_port'] = conf\
        .getClientSecurePort()
        connectionParams['server_secure_port'] = conf\
        .getServerSecurePort()

        input2 = Input(
            'connectionParams',
            json.dumps(connectionParams,
                       default=json_serializer.toJson,
                       indent=4))  # a json structure that needs to be dumped
        fields.append(input2)

        response = self.putRequest(
            ServerRequest.prepareRequest(fields, [], headers))

        return response
コード例 #2
0
    def addNodeAccepted(self):
        conf = ServerConf()

        inf = open(conf.getCACertFile(), "r")
        key = inf.read()
        #only sending fqdn the requesting should already know the unqualified
        # hostname
        node = NodeConnectRequest(conf.getServerId(),
                                  conf.getClientSecurePort(),
                                  conf.getServerSecurePort(), key,
                                  conf.getFqdn(), None)
        cmdstring = 'node-connection-accepted'
        fields = []
        input = Input('cmd', cmdstring)

        input2 = Input(
            'connectRequest',
            json.dumps(node, default=json_serializer.toJson, indent=4))

        fields.append(input)
        fields.append(input2)
        fields.append(Input('version', "1"))

        # this goes over  client secure port , and we don't want the server to use
        # cookies
        response = self.postRequest(ServerRequest.prepareRequest(fields),
                                    require_certificate_authentication=False,
                                    disable_cookies=True)
        return response
コード例 #3
0
    def sendAddNodeRequest(self, host):
        """

        """
        conf = ServerConf()
        cmdstring = 'connect-server-request'
        fields = []
        input = Input('cmd', cmdstring)

        inf = open(conf.getCACertFile(), "r")
        key = inf.read()

        nodeConnectRequest = NodeConnectRequest(conf.getServerId(),
                                                conf.getClientSecurePort(),
                                                conf.getServerSecurePort(),
                                                key, conf.getFqdn(),
                                                conf.getHostName())

        input2 = Input(
            'nodeConnectRequest',
            json.dumps(nodeConnectRequest,
                       default=json_serializer.toJson,
                       indent=4))
        input3 = Input('unqalifiedDomainName', host)
        fields.append(input)
        fields.append(input2)
        fields.append(input3)
        fields.append(Input('version', "1"))
        # this goes over the client Secure Port, and we don't want the server to use
        # cookies
        response = self.postRequest(ServerRequest.prepareRequest(fields),
                                    require_certificate_authentication=False,
                                    disable_cookies=True)
        return response
コード例 #4
0
 def projectsRequest(self):
     """List all projects"""
     cmdstring = "projects"
     fields = []
     fields.append(Input('cmd', cmdstring))
     fields.append(Input('version', "1"))
     response = self.postRequest(ServerRequest.prepareRequest(fields, []))
     return response
コード例 #5
0
 def listModules(self):
     cmdString = "list-modules"
     fields = []
     input = Input('cmd', cmdString)
     fields.append(input)
     fields.append(Input('version', "1"))
     msg = ServerRequest.prepareRequest(fields, [])
     return self.postRequest(msg)
コード例 #6
0
 def projectRollbackRequest(self, project):
     """Cancel a series of previously scheduled set&connect requests."""
     cmdstring = "project-rollback"
     fields = []
     fields.append(Input('cmd', cmdstring))
     fields.append(Input('version', "1"))
     response = self.postRequest(ServerRequest.prepareRequest(fields, []))
     return response
コード例 #7
0
 def projectGetDefaultRequest(self):
     """Get the default project project name"""
     cmdstring = "project-get-default"
     fields = []
     fields.append(Input('cmd', cmdstring))
     fields.append(Input('version', "1"))
     response = self.postRequest(ServerRequest.prepareRequest(fields, []))
     return response
コード例 #8
0
 def projectStartRequest(self, name):
     """Start a new empty project """
     cmdstring = "project-start"
     fields = []
     fields.append(Input('cmd', cmdstring))
     fields.append(Input('version', "1"))
     fields.append(Input('name', name))
     response = self.postRequest(ServerRequest.prepareRequest(fields, []))
     return response
コード例 #9
0
 def saveStateRequest(self):
     """Tell the server to save its state now."""
     cmdstring = "save-state"
     fields = []
     input = Input('cmd', cmdstring)
     fields.append(input)
     fields.append(Input('version', "1"))
     response = self.postRequest(ServerRequest.prepareRequest(fields, []))
     return response
コード例 #10
0
 def readConfRequest(self):
     """Tell the server to re-read its configuration."""
     cmdstring = "readconf"
     fields = []
     input = Input('cmd', cmdstring)
     fields.append(input)
     fields.append(Input('version', "1"))
     response = self.postRequest(ServerRequest.prepareRequest(fields, []))
     return response
コード例 #11
0
 def revokeNode(self, serverId):
     cmdString = "revoke-node"
     fields = []
     input = Input('cmd', cmdString)
     fields.append(input)
     fields.append(Input('version', "1"))
     fields.append(Input('serverId', serverId))
     msg = ServerRequest.prepareRequest(fields, [])
     return self.postRequest(msg)
コード例 #12
0
 def grantAccess(self, user):
     cmdstring = "grant-access"
     fields = []
     input = Input('cmd', cmdstring)
     fields.append(input)
     fields.append(Input('name', user))
     msg = ServerRequest.prepareRequest(fields, [])
     response = self.postRequest(msg)
     return response
コード例 #13
0
 def projectCommitRequest(self, project):
     """Commit a series of previously scheduled set&connect requests, 
        atomically."""
     cmdstring = "project-commit"
     fields = []
     fields.append(Input('cmd', cmdstring))
     fields.append(Input('version', "1"))
     response = self.postRequest(ServerRequest.prepareRequest(fields, []))
     return response
コード例 #14
0
 def deleteUser(self, user):
     cmdstring = "delete-user"
     fields = []
     input = Input('cmd', cmdstring)
     fields.append(input)
     fields.append(Input('user', user))
     msg = ServerRequest.prepareRequest(fields, [])
     response = self.postRequest(msg)
     return response
コード例 #15
0
 def stopRequest(self):
     cmdstring = "stop"
     fields = []
     input = Input('cmd', cmdstring)
     fields.append(input)
     fields.append(Input('version', "1"))
     response = self.postRequest(ServerRequest.prepareRequest(fields, []))
     #response= self.putRequest(ServerRequest.prepareRequest(fields, []))
     return response
コード例 #16
0
 def serverInfo(self):
     cmdstring = 'server-info'
     fields = []
     input = Input('cmd', cmdstring)
     fields.append(input)
     fields.append(Input('version', "1"))
     msg = ServerRequest.prepareRequest(fields, [])
     response = self.postRequest(msg)
     return response
コード例 #17
0
 def projectSaveRequest(self, project):
     """Get a data item from a project."""
     cmdstring = "project-save"
     fields = []
     fields.append(Input('cmd', cmdstring))
     fields.append(Input('version', "1"))
     #if project is not None:
     fields.append(Input('project', project))
     response = self.postRequest(ServerRequest.prepareRequest(fields, []))
     return response
コード例 #18
0
    def grantNodeConnection(self, serverId):
        cmdString = "grant-node-connection"
        input = Input('cmd', cmdString)
        fields = []
        fields.append(input)
        fields.append(Input('version', "1"))
        fields.append(Input('serverId', serverId))

        msg = ServerRequest.prepareRequest(fields, [])
        return self.postRequest(msg)
コード例 #19
0
    def grantAllNodeConnections(self):
        cmdString = "grant-all-node-connections"
        input = Input('cmd', cmdString)
        fields = []
        fields.append(input)
        fields.append(Input('version', "1"))

        msg = ServerRequest.prepareRequest(fields, [])

        return self.postRequest(msg)
コード例 #20
0
 def projectDebugRequest(self, project, item):
     """Get debug info for project items"""
     cmdstring = "project-debug"
     fields = []
     fields.append(Input('cmd', cmdstring))
     if project is not None:
         fields.append(Input('project', project))
     fields.append(Input('item', item))
     response = self.postRequest(ServerRequest.prepareRequest(fields, []))
     return response
コード例 #21
0
 def projectInfoRequest(self, project, item):
     """List descriptions of project items"""
     cmdstring = "project-info"
     fields = []
     fields.append(Input('cmd', cmdstring))
     fields.append(Input('version', "1"))
     if project is not None:
         fields.append(Input('project', project))
     fields.append(Input('item', item))
     response = self.postRequest(ServerRequest.prepareRequest(fields, []))
     return response
コード例 #22
0
    def networkTopology(self):
        cmdstring = "network-topology-client"
        fields = []
        input = Input('cmd', cmdstring)
        fields.append(input)
        fields.append(Input('version', "1"))

        msg = ServerRequest.prepareRequest(fields, [])

        response = self.postRequest(msg)
        return response
コード例 #23
0
    def addUser(self, user, password):
        cmdstring = "add-user"
        fields = []
        input = Input('cmd', cmdstring)
        fields.append(input)

        fields.append(Input('user', user))
        fields.append(Input('password', password))
        msg = ServerRequest.prepareRequest(fields, [])
        response = self.postRequest(msg)
        return response
コード例 #24
0
 def projectImportRequest(self, project, module):
     """Import a module in a network"""
     cmdstring = "project-import"
     fields = []
     fields.append(Input('cmd', cmdstring))
     fields.append(Input('version', "1"))
     if project is not None:
         fields.append(Input('project', project))
     fields.append(Input('module', module))
     response = self.postRequest(ServerRequest.prepareRequest(fields, []))
     return response
コード例 #25
0
 def projectHoldRequest(self, project, item):
     """List all projects"""
     cmdstring = "project-deactivate"
     fields = []
     fields.append(Input('cmd', cmdstring))
     fields.append(Input('version', "1"))
     if project is not None:
         fields.append(Input('project', project))
     fields.append(Input('item', item))
     response = self.postRequest(ServerRequest.prepareRequest(fields, []))
     return response
コード例 #26
0
 def statusRequest(self, project):
     """Fetches an aggregated general information about the server and
        and its projects. The argument project is optional"""
     cmdstring = "status"
     fields = []
     fields.append(Input('cmd', cmdstring))
     if project is not None:
         fields.append(Input('project', project))
     fields.append(Input('version', "1"))
     response = self.postRequest(ServerRequest.prepareRequest(fields, []))
     return response
コード例 #27
0
 def projectDeleteRequest(self, project, deleteDir):
     """Delete a project and optionally also its directory """
     cmdstring = "project-delete"
     fields = []
     fields.append(Input('cmd', cmdstring))
     fields.append(Input('version', "1"))
     fields.append(Input('project', project))
     if deleteDir:
         fields.append(Input('delete-dir', 1))
     response = self.postRequest(ServerRequest.prepareRequest(fields, []))
     return response
コード例 #28
0
ファイル: message.py プロジェクト: vivek-bala/copernicus
 def workerRequest(self, workerID, archdata):
     cmdstring='worker-ready'
     fields = []
     fields.append(Input('cmd', cmdstring))
     fields.append(Input('version', "1"))
     fields.append(Input('worker', archdata))
     fields.append(Input('worker-id', workerID))
     headers = dict()
     response= self.putRequest(ServerRequest.prepareRequest(fields, [],
                                                            headers))
     return response
コード例 #29
0
 def projectGraphRequest(self, project, item):
     """Graph item's network in a project"""
     cmdstring = "project-graph"
     fields = []
     fields.append(Input('cmd', cmdstring))
     fields.append(Input('version', "1"))
     if project is not None:
         fields.append(Input('project', project))
     fields.append(Input('item', item))
     response = self.postRequest(ServerRequest.prepareRequest(fields, []))
     return response
コード例 #30
0
 def pingServer(self, serverId):
     cmdstring = 'ping'
     fields = []
     input = Input('cmd', cmdstring)
     fields.append(input)
     fields.append(Input('version', "1"))
     headers = dict()
     if serverId != None:
         headers['server-id'] = serverId
     msg = ServerRequest.prepareRequest(fields, [], headers)
     response = self.putRequest(msg)
     return response