コード例 #1
0
ファイル: restClient.py プロジェクト: cclauss/cargo
def isNFSMounted(host, port, volume):
    clientUrl = EXPORT_FS.substitute(HOST=host, PORT=port)
    headers = {"content-type": "application/json"}
    payload = dict()
    payload["role"] = "source"
    payload["opcode"] = "CHECK_NFS"
    params = dict()
    params["volume"] = volume
    payload["params"] = params

    rc = codes.SUCCESS
    nfsMeta = None

    try:
        resp = requests.get(clientUrl,
                            data=json.dumps(payload),
                            headers=headers)
    except requests.exceptions.ConnectionError as e:
        logging.error("Can not connect to cargo agent at: {}".format(host))
        rc = codes.FAILED
    else:
        if resp.status_code == codes.herror(codes.SUCCESS):
            nfsMeta = json.loads(resp.content)

    return (rc, nfsMeta)
コード例 #2
0
ファイル: restClient.py プロジェクト: MFALHI/cargo
def inspectContainer(host, port, container):
    clientUrl = OPERATE_CONTAINER.substitute(HOST = host, PORT = port,
            NAME = container)
    containerMeta = dict()
    rc = codes.SUCCESS
    try:
        resp = requests.get(clientUrl, headers=HEADERS)
    except requests.exceptions.ConnectionError as e:
        logging.error(ERR_FMT.format(e, host))
        rc = codes.FAILED
    else:
        if resp.status_code == codes.herror(codes.SUCCESS):
            containerMeta = json.loads(resp.content)
    return rc, containerMeta
コード例 #3
0
def inspectContainer(host, port, container):
    clientUrl = OPERATE_CONTAINER.substitute(HOST=host,
                                             PORT=port,
                                             NAME=container)
    containerMeta = dict()
    rc = codes.SUCCESS
    try:
        resp = requests.get(clientUrl, headers=HEADERS)
    except requests.exceptions.ConnectionError as e:
        logging.error(ERR_FMT.format(e, host))
        rc = codes.FAILED
    else:
        if resp.status_code == codes.herror(codes.SUCCESS):
            containerMeta = json.loads(resp.content)
    return rc, containerMeta
コード例 #4
0
ファイル: restClient.py プロジェクト: MFALHI/cargo
def isNFSMounted(host, port, volume):
    clientUrl = EXPORT_FS.substitute(HOST = host, PORT = port)
    params = {"volume": volume}
    payload = {"role": "source", "opcode": "CHECK_NFS", "params": params}

    rc = codes.SUCCESS
    nfsMeta  = None

    try:
        resp = requests.get(clientUrl, data=json.dumps(payload), headers=HEADERS)
    except requests.exceptions.ConnectionError as e:
        logging.error(ERR_FMT.format(e, host))
        rc = codes.FAILED
    else:
        if resp.status_code == codes.herror(codes.SUCCESS):
            nfsMeta = json.loads(resp.content)

    return rc, nfsMeta
コード例 #5
0
ファイル: restClient.py プロジェクト: cclauss/cargo
def inspectContainer(host, port, container):
    clientUrl = OPERATE_CONTAINER.substitute(HOST = host, PORT = port, \
            NAME = container)
    headers = {"content-type": "application/json"}
    payload = dict()
    containerMeta = dict()
    rc = codes.SUCCESS

    try:
        resp = requests.get(clientUrl, data=json.dumps(payload), headers=headers)
    except requests.exceptions.ConnectionError as e:
        logging.error("Can not connect to cargo agent at: {}".format(host))
        rc = codes.FAILED
    
    else:
        if resp.status_code == codes.herror(codes.SUCCESS):
            containerMeta = json.loads(resp.content)
    
    return (rc, containerMeta)
コード例 #6
0
def isNFSMounted(host, port, volume):
    clientUrl = EXPORT_FS.substitute(HOST=host, PORT=port)
    params = {"volume": volume}
    payload = {"role": "source", "opcode": "CHECK_NFS", "params": params}

    rc = codes.SUCCESS
    nfsMeta = None

    try:
        resp = requests.get(clientUrl,
                            data=json.dumps(payload),
                            headers=HEADERS)
    except requests.exceptions.ConnectionError as e:
        logging.error(ERR_FMT.format(e, host))
        rc = codes.FAILED
    else:
        if resp.status_code == codes.herror(codes.SUCCESS):
            nfsMeta = json.loads(resp.content)

    return rc, nfsMeta
コード例 #7
0
ファイル: restClient.py プロジェクト: cclauss/cargo
def inspectContainer(host, port, container):
    clientUrl = OPERATE_CONTAINER.substitute(HOST = host, PORT = port, \
            NAME = container)
    headers = {"content-type": "application/json"}
    payload = dict()
    containerMeta = dict()
    rc = codes.SUCCESS

    try:
        resp = requests.get(clientUrl,
                            data=json.dumps(payload),
                            headers=headers)
    except requests.exceptions.ConnectionError as e:
        logging.error("Can not connect to cargo agent at: {}".format(host))
        rc = codes.FAILED

    else:
        if resp.status_code == codes.herror(codes.SUCCESS):
            containerMeta = json.loads(resp.content)

    return (rc, containerMeta)
コード例 #8
0
ファイル: controller.py プロジェクト: MFALHI/cargo
    def getAllContainers(self):
        agentList = self.__get_agents()
        containerMap = dict()
        rc = codes.SUCCESS 
        for agent in agentList:
            agentip = str(agentList[agent]["ip"])
            agentport = int(agentList[agent]["port"])
            clientUrl = GET_CONTAINERS.substitute(HOST = agentip, PORT = agentport)
            headers = {"content-type": "application/json"}
            payload = dict()
            try:
                resp = requests.get(clientUrl, data=json.dumps(payload), headers=headers)
            except requests.exceptions.ConnectionError as e:
                logging.error("Can not connect to cargo agent at: {}".format(agent))
                rc = codes.FAILED
                pass

            else:
                if resp.status_code == codes.herror(codes.SUCCESS):
                        containerMap[agent] = json.loads(resp.content)   

        return (rc, json.dumps(containerMap))
コード例 #9
0
ファイル: restClient.py プロジェクト: cclauss/cargo
def isNFSMounted(host, port, volume):
    clientUrl = EXPORT_FS.substitute(HOST = host, PORT = port)
    headers = {"content-type": "application/json"}
    payload = dict()
    payload["role"] = "source"
    payload["opcode"] = "CHECK_NFS"
    params = dict()
    params["volume"] = volume
    payload["params"] = params

    rc = codes.SUCCESS
    nfsMeta  = None

    try:
        resp = requests.get(clientUrl, data=json.dumps(payload), headers=headers)
    except requests.exceptions.ConnectionError as e:
        logging.error("Can not connect to cargo agent at: {}".format(host))
        rc = codes.FAILED
    else:
        if resp.status_code == codes.herror(codes.SUCCESS):
            nfsMeta = json.loads(resp.content)

    return (rc, nfsMeta) 
コード例 #10
0
 def post(self, nodeid, containerid):
     rc = reqHandler.doFailover(nodeid, containerid)
     return make_response("", codes.herror(rc))
コード例 #11
0
 def post(self, containerid):
     payload = request.data
     rc = reqHandler.updateStatus(containerid, payload)
     return make_response("", codes.herror(rc))
コード例 #12
0
 def get(self, containerid):
     rc, msg = reqHandler.getStatus(containerid)
     return make_response(msg, codes.herror(rc))
コード例 #13
0
 def post(self):
     agent = request.data
     rc = reqHandler.register(agent)
     return make_response("", codes.herror(rc))
コード例 #14
0
 def post(self):
     migreq  = json.loads(request.data)
     rc = reqHandler.migrate(migreq)
     return make_response("", codes.herror(rc))
コード例 #15
0
 def get(self):
     rc, msg = reqHandler.getAllContainers()
     return make_response(msg, codes.herror(rc))