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 __init__(self): self.db = mongodb self.current_import_path = import_full_path if self.current_import_path in [None, ""]: raise ValueError("Import path was not provided") if not os.path.exists(self.current_import_path): os.makedirs(self.current_import_path) if not os.access(os.path.dirname(self.current_import_path), os.W_OK): raise ValueError("The directory does not have write access :" + self.current_import_path) self.current_export_path = export_full_path if self.current_export_path in [None, ""]: raise ValueError("Export path was not provided") if not os.path.exists(self.current_export_path): os.makedirs(self.current_export_path) if not os.access(os.path.dirname(self.current_export_path), os.W_OK): raise ValueError("The directory does not have write access :" + self.current_export_path) self.configdb = Config.Config(self.db) self.versionsDB = Versions.Versions(self.db) self.toolDB = Tool.Tool(self.db) self.deploymentFieldsDB = DeploymentFields.DeploymentFields(self.db) self.machineDB = Machine.Machine(self.db) self.syncDb = Sync.Sync(self.db) self.mailer = Mailer.Mailer() self.syncRequestDb = SyncRequest.SyncRequest(self.db) self.buildsDB = Build.Build() self.documentsDB = Documents.Documents(self.db) self.toolDB = Tool.Tool(self.db) self.deploymentunitDB = DeploymentUnit.DeploymentUnit() self.deploymentunitsetDB = DeploymentUnitSet.DeploymentUnitSet() self.mediaFilesDB = MediaFiles.MediaFiles(self.db) self.tagsDB = Tags.Tags() self.preRequisitesDB = PreRequisites.PreRequisites(self.db) self.logo_path = logo_path self.full_logo_path = logo_full_path self.media_files_path = media_path self.full_media_files_path = media_full_path self.systemDetailsDb = SystemDetails.SystemDetails(self.db) self.systemDetail = self.systemDetailsDb.get_system_details_single() self.statedb = State.State(self.db) if not self.systemDetail: raise Exception("systemDeatils not found") self.config_id = 9 self.load_configuration() self.schedulerService = SchedulerService.SchedulerService() self.flexAttrDB = FlexibleAttributes.FlexibleAttributes()
from werkzeug import secure_filename from urlparse import urlparse from bson.json_util import dumps from flask import Blueprint, jsonify, request from DBUtil import Build, Users, SystemDetails, State, Config from settings import mongodb, default_nexus_container_name, temp_files_full_path from Services import StateHelperService, BuildHelperService, HelperServices from Services.AppInitServices import authService import os import json # blueprint declaration buildAPI = Blueprint('buildAPI', __name__) # get global db connection db = mongodb buildDB = Build.Build() userDB = Users.Users(db) systemDetailsDB = SystemDetails.SystemDetails(db) stateDb = State.State(mongodb) configDb = Config.Config(mongodb) ''' INPUT REQUEST: { "_id" : ObjectId("5abbc6749e53f700787d3997"), "status" : "1", "file_size" : "4.0K", "type" : "url", "file_path" : "http://illin4490:8081/nexus/content/repositories/yum-test/com/amdocs/core/crm/crm-playbooks/10.2.4-1620/crm-playbooks-10.2.4-1620.tar", "build_number": 22, "package_name" : "crm-playbooks-10.2.4-1620.tar", "package_type" : "tar",
import unittest import requests import time from GetAuthToken import getToken import json from settings import mongodb,unittest_test_url from DBUtil import DeploymentRequestGroup,MachineType,Machine,Versions,Tool,Config,Build,MachineGroups,DeploymentUnitSet import verifyResponse DeploymentUnitSetDb=DeploymentUnitSet.DeploymentUnitSet() MachineGroupsDb=MachineGroups.MachineGroups(mongodb) BuildDb=Build.Build() ToolDb=Tool.Tool(mongodb) ConfigDb = Config.Config(mongodb) MachineDb=Machine.Machine(mongodb) MachineTypeDb=MachineType.MachineType(mongodb) VersionsDb=Versions.Versions(mongodb) DeploymentRequestGroupdb=DeploymentRequestGroup.DeploymentRequestGroup(mongodb) Baseurl = unittest_test_url+"deploymentrequest/group/" header = {'content-type': "application/json", 'token':str(getToken())} class AddDepGroupReqTest(unittest.TestCase): oid=None; def runTest(self): url=Baseurl+"add" print "--------------------------------------------------------------------------------------------------------" print "Calling API :"+url + " For Create Deployment Group Request test" payload={"deployment_requests":[{"parent_entity_id":str(VersionsDb.get_last_active_version_by_tool_id(str(ToolDb.get_tool_by_name("jTrace").get("_id")),False).get("_id")), "requested_by":"SuperAdmin",
''' Created on Dec 18, 2017 @author: pdinda ''' import os,shutil,traceback from datetime import datetime from DBUtil import Build,State,Repository from settings import mongodb from Services import HelperServices,CustomClassLoaderService from Services import ExternalRepoDownloadHelper buildsDB = Build.Build() stateDB=State.State(mongodb) repositoryDB=Repository.Repository() def get_build_for_parent(parent_entity_id, build_id=None,state_id=None,build_number=None): ''' General description: Args: param1 (object_id) : This is the ID of the existing \ Build which we have to set active. parent_entity_id(object) : This is the parameter which has details of Build. Returns: Returns the count of the records set active successfully \ for the given id of the build. Example : get_build_for_parent(parent_entity_id, build_id,state_id,build_number)