Exemple #1
0
 def decorator(framework):
     framework = flow.RichFramework(framework)
     creds_manager = flow.CredsManager(framework)
     creds = creds_manager.get_creds_for_destination(proto_name)
     creds = filter(Fn(is_cred_ok_fn, framework, creds_manager, __), creds)
     return iterate_over_args(main_fn, framework, creds,
                              proto_name, stop_on_first)
Exemple #2
0
def iterate_over_args(main_fn, framework, cred_args, proto_name, stop_on_first):
    '''
    @param cred_args: parameters you decided to iterate over
    '''
    vector = ObjectStateHolderVector()
    framework = flow.RichFramework(framework)
    creds_manager = flow.CredsManager(framework)
    # as cred_args possibly generator or iterator, realize only first
    first_ = first(cred_args)
    if first_ is None:
        logger.reportErrorObject(flow._create_missed_creds_error(proto_name))
    else:
        # restore cred_args
        cred_args = chain((first_,), cred_args)
        connection_exs = []
        discovery_exs = []
        warnings = []
        at_least_once_discovered = False
        for args in cred_args:
            try:
                oshs, warnings_ = main_fn(framework, creds_manager, *args)
                warnings.extend(warnings_ or ())
                vector.addAll(oshs)
                at_least_once_discovered = True
                if stop_on_first:
                    break
            except flow.ConnectionException, ce:
                logger.debugException(str(ce))
                connection_exs.append(ce)
            except (flow.DiscoveryException, Exception, JException), de:
                logger.debugException(str(de))
                discovery_exs.append(de)
Exemple #3
0
    def decorator(framework):
        framework = flow.RichFramework(framework)
        proto_name = clients.SAPJmxClient.SAPJMX_CLIENT_TYPE
        versions = get_sap_java_client_versions()
        if not filter(len, versions):
            msg = 'SAP_JMX drivers are missing'
            obj = flow._create_connection_errorobj(proto_name, msg)
            logger.reportErrorObject(obj)
            return ObjectStateHolderVector()

        pairs = get_applicable_credentials(framework, P4_PORT_PATTERN)
        creds = ((creds_id, port, v) for creds_id, port in pairs
                                            for v in versions)
        return iterate_over_args(main_fn, framework, creds,
                                 proto_name, stop_on_first)
Exemple #4
0
def getCredentialId(framework):
    config = (flow.DiscoveryConfigBuilder(framework)
              .dest_data_params_as_list(
        # generic application server instance and client numbers
        'instance_number', 'connection_client')
              .dest_data_required_params_as_str('ip_address')
              .build())
    framework = flow.RichFramework(framework)
    creds_manager = flow.CredsManager(framework)
    cred_args = _getCredsArgsForTopologyJob(creds_manager, config)
    cred_args = _makeSetOfSystemNamesAsLastArgument(cred_args, set())
    first_ = first(cred_args)
    if first_ is None:
        return None
    else:
        return chain((first_,), cred_args)
Exemple #5
0
 def decorator(framework):
     config = (flow.DiscoveryConfigBuilder(framework)
             .dest_data_params_as_list(
                 # generic application server instance and client numbers
                'sapas_instance', 'sapas_client',
                 # central service instance and client numbers
                'sapcs_instance', 'sapcs_client',
                 # message server ports
                'sap_port')
             .dest_data_required_params_as_str('ip_address')
             .build())
     framework = flow.RichFramework(framework)
     creds_manager = flow.CredsManager(framework)
     cred_args = _getCredsArgsForConnectionJob(creds_manager, config)
     cred_args = _makeSetOfSystemNamesAsLastArgument(cred_args, set())
     stop_on_first = False
     return iterate_over_args(main_fn, framework, cred_args,
                              JCO_PROTOCOL_NAME, stop_on_first)
Exemple #6
0
 def decorator(framework):
     framework = flow.RichFramework(framework)
     proto_name = clients.SAPJmxClient.SAPJMX_CLIENT_TYPE
     creds = get_applicable_credentials(framework, HTTP_PORT_PATTERN)
     return iterate_over_args(main_fn, framework, creds,
                              proto_name, stop_on_first)