def parse_launch_runtime_vars(launch_params): if launch_params: if file_exists(launch_params) and launch_params.endswith(".py"): return import_var_from_file(launch_params, "runtime_vars", []) else: LOG.warning( "Invalid launch_params passed! Must be a valid and existing.py file! Ignoring..." ) return []
def parse_launch_runtime_credentials(launch_params): """Returns credential_list object from launch_params file""" if launch_params: if file_exists(launch_params) and launch_params.endswith(".py"): return import_var_from_file(launch_params, "credential_list", []) else: LOG.warning( "Invalid launch_params passed! Must be a valid and existing.py file! Ignoring..." ) return []
def parse_launch_params_attribute(launch_params, parse_attribute): """Parses launch params and return value of parse_attribute i.e. variable_list, substrate_list, deployment_list, credenetial_list in file""" if launch_params: if file_exists(launch_params) and launch_params.endswith(".py"): return import_var_from_file(launch_params, parse_attribute, []) else: LOG.error( "Invalid launch_params passed! Must be a valid and existing.py file!" ) sys.exit(-1) return []
def parse_launch_runtime_deployments(launch_params): """Returns deployment_list object from launch_params file""" if launch_params: if file_exists(launch_params) and launch_params.endswith(".py"): return import_var_from_file(launch_params, "deployment_list", []) else: LOG.error( "Invalid launch_params passed! Must be a valid and existing.py file!" ) sys.exit(-1) return []
def read_spec(filename, depth=1): file_path = os.path.join( os.path.dirname(inspect.getfile(sys._getframe(depth))), filename) if not file_exists(file_path): LOG.debug("file {} not found at location {}".format( filename, file_path)) raise ValueError("file {} not found".format(filename)) with open(file_path, "r") as f: spec = yaml.safe_load(f.read()) return spec
def parse_input_file(client, runbook, input_file): if file_exists(input_file) and input_file.endswith(".py"): input_variable_list = import_var_from_file(input_file, "variable_list", []) target = import_var_from_file(input_file, "default_target", "") else: LOG.error("Invalid input_file passed! Must be a valid and existing.py file!") sys.exit(-1) args = [] variable_list = runbook["spec"]["resources"]["runbook"].get("variable_list", []) for variable in variable_list: if variable.get("editables", {}).get("value", False): filtered_input_runtime_var = list( filter(lambda e: e["name"] == variable.get("name"), input_variable_list) ) new_val = "" if len(filtered_input_runtime_var) == 1: new_val = filtered_input_runtime_var[0].get("value", "") if new_val: args.append( { "name": variable.get("name"), "value": type(variable.get("value"))(new_val), } ) payload = {"spec": {"args": args}} if target: endpoint = get_endpoint(client, target) endpoint_id = endpoint.get("metadata", {}).get("uuid", "") payload["spec"]["default_target_reference"] = { "kind": "app_endpoint", "uuid": endpoint_id, "name": target, } return payload