def post(self): args = self.parser.parse_args() mainLogger.debug("## args = {0}".format(args)) if is_none(args.get("ServiceName")) or is_none(args.get("Application")) or is_none(args.get("Workflow")): raise MissingRequiredParametersException(" ServiceName and Application and Workflow are/is requried") # return serilization type ret_type = args.get("RT") if ret_type is None: ret_type = "JSON" # current_node_envs = infa_env.get_envs(current_node.id) # type: dict current_node_envs = get_current_node_infa_envs() os.environ.update(current_node_envs) mainLogger.debug("environment variables is {0}".format(current_node_envs)) args.pop("RT") res = startWorkflow(**args) mainLogger.debug(res) stdout = str(res.stdout) if ret_type.upper() == "PROTOBUF": proto_resp = infaCliResponse_pb2.InfaCliResponse() proto_resp.retcode = res.retcode proto_resp.stdout = stdout res = proto_resp.SerializeToString() mainLogger.debug("protobuf: the result is {0}".format(res)) content_type = Config.PREDEFINED_CONTENT_TYPES.get("PROTOBUF") else: output_dict = {"retcode": res.retcode, "stdout": stdout } res = json.dumps(output_dict) content_type = Config.PREDEFINED_CONTENT_TYPES.get("JSON") response = make_response(res) response.headers["Content-Type"] = content_type return response
def post(self): args = self.parser.parse_args() mainLogger.info("the pmpasswd args is {0}".format(args)) encrypt_type = args.get("EncryptType") passwd = args.get("Passwd") if encrypt_type is None or encrypt_type not in ( 'CRYPT_DATA', 'CRYPT_SYSTEM') or passwd is None: abort(401) ret_type = args.get('RT') # type: str if ret_type is None: ret_type = "JSON" # node = Node() # current_node = node.get_current_node() # type: Node # # infa_env = INFA_ENV() # # set_task_envs = infa_env.get_envs(current_node.id) set_task_envs = get_current_node_infa_envs() print("############## os.environ is {0}".format(os.environ)) os.environ.update(set_task_envs) commandResult = pmpasswd( passwd, encrypt_type=encrypt_type) # type: namedtuple("pmpasswdResult", # ['retcode', 'stdout']) content_type = None if ret_type.upper() == "PROTOBUF": pmpasswd_resp = infaCliResponse_pb2.InfaCliResponse() pmpasswd_resp.retcode = commandResult.retcode pmpasswd_resp.stdout = commandResult.stdout commandResult = pmpasswd_resp.SerializeToString() mainLogger.debug( "protobuf: the result is {0}".format(commandResult)) content_type = Config.PREDEFINED_CONTENT_TYPES.get("PROTOBUF") else: commandResult = json.dumps(commandResult._asdict()) content_type = Config.PREDEFINED_CONTENT_TYPES.get("JSON") response = make_response(commandResult) response.headers["Content-Type"] = content_type return response