コード例 #1
0
ファイル: restore_dbs.py プロジェクト: paull87/ht-pipeline
def restore_db(server, database, database_name, version, copy_file_from=None):
    backup_directory = BACKUP_DIRS[server][database]
    backup_regex = BACKUP_REGEXS[database]
    if copy_file_from:
        copy_backups(
            remote_server=SERVERS[server],
            backup_regex=backup_regex.format(version_number=version),
            source_directory=BACKUP_DIRS[copy_file_from][database],
            target_directory=backup_directory
        )
    backup_file_name = get_latest_backup(
        server=server,
        source_directory=backup_directory,
        file_regex=backup_regex.format(version_number=version),
    )
    full_backup_path = os.path.join(backup_directory, backup_file_name)
    sql_runner = get_sql_runner(server)
    sql_runner.restore_db(database_name, full_backup_path)
    if copy_file_from:
        delete_backups(
            remote_server=SERVERS[server],
            backup_file=full_backup_path,
        )
コード例 #2
0
ファイル: build_config.py プロジェクト: paull87/ht-pipeline
import os
from app.core.sql import get_sql_runner
from app.settings.envs import ADHOC_FILE_PATH

LON_SQL_04_SQL_RUNNER = get_sql_runner('lon-sql-04')
LON_SQL_02_SQL_RUNNER = get_sql_runner('lon-sql-02')
CONFIG_FILE = os.path.join(ADHOC_FILE_PATH, 'comps_build_config')

CONFIG_TEMPLATE = '''<buildConfiguration>
 <ticketNumber />
 <asOfDate>{as_of_date}</asOfDate>
 <basedOnBuildVersionNumber>{based_on_version}</basedOnBuildVersionNumber>
 <compareToBuildVersionNumber>{compared_to_version}</compareToBuildVersionNumber>
 <bulkTestAVMType>hybrid</bulkTestAVMType>
 <releaseDate />
 <basedOnOSVersion>{os_version}</basedOnOSVersion>
 <bulkTestIdSecondaryCapital>{secondary_capital}</bulkTestIdSecondaryCapital>
 <bulkTestIdSecondaryRental>{secondary_rental}</bulkTestIdSecondaryRental>
 <bulkTestIdSecondaryClient>{secondary_client}</bulkTestIdSecondaryClient>
 <bulkTestIdSecondaryCapitalInCycle />
 <bulkTestIdSecondaryRentalClient>{secondary_rental_client}</bulkTestIdSecondaryRentalClient>
 <rebuildCandidate>{rebuild}</rebuildCandidate>
 <updateCandidate>{update}</updateCandidate>
 <generateGeoService>{geo_service}</generateGeoService>
</buildConfiguration>'''

bulk_test_id_sql = '''
SELECT TOP 1 bulkTestId
FROM bulktestmanager.realtime.vw_bulkTestDetails
WHERE
    buildversionnumber = {version}
コード例 #3
0
ファイル: db_versions.py プロジェクト: paull87/ht-pipeline
from app.core.sql import get_sql_runner
from collections import namedtuple

GeoDB = namedtuple('GeoDB', 'current previous')

DB_TYPES = ['pcl', '20cc', 'allgeos']
LON_SQL_06_SQL_RUNNER = get_sql_runner('lon-sql-06')


def get_database_names(db_type):
    query = f'''
        SELECT LOWER([name]) as [name]
        FROM sys.databases
        WHERE LOWER([name]) LIKE 'geographyindex[_]%[_]{db_type}'
        ORDER BY [name];
    '''
    return LON_SQL_06_SQL_RUNNER.read(query)['name'].values


def geo_index_dbs():
    geo_databases = {}
    for db_type in DB_TYPES:
        databases = get_database_names(db_type)
        check_databases(databases, db_type)
        geo_databases[db_type] = database_versions(databases)
    return geo_databases


def get_database_version(database):
    try:
        version_number = database.split('_')[1]
コード例 #4
0
ファイル: build_versions.py プロジェクト: paull87/ht-pipeline
def nhbc_version(server):
    query = 'SELECT MAX(BuildID) as BuildID FROM nhbc.nhbc.tab_build'
    sql_runner = get_sql_runner(server)
    result = sql_runner.read(query)
    return result.loc[0, 'BuildID']
コード例 #5
0
ファイル: build_versions.py プロジェクト: paull87/ht-pipeline
def gdw_version(server):
    query = 'SELECT buildNumber FROM [GDW3].[dbo].[tab_buildManifest]'
    sql_runner = get_sql_runner(server)
    result = sql_runner.read(query)
    return result.loc[0, 'buildNumber']
コード例 #6
0
ファイル: build_versions.py プロジェクト: paull87/ht-pipeline
def raw_comps_version(server):
    query = 'SELECT currentVersion FROM rawComparables.dbo.tab_realtimeDataVersion'
    sql_runner = get_sql_runner(server)
    result = sql_runner.read(query)
    return result.loc[0, 'currentVersion']
コード例 #7
0
ファイル: build_versions.py プロジェクト: paull87/ht-pipeline
def os_data_version(server):
    query = 'SELECT buildNumber FROM os_data.meta.tab_buildManifest'
    sql_runner = get_sql_runner(server)
    result = sql_runner.read(query)
    return result.loc[0, 'buildNumber']
コード例 #8
0
ファイル: run_build.py プロジェクト: paull87/ht-pipeline
from app.core.logger import logger
from app.core.slack_client import send_message
from app.core.sql import get_sql_runner
from app.core.remote_windows import RemoteSession
from app.process.comparables.build_config import current_config, delete_config, CONFIG_FILE

from xml.etree import ElementTree
import time

comps_server = 'lon-sql-04'
lon_sql_02 = 'lon-sql-02'

LON_SQL_04_SQL_RUNNER = get_sql_runner(comps_server)
LON_SQL_02_SQL_RUNNER = get_sql_runner(lon_sql_02)
LON_SQL_02_SESSION = RemoteSession(lon_sql_02)


run_build_sql = '''
EXEC buildManager.dbo.proc_runBuildManager
      @buildTypeID = {build_type_id}
    , @buildControllerId = {build_controller_id}
    , @buildJobName = '{build_job_name}'
    , @buildDescription = '{build_description}'
    , @buildConfiguration = '{build_config}'
    , @isReleaseBuild = {is_release_build};
'''

BUILD_TYPE_ID = 1
BUILD_CONTROLLER_ID = 24
BUILD_JOB_NAME = '1_comparablesBuildController.dtsx'