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)
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
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
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
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)
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
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))
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)
def post(self, nodeid, containerid): rc = reqHandler.doFailover(nodeid, containerid) return make_response("", codes.herror(rc))
def post(self, containerid): payload = request.data rc = reqHandler.updateStatus(containerid, payload) return make_response("", codes.herror(rc))
def get(self, containerid): rc, msg = reqHandler.getStatus(containerid) return make_response(msg, codes.herror(rc))
def post(self): agent = request.data rc = reqHandler.register(agent) return make_response("", codes.herror(rc))
def post(self): migreq = json.loads(request.data) rc = reqHandler.migrate(migreq) return make_response("", codes.herror(rc))
def get(self): rc, msg = reqHandler.getAllContainers() return make_response(msg, codes.herror(rc))