Exemplo n.º 1
0
def ds_enable (staged_connection,parameters,repository,source_config):
    logger = setupLogger._setup_logger(__name__)

    env = {
            "DLPX_TOOLKIT_NAME" : "Oracle on Windows",
            "DLPX_TOOLKIT_WORKFLOW" : "ds_enable",
            "DLPX_TOOLKIT_PATH" : repository.delphix_tookit_path,
            "ORACLE_HOME" : repository.ora_home,
            "ORACLE_INST" : parameters.instance_name,
            "ORACLE_USER" : parameters.username,
            "ORACLE_PASSWD" : parameters.password,
            "ORACLE_BASE" : repository.ora_base,
            "ORACLE_DBID" : parameters.dbid,
            "ORACLE_CTRL_FILE_BKP" : parameters.dbctrlbkppiece,
            "ORACLE_BKP_LOC" : parameters.dbrmanbkploc,
            "STG_MNT_PATH" : parameters.mount_path,
            "ORA_SRC" : source_config.db_name,
            "ORACLE_DB_IDENTITY_NAME" : source_config.db_identity_name,
            "ORA_UNQ_NAME" : source_config.db_uniq_name
           }

    logger.debug("Staged Parameters: {}".format(parameters))
    logger.debug("Staged Repository Parameters: {}".format(repository))
    logger.debug("Source Config Parameters: {}".format(source_config))

    enable_ds =  executeScript.execute_powershell(staged_connection,'ds_enable.ps1',env)
    logger.debug("Enable dSource: {}".format(enable_ds))
def _make_ds_postsnapshot (source_connection,parameters,repository,source_config,snapshot_parameters=None):
    logger = setupLogger._setup_logger(__name__)

    env = {
            "DLPX_TOOLKIT_NAME" : "Oracle on Windows",
            "DLPX_TOOLKIT_WORKFLOW" : "_make_ds_postsnapshot",
            "DLPX_TOOLKIT_PATH" : repository.delphix_tookit_path,
            "ORACLE_HOME" : repository.ora_home,
            "ORACLE_INST" : parameters.instance_name,
            "ORACLE_USER" : parameters.username,
            "ORACLE_PASSWD" : parameters.password,
            "ORACLE_BASE" : repository.ora_base,
            "ORACLE_SRC_NAME" : source_config.db_name,
            "ORACLE_DB_IDENTITY_NAME" : source_config.db_identity_name,
            "ORA_UNQ_NAME" : source_config.db_uniq_name
           }

    logger.debug("Staged Parameters: {}".format(parameters))
    logger.debug("Repository Parameters: {}".format(repository))
    logger.debug("Source Config Parameters: {}".format(source_config))
    logger.debug("Snapshot Parameters: {}".format(snapshot_parameters))

    snapshotMetadata = executeScript.execute_powershell(source_connection,'ds_postSnapshot.ps1',env)
    logger.debug("Snapshot Metadata: {}".format(snapshotMetadata))
    parsedSnapshotMeta = json.loads(snapshotMetadata)
    logger.debug("parsedSnapshotMeta: {}".format(parsedSnapshotMeta))
    return SnapshotDefinition(oracle_home=parsedSnapshotMeta["oracleHome"],
    delphix_tookit_path=parsedSnapshotMeta["delphixToolkitPath"],
    ora_inst=parsedSnapshotMeta["oraInstName"],
    ora_user=parsedSnapshotMeta["oraUser"],
    ora_base=parsedSnapshotMeta["oraBase"],
    ora_bkp_loc=parsedSnapshotMeta["oraBkpLoc"],
    ora_src=parsedSnapshotMeta["oraSrc"],
    ora_unq=parsedSnapshotMeta["oraUnq"],
    src_type=parsedSnapshotMeta["srcType"])
Exemplo n.º 3
0
def vdb_enable (virtual_connection,parameters,repository,source_config, snapshot):
    logger = setupLogger._setup_logger(__name__)

    env = {
            "DLPX_TOOLKIT_NAME" : "Oracle on Windows",
            "DLPX_TOOLKIT_WORKFLOW" : "vdb_enable",
            "DLPX_TOOLKIT_PATH" : repository.delphix_tookit_path,
            "ORACLE_HOME" : repository.ora_home,
            "ORACLE_BASE" : repository.ora_base,
            "ORACLE_INST" : parameters.instance_name,
            "ORACLE_USER" : parameters.username,
            "ORACLE_PASSWD" : parameters.password,
            "VDB_MNT_PATH" : parameters.mount_path,
            "ORA_UNQ_NAME" : parameters.dbunique_name,
            "ORA_DB_NAME" : parameters.db_name
           }

    logger.debug("Virtual Parameters: {}".format(parameters))
    logger.debug("Virtual Repository Parameters: {}".format(repository))
    logger.debug("Source Config Parameters: {}".format(source_config))
    logger.debug("Snapshot Parameters: {}".format(snapshot))

    enable_vdb =  executeScript.execute_powershell(virtual_connection,'vdb_enable.ps1',env)
    logger.debug("Enable VDB: {}".format(enable_vdb))

    db_name = parameters.db_name
    db_uniq_name = parameters.dbunique_name
    db_identity_name = parameters.instance_name

    return SourceConfigDefinition(db_name=db_name, db_uniq_name=db_uniq_name,db_identity_name=db_identity_name)
Exemplo n.º 4
0
def vdb_status(virtual_connection, parameters, repository, source_config):
    logger = setupLogger._setup_logger(__name__)

    env = {
        "DLPX_TOOLKIT_NAME": "Oracle on Windows",
        "DLPX_TOOLKIT_WORKFLOW": "vdb_status",
        "DLPX_TOOLKIT_PATH": repository.delphix_tookit_path,
        "ORACLE_HOME": repository.ora_home,
        "ORACLE_BASE": repository.ora_base,
        "ORACLE_INST": parameters.instance_name,
        "ORACLE_USER": parameters.username,
        "ORACLE_PASSWD": parameters.password,
        "VDB_MNT_PATH": parameters.mount_path,
        "ORA_UNQ_NAME": parameters.dbunique_name,
        "ORA_DB_NAME": parameters.db_name
    }

    logger.debug("Virtual Parameters: {}".format(parameters))
    logger.debug("Virtual Repository Parameters: {}".format(repository))
    logger.debug("Source Config Parameters: {}".format(source_config))

    status_vdb = executeScript.execute_powershell(virtual_connection,
                                                  'vdb_status.ps1', env)
    logger.debug("Status VDB: {}".format(status_vdb))
    status = Status.ACTIVE if (status_vdb == "ACTIVE") else Status.INACTIVE
    logger.debug("status for {} : {}".format(parameters.dbunique_name, status))
    return status
Exemplo n.º 5
0
def incremental_sync (source_connection,parameters,repository,source_config):
    logger = setupLogger._setup_logger(__name__)

    env = {
            "DLPX_TOOLKIT_NAME" : "Oracle on Windows",
            "DLPX_TOOLKIT_WORKFLOW" : "initial_sync",
            "DLPX_TOOLKIT_PATH" : repository.delphix_tookit_path,
            "ORACLE_HOME" : repository.ora_home,
            "ORACLE_INST" : parameters.instance_name,
            "ORACLE_USER" : parameters.username,
            "ORACLE_PASSWD" : parameters.password,
            "ORACLE_BASE" : repository.ora_base,
            "ORACLE_DBID" : parameters.dbid,
            "ORACLE_CTRL_FILE_BKP" : parameters.dbctrlbkppiece,
            "ORACLE_BKP_LOC" : parameters.dbrmanbkploc,
            "STG_MNT_PATH" : parameters.mount_path,
            "ORA_SRC" : source_config.db_name,
            "ORACLE_DB_IDENTITY_NAME" : source_config.db_identity_name,
            "ORA_UNQ_NAME" : source_config.db_uniq_name
           }

    logger.debug("Staged Parameters: {}".format(parameters))
    logger.debug("Repository Parameters: {}".format(repository))

    ds_inc_find_bkp =  executeScript.execute_powershell(source_connection,'ds_inc_find_bkp.ps1',env)
    logger.debug("Find New Backups: {}".format(ds_inc_find_bkp))

    if (ds_inc_find_bkp != 'NoNewBackup'):
        crt_rstr_files =  executeScript.execute_powershell(source_connection,'ds_inc_crtRestoreScripts.ps1',env)
        logger.debug("Create Restore Files: {}".format(crt_rstr_files))

        rstr_db =  executeScript.execute_powershell(source_connection,'ds_inc_restore.ps1',env)
        logger.debug("Restore Database: {}".format(rstr_db))
Exemplo n.º 6
0
def find_repos(source_connection):
    logger = setupLogger._setup_logger(__name__)

    env = {"DLPX_TOOLKIT_NAME": "Oracle on Windows"}

    delphixToolkitPath = executeScript.execute_powershell(
        source_connection, 'writeLibrary.ps1', env).strip('"')
    logger.debug("Delphix Toolkit path: {}".format(delphixToolkitPath))
    env = {
        "DLPX_TOOLKIT_NAME": "Oracle on Windows",
        "DLPX_TOOLKIT_WORKFLOW": "repository_discovery",
        "DLPX_TOOLKIT_PATH": delphixToolkitPath
    }

    repoDiscovery = executeScript.execute_powershell(source_connection,
                                                     'repoDiscovery.ps1', env)
    logger.debug("Repository discovered: {}".format(repoDiscovery))
    parsedRepositories = json.loads(repoDiscovery)
    logger.debug("parsedRepositories: {}".format(parsedRepositories))
    return [
        RepositoryDefinition(
            toolkit_name=installedRepository["toolkitName"],
            delphix_tookit_path=installedRepository["delphixToolkitPath"],
            pretty_name=installedRepository["prettyName"],
            ora_base=installedRepository["oraBase"],
            ora_edition=installedRepository["oraEdition"],
            ora_home=installedRepository["oraHome"])
        for installedRepository in parsedRepositories
    ]
Exemplo n.º 7
0
def initial_sync (source_connection,parameters,repository,source_config):
    logger = setupLogger._setup_logger(__name__)

    env = {
            "DLPX_TOOLKIT_NAME" : "Oracle on Windows",
            "DLPX_TOOLKIT_WORKFLOW" : "initial_sync",
            "DLPX_TOOLKIT_PATH" : repository.delphix_tookit_path,
            "ORACLE_HOME" : repository.ora_home,
            "ORACLE_INST" : parameters.instance_name,
            "ORACLE_USER" : parameters.username,
            "ORACLE_PASSWD" : parameters.password,
            "ORACLE_BASE" : repository.ora_base,
            "ORACLE_DBID" : parameters.dbid,
            "ORACLE_CTRL_FILE_BKP" : parameters.dbctrlbkppiece,
            "ORACLE_BKP_LOC" : parameters.dbrmanbkploc,
            "STG_MNT_PATH" : parameters.mount_path,
            "ORA_SRC" : source_config.db_name,
            "ORACLE_DB_IDENTITY_NAME" : source_config.db_identity_name,
            "ORA_UNQ_NAME" : source_config.db_uniq_name,
            "CUSTOM_INIT_PARAMS" : str(parameters.custom_init_params),
            "CUSTOM_INIT_PARAMS_FILE" : parameters.custom_init_params_file,
            "RMAN_CHANNELS" : str(parameters.rman_channels)
           }

    logger.debug("Staged Parameters: {}".format(parameters))
    logger.debug("Repository Parameters: {}".format(repository))
    logger.debug("Source Config Parameters: {}".format(source_config))

    reSyncPrep =  executeScript.execute_powershell(source_connection,'ds_resyncprep.ps1',env)
    logger.debug("reSyncPrep: {}".format(reSyncPrep))

    crt_svc =  executeScript.execute_powershell(source_connection,'crtOraSvc.ps1',env)
    logger.debug("Creating Service: {}".format(crt_svc))

    crt_init =  executeScript.execute_powershell(source_connection,'ds_crtOraInit.ps1',env)
    logger.debug("Creating Initial Init File: {}".format(crt_init))

    crt_dirs =  executeScript.execute_powershell(source_connection,'ds_crtDirectories.ps1',env)
    logger.debug("Creating Directories: {}".format(crt_dirs))

    start_nomount =  executeScript.execute_powershell(source_connection,'ds_startup_nomount.ps1',env)
    logger.debug("Startup No-Mount: {}".format(start_nomount))

    restore_ctrlfile =  executeScript.execute_powershell(source_connection,'ds_restore_controlfile.ps1',env)
    logger.debug("Restore Control File: {}".format(restore_ctrlfile))

    start_mount_spfile =  executeScript.execute_powershell(source_connection,'ds_startup_spfile.ps1',env)
    logger.debug("Startup Mount with SP File: {}".format(start_mount_spfile))

    crt_rstr_files =  executeScript.execute_powershell(source_connection,'ds_crtRestoreScripts.ps1',env)
    logger.debug("Create Restore Files: {}".format(crt_rstr_files))

    rstr_db =  executeScript.execute_powershell(source_connection,'ds_restore.ps1',env)
    logger.debug("Restore Database: {}".format(rstr_db))
def execute_powershell(source_connection, script_name,env):
    logger = setupLogger._setup_logger(__name__)
    command = pkgutil.get_data('resources', script_name)
    env['DLPX_LIBRARY_SOURCE'] = pkgutil.get_data('resources','library.ps1')
    env['ORA_LIBRARY_SOURCE'] = pkgutil.get_data('resources','oralibrary.ps1')
    result = libs.run_powershell(source_connection,command,variables=env)

    logger.debug("Powershell Result: {}".format(result))

    if result.exit_code != 0:
        message = """The script {} failed with exit code {}. An exception {} was raised along with the message:
        {}""".format(script_name,result.exit_code,result.stdout,result.stderr)
        logger.exception(message)
        raise exceptions.PluginScriptError(message)

    return result.stdout.strip()
Exemplo n.º 9
0
def initial_provision(virtual_connection, parameters, snapshot, repository):
    logger = setupLogger._setup_logger(__name__)

    env = {
        "DLPX_TOOLKIT_NAME": "Oracle on Windows",
        "DLPX_TOOLKIT_WORKFLOW": "initial_provision",
        "DLPX_TOOLKIT_PATH": repository.delphix_tookit_path,
        "ORACLE_HOME": repository.ora_home,
        "ORACLE_BASE": repository.ora_base,
        "ORACLE_INST": parameters.instance_name,
        "ORACLE_USER": parameters.username,
        "ORACLE_PASSWD": parameters.password,
        "VDB_MNT_PATH": parameters.mount_path,
        "ORA_UNQ_NAME": parameters.dbunique_name,
        "ORA_DB_NAME": parameters.db_name,
        "ARCHIVE_LOG_MODE": str(parameters.archivelog_mode),
        "CUSTOM_INIT_PARAMS": str(parameters.custom_init_params),
        "CUSTOM_INIT_PARAMS_FILE": parameters.custom_init_params_file,
        "ORA_SRC": snapshot.ora_src,
        "ORA_STG": snapshot.ora_inst,
        "ORA_SRC_TYPE": snapshot.src_type,
        "ORA_VDB_SRC": snapshot.ora_unq
    }

    logger.debug("Virtual Parameters: {}".format(parameters))
    logger.debug("Virtual Repository Parameters: {}".format(repository))
    logger.debug("Snapshot Parameters: {}".format(snapshot))

    crt_svc = executeScript.execute_powershell(virtual_connection,
                                               'crtOraSvc.ps1', env)
    logger.debug("Creating Service: {}".format(crt_svc))

    copy_to_vdbdir = executeScript.execute_powershell(
        virtual_connection, 'vdb_copy_to_vdbdir.ps1', env)
    logger.debug("Copying dSource to VDB Dir: {}".format(copy_to_vdbdir))

    crt_dirs = executeScript.execute_powershell(virtual_connection,
                                                'vdb_crtDirectories.ps1', env)
    logger.debug("Creating Directories: {}".format(crt_dirs))

    vdb_prep_pfile = executeScript.execute_powershell(virtual_connection,
                                                      'vdb_prep_pfile.ps1',
                                                      env)
    logger.debug("VDB Prep pFile: {}".format(vdb_prep_pfile))

    if (snapshot.src_type == 'dSource'):
        vdb_startup_mount = executeScript.execute_powershell(
            virtual_connection, 'vdb_startup_mount.ps1', env)
        logger.debug("VDB StartUp Mount: {}".format(vdb_startup_mount))

        vdb_rename_files = executeScript.execute_powershell(
            virtual_connection, 'vdb_rename_files.ps1', env)
        logger.debug("VDB Rename Files: {}".format(vdb_rename_files))

        vdb_configure = executeScript.execute_powershell(
            virtual_connection, 'vdb_configure.ps1', env)
        logger.debug("VDB Configure: {}".format(vdb_configure))

        vdb_change_dbname_dbid = executeScript.execute_powershell(
            virtual_connection, 'vdb_change_dbname_dbid.ps1', env)
        logger.debug("VDB Change DB ID: {}".format(vdb_change_dbname_dbid))

        vdb_finalize = executeScript.execute_powershell(
            virtual_connection, 'vdb_finalize.ps1', env)
        logger.debug("VDB Finalize: {}".format(vdb_finalize))

    else:  ### snapshot.src_type=='VDB'
        child_vdb_provision = executeScript.execute_powershell(
            virtual_connection, 'vdb_childProvision.ps1', env)
        logger.debug("Child VDB Provision: {}".format(child_vdb_provision))

    if (str(parameters.archivelog_mode) == 'True'):
        vdb_disable_archivelog = executeScript.execute_powershell(
            virtual_connection, 'vdb_disable_archivelog.ps1', env)
        logger.debug(
            "VDB Disable Archive Log: {}".format(vdb_disable_archivelog))

    db_name = parameters.db_name
    db_uniq_name = parameters.dbunique_name
    db_identity_name = parameters.instance_name

    return SourceConfigDefinition(db_name=db_name,
                                  db_uniq_name=db_uniq_name,
                                  db_identity_name=db_identity_name)