def retryGroupDeploymentRequest(): data = request.json validate(data, 'Retry', relative_path + '/swgger/DeploymentGroupRequestAPI/retryGroupDeploymentRequest.yml') DeploymentRequest = request.get_json() dep_id = DeploymentRequest.get("_id") if dep_id is None: raise Exception("_id is missing") oid = dep_id.get("oid") if oid is None: raise Exception("oid is missing") data = deploymentRequestGroupDB.get_group_deployment_request(str(oid), False,False) details = data.get("details") if data is None: raise Exception("Request was not found") if data.get('status').lower() != 'failed': raise Exception("Only failed request can be retried") retryCount = data.get("retry_count") if retryCount is None: retryCount = "1" else: retryCount = str(int(retryCount) + 1) data = {} data["_id"] = DeploymentRequest["_id"] data["retry_count"] = retryCount data["status"] = "Retry" # GETS UPDATED WITH METHOD # update_DeploymentGroups updated = deploymentRequestGroupDB.upd_group_depreq(data) # UPDATE INDIVIDUAL REQUESTS for rec in details: if str(rec.get("status")).lower() in ["Failed".lower()]: updated = deploymentRequestService.retryDeploymentRequest( str(rec["deployment_id"])) return jsonify(json.loads(dumps({"result": "success", "message": "The request was updated successfully", "data": updated}))), 200
def __init__(self, db): ''' General description : This function initializes the database variables and \ index to refer in functions. ''' self.db = db self.configdb = Config.Config(db) self.toolDB = Tool.Tool(self.db) self.userDB = Users.Users(self.db) self.roleDB = Role.Role(self.db) self.buildsDB = Build.Build() self.versionsDB = Versions.Versions(db) self.emailsDB = Emails.Emails(self.db) self.deploymentRequestDB = DeploymentRequest.DeploymentRequest(db) self.CloneRequestDB = CloneRequest.CloneRequest(db) self.contributionGitPushLogs = ContributionGitPushLogs.ContributionGitPushLogs( db) self.sync = Sync.Sync(db) self.auditingDB = Auditing.Auditing() self.distributionSync = DistributionSync.DistributionSync(db) self.mediaFilesDB = MediaFiles.MediaFiles(self.db) self.logo_path = logo_path self.full_logo_path = str(current_path) + self.logo_path self.media_files_path = media_path self.full_media_files_path = media_full_path self.folder_list_to_clean = [ export_full_path, distribution_center_export_full_path ] self.config_id = 15 self.load_configuration() self.schedulerService = SchedulerService.SchedulerService() self.deploymentUnitDB = DeploymentUnit.DeploymentUnit() self.repositoryDB = Repository.Repository()
def put(self): data = request.json DeploymentRequest = request.get_json() dep_id = DeploymentRequest.get("_id") if dep_id is None: raise Exception("_id is missing") oid = dep_id.get("oid") if oid is None: raise Exception("oid is missing") updated = deploymentRequestService.retryDeploymentRequest(oid) if updated == 1: return { "result": "success", "message": "The request was updated successfully", "data": updated }, 200 else: raise Exception("The request is not in failed status")
''' Created on Mar 8, 2018 @author: pdinda ''' from DBUtil import DeploymentRequest, ToolsOnMachine, Build, State, DeploymentUnitSet from settings import mongodb statedb = State.State(mongodb) deploymentUnitSetdb = DeploymentUnitSet.DeploymentUnitSet() deploymentRequestDb = DeploymentRequest.DeploymentRequest(mongodb) toolsonmachinedb = ToolsOnMachine.ToolsOnMachine(mongodb) buildDB = Build.Build() def check_if_revert_undeploy_allwed_for_group(deployment_request_group_data): """This def is responsible to decide if a Group Deployment is valid to Revert or un deploy""" deployment_request_group_data["allow_revert"] = False deployment_request_group_data["allow_undeploy"] = False deployment_request_group_data["allow_retry"] = False try: #DECIDE IF RETRY IS ALLOWED # IF one of the deployments of this request is failed it should be allowed to retry if str(deployment_request_group_data.get( "status")).lower() == "failed": deployment_request_group_data["allow_retry"] = True elif str( deployment_request_group_data.get("status")).lower() == "done": # I REQUEST CAN BE ALLOWED TO UNDEPLOYED ONLY IF IT WAS DEPLOYED OR REDEPLOYED if deployment_request_group_data.get( "request_type").lower() not in ["undeploy"]:
''' Created on Jan 5, 2018 @author: vijasing ''' from DBUtil import Teams,Machine,DeploymentRequest,DeploymentUnitSet,DeploymentUnit,MachineGroups,\ DistributionMachine,DeploymentRequestGroup,CloneRequest,ToolsOnMachine,UserFavoriteMachine,MachineType,\ Accounts,Tags,Users, Tool, Versions, Build from settings import mongodb from Services import HelperServices, TeamService, FlexibleAttributesHelper, EnvironmentVariablesHelper, Utils, AccountHelperService teamsdb = Teams.Teams(mongodb) machinedb = Machine.Machine(mongodb) deploymentrequestdb = DeploymentRequest.DeploymentRequest(mongodb) deploymentrequestgroupdb = DeploymentRequestGroup.DeploymentRequestGroup( mongodb) deploymentunitsetdb = DeploymentUnitSet.DeploymentUnitSet() deploymentunitdb = DeploymentUnit.DeploymentUnit() machinegroupdb = MachineGroups.MachineGroups(mongodb) distributionmachinetdb = DistributionMachine.DistributionMachine(mongodb) clonerequestdb = CloneRequest.CloneRequest(mongodb) toolsonmachinedb = ToolsOnMachine.ToolsOnMachine(mongodb) machineFavDb = UserFavoriteMachine.UserFavoriteMachine(mongodb) machineTypeDb = MachineType.MachineType(mongodb) accountDB = Accounts.Accounts() machineDB = Machine.Machine(mongodb) tagDB = Tags.Tags() teamsDb = Teams.Teams(mongodb) teamService = TeamService.TeamService() machinegroupDB = MachineGroups.MachineGroups(mongodb)
from settings import mongodb, import_full_path, relative_path from modules.apimodels import DeploymentRequestModel # from time import time # from collections import OrderedDict # blueprint declaration deploymentrequestAPI = Blueprint('deploymentrequestAPI', __name__) deploymentrequestAPINs = api.namespace( 'deploymentrequest', description='Deployment Request Operations') # get global db connection db = mongodb # collections deploymentRequestDB = DeploymentRequest.DeploymentRequest(db) deploymentRequestGroupDB = DeploymentRequestGroup.DeploymentRequestGroup(db) machineDB = Machine.Machine(db) versionsDB = Versions.Versions(db) machinegroupsDB = MachineGroups.MachineGroups(db) toolSetDB = ToolSet.ToolSet(db) deploymentRequestService = DeploymentRequestService.DeploymentRequestService( db) deploymentUnitDB = DeploymentUnit.DeploymentUnit() toolDB = Tool.Tool(db) statedb = State.State(db) @deploymentrequestAPI.route('/deploymentrequest/deploymentfield/upload', methods=['POST']) @authService.authorized