def list_databases(dlpx_obj):
    """
    Function to list all databases and stats for an engine

    :param dlpx_obj: Virtualization Engine session object
    :type dlpx_obj: lib.GetSession.GetSession
    """

    source_stats_lst = find_all_objects(dlpx_obj.server_session, source)
    is_dSource = None
    try:
        for db_stats in find_all_objects(dlpx_obj.server_session, consumer):
            source_stats = find_obj_list(source_stats_lst, db_stats.name)
            if source_stats is not None:
                if source_stats.virtual is False:
                    db_size = source_stats.runtime.database_size / 1024 / 1024 / 1024
                    print(
                        "name: {}, provision container: dSource, disk usage: "
                        "{:.2f}GB, Size of Snapshots: {:.2f}GB, "
                        "dSource Size: {:.2f}GB, Log Size: {:.2f}MB,"
                        "Enabled: {}, Status: {}".format(
                            str(db_stats.name),
                            db_stats.breakdown.active_space / 1024 / 1024 /
                            1024,
                            db_stats.breakdown.sync_space / 1024 / 1024 / 1024,
                            source_stats.runtime.database_size / 1024 / 1024 /
                            1024,
                            db_stats.breakdown.log_space / 1024 / 1024,
                            source_stats.runtime.enabled,
                            source_stats.runtime.status,
                        ))
                elif source_stats.virtual is True:
                    print(
                        "name: {}, provision container: {}, disk usage: "
                        "{:.2f}GB, Size of Snapshots: {:.2f}GB, "
                        "Log Size: {:.2f}MB, Enabled: {}, "
                        "Status: {}".format(
                            str(db_stats.name),
                            db_stats.parent,
                            db_stats.breakdown.active_space / 1024 / 1024 /
                            1024,
                            db_stats.breakdown.sync_space / 1024 / 1024 / 1024,
                            db_stats.breakdown.log_space / 1024 / 1024,
                            source_stats.runtime.enabled,
                            source_stats.runtime.status,
                        ))
            elif source_stats is None:
                print("name: {},provision container: {},database disk "
                      "usage: {:.2f} GB,Size of Snapshots: {:.2f} GB,"
                      "Could not find source information. This could be a "
                      "result of an unlinked object".format(
                          str(db_stats.name),
                          str(db_stats.parent),
                          db_stats.breakdown.active_space / 1024 / 1024 / 1024,
                          db_stats.breakdown.sync_space / 1024 / 1024 / 1024,
                      ))
    except (RequestError, JobError, AttributeError, DlpxException) as err:
        print("An error occurred while listing databases: {}".format(err))
def list_databases(dlpx_obj):
    """
    Function to list all databases and stats for an engine

    :param dlpx_obj: Virtualization Engine session object
    :type dlpx_obj: lib.GetSession.GetSession
    """

    source_stats_lst = find_all_objects(dlpx_obj.server_session, source)
    is_dSource = None
    try:
        for db_stats in find_all_objects(dlpx_obj.server_session,
                                         consumer):
            source_stats = find_obj_list(source_stats_lst, db_stats.name)
            if source_stats is not None:
                if source_stats.virtual is False:
                    db_size = source_stats.runtime.database_size/1024/1024/1024
                    print('name: {}, provision container: dSource, disk usage: '
                          '{:.2f}GB, Size of Snapshots: {:.2f}GB, '
                          'dSource Size: {:.2f}GB, Log Size: {:.2f}MB,'
                          'Enabled: {}, Status: {}'.format(str(db_stats.name),
                          db_stats.breakdown.active_space/1024/1024/1024,
                          db_stats.breakdown.sync_space/1024/1024/1024,
                          source_stats.runtime.database_size/1024/1024/1024,
                          db_stats.breakdown.log_space/1024/1024,
                          source_stats.runtime.enabled,
                          source_stats.runtime.status))
                elif source_stats.virtual is True:
                    print('name: {}, provision container: {}, disk usage: '
                          '{:.2f}GB, Size of Snapshots: {:.2f}GB, '
                          'Log Size: {:.2f}MB, Enabled: {}, '
                          'Status: {}'.format(str(db_stats.name),
                          db_stats.parent,
                          db_stats.breakdown.active_space/1024/1024/1024,
                          db_stats.breakdown.sync_space/1024/1024/1024,
                          db_stats.breakdown.log_space/1024/1024,
                          source_stats.runtime.enabled,
                          source_stats.runtime.status))
            elif source_stats is None:
                print('name: {},provision container: {},database disk '
                      'usage: {:.2f} GB,Size of Snapshots: {:.2f} GB,'
                      'Could not find source information. This could be a '
                      'result of an unlinked object'.format(
                      str(db_stats.name), str(db_stats.parent),
                      db_stats.breakdown.active_space / 1024 / 1024 / 1024,
                      db_stats.breakdown.sync_space / 1024 / 1024 / 1024))
    except (RequestError, JobError, AttributeError, DlpxException) as err:
        print 'An error occurred while listing databases: {}'.format(err)
def find_missing_archivelogs(hostname):
    """
    Function to find missing archive log files for Oracle dSources.
    """
    print("Now working on engine {}.".format(hostname))

    log_file = open("{}/{}.csv".format(arguments["--outdir"], hostname), "a+")

    log_file.write("InstanceNumber,Sequence,StartSCN,EndSCN\n")
    src_objs = find_all_objects(dx_session_obj.server_session, source)

    for src_obj in src_objs:
        if src_obj.virtual is False and src_obj.type == "OracleLinkedSource":
            ora_logs = oracle.log.get_all(
                dx_session_obj.server_session,
                database=find_obj_by_name(dx_session_obj.server_session,
                                          database, src_obj.name).reference,
                missing=True,
                page_size=1000,
            )

            if ora_logs:
                for log_data in ora_logs:
                    log_file.write("{}, {}, {}, {}, {}, {}\n".format(
                        src_obj.name,
                        log_data.instance_num,
                        log_data.instance_num,
                        log_data.sequence,
                        log_data.start_scn,
                        log_data.end_scn,
                    ))
            elif not ora_logs:
                log_file.write("{} has no missing files.\n".format(
                    src_obj.name))
    log_file.close()
def refresh_env(dlpx_obj, env_name):
    """
    Refresh the environment

    engine: Dictionary of engines
    env_name: Name of the environment to refresh
    """
    engine_name = dlpx_obj.dlpx_engines.keys()[0]

    if env_name == "all":
        env_list = find_all_objects(dlpx_obj.server_session, environment)
        for env_obj in env_list:
            try:
                environment.refresh(dlpx_obj.server_session, env_obj.reference)
                dlpx_obj.jobs[engine_name] = dlpx_obj.server_session.last_job

            except (DlpxException, RequestError) as e:
                print_exception("\nERROR: Refreshing the environment {} "
                                "encountered an error:\n{}".format(
                                    env_name, e))
                sys.exit(1)
    else:

        try:
            env_obj = find_obj_by_name(dlpx_obj.server_session, environment,
                                       env_name)

            environment.refresh(dlpx_obj.server_session, env_obj.reference)
            dlpx_obj.jobs[engine_name] = dlpx_obj.server_session.last_job

        except (DlpxException, RequestError) as e:
            print_exception("\nERROR: Refreshing the environment {} "
                            "encountered an error:\n{}".format(env_name, e))
            sys.exit(1)
def refresh_env(dlpx_obj, env_name):
    """
    Refresh the environment

    engine: Dictionary of engines
    env_name: Name of the environment to refresh
    """
    engine_name = dlpx_obj.dlpx_engines.keys()[0]

    if env_name == "all":
      env_list = find_all_objects(dlpx_obj.server_session, environment)
      for env_obj in env_list:
        try:
          environment.refresh(dlpx_obj.server_session, env_obj.reference)
          dlpx_obj.jobs[engine_name] = \
                                     dlpx_obj.server_session.last_job

        except (DlpxException, RequestError) as e:
          print_exception('\nERROR: Refreshing the environment {} '
                          'encountered an error:\n{}'.format(env_name, e))
          sys.exit(1)
    else:

      try:
          env_obj = find_obj_by_name(dlpx_obj.server_session, environment,
                                     env_name)

          environment.refresh(dlpx_obj.server_session, env_obj.reference)
          dlpx_obj.jobs[engine_name] = \
                                     dlpx_obj.server_session.last_job

      except (DlpxException, RequestError) as e:
          print_exception('\nERROR: Refreshing the environment {} '
                          'encountered an error:\n{}'.format(env_name, e))
          sys.exit(1)
def find_missing_archivelogs(hostname):
    """
    Function to find missing archive log files for Oracle dSources.
    """
    print 'Now working on engine {}.'.format(hostname)

    log_file = open('{}/{}.csv'.format(arguments['--outdir'], hostname), 'a+')

    log_file.write('InstanceNumber,Sequence,StartSCN,EndSCN\n')
    src_objs = find_all_objects(dx_session_obj.server_session, source)

    for src_obj in src_objs:
        if src_obj.virtual is False and src_obj.type == 'OracleLinkedSource':
            ora_logs = oracle.log.get_all(dx_session_obj.server_session,
                                          database=find_obj_by_name(
                                              dx_session_obj.server_session,
                                              database, src_obj.name).reference,
                                          missing=True, page_size=1000)

            if ora_logs:
                for log_data in ora_logs:
                    log_file.write('{}, {}, {}, {}, {}, {}\n'.format(
                        src_obj.name, log_data.instance_num,
                        log_data.instance_num, log_data.sequence,
                        log_data.start_scn, log_data.end_scn))
            elif not ora_logs:
                log_file.write('{} has no missing files.\n'.format(
                    src_obj.name))
    log_file.close()
예제 #7
0
def list_groups():
    """
    This function lists all groups
    """
    group_list = find_all_objects(dx_session_obj.server_session, group)

    for group_obj in group_list:
        print('Group: {}'.format(group_obj.name))
예제 #8
0
def list_users():
    """
    This function lists all users
    """
    user_list = find_all_objects(dx_session_obj.server_session, user)

    for user_obj in user_list:
        print('User: {}'.format(user_obj.name))
예제 #9
0
def list_users():
    """
    This function lists all users
    """
    user_list = find_all_objects(dx_session_obj.server_session, user)

    for user_obj in user_list:
        print('User: {}'.format(user_obj.name))
예제 #10
0
def list_databases():
    """
    Function to list all databases for a given engine
    """

    source_stats_lst = find_all_objects(dx_session_obj.server_session, source)
    is_dSource = None

    try:
        for db_stats in find_all_objects(dx_session_obj.server_session,
                                         consumer):

            source_stats = find_obj_list(source_stats_lst, db_stats.name)

            if source_stats is not None:
                if source_stats.virtual is False:
                    is_dSource = 'dSource'

                elif source_stats.virtual is True:
                    is_dSource = db_stats.parent

                print(
                    'name = {}\nprovision container= {}\ndatabase disk '
                    'usage: {:.2f} GB\nSize of Snapshots: {:.2f} GB\n'
                    'Enabled: {}\nStatus:{}\n'.format(
                        str(db_stats.name), str(is_dSource),
                        db_stats.breakdown.active_space / 1024 / 1024 / 1024,
                        db_stats.breakdown.sync_space / 1024 / 1024 / 1024,
                        source_stats.runtime.enabled,
                        source_stats.runtime.status))

            elif source_stats is None:
                print(
                    'name = {}\nprovision container= {}\ndatabase disk '
                    'usage: {:.2f} GB\nSize of Snapshots: {:.2f} GB\n'
                    'Could not find source information. This could be a '
                    'result of an unlinked object.\n'.format(
                        str(db_stats.name), str(db_stats.parent),
                        db_stats.breakdown.active_space / 1024 / 1024 / 1024,
                        db_stats.breakdown.sync_space / 1024 / 1024 / 1024))

    except (RequestError, JobError, AttributeError, DlpxException) as e:
        print 'An error occurred while listing databases: {}'.format((e))