Esempio n. 1
0
 def __init__(self, db):
     """Initializing Variable """
     self.configdb = Config.Config(db)
     self.distributionMachinetDB = DistributionMachine.DistributionMachine(
         db)
     self.syncService = SyncServices.SyncServices()
     self.machineDB = Machine.Machine(db)
     self.mailer = Mailer.Mailer()
     self.current_path = distribution_center_export_full_path
     self.systemDetailsDb = SystemDetails.SystemDetails(db)
     if not os.path.exists(self.current_path):
         os.makedirs(self.current_path)
     if not os.access(os.path.dirname(self.current_path), os.W_OK):
         raise ValueError("The directory does not have write access :" +
                          self.current_path)
     systemDetail = self.systemDetailsDb.get_system_details_single()
     if not systemDetail:
         raise Exception("systemDeatils not found")
     if not systemDetail.get("hostname"):
         raise Exception("hostname not found in systemDeatils")
     self.remote_trigger_api_path = "/clonerequest/distribution/pull/" + \
         systemDetail.get("hostname")
     self.config_id = 12
     self.load_configuration()
     self.schedulerService = SchedulerService.SchedulerService()
     self.remote_authentication_service = RemoteAuthenticationService.RemoteAuthenticationService(
     )
Esempio n. 2
0
 def __init__(self):
     self.db = mongodb
     self.current_import_path = import_full_path
     if not os.path.exists(self.current_import_path):
         os.makedirs(self.current_import_path)
     if not os.access(self.current_import_path, os.W_OK):
         raise ValueError(
             "The directory does not have write access :" + self.current_import_path)
     self.configdb = Config.Config(self.db)
     self.syncdb = Sync.Sync(self.db)
     self.syncRequestdb = SyncRequest.SyncRequest(self.db)
     self.mailer = Mailer.Mailer()
     self.syncService = SyncServices.SyncServices()
     self.systemDetailsDb = SystemDetails.SystemDetails(self.db)
     self.systemDetail = self.systemDetailsDb.get_system_details_single()
     self.remoteAuthenticationService = RemoteAuthenticationService.RemoteAuthenticationService()
     if not self.systemDetail:
         raise Exception("systemDeatils not found")
     if not self.systemDetail.get("hostname"):
         raise Exception("hostname not found in systemDeatils")
     self.host_name = self.systemDetail.get("hostname")
     self.post_url = "/sync/pull/export"
     self.config_id = 10
     self.count_of_files = 2  # Minimum Threads is 2
     self.load_configuration()
     self.schedulerService = SchedulerService.SchedulerService()
Esempio n. 3
0
def addDistributionCenterDistributionRequest():
    SystemDetails = request.get_json()
    if not SystemDetails:
        raise ValueError("No data in input")
    found = systemDetailsDB.get_system_details_single()
    if found is None:
        updated = systemDetailsDB.add_system_details(SystemDetails)
    else:
        SystemDetails["_id"] = {"oid": str(found["_id"])}
        for key in found.keys():
            if key not in ["_id"] and key not in SystemDetails.keys():
                SystemDetails[key] = found[key]
        updated = systemDetailsDB.update_system_details(SystemDetails)
    return jsonify(json.loads(dumps({"result": "success", "message": "System Details updated", "data": str(updated)}))), 200
Esempio n. 4
0
 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()
Esempio n. 5
0
    def __init__(self, db):
        '''
           General description :
           This function initializes the database variables and \
           index to refer in functions.
        '''

        self.configdb = Config.Config(db)
        self.toolDb = Tool.Tool(db)
        self.versionsDb = Versions.Versions(db)
        self.contributionGitPushLogsDb = \
            ContributionGitPushLogs.ContributionGitPushLogs(db)
        self.mailer = Mailer.Mailer()
        self.systemDetailsDb = SystemDetails.SystemDetails(db)
        self.config_id = 14
        self.load_configuration()
        self.schedulerService = SchedulerService.SchedulerService()
Esempio n. 6
0
    def __init__(self, db, key):
        self.RSAKEY = RSA.generate(1024)
        self.SECRET_KEY = self.RSAKEY.exportKey('PEM')
        self.SECRET_PUBLIC_KEY = self.RSAKEY.publickey().exportKey('PEM')
        self.ENCRYPTION_METHOD = 'RS512'
        # WE WILL VERIFY EXPIRATION BY OURSELVES
        self.JWT_OPTIONS = {'verify_exp': False, }
        self.userdb = Users.Users(db)
        self.auditdb = Auditing.Auditing()
        self.roledb = Role.Role(db)
        self.passHelper = PasswordHelper.PasswordHelper(key)
        self.permissiondb = Permissions.Permissions(db)
        self.permissiongroupdb = PermissionGroup.PermissionGroup(db)
        self.accountDB = Accounts.Accounts()
        self.configdb = Config.Config(db)
        self.systemDetailsDB = SystemDetails.SystemDetails(db)
        self.configdbData = self.configdb.getConfigByName("AuthService")  # 6 is for AuthRequestService configuration
        self.auditing_config = self.configdb.getConfigByName("AuditingServices")  # 6 is for AuthRequestService configuration
        self.mailer = Mailer.Mailer()
        self.validTokens = {}
        self.teamService = TeamService.TeamService()
        self.collection = db.SystemDetails  # Set Collection as Permissions
        self.teamsdb = Teams.Teams(db)
        if self.configdbData is not None:
            if self.configdbData.get("expiration") is not None:
                self.expiration = int(self.configdbData.get("expiration"))
            else:
                raise Exception(
                    "Config AuthService does not have expiration set")
            if self.configdbData.get("email_domain") is not None:
                self.email_domain = str(self.configdbData.get("email_domain"))
            else:
                raise Exception(
                    "Config AuthService does not have email_domain set")
            self.allow_multi_user_session = self.configdbData.get("allow_multi_user_session","false")        
        else:
            raise Exception("Config was not found for Authorization services")

        # ADD DEAMON THREAD TO REMOVE IN VALID TOKENS AUTOMATICALLY
        pool = ThreadPoolExecutor(2,__name__+".__init__")
        pool.submit(self.removeInvalidTokens)
        pool.submit(self.check_if_user_logged_in_from_last_6_months)
Esempio n. 7
0
    def __init__(self, db=None):
        # init db conneciton
        if db is None:
            self.db = mongodb

        """# Init's Data"""
        self.app = Flask(__name__)
        self.mail = Mail(self.app)

        self.app.config.from_object(__name__)
        self.app.config.from_envvar('MINITWIT_SETTINGS', silent=True)
        ###############
        # Collection
        ##############
        self.templatedb = EmailTemplate.EmailTemplate(self.db)
        self.emaildb = Emails.Emails(self.db)
        self.configdb = Config.Config(self.db)
        self.SystemDetailsDb = SystemDetails.SystemDetails(self.db)
        # Initialize Email Configuration
        self.result = self.configdb.getConfigByName("Mailer")  # 1 is for mailer configuration
        if self.result is None:
            raise Exception("Config not found for Mailer")
        self.app.config.update(
            DEBUG=self.str_to_bool(str(self.result['debug']).strip()),
            MAIL_HOST=str(self.result['host']).strip(),
            MAIL_SERVER=str(self.result['server']).strip(),
            MAIL_PORT=int(str(self.result['port']).strip()),
            MAIL_USE_TLS=self.str_to_bool(str(self.result['tls']).strip()),
            MAIL_USE_SSL=self.str_to_bool(str(self.result['ssl']).strip()),
            MAIL_USERNAME=str(self.result['username']).strip(),
            MAIL_PASSWORD=str(self.result['password']).strip(),
            DEFAULT_MAIL_SENDER=str(self.result['defaultsender']).strip()
        )
        # Setup socket Info
        socket.getaddrinfo(str(self.result['socketip']).strip(), str(
            self.result['socketport']).strip())
        # Env Variable
        self.mailfrom = str(self.result['defaultsender']).strip()
Esempio n. 8
0
from datetime import datetime
import os, json, shutil, subprocess, traceback
from DBUtil import ProposedTools, Tool, Config, SystemDetails, Versions, Repository
from settings import mongodb, proposed_tool_git_full_path,\
    proposed_tool_jenkins_full_path,logo_path, logo_full_path, current_path
from Services import Mailer, HelperServices
from modules import ToolAPI

#DB
proposedToolsDB = ProposedTools.ProposedTools()
toolDB = Tool.Tool(mongodb)
configdb = Config.Config(mongodb)
sysdetailsDB = SystemDetails.SystemDetails(mongodb)
system_details = sysdetailsDB.get_system_details_single()
tooldb = Tool.Tool(mongodb)
versionsDB = Versions.Versions(mongodb)
RepositoryDB = Repository.Repository()
#SERVICES
mailer = Mailer.Mailer()


def email_tool_proposed(pt_details):
    mailer.send_html_notification(
        pt_details.get("support_details"), None, None, 17, {
            "name": pt_details.get("name"),
            "machine_host": system_details.get("hostname")
        })


def email_approval_req(pt_details):
    proposed_tool_support_email = configdb.getConfigByName(
Esempio n. 9
0
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", 
    "parent_entity_id" : "5abbbf5ff13a94007945f01a",   
    "additional_artifacts" : {
Esempio n. 10
0
Created on Mar 29, 2018

@author: PDINDA
'''

import copy, traceback, json, os, shutil, requests
from DBUtil import SyncRequest, SystemDetails, Config
from settings import mongodb, dpm_url_prefix
from Services import Mailer
from requests.exceptions import ConnectionError
from Services.fabfile import runCommand

# collection
syncRequestdb = SyncRequest.SyncRequest(mongodb)
mailer = Mailer.Mailer()
systemDetailsDb = SystemDetails.SystemDetails(mongodb)
systemDetail = systemDetailsDb.get_system_details_single()
if not systemDetail: raise Exception("systemDeatils not found")
if not systemDetail.get("hostname"):
    raise Exception("hostname not found in systemDeatils")
remote_trigger_api_path = "/sync/push/trigger/" + systemDetail.get("hostname")
# collection
configdb = Config.Config(mongodb)
pushConfig = configdb.getConfigByName("PushServices")
syncRequestdb = SyncRequest.SyncRequest(mongodb)
if pushConfig.get("remote_machine_import_path") is None:
    raise Exception(
        "remote_machine_import_path not found in config of PushServices")
remote_import_path = pushConfig["remote_machine_import_path"]
count_of_files = int(pushConfig["count_of_files"])
allow_split = str(pushConfig.get("allow_split")).lower()