Beispiel #1
0
def discoverySingleUCS(Framework, url, credentialIds):
    for credentialId in credentialIds:
        logger.debug('Begin trying credential id:', credentialId)
        params = {'credentialsId': credentialId}
        tmpFramework = MyFramework(Framework, parameters=params)
        manager = FrameworkBasedConnectionDataManager(tmpFramework, url=url)
        try:
            client = manager.getClient()
            if client:
                logger.debug("UCS Connected on URL:", manager.getConnectionUrl)
                logger.debug("Begin discovery topology...")
                return ucs_pull_base.discovery(Framework, manager)
        except:
            logger.debugException('')
            logger.debug('Can not connection by credential:', credentialId)
        finally:
            if manager:
                manager.closeClient()
    else:
        logger.warn(
            'All credentials have been tried. No credential can connect to UCS by url %s'
            % url)
        Framework.reportWarning(
            'All credentials have been tried. No credential can connect to UCS by ip %s'
            % url)
Beispiel #2
0
def DiscoveryMain(Framework):
    ip = Framework.getTriggerCIData('ip_address')
    if not ip:
        logger.warn('No Application IP for UCS')
        Framework.reportError('No Application IP for UCS')
        return

    preferCredential = Framework.getTriggerCIData('credentialsId')
    if not preferCredential:
        logger.warn('No credential found on UCS')
        Framework.reportError('No credential found on UCS')
        return

    originFramework = Framework
    connectionManager = None
    params = {'credentialsId': preferCredential}
    tmpFramework = MyFramework(originFramework, parameters=params)
    logger.debug("Connect IP %s by credential Id %s" % (ip, preferCredential))
    manager = FrameworkBasedConnectionDataManager(tmpFramework, ip)
    try:
        client = manager.getClient()
        if client:
            logger.debug("Connected")
            connectionManager = manager
    except:
        logger.debugException('')

    if connectionManager:
        return ucs_pull_base.discovery(Framework, connectionManager)
    else:
        logger.error('The credential is invalid on ip %s' % ip)
        Framework.reportError('The credential is invalid on ip %s' % ip)
Beispiel #3
0
def discovery(Framework, connectionManager=None):
    connectionDataManager = connectionManager
    try:
        logger.debug('Replicating topology from HP ucs')
        if not connectionDataManager:
            connectionDataManager = FrameworkBasedConnectionDataManager(
                Framework)
            if not connectionDataManager.validate():
                return
        mappingFileFolder = os.path.join(
            CollectorsParameters.BASE_PROBE_MGR_DIR,
            CollectorsParameters.getDiscoveryConfigFolder(),
            MAPPING_CONFIG_FOLDER)
        mappingFileManager = UCSMappingFileManager(mappingFileFolder)

        mappingFile = getMappingFileFromFramework(Framework)
        if mappingFile:
            return replicateTopologyUsingMappingFile(
                os.path.join(mappingFileFolder, mappingFile),
                connectionDataManager, mappingFileManager)
        else:
            Framework.reportError('No mapping file found.')
            logger.errorException("No mapping file found.")
    except Exception, e:
        Framework.reportError('%s' % e)
        logger.errorException('%s' % e)
Beispiel #4
0
def DiscoveryMain(Framework):
    ip = Framework.getTriggerCIData('ip_address')
    credentialIds = netutils.getAvailableProtocols(Framework, 'ucs', ip)
    if not credentialIds:
        logger.warn('No generic credential for UCS')
        Framework.reportWarning('No generic credential for UCS')
        return

    ucs_id = Framework.getTriggerCIData('ucs_id')

    originFramework = Framework
    connectionManager = None
    connectedCredentialId = None
    for credentialId in credentialIds:
        logger.debug('Begin trying credential id:', credentialId)
        params = {'credentialsId': credentialId}
        tmpFramework = MyFramework(originFramework, parameters=params)
        manager = FrameworkBasedConnectionDataManager(tmpFramework, ip)
        try:
            client = manager.getClient()
            if client:
                logger.debug("Connected")
                connectionManager = manager
                connectedCredentialId = credentialId
                break
        except:
            logger.debugException('')
            logger.debug('Can not connection by credential:', credentialId)
        finally:
            if connectionManager:
                connectionManager.closeClient()

    if connectionManager:
        logger.debug('Connected by credential Id:', connectedCredentialId)
        vec = ObjectStateHolderVector()
        hostOsh = modeling.createHostOSH(ip)
        appOsh = modeling.createApplicationOSH('running_software',
                                               'UCS',
                                               hostOsh,
                                               vendor='Cisco')
        appOsh.setAttribute('application_ip', ip)
        appOsh.setAttribute('credentials_id', connectedCredentialId)
        vec.add(hostOsh)
        vec.add(appOsh)
        return vec
    else:
        if ucs_id:
            logger.debug('Delete the ucs since it can not be connected:%s' %
                         ucs_id)
            softwareOsh = modeling.createOshByCmdbId('running_software',
                                                     ucs_id)
            Framework.deleteObject(softwareOsh)

        logger.warn(
            'All credentials have been tried. No credential can connect to UCS by ip %s'
            % ip)
        Framework.reportWarning(
            'All credentials have been tried. No credential can connect to UCS by ip %s'
            % ip)
def DiscoveryMain(Framework):
    ip = Framework.getTriggerCIData('ip_address')
    credentialIds = netutils.getAvailableProtocols(Framework, 'ucs', ip)
    if not credentialIds:
        logger.warn('No generic credential for UCS')
        Framework.reportWarning('No generic credential for UCS')
        return

    ucs_id = Framework.getTriggerCIData('ucs_id')

    originFramework = Framework
    connectionManager = None
    connectedCredentialId = None
    for credentialId in credentialIds:
        logger.debug('Begin trying credential id:', credentialId)
        params = {'credentialsId': credentialId}
        tmpFramework = MyFramework(originFramework, parameters=params)
        manager = FrameworkBasedConnectionDataManager(tmpFramework, ip)
        try:
            client = manager.getClient()
            if client:
                logger.debug("Connected")
                connectionManager = manager
                connectedCredentialId = credentialId
                break
        except:
            logger.debugException('')
            logger.debug('Can not connection by credential:', credentialId)
        finally:
            if connectionManager:
                connectionManager.closeClient()

    if connectionManager:
        logger.debug('Connected by credential Id:', connectedCredentialId)
        vec = ObjectStateHolderVector()
        hostOsh = modeling.createHostOSH(ip)
        appOsh = modeling.createApplicationOSH('running_software', 'UCS', hostOsh, vendor='Cisco')
        appOsh.setAttribute('application_ip', ip)
        appOsh.setAttribute('credentials_id', connectedCredentialId)
        vec.add(hostOsh)
        vec.add(appOsh)
        return vec
    else:
        if ucs_id:
            logger.debug('Delete the ucs since it can not be connected:%s' % ucs_id)
            softwareOsh = modeling.createOshByCmdbId('running_software', ucs_id)
            Framework.deleteObject(softwareOsh)

        logger.warn('All credentials have been tried. No credential can connect to UCS by ip %s' % ip)
        Framework.reportWarning('All credentials have been tried. No credential can connect to UCS by ip %s' % ip)
Beispiel #6
0
def discoverySingleUCS(Framework, url, credentialIds):
    for credentialId in credentialIds:
        logger.debug('Begin trying credential id:', credentialId)
        params = {'credentialsId': credentialId}
        tmpFramework = MyFramework(Framework, parameters=params)
        manager = FrameworkBasedConnectionDataManager(tmpFramework, url=url)
        try:
            client = manager.getClient()
            if client:
                logger.debug("UCS Connected on URL:", manager.getConnectionUrl)
                logger.debug("Begin discovery topology...")
                return ucs_pull_base.discovery(Framework, manager)
        except:
            logger.debugException('')
            logger.debug('Can not connection by credential:', credentialId)
        finally:
            if manager:
                manager.closeClient()
    else:
        logger.warn('All credentials have been tried. No credential can connect to UCS by url %s' % url)
        Framework.reportWarning('All credentials have been tried. No credential can connect to UCS by ip %s' % url)
Beispiel #7
0
def discovery(Framework, connectionManager=None):
    connectionDataManager = connectionManager
    try:
        logger.debug('Replicating topology from HP ucs')
        if not connectionDataManager:
            connectionDataManager = FrameworkBasedConnectionDataManager(Framework)
            if not connectionDataManager.validate():
                return
        mappingFileFolder = os.path.join(CollectorsParameters.BASE_PROBE_MGR_DIR,
                                         CollectorsParameters.getDiscoveryConfigFolder(), MAPPING_CONFIG_FOLDER)
        mappingFileManager = UCSMappingFileManager(mappingFileFolder)

        mappingFile = getMappingFileFromFramework(Framework)
        if mappingFile:
            return replicateTopologyUsingMappingFile(os.path.join(mappingFileFolder, mappingFile),
                                                     connectionDataManager, mappingFileManager)
        else:
            Framework.reportError('No mapping file found.')
            logger.errorException("No mapping file found.")
    except Exception, e:
        Framework.reportError('%s' % e)
        logger.errorException('%s' % e)