def verify_tool_set_data(toolsetData): """Verify ToolSetData""" if toolsetData.get("name"): HelperServices.validate_name(toolsetData.get("name"),"toolset name") if toolsetData.get("tool_set") and len(toolsetData.get("tool_set")) > 1: tool_set = [] for tool_version in toolsetData.get("tool_set"): if not tool_version.get("version_id"): raise ValueError("version_id was not found in request") if not tool_version.get("tool_version"): raise ValueError("tool_version was not found in request") versionDetails = versionsDB.get_version( tool_version.get("version_id"), False) if not versionDetails: raise ValueError("Version with version_id:" + tool_version.get("version_id") + " was not found in database") if not versionDetails.get("tool_id"): raise ValueError("Version with version_id:" + tool_version.get( "version_id") + " in database has missing tool_id") tool_set.append({"version_id": tool_version.get("version_id"), "tool_version": tool_version.get( "version_id"), "tool_id": versionDetails.get("tool_id")}) toolsetData["tool_set"] = tool_set else: raise ValueError("Specify at least two tool versions in the ToolSet") # CHECK TAG if not toolsetData.get("tag"): toolsetData["tag"] = [] else: toolsetData["tag"] = tagDB.get_tag_ids_from_given_ids_list( toolsetData["tag"]) return toolsetData
def validate_machine_group(machine_group_details): keys_to_validate = ["group_name", "machine_id_list"] for key in keys_to_validate: if not machine_group_details.get(key): raise Exception("Mandatory Field: " + (str(key).replace('_', ' ')).upper() + " is missing") if "," in machine_group_details.get("group_name"): raise Exception("Field: " + (str("group_name").replace('_', ' ')).upper() + " cannot contain comma") if (machine_group_details.get("group_name") and machine_group_details.get("machine_id_list")) is None: raise Exception( "Mandatory fields to create a new group was not found.") HelperServices.validate_name(machine_group_details.get("group_name"), "machine group name") if len(machine_group_details.get("machine_id_list", [])) < 1: raise Exception("atleast one machine is required in group") for machine_id in machine_group_details["machine_id_list"]: if machineDB.GetMachine(machine_id) is None: raise Exception("Machine with _id : " + machine_id + " not exists") if machine_group_details.get("flexible_attributes"): FlexibleAttributesHelper.validate_entity_value( "MachineGroup", machine_group_details.get("flexible_attributes"))
def add_update_version(VersionsData, tool_id, version_id, allDetails=False): """Add Update a Version""" versionInsert = {} versionInsert['tool_id'] = tool_id if VersionsData.get("pre_requiests") is not None: versionInsert['pre_requiests'] = VersionsData['pre_requiests'] if VersionsData.get("version_name") is not None: HelperServices.validate_name(VersionsData.get("version_name"),"version label") versionInsert['version_name'] = VersionsData['version_name'] if VersionsData.get("version_date") is not None: try: versionInsert['version_date'] = datetime.strptime( (str(str(VersionsData['version_date']).split()[0])), "%Y-%m-%d") except Exception: # catch *all* exceptions traceback.print_exc() raise Exception( "Failed while parsing version_date. Expected format is %Y-%m-%d %H:%M:%S.%f . Example 2016-07-15 13:01:09.758000") if VersionsData.get("version_number") is not None: HelperServices.validate_name(VersionsData.get("version_number"),"version number") versionInsert['version_number'] = VersionsData['version_number'] if VersionsData.get("backward_compatible") is not None: versionInsert['backward_compatible'] = VersionsData['backward_compatible'] if VersionsData.get("mps_certified") is not None: versionInsert['mps_certified'] = VersionsData['mps_certified'] if VersionsData.get("release_notes") is not None: versionInsert['release_notes'] = VersionsData['release_notes'] if VersionsData.get("gitlab_branch") is not None: versionInsert['gitlab_branch'] = VersionsData['gitlab_branch'] if VersionsData.get("branch_tag") is not None: versionInsert['branch_tag'] = VersionsData['branch_tag'] if VersionsData.get("dependent_tools") is not None: versionInsert['dependent_tools'] = VersionsData['dependent_tools'] else: versionInsert['dependent_tools'] = [] if VersionsData.get("deployer_to_use") is not None: versionInsert['deployer_to_use'] = VersionsData['deployer_to_use'] if VersionsData.get("repository_to_use") is not None: if RepositoryHelperService.check_if_repo_exists_by_name(VersionsData.get("repository_to_use")): versionInsert['repository_to_use'] = VersionsData['repository_to_use'] else: raise Exception(VersionsData.get("repository_to_use") + ": No such repository exists") if allDetails: # WE DONT WANT TO UPDATE THESE FIELS WHILE USING SYNC ONLY WHEN EDIT TOOLS if VersionsData.get("jenkins_job") is not None: versionInsert['jenkins_job'] = VersionsData['jenkins_job'] if VersionsData.get("gitlab_repo") is not None: versionInsert['gitlab_repo'] = VersionsData['gitlab_repo'] if VersionsData.get("git_url") is not None: versionInsert['git_url'] = VersionsData['git_url'] if version_id: versionInsert["_id"] = {} versionInsert["_id"]["oid"] = version_id versionInsert["status"] = VersionsData["status"] result = versionsDB.update_version(versionInsert) else: versionInsert["status"] = "1" result = versionsDB.add_version(versionInsert) if result is None: raise Exception("Unable to add new version") return str(result)
def post(self): user = request.get_json() HelperServices.validate_name(user.get("user"), "username") user_id = authService.get_userid_by_auth_token() if user_id is None: raise Exception("Token verification failed") loggedInUser = userdb.get_user_by_id(user_id, False) loggedInUserRole = roledb.get_role_by_id(loggedInUser["roleid"], True) if loggedInUserRole["name"].lower() == "superadmin": pass else: newUserRole = roledb.get_role_by_id(user.get("roleid"), False) if newUserRole["name"].lower() == "superadmin": raise ValueError( "Only SuperAdmin can create a SuperAdmin user") else: pass if (user.get("employeeid") and user.get("user") and user.get("email") and user.get("accountid")) is None: raise Exception( "Mandatory fields to create a new user was not found.") if userdb.get_user(user.get("user"), False) is not None: raise Exception("User already exists") if accountDB.get_account(user.get("accountid")) is None: raise Exception("Account does not exists") addData = {"user": user.get("user").lower(), "status": "active"} if user.get("roleid") is None: addData["roleid"] = str( roledb.get_role_by_name('Guest', False)["_id"]) else: if roledb.get_role_by_id(user.get("roleid"), False) is None: raise Exception("Role does not exists") user.update(addData) passw = genrate_random_key() user["password"] = passw result = userdb.add_user(user) if user.get("included_in"): for team_id in user["included_in"]: teamDB.add_user_to_team(team_id, str(result)) try: systemdetails = systemDetailsDB.get_system_details_single() mailer.send_html_notification( user.get("email"), None, None, 14, { "name": user.get("user"), "password": passw, "machine_host": systemdetails.get("hostname") }) teamService.generate_details() except Exception as e: traceback.print_exc() return { "result": "success", "message": "A new user was created..Token was generated", "data": { "Token": authService.generate_auth_token(str(result)) } }, 200
def add_update_tool(tooldata, tool_id, logo_path, directory_to_import_from, full_logo_path): """Add Update a Tool""" # CHECK TOOL NAME # if tooldata.get("status"): # if (tool_id): # if(tooldata.get("status")=="3"): # validate_tool(tool_id) # if not tooldata.get("name"): raise ValueError("Invalid Tool Name") HelperServices.validate_name(tooldata.get("name"),"tool name") Tool = {} Tool["name"] = tooldata["name"] # CHECK TAG if not tooldata.get("tag"): Tool["tag"] = [] else: Tool["tag"] = tagDB.get_tag_ids_from_given_ids_list(tooldata["tag"]) if tooldata.get("support_details"): Tool["support_details"] = tooldata["support_details"] if tooldata.get("logo"): Tool["logo"] = tooldata["logo"] if tooldata.get("description"): Tool["description"] = tooldata["description"] if tooldata.get("tool_creation_source"): Tool["tool_creation_source"] = tooldata.get("tool_creation_source") if tooldata.get("allow_build_download"): Tool["allow_build_download"] = str( tooldata.get("allow_build_download")) else: Tool["allow_build_download"] = 'False' if tooldata.get("is_tool_cloneable"): Tool["is_tool_cloneable"] = str( tooldata.get("is_tool_cloneable")) if tooldata.get("artifacts_only"): Tool["artifacts_only"] = str( tooldata.get("artifacts_only")) Tool["status"]=tooldata.get("status","1") Tool = HelperServices.add_update_logo(Tool, logo_path, full_logo_path, directory_to_import_from) # ADD UPDATE DATA if tool_id: Tool["_id"] = {} Tool["_id"]["oid"] = tool_id result = toolDB.update_tool(Tool) else: result = toolDB.add_tool(Tool) if result is None: raise Exception("Unable to create/update tool " + Tool["name"]) else: # RELOAD TEAM PERMISSIONS teamService.generate_details() return str(result)
def put(self): preRequisites = request.get_json() HelperServices.validate_name(preRequisites.get("prerequisites_name"),"prerequisite name") soft = preRequisitesDB.get_pre_requisites( preRequisites.get("prerequisites_name")) if soft and soft.get("prerequisites_name"): preRequisites["_id"] = soft["_id"] preRequisitesDB.update_pre_requisites(preRequisites) return {"result": "success", "message": "preRequisites updated successfully"}, 200 else: raise Exception("Invalid input data")
def post(self): preRequisites = request.get_json() if (preRequisites.get("prerequisites_name"))is None: raise Exception("Mandatory fields prerequisites_name to create a new prerequisite was not found.") HelperServices.validate_name(preRequisites.get("prerequisites_name"),"prerequisite name") if preRequisitesDB.get_pre_requisites(preRequisites.get("prerequisites_name")) is not None: raise Exception("Prerequisite with name " + preRequisites.get("prerequisites_name") + " already exists") if preRequisites["version_command"] == "": preRequisites["version_command"] = "--version" new_ver_id = preRequisitesDB.add_pre_requisites(preRequisites) return {"result": "success", "message": "New preRequisites added successfully", "data": {"id": new_ver_id}}, 200
def put(self): teamDetails = request.get_json() if teamDetails.get("team_name"): HelperServices.validate_name(teamDetails.get("team_name"), "team name") updated_team = teamDB.update_team(teamDetails) teamService.generate_details() return { "result": "success", "message": "Team Group updated successfully" }, 200
def add_update_du_set(deploymentUnitSetData, deployment_unit_set_id=None, logo_path=None, logo_full_path=None,directory_to_import_from=None): """Add update DeploymentUnitSet data""" # Mandatory Keys keys_to_validate=["name","du_set"] for key in keys_to_validate: if not deploymentUnitSetData.get(key): raise Exception ("mandatory key: "+ key+" is missing in DU details") if (deploymentUnitSetData.get("name")): HelperServices.validate_name(deploymentUnitSetData.get("name"),"deploymentunit package name") verify_du_set_data(deploymentUnitSetData) verify_du_and_du_set_data(deploymentUnitSetData) #ADD LOGO deploymentUnitSetData = HelperServices.add_update_logo( deploymentUnitSetData, logo_path, logo_full_path, directory_to_import_from) #TRIM NOT REQUIRED DATA deploymentUnitSetData = trim_du_duset_data(deploymentUnitSetData) #VALIDATION if deployment_unit_set_id: existing_du_set_details = deploymentunitsetdb.GetDeploymentUnitSetById( deployment_unit_set_id, False) if not existing_du_set_details: raise Exception("No such DeploymentUnit Set was found with _id: ") else: #TRY TO SEARCH WITH NAME existing_du_set=deploymentunitsetdb.GetDeploymentUnitSetByName(deploymentUnitSetData.get("name"),False) if existing_du_set: deployment_unit_set_id=str(existing_du_set["_id"]) if deployment_unit_set_id: deploymentUnitSetData["_id"] = {} deploymentUnitSetData["_id"]["oid"] = deployment_unit_set_id result = deploymentunitsetdb.UpdateDeploymentUnitSet( deploymentUnitSetData) else: add_missing_attributes_for_duset(deploymentUnitSetData) result = deploymentunitsetdb.AddNewDeploymentUnitSet( deploymentUnitSetData) if result is None: raise Exception("Unable to create/update DeploymentUnit Set") else: # RELOAD TEAM PERMISSIONS teamService.generate_details() return str(result)
def put(self): user_data = request.get_json() if user_data.get("user"): HelperServices.validate_name(user_data.get("user"), "username") if user_data.get("_id"): user_id = user_data["_id"]["oid"] if user_data.get("roleid") is not None: if roledb.get_role_by_id(user_data.get("roleid"), False) is None: raise Exception("Role does not exists") # other way is to get account id from GUI if user_data.get("accountid") is not None: if accountDB.get_account(user_data.get("accountid")) is None: raise Exception("Account does not exists") auth_user_id = authService.get_userid_by_auth_token() if auth_user_id is None: raise Exception("Token verification failed") loggedInUser = userdb.get_user_by_id(auth_user_id, False) loggedInUserRole = roledb.get_role_by_id(loggedInUser["roleid"], True) if loggedInUserRole["name"].lower() == "superadmin": pass else: newUserRole = roledb.get_role_by_id(user_data.get("roleid"), False) if newUserRole["name"].lower() == "superadmin": raise ValueError( "Only SuperAdmin can update role to SuperAdmin") else: pass for group in teamDB.get_team_by_user(user_id): teamDB.remove_user_from_team(str(group["_id"]), user_id) if user_data.get("included_in"): for group_id in user_data.get("included_in"): teamDB.add_user_to_team(group_id, user_id) updated = userdb.update_user(user_data) if updated == 1: teamService.generate_details() return { "result": "success", "message": "User was updated", "data": updated }, 200 else: raise Exception("User was not updated.")
def put(self): tag = request.get_json() if (tag.get("name")) is None: raise Exception( "Mandatory fields name to create a new Tag was not found.") if tagDB.get_tag_by_name(tag.get("name")) is not None: raise Exception("Tag with name " + tag.get("name") + " already exists") HelperServices.validate_name(tag.get("name"), "tag name") is_updated = tagDB.update_tag(tag) if is_updated == 1: # RELOAD TEAM PERMISSIONS teamService.generate_details() return { "result": "success", "message": "The Tag is updated successfully" }, 200 else: raise Exception("Tag was not updated")
def post(self): newTag = request.get_json() if (newTag.get("name")) is None: raise Exception( "Mandatory fields name to create a new Tag was not found.") if tagDB.get_tag_by_name(newTag.get("name")) is not None: raise Exception("Tag with name " + newTag.get("name") + " already exists") HelperServices.validate_name(newTag.get("name"), "tag name") tag_id = tagDB.add_tag(newTag) # RELOAD TEAM PERMISSIONS teamService.generate_details() return { "result": "success", "message": "The Tag is saved successfully", "data": { "id": tag_id } }, 200
def create_request(pt_details): all_default_repos = list( RepositoryDB.get_all({"is_default_repo_ind": "true"})) if not all_default_repos: raise Exception("Default Repository could not be found") final_data = { "name": pt_details.get("name"), "tag": [], "support_details": pt_details.get("support_details"), "request_reason": pt_details.get("request_reason"), "description": pt_details.get("description"), "version": { "version_name": pt_details.get("version").get("version_name"), "version_date": str(datetime.now()), "version_number": pt_details.get("version").get("version_number"), "pre_requiests": [], "branch_tag": "Branch", "gitlab_repo": "", "gitlab_branch": "master", "jenkins_job": "", # "document": {"documents": []}, "backward_compatible": "no", "release_notes": "", "mps_certified": [], # "deployment_field": {"fields": []}, "deployer_to_use": "DefaultDeploymentPlugin", "dependent_tools": [], "repository_to_use": all_default_repos[0].get("name") }, "artifacts_only": "false", "is_tool_cloneable": "true", "allow_build_download": "false" } HelperServices.validate_name(final_data.get("name"), "tool name") final_data = HelperServices.add_update_logo(final_data, logo_path, logo_full_path, None) validate_mandatory_details(final_data) validate_existing_tool(final_data) validate_pk_tool(final_data) validate_mandatory_details(final_data) return final_data
def validate_machine_details(machine_details): keys_to_validate=["username","account_id","ip","host","password",\ "machine_type","auth_type"] for key in keys_to_validate: if not machine_details.get(key): raise Exception("mandatory key: " + key + " is missing in machine details") machine_details["machine_type"] = validate_machine_type( machine_details.get("machine_type")) machine_details["account_id"] = AccountHelperService.validate_account_id( machine_details.get("account_id")) if not machine_details.get("machine_name"): machine_details["machine_name"] = str( machine_details.get("username")) + '@' + str( machine_details.get('host')) HelperServices.validate_name(machine_details.get("machine_name"), "machine name") if machine_details.get("tag"): machine_details["tag"] = tagDB.get_tag_ids_from_given_ids_list( machine_details.get("tag")) if machine_details.get('permitted_users'): for record in machine_details["permitted_users"]: if str(record).lower() <> "all": if userdb.get_user_by_id(record, False) is None: raise Exception(" user id: " + str(record) + " don't exist") if machine_details.get('permitted_teams'): for team in machine_details["permitted_teams"]: if teamsDb.get_team(team) is None: raise Exception("team id: " + str(team) + "don't exist") if machine_details.get('included_in'): for include in machine_details["included_in"]: if machinegroupDB.get_machine_groups(include) is None: raise Exception("machine group: " + str(include) + "don't exist") if machine_details.get("flexible_attributes"): FlexibleAttributesHelper.validate_entity_value( "Machine", machine_details.get("flexible_attributes")) if machine_details.get("environment_variables"): EnvironmentVariablesHelper.validate_env_vars( machine_details.get("environment_variables"))
def post(self): teamDetails = request.get_json() if (teamDetails.get("team_name") and teamDetails.get("users_id_list") and teamDetails.get("distribution_list")) is None: raise Exception( "Mandatory fields to create a new team was not found.") if teamDB.get_team_by_name(teamDetails.get("team_name")): raise Exception("Team with name " + teamDetails.get("team_name") + " already exists") HelperServices.validate_name(teamDetails.get("team_name"), "team name") if not teamDetails.get("users_id_list"): teamDetails["users_id_list"] = [] if not teamDetails.get("tag_id_list"): teamDetails["tag_id_list"] = [] if not teamDetails.get("machine_id_list"): teamDetails["machine_id_list"] = [] if not teamDetails.get("machine_group_id_list"): teamDetails["machine_group_id_list"] = [] if not teamDetails.get("parent_entity_id_tool_list"): teamDetails["parent_entity_id_tool_list"] = [] if not teamDetails.get("parent_entity_id_du_list"): teamDetails["parent_entity_id_du_list"] = [] if not teamDetails.get("parent_entity_tool_set_id_list"): teamDetails["parent_entity_tool_set_id_list"] = [] if not teamDetails.get("parent_entity_du_set_id_list"): teamDetails["parent_entity_du_set_id_list"] = [] if not teamDetails.get("parent_entity_tag_list"): teamDetails["parent_entity_tag_list"] = [] if not teamDetails.get("parent_entity_set_tag_list"): teamDetails["parent_entity_set_tag_list"] = [] new_team_id = teamDB.add_team(teamDetails) teamService.generate_details() return { "result": "success", "message": "The team is created successfully", "data": { "id": new_team_id } }, 200
def add_update_state(state_data, state_Id): """Add update DeploymentUnit data""" if state_data.get("approval_status"): approval_status = deploymentUnitApprovalStatusdb.GetDeploymentUnitApprovalStatusByName( state_data.get("approval_status")) if approval_status: state_data["approval_status"] = str(approval_status.get("_id")) else: raise Exception("The approval status provided is not correct") if not state_Id: # MANDATORY ATTRIBUTES for rec in ["parent_entity_id", "approval_status"]: if not state_data.get(rec): raise Exception(rec + " is not provided") state_data = trim_state_data(state_data) existing_du = deploymentunitdb.GetDeploymentUnitById( state_data.get("parent_entity_id")) existing_du_set = deploymentunitsetdb.GetDeploymentUnitSetById( state_data.get("parent_entity_id")) if existing_du: state_data["type"] = "dustate" if not state_data.get("name"): state_data["name"] = existing_du.get("name") + " State-" + str( counterDB.get_counter()) # MANDATORY ATTRIBUTES for rec in ["build_id"]: if not state_data.get(rec): raise Exception(rec + " is not provided") elif existing_du_set: state_data["type"] = "dusetstate" if not state_data.get("name"): state_data["name"] = existing_du_set.get( "name") + " Package State-" + str(counterDB.get_counter()) # MANDATORY ATTRIBUTES for rec in ["states"]: if not state_data.get(rec): raise Exception(rec + " is not provided") else: raise Exception( "parent_entity_id provided is neither du or duPackage") HelperServices.validate_name(state_data.get("name"), "state name") existing_state = statedb.get_state_by_parent_entity_id_name( state_data.get("name"), state_data.get("parent_entity_id"), False) if existing_state: if (state_data.get("type") == "dustate"): raise Exception("Duplicate state error, state '" + existing_state.get("name") + "' already present with same name for this Du") else: raise Exception( "Duplicate state error, state '" + existing_state.get("name") + "' already present with same name for this DuSet") result = statedb.add_state(state_data) # ADD UPDATE DATA if state_Id: if state_data.get("name") is not None: prev_data = statedb.get_state_by_id(state_Id, False) duplicate = statedb.get_state_by_parent_entity_id_name( state_data.get("name"), prev_data.get("parent_entity_id"), False) if not (duplicate is None or str(duplicate.get("_id")) == str(state_Id)): raise Exception( "Duplicate state error, state already present with same name" ) state_data["_id"] = {"oid": state_Id} state_data = trim_state_data(state_data) result = statedb.update_state(state_data) if result is None: raise Exception("Unable to create/update state") return result
def add_update_du(deploymentUnitData, deploymentUnitId=None, logo_path=None, directory_to_import_from=None, full_logo_path=None,handle_dependencies=True): """Add update DeploymentUnit data""" # Mandatory Keys keys_to_validate=["name"] for key in keys_to_validate: if not deploymentUnitData.get(key): raise Exception ("mandatory key: "+ key+" is missing in DU details") buildData = None deploymentFeildData = None result = None transaction_type = None if not deploymentUnitId: transaction_type = "new" # preparing deploymentUnit data if deploymentUnitData.get("build") is not None: buildData = deploymentUnitData.get("build") if deploymentUnitData.get("deployment_field") is not None: deploymentFeildData = deploymentUnitData.get("deployment_field")[ "fields"] #VALIDATION if deploymentUnitId: if not deploymentunitdb.GetDeploymentUnitById(deploymentUnitId): raise ValueError("No DU with this _id is found in database") else: #TRY TO SEARCH WITH NAME existing_du=deploymentunitdb.GetDeploymentUnitByName(deploymentUnitData.get("name")) if existing_du: deploymentUnitId=str(existing_du["_id"]) #VALIDATIONS FOR NEW DU if not deploymentUnitId: keys_to_validate=["type"] for key in keys_to_validate: if not deploymentUnitData.get(key): raise Exception ("mandatory key: "+ key+" is missing in du details") add_missing_attributes_for_du(deploymentUnitData) if deploymentUnitData.get("name"): HelperServices.validate_name(deploymentUnitData.get("name"),"deploymentunit name") if deploymentUnitData.get("flexible_attributes"): FlexibleAttributesHelper.validate_entity_value("DeploymentUnit", deploymentUnitData.get("flexible_attributes")) deploymentUnitData = verify_du_and_du_set_data(deploymentUnitData) deploymentUnitData = HelperServices.add_update_logo( deploymentUnitData, logo_path, full_logo_path, directory_to_import_from) #TRIM NOT REQUIRED DATA deploymentUnitData = trim_du_duset_data(deploymentUnitData) if deploymentUnitData.get("repository_to_use"): if not RepositoryHelperService.check_if_repo_exists_by_name(deploymentUnitData.get("repository_to_use")): raise Exception(deploymentUnitData.get("repository_to_use") + ": No such repository exists") # ADD UPDATE DATA if deploymentUnitId: deploymentUnitData["_id"] = {"oid": deploymentUnitId} result = deploymentunitdb.UpdateDeploymentUnit(deploymentUnitData) else: deploymentUnitData["status"] = "1" result = deploymentunitdb.AddDeploymentUnit(deploymentUnitData) deploymentUnitId = result if result is None: raise Exception( "Unable to create/update deploymentUnit " + deploymentUnitData["name"]) else: # RELOAD TEAM PERMISSIONS teamService.generate_details() if handle_dependencies: dep_fields_result = None try: if buildData is not None: for build in buildData: build["parent_entity_type"] = "du" BuildHelperService.add_update_build(build, deploymentUnitId, None) # preparing deployment_field data # if duDatabackup.get("deployment_field") is not None: if deploymentFeildData is not None: dep_fields_result = HelperServices.add_update_deployment_fields( deploymentFeildData, deploymentUnitId) #SET DU AS UPDATED if either of dep fields or build is updated if transaction_type <> "new" and str(result) == "0" \ and str(dep_fields_result) == "1": result = "1" except Exception as e: if transaction_type == "new": deploymentunitdb.DeleteDeploymentUnit(deploymentUnitId) buildsDB.delete_build_by_parent_entitity_id(deploymentUnitId) deploymentFieldsDB.delete_dep_field_by_parent_entity_id(deploymentUnitId) return e return str(result)