Пример #1
0
 def find(tools):
     discoverers = service_loader.global_lookup[Discoverer]
     for discoverer in discoverers:
         is_applicable = webseal_wiring.wired()(discoverer.is_applicable)
         if Sfn(is_applicable)(**tools):
             return discoverer.create(**tools)
     raise flow.DiscoveryException('No webseal discoverer found')
Пример #2
0
    def __discoverAliasInfo(self, scope, db2_home, shell, instance_name=None):
        # get version using db2level
        # User scope:
        # %USERPROFILE%\db2cli.ini
        # System scope:
        # < 9.7
        # <db2 home>\db2cli.ini
        # > 9.7
        # %ALLUSERSPROFILE%\IBM\DB2\<instance name>\CFG\db2cli.ini
        executor = db2_base_shell_discoverer.get_command_executor(shell)
        major, minor = db2_base_shell_discoverer.get_version_by_instance_home(
            executor, db2_home)
        iniFile = None
        user_path = r"%USERPROFILE%\db2cli.ini"
        system_path = None
        if major == 9 and minor < 7:
            system_path = r"%s\db2cli.ini" % db2_home
        elif major == 9 and minor >= 7 and instance_name:
            system_path = r"%%ALLUSERSPROFILE%%\IBM\DB2\%s\cfg\db2cli.ini" % instance_name

        fs = file_system.createFileSystem(shell)
        if scope == ScopeEnum.USER:
            iniFile = fs.getFileContent(user_path)
        elif scope == ScopeEnum.SYSTEM and system_path:
            iniFile = fs.getFileContent(system_path)

        if iniFile:
            return self.__parse_db2cli_ini(iniFile.content)

        raise flow.DiscoveryException("Cannot parse db2 information for %s" %
                                      self._name)
Пример #3
0
    def discover(self, shell, host_ips=None, webservice_ext_filter=[]):
        executor = self.get_executor(shell)

        self.check_module_exists(executor)

        apppools_map_object = self.discover_apppools(executor)

        if not apppools_map_object:
            raise flow.DiscoveryException("Cannot retrieve information about IIS Applications Pools")

        sites = self.discover_websites(apppools_map_object, executor, shell, host_ips, webservice_ext_filter)

        if not sites:
            raise flow.DiscoveryException("Cannot retrieve information about IIS Web Sites")

        return apppools_map_object.values(), sites
Пример #4
0
def find_discoverer_by_os_platform(platform, executor=None, protocol_name=None):
    discoverers = service_loader.global_lookup[Discoverer]
    for discoverer in discoverers:
        if Sfn(discoverer.is_applicable)(platform,
                                         executor=executor,
                                         protocol_name=protocol_name):
            return discoverer
    raise flow.DiscoveryException('No fc hba discoverer found for %s' % platform)
Пример #5
0
def _raiseFailedToDetermineDnsDetails(address=None):
    ''' Helper function to raise flow.DiscoveryException with the same message
    @types: str?
    @raise flow.DiscoveryException:
    '''
    if address:
        logger.warn("Cannot retrieve nslookup data from %s" % address)
    raise flow.DiscoveryException("Failed to determine DNS server address"
                                  " and domain name")
Пример #6
0
def _discoverBasedOnProfiles(sapUtils, oshPerInstance, system, systemOsh, discoverSapProfiles):
    profiles_result = None
    profiles_warning = None
    
    try:
        profiles_result = _discoverBasedOnProfilesUnsafe(sapUtils, oshPerInstance, system, systemOsh, discoverSapProfiles)
    except SapSystemInconsistentDataException:
        raise flow.DiscoveryException('SAP System Name in triggered data is different from the one provided by destination. Assuming false trigger. No Topology will be reported.')
    except (Exception, JException), e:
        profiles_warning = '"Failed to discover profiles"'
        logger.warnException("%s. %s" % (profiles_warning, e))
Пример #7
0
def discover_platform_by_shell(shell):
    r'''
    @types: shellutils.Shell -> os_platform_discoverer.Platform
    @raise ValueError: if shell is not passed
    @raise flow.DiscoveryException: if no os platform discoverer found
        or on platform discovery error
    '''
    discoverer = find_discoverer_by_shell(shell)
    try:
        return discoverer.get_platform(shell)
    except command.ExecuteException, e:
        raise flow.DiscoveryException(e)
Пример #8
0
def getRootByScope(scope):
    """

    :param scope: Scope of DSN
    :type scope: str
    :return: root of Windows Registry where discover process will be performed
    :rtype: regutils.RegistryFolder
    """
    if scope == ScopeEnum.SYSTEM:
        return regutils.HKLM
    if scope == ScopeEnum.USER:
        return regutils.HKCU
    raise flow.DiscoveryException("Unknown scope was defined")
Пример #9
0
def find(executor):
    '''Finds ls command implementation

    @param executor: a command executor instance
    @type executor: command.Executor
    @return: ls command implementation
    @rtype: ls.Cmd
    '''
    ls_impls = service_loader.global_lookup[Cmd]
    for ls_impl in ls_impls:
        if ls_impl.is_applicable(executor):
            return ls_impl
    raise flow.DiscoveryException('No ls impl found')
Пример #10
0
    def discover(self, name, driverName, scope, shell):
        DSNRegistryEntryDiscoverer.discover(self, name, driverName, scope, shell)
        fs = file_system.createFileSystem(shell)
        path_tool = file_system.getPathTool(fs)
        oracle_home_bin = file_system.Path(self._raw_object.Driver, path_tool).get_parent()
        logger.debug("Oracle home bin folder:%s" % oracle_home_bin)
        if oracle_home_bin:
            self.__oracle_home = oracle_home_bin.get_parent()
            logger.debug("Oracle home:%s" % oracle_home_bin)
            self.__address, self.__port, self.__database = self.__discoverAliasInfo(scope, self.__oracle_home, shell)

        if not self.__address:
            raise flow.DiscoveryException("Address is empty")
Пример #11
0
def find_discoverer_by_shell(shell):
    r'''
    @types: shellutils.Shell -> os_platform_discoverer.Discoverer
    @raise ValueError: if shell is not passed
    @raise flow.DiscoveryException: if no os platform discoverer found
    '''
    if not shell:
        raise ValueError('Invalid shell')
    discoverers = service_loader.global_lookup[Discoverer]
    for discoverer in discoverers:
        if discoverer.is_applicable(shell):
            return discoverer

    raise flow.DiscoveryException('No os platform discoverer '
                                  'implementation found')
Пример #12
0
    def discover(self, name, driverName, scope, shell):
        DSNRegistryEntryDiscoverer.discover(self, name, driverName, scope,
                                            shell)
        fs = file_system.createFileSystem(shell)
        path_tool = file_system.getPathTool(fs)
        db2_home_bin = file_system.Path(self._raw_object.Driver,
                                        path_tool).get_parent()
        if db2_home_bin:
            self.__db2_home = db2_home_bin.get_parent()

            instance_name = self.__parseInstanceName(driverName)
            self.__address, self.__port, self.__database = self.__discoverAliasInfo(
                scope, self.__db2_home, shell, instance_name)

        if not self.__address:
            raise flow.DiscoveryException("Address is empty")
Пример #13
0
def discoverTopologyBasedOnProfiles(sapUtils, systemName, containerOsh):
    r'''
    @types: SapUtils, str, osh -> dict[str, osh], tuple, tuple
    @return: tuple of
                - mapping profile OSH to its name
                - default profile
                - other profiles (START, instance) of different instances

    '''
    logger.info("Discover profiles")
    defaultPf, otherPfs = sap_abap_discoverer.discover_profiles(sapUtils)
    profiles = filter(None, otherPfs + [defaultPf])
    if not profiles:
        raise flow.DiscoveryException("Failed to discover topology "
                                          "based on profiles")
    pfNameToOsh = _reportProfiles(profiles, containerOsh)
    return pfNameToOsh, defaultPf, otherPfs
Пример #14
0
    def __discoverAliasInfo(self, scope, oracle_home, shell):
        #The tnsnames.ora file is under %ORACLE_HOME%\network\admin
        #Try to get this file and parse it.
        oraFile = None
        user_path = r"%USERPROFILE%\tnsnames.ora"
        system_path = None
        system_path = r"%s\network\admin\tnsnames.ora" % oracle_home

        fs = file_system.createFileSystem(shell)
        if scope == ScopeEnum.USER:
            oraFile = fs.getFileContent(user_path)
        elif scope == ScopeEnum.SYSTEM and system_path:
            oraFile = fs.getFileContent(system_path)

        if oraFile:
            return self.__parse_tnsnames_ora(oraFile.content)

        raise flow.DiscoveryException("Cannot parse db2 information for %s" % self._name)
Пример #15
0
def _discoverWorkProceses(sapUtils, inst, osh, system):
    '''
    @types: SapUtils, InstanceInfo, osh, System -> oshv
    @param osh: Built InstanceInfo
    '''
    logger.info("Discover work processes for %s" % inst)
    try:
        hostname = inst.hostname
        nr = inst.number
        fullName = sap.composeInstanceName(hostname, nr, system)
        logger.info("Instance full name composed: %s" % fullName)
    except ValueError:
        raise flow.DiscoveryException("Failed to compose full instance name"
                                          " of %s" % inst)
    workProcesses = _getWorkProcesses(sapUtils, system.getName(), fullName)
    oshs = []
    for name, numberOfProcesses in workProcesses:
        serviceOsh = _reportWorkProcess(name, numberOfProcesses, osh)
        oshs.append(serviceOsh)
        if name.lower() == 'enqueue':
            logger.info("This instance has enqueue process, so it is considered as CI")
            osh.setBoolAttribute("is_central", True)
    logger.info("Discovered %s work processes" % len(oshs))
    return oshs
def find_impl(**context):
    discoverers = service_loader.global_lookup[get_fc_hba_descriptors]
    for discoverer in discoverers:
        if Sfn(discoverer.isapplicable)(**context):
            return discoverer
    raise flow.DiscoveryException('No fc hba descriptors by vmkmgmt_keyval implementations found for %s', context)
Пример #17
0
def get_discoverer(shell):
    discovers = service_loader.global_lookup[Discoverer]
    for discover in discovers:
        if discover.is_applicable(shell):
            return discover
    raise flow.DiscoveryException("There is no discoverer for %s platform" % shell.getClientType())
Пример #18
0
 def check_module_exists(self, executor):
     try:
         IISPowerShellScriptCmd() | executor
     except command.ExecuteException, ex:
         logger.debug("Return code: %s" % ex.result.returnCode)
         raise flow.DiscoveryException(ex)