Ejemplo n.º 1
0
def getShellDiscoverer(shell, fs, pathTool, userName, installationPath, sid):
    executor = ChainedCmdlet(command.getExecutor(shell),
                             command.cmdlet.produceResult)
    is_command_exist_cmd = hana_shell_command.get_is_command_exist_cmd(shell)
    layout_cls = getFileSystemLayoutClass(shell)
    layout = layout_cls(fs, executor, is_command_exist_cmd, installationPath)
    hdbsqlpath = layout.getHdbsqlPath(sid)
    hdbsqlCmd = getHdbsqlCommandClass(shell)(hdbsqlpath, userName)

    executor = ChainedCmdlet(hdbsqlCmd, executor)
    return Discoverer(executor, pathTool)
Ejemplo n.º 2
0
def _discover(client, framework, dns_resolver, cred_id, dbname, port):
    r'@types: Client, db2_flow.RichFramework, dns_resolver.Resolver, str, str, str -> list[osh], list[osh], list[errorobject.ErrorObject]'
    warnings = []
    oshs = []
    executor = ChainedCmdlet(SqlCommandExecutor(client),
                             command.cmdlet.produceResult)
    version, warnings_ = discover_or_warn(
        ('db2 version', db2_sql_discoverer.get_db2_version, executor), )
    warnings.extend(warnings_)

    discoverer = db2_sql_discoverer.registry.get_discoverer(version)
    version = version and db2_topology.build_version_pdo(version)

    dbname_, svcename, host, instance_name, warnings_ = discover_or_warn(
        ('db2 database name', discoverer.get_current_dbname, executor),
        ('db2 database svcename', discoverer.get_current_svcename, executor),
        ('db2 instance host', discoverer.get_instance_host, executor,
         dns_resolver),
        ('db2 instance name', discoverer.get_instance_name, executor),
    )
    warnings.extend(warnings_)

    oshs_, db_oshs = _report_remote(host, svcename, instance_name, version,
                                    dbname_)
    oshs.extend(oshs_)

    return db_oshs, oshs, warnings
def get_remote_fc_hba_descriptors(shell, device_filename):
    r'''
    Discovers fibre channel info using ioscan and fcmsutil commands
    shellutils.Shell, str -> tuple[fcmsutil.RemoteOptionDescriptor]]
    @raise ValueError: if no shell passed
    @raise command.ExecutionException: on command execution failure
    @raise com.hp.ucmdb.discovery.library.clients.protocols.command.TimeoutException: on command timeout
    '''
    executor = ChainedCmdlet(command.getExecutor(shell),
                             command.cmdlet.produceResult)

    fcmsutil_cmd = fcmsutil.Cmd(device_filename=device_filename)
    return fcmsutil_cmd.remote() | executor
Ejemplo n.º 4
0
def get_fc_hba_descriptors(executor):
    r'''
    Discovers fibre channel info using wmi `MSFC_FCAdapterHBAAttributes` and
    `MSFC_FibrePortHBAAttributes` classes

    @param executor: an executor instance to run WMI commands
    @type executor: command.ExecutorCmdlet
    @return: collection of FC HBA descriptor and its ports pairs
    @rtype: tuple[MSFC_FCAdapterHBAAttributesCmd.WMI_CLASS, tuple[MSFC_FibrePortHBAAttributesCmd.WMI_CLASS]]
    @raise ValueError: if no executor passed
    @raise command.ExecutionException: on command execution failure
    @raise com.hp.ucmdb.discovery.library.clients.protocols.command.TimeoutException: on command timeout
    '''
    executor = ChainedCmdlet(executor, command.cmdlet.produceResult)
    adapters = hba_wmi_command.MSFC_FCAdapterHBAAttributesCmd() | executor
    ports = hba_wmi_command.MSFC_FibrePortHBAAttributesCmd() | executor
    fn = operator.attrgetter('InstanceName')
    ports_by_instancename = fptools.groupby(fn, ports)
    result = []
    for adapter in adapters:
        result.append((adapter, ports_by_instancename.get(adapter.InstanceName) or ()))
    return tuple(result)
def get_fc_hba_descriptors(shell):
    r'''
    Discovers fibre channel info using ioscan and fcmsutil commands
    shellutils.Shell -> tuple[tuple[ioscan.fOptionDescriptor, fcmsutil.FcmsutilDescriptor, fcmsutil.FcmsutilVpdOptionDescriptor]]
    @raise ValueError: if no shell passed
    @raise command.ExecutionException: on command execution failure
    @raise com.hp.ucmdb.discovery.library.clients.protocols.command.TimeoutException: on command timeout
    '''
    executor = ChainedCmdlet(command.getExecutor(shell),
                             command.cmdlet.produceResult)
    cmd = ioscan.Cmd().fnC('fc')
    ioscan_result = cmd | executor

    result = []
    for ioscan_result_descriptor in ioscan_result:
        device_filename = ioscan_result_descriptor.device_filename
        fcmsutil_cmd = fcmsutil.Cmd(device_filename=device_filename)
        fc_descriptor = fcmsutil_cmd | executor
        fc_vpd_descriptor = fcmsutil_cmd.vpd() | executor
        result.append(
            (ioscan_result_descriptor, fc_descriptor, fc_vpd_descriptor))

    return tuple(result)
Ejemplo n.º 6
0
 def get_executor(self, shell):
     return ChainedCmdlet(wmic.Cmd(), getExecutor(shell))
Ejemplo n.º 7
0
def _discover(client, dns_resolver, cred_id, ip, config):
    warnings = []
    executor = ChainedCmdlet(db2_sql_base_discoverer.SqlCommandExecutor(client),
                                 command.cmdlet.produceResult)
    db2_version, warnings_ = discover_or_warn(('db2 version',
                                           db2_sql_discoverer.get_db2_version,
                                           executor),)
    warnings.extend(warnings_)
    discoverer = db2_sql_discoverer.registry.get_discoverer(db2_version)

    version_info, warnings_ = discover_or_warn(
       ('db2 version description', discoverer.get_db2_version_info, executor),
    )
    warnings.extend(warnings_)

    (tablespaces, containers, sessions, schemas,
     partition_groups, partitions, partition_name_pg_name_pairs,
     buffer_pools_by_partition_nr, warnings_) = discover_or_warn(
       ('tablespaces', discoverer.get_tablespaces, executor),
       ('containers', discoverer.get_containers, executor),
       ('sessions', discoverer.get_db_sessions, executor, config.db_name),
       ('schemas', discoverer.get_schemas, executor),
       ('partition groups', discoverer.get_partition_groups, executor),
       ('partitions', discoverer.get_partitions, executor),
       ('partition to partition group relation', discoverer.get_partition_number_to_pg_name_relation, executor),
       ('buffer pools', discoverer.get_buffer_pools, executor),
    )
    warnings.extend(warnings_)

    tables = ()
    if config.discover_tables:
        tables, warnings_ = discover_or_warn(
           ('tables', discoverer.get_tables, executor),
           )
        warnings.extend(warnings_)

    instance_name, svcename = None, None
    if not config.db2_id or not config.ipse_id:
        instance_name, svcename, warnings_ = discover_or_warn(
         ('db2 instance name', discoverer.get_instance_name, executor),
         ('db2 database svcename', discoverer.get_current_svcename, executor),)
        warnings.extend(warnings_)

    partition_nr_by_container = {}
    for tbsp_id, container_name, partition_nr in containers:
        partition_nr_by_container[container_name] = partition_nr
    containers_by_tablespace_id = groupby(containers, first, second)
    containers = map(second, containers)

    mountpoint_by_container = dict(zip(containers,
                                       map(parse_mountpoint_from_path,
                                           containers)))

    resolve_ips = safeFunc(dns_resolver.resolve_ips)
    get_host = fptools.safeFunc(db2_discoverer.get_host)
    partitions = ((partition, get_host(hostname, resolve_ips),
                   port, switch_name)
                    for partition, hostname, port, switch_name in partitions)

    pg_names_by_partition_number = groupby(partition_name_pg_name_pairs,
                                         first, second)

    partition_numbers_by_pg_name = groupby(partition_name_pg_name_pairs,
                                         second, first)

    if config.discover_tables and not config.discover_system_tables:
        tables = ifilterfalse(comp(discoverer.is_reserved_schema_name,
                                   third), tables)

    default_client_program = comp(operator.not_,
                                  discoverer.is_default_client_program_name,
                                  process.Process.getName,
                                  discoverer.Session.client_process.fget)
    sessions = ifilter(default_client_program, sessions)

    version = db2_version and db2_topology.build_version_pdo(db2_version)
    oshs = _report(ip, config, version_info, partition_groups, partitions,
                   pg_names_by_partition_number, buffer_pools_by_partition_nr,
                   tablespaces, partition_numbers_by_pg_name,
                   mountpoint_by_container,
                   containers_by_tablespace_id, partition_nr_by_container,
                   schemas, tables, sessions, instance_name, svcename, version)

    return oshs, warnings