Exemplo n.º 1
0
def link_ora_dsource(srcconfig_ref, primary_user_ref):
    """
    :param srcconfig_ref: Reference to the sourceconfig object
    :param primary_user_ref: Reference to the environment user
    :return: Reference of the linked dSource
    """

    link_params = LinkParameters()
    link_params.link_data = OracleLinkData()
    link_params.link_data.sourcing_policy = OracleSourcingPolicy()
    link_params.name = arguments['--dsource_name']
    link_params.group = find_obj_by_name(dx_session_obj.server_session, group,
                                         arguments['--dx_group']).reference
    link_params.link_data.compressedLinkingEnabled = True
    link_params.link_data.environment_user = primary_user_ref
    link_params.link_data.db_user = arguments['--db_user']
    link_params.link_data.number_of_connections = \
        int(arguments['--num_connections'])
    link_params.link_data.link_now = bool(arguments['--link_now'])
    link_params.link_data.files_per_set = int(arguments['--files_per_set'])
    link_params.link_data.rman_channels = int(arguments['--rman_channels'])
    link_params.link_data.db_credentials = {
        'type': 'PasswordCredential',
        'password': arguments['--db_passwd']
    }
    link_params.link_data.sourcing_policy.logsync_enabled = True
    #link_params.link_data.sourcing_policy.logsync_mode = 'ARCHIVE_REDO_MODE'
    link_params.link_data.config = srcconfig_ref
    try:
        return database.link(dx_session_obj.server_session, link_params)
    except (RequestError, HttpError) as e:
        print_exception('Database link failed for {}:\n{}\n'.format(
            arguments['--dsource_name'], e))
        sys.exit(1)
def link_ase_dsource(engine_name):
    """
    Link an ASE dSource
    """

    link_params = LinkParameters()
    link_params.name = arguments['--dsource_name']
    link_params.link_data = ASELinkData()
    link_params.link_data.db_credentials = {'type': 'PasswordCredential',
                                            'password':
                                                arguments['--ase_passwd']}
    link_params.link_data.db_user = arguments['--ase_user']
    link_params.link_data.load_backup_path = arguments['--backup_path']

    if arguments['--bck_file']:
        link_params.link_data.sync_parameters = \
            ASESpecificBackupSyncParameters()
        bck_files = (arguments['--bck_file']).split(' ')
        link_params.link_data.sync_parameters.backup_files = bck_files

    elif arguments['--create_bckup']:
        link_params.link_data.sync_parameters = ASENewBackupSyncParameters()

    else:
        link_params.link_data.sync_parameters = ASELatestBackupSyncParameters()

    try:
        link_params.group = find_obj_by_name(
            dx_session_obj.server_session, group,
            arguments['--dx_group']).reference
        env_user_ref = link_params.link_data.stage_user = find_obj_by_name(
            dx_session_obj.server_session, environment,
            arguments['--env_name']).primary_user
        link_params.link_data.staging_host_user = env_user_ref
        link_params.link_data.source_host_user = env_user_ref

        link_params.link_data.config = find_obj_by_name(
            dx_session_obj.server_session, sourceconfig,
            arguments['--src_config']).reference
        link_params.link_data.staging_repository = find_obj_by_name(
            dx_session_obj.server_session, repository,
            arguments['--stage_repo']).reference

    except DlpxException as e:
        print_exception('Could not link {}: {}\n'.format(
            arguments['--dsource_name'], e))
        sys.exit(1)

    try:
        dsource_ref = database.link(dx_session_obj.server_session, link_params)
        dx_session_obj.jobs[engine_name] = dx_session_obj.server_session.last_job
        dx_session_obj.jobs[engine_name + 'snap'] = get_running_job(
            dx_session_obj.server_session, find_obj_by_name(
                dx_session_obj.server_session, database,
                arguments['--dsource_name']).reference)
        print '{} sucessfully linked {}'.format(dsource_ref,
                                                arguments['--dsource_name'])
    except (RequestError, HttpError) as e:
        print_exception('Database link failed for {}:\n{}'.format(
            arguments['--dsource_name'], e))
def link_ora_dsource(srcconfig_ref, primary_user_ref):
    """
    :param srcconfig_ref: Reference to the sourceconfig object
    :param primary_user_ref: Reference to the environment user
    :return: Reference of the linked dSource
    """

    link_params = LinkParameters()
    link_params.link_data = OracleLinkData()
    link_params.link_data.sourcing_policy = OracleSourcingPolicy()
    link_params.name = arguments['--dsource_name']
    link_params.group = find_obj_by_name(dx_session_obj.server_session, group,
                                         arguments['--dx_group']).reference
    link_params.link_data.compressedLinkingEnabled = True
    link_params.link_data.environment_user = primary_user_ref
    link_params.link_data.db_user = arguments['--db_user']
    link_params.link_data.number_of_connections = \
        int(arguments['--num_connections'])
    link_params.link_data.link_now = bool(arguments['--link_now'])
    link_params.link_data.files_per_set = int(arguments['--files_per_set'])
    link_params.link_data.rman_channels = int(arguments['--rman_channels'])
    link_params.link_data.db_credentials = {'type': 'PasswordCredential',
                                            'password':
                                                arguments['--db_passwd']}
    link_params.link_data.sourcing_policy.logsync_enabled = True
    #link_params.link_data.sourcing_policy.logsync_mode = 'ARCHIVE_REDO_MODE'
    link_params.link_data.config = srcconfig_ref
    try:
        return database.link(dx_session_obj.server_session, link_params)
    except (RequestError, HttpError) as e:
        print_exception('Database link failed for {}:\n{}\n'.format(
            arguments['--dsource_name'], e))
        sys.exit(1)
Exemplo n.º 4
0
def link_ase_dsource(engine_name):
    """
    Link an ASE dSource
    """

    link_params = LinkParameters()
    link_params.name = arguments['--dsource_name']
    link_params.link_data = ASELinkData()
    link_params.link_data.db_credentials = {
        'type': 'PasswordCredential',
        'password': arguments['--ase_passwd']
    }
    link_params.link_data.db_user = arguments['--ase_user']
    link_params.link_data.load_backup_path = arguments['--backup_path']

    if arguments['--bck_file']:
        link_params.link_data.sync_parameters = \
            ASESpecificBackupSyncParameters()
        bck_files = (arguments['--bck_file']).split(' ')
        link_params.link_data.sync_parameters.backup_files = bck_files

    elif arguments['--create_bckup']:
        link_params.link_data.sync_parameters = ASENewBackupSyncParameters()

    else:
        link_params.link_data.sync_parameters = ASELatestBackupSyncParameters()

    try:
        link_params.group = find_obj_by_name(dx_session_obj.server_session,
                                             group,
                                             arguments['--dx_group']).reference
        env_user_ref = link_params.link_data.stage_user = find_obj_by_name(
            dx_session_obj.server_session, environment,
            arguments['--env_name']).primary_user
        link_params.link_data.staging_host_user = env_user_ref
        link_params.link_data.source_host_user = env_user_ref

        link_params.link_data.config = find_obj_by_name(
            dx_session_obj.server_session, sourceconfig,
            arguments['--src_config']).reference
        link_params.link_data.staging_repository = find_obj_by_name(
            dx_session_obj.server_session, repository,
            arguments['--stage_repo']).reference

    except DlpxException as e:
        print_exception('Could not link {}: {}\n'.format(
            arguments['--dsource_name'], e))
        sys.exit(1)

    try:
        dsource_ref = database.link(dx_session_obj.server_session, link_params)
        dx_session_obj.jobs[
            engine_name] = dx_session_obj.server_session.last_job
        dx_session_obj.jobs[engine_name + 'snap'] = get_running_job(
            dx_session_obj.server_session,
            find_obj_by_name(dx_session_obj.server_session, database,
                             arguments['--dsource_name']).reference)
        print '{} sucessfully linked {}'.format(dsource_ref,
                                                arguments['--dsource_name'])
    except (RequestError, HttpError) as e:
        print_exception('Database link failed for {}:\n{}'.format(
            arguments['--dsource_name'], e))
Exemplo n.º 5
0
def link_mssql_dsource(engine_name):
    """
    Link an MSSQL dSource
    """
    link_params = LinkParameters()
    link_params.name = arguments['--dsource_name']
    link_params.link_data = MSSqlLinkData()

    try:
        env_obj_ref = find_obj_by_name(dx_session_obj.server_session,
                                       environment,
                                       arguments['--stage_env']).reference

        link_params.link_data.ppt_repository = find_dbrepo(
            dx_session_obj.server_session, 'MSSqlInstance', env_obj_ref,
            arguments['--stage_instance']).reference
        link_params.link_data.config = find_obj_by_name(
            dx_session_obj.server_session, sourceconfig,
            arguments['--dsource_name']).reference
        link_params.group = find_obj_by_name(dx_session_obj.server_session,
                                             group,
                                             arguments['--dx_group']).reference

    except DlpxException as e:
        print_exception('Could not link {}: {}\n'.format(
            arguments['--dsource_name'], e))
        sys.exit(1)

    if arguments['--backup_path'] != "auto":
        link_params.link_data.shared_backup_location = arguments[
            '--backup_path']

    if arguments['--backup_loc_passwd']:
        link_params.link_data.backup_location_credentials = {
            'type': 'PasswordCredential',
            'password': arguments['--backup_loc_passwd']
        }
        link_params.link_data.backup_location_user = \
            arguments['--backup_loc_user']

    link_params.link_data.db_credentials = {
        'type': 'PasswordCredential',
        'password': arguments['--db_passwd']
    }
    link_params.link_data.db_user = arguments['--db_user']

    link_params.link_data.sourcing_policy = SourcingPolicy()

    if arguments['--load_from_backup']:
        link_params.link_data.sourcing_policy.load_from_backup = True

    if arguments['--sync_mode']:
        link_params.link_data.validated_sync_mode = arguments['sync_mode']

    if arguments['--logsync']:
        link_params.link_data.sourcing_policy.logsync_enabled = True

    try:
        database.link(dx_session_obj.server_session, link_params)
        dx_session_obj.jobs[
            engine_name] = dx_session_obj.server_session.last_job
        dx_session_obj.jobs[engine_name + 'snap'] = get_running_job(
            dx_session_obj.server_session,
            find_obj_by_name(dx_session_obj.server_session, database,
                             arguments['--dsource_name']).reference)

    except (HttpError, RequestError, JobError) as e:
        print_exception('Database link failed for {}:\n{}\n'.format(
            arguments['--dsource_name'], e))
def link_mssql_dsource(engine_name):
    """
    Link an MSSQL dSource
    """
    link_params = LinkParameters()
    link_params.name = arguments['--dsource_name']
    link_params.link_data = MSSqlLinkData()

    try:
        env_obj_ref = find_obj_by_name(dx_session_obj.server_session,
                                       environment,
                                       arguments['--stage_env']).reference

        link_params.link_data.ppt_repository = find_dbrepo(
            dx_session_obj.server_session, 'MSSqlInstance', env_obj_ref,
            arguments['--stage_instance']).reference
        link_params.link_data.config = find_obj_by_name(
            dx_session_obj.server_session, sourceconfig,
            arguments['--dsource_name']).reference
        link_params.group = find_obj_by_name(dx_session_obj.server_session,
                                             group,
                                             arguments['--dx_group']).reference

    except DlpxException as e:
        print_exception('Could not link {}: {}\n'.format(
            arguments['--dsource_name'], e))
        sys.exit(1)

    if arguments['--backup_path'] != "auto":
      link_params.link_data.shared_backup_location = arguments['--backup_path']

    if arguments['--backup_loc_passwd']:
        link_params.link_data.backup_location_credentials = {'type':
                                                        'PasswordCredential',
                                                             'password':
                                            arguments['--backup_loc_passwd']}
        link_params.link_data.backup_location_user = \
            arguments['--backup_loc_user']

    link_params.link_data.db_credentials = {'type': 'PasswordCredential',
                                            'password':
                                                arguments['--db_passwd']}
    link_params.link_data.db_user = arguments['--db_user']

    link_params.link_data.sourcing_policy = SourcingPolicy()

    if arguments['--load_from_backup']:
      link_params.link_data.sourcing_policy.load_from_backup = True

    if arguments['--sync_mode']:
        link_params.link_data.validated_sync_mode = arguments['sync_mode']

    if arguments['--logsync']:
        link_params.link_data.sourcing_policy.logsync_enabled = True

    try:
        database.link(dx_session_obj.server_session, link_params)
        dx_session_obj.jobs[engine_name] = dx_session_obj.server_session.last_job
        dx_session_obj.jobs[engine_name + 'snap'] = get_running_job(
            dx_session_obj.server_session, find_obj_by_name(
                dx_session_obj.server_session, database,
                arguments['--dsource_name']).reference)

    except (HttpError, RequestError, JobError) as e:
        print_exception('Database link failed for {}:\n{}\n'.format(
            arguments['--dsource_name'], e))