Exemplo n.º 1
0
def calc_glidein_ccbs(collectors):
    # All CCB collectors are equivalent
    glidein_ccbs = []

    for el in collectors:
        cWDictFile.validate_node(el.node,allow_prange=True)
        glidein_ccbs.append(el.node)
    return string.join(glidein_ccbs, ",")
Exemplo n.º 2
0
def calc_glidein_ccbs(collectors):
    # CCB collectors are subdivided in groups, mainly to control how many to use at the same time
    ccb_nodes = {}
    glidein_ccbs = []

    for el in collectors:
        if not ccb_nodes.has_key(el.group):
            ccb_nodes[el.group] = []
        cWDictFile.validate_node(el.node,allow_prange=True)
        ccb_nodes[el.group].append(el.node)

    for group in ccb_nodes.keys():
        glidein_ccbs.append(string.join(ccb_nodes[group], ","))

    return string.join(glidein_ccbs, ";")
Exemplo n.º 3
0
def calc_primary_monitoring_collectors(collectors):
    collector_nodes = {}

    for el in collectors:
        if not eval(el[u"secondary"]):
            # only consider the primary collectors
            cWDictFile.validate_node(el[u"node"])
            # we only expect one per group
            if collector_nodes.has_key(el[u"group"]):
                raise RuntimeError, "Duplicate primary monitoring collector found for group %s" % el[u"group"]
            collector_nodes[el[u"group"]] = el[u"node"]

    if len(collector_nodes) == 0:
        return None
    else:
        return string.join(collector_nodes.values(), ",")
Exemplo n.º 4
0
def calc_glidein_collectors(collectors):
    collector_nodes = {}
    glidein_collectors = []

    for el in collectors:
        if not collector_nodes.has_key(el.group):
            collector_nodes[el.group] = {'primary': [], 'secondary': []}
        if is_true(el.secondary):
            cWDictFile.validate_node(el.node,allow_prange=True)
            collector_nodes[el.group]['secondary'].append(el.node)
        else:
            cWDictFile.validate_node(el.node)
            collector_nodes[el.group]['primary'].append(el.node)

    for group in collector_nodes.keys():
        if len(collector_nodes[group]['secondary']) > 0:
            glidein_collectors.append(string.join(collector_nodes[group]['secondary'], ","))
        else:
            glidein_collectors.append(string.join(collector_nodes[group]['primary'], ","))
    return string.join(glidein_collectors, ";")
Exemplo n.º 5
0
def calc_monitoring_collectors_string(collectors):
    collector_nodes = {}
    monitoring_collectors = []

    for el in collectors:
        if not collector_nodes.has_key(el[u"group"]):
            collector_nodes[el[u"group"]] = {"primary": [], "secondary": []}
        if eval(el[u"secondary"]):
            cWDictFile.validate_node(el[u"node"], allow_prange=True)
            collector_nodes[el[u"group"]]["secondary"].append(el[u"node"])
        else:
            cWDictFile.validate_node(el[u"node"])
            collector_nodes[el[u"group"]]["primary"].append(el[u"node"])

    for group in collector_nodes.keys():
        if len(collector_nodes[group]["secondary"]) > 0:
            monitoring_collectors.append(string.join(collector_nodes[group]["secondary"], ","))
        else:
            monitoring_collectors.append(string.join(collector_nodes[group]["primary"], ","))

    if len(monitoring_collectors) == 0:
        return None
    else:
        return string.join(monitoring_collectors, ";")
Exemplo n.º 6
0
def calc_monitoring_collectors_string(collectors):
    collector_nodes = {}
    monitoring_collectors = []

    for el in collectors:
        if not collector_nodes.has_key(el.group):
            collector_nodes[el.group] = {'primary': [], 'secondary': []}
        if eval(el.secondary):
            cWDictFile.validate_node(el.node,allow_prange=True)
            collector_nodes[el.group]['secondary'].append(el.node)
        else:
            cWDictFile.validate_node(el.node)
            collector_nodes[el.group]['primary'].append(el.node)

    for group in collector_nodes.keys():
        if len(collector_nodes[group]['secondary']) > 0:
            monitoring_collectors.append(string.join(collector_nodes[group]['secondary'], ","))
        else:
            monitoring_collectors.append(string.join(collector_nodes[group]['primary'], ","))

    if len(monitoring_collectors)==0:
        return None
    else:
        return string.join(monitoring_collectors, ";")
Exemplo n.º 7
0
def populate_common_descript(descript_dict, params):
    """
    Populate info in the common descript dict
    descript_dict will be modified in this function
    """

    if params.match.policy_file:
        policy_module = MatchPolicy(params.match.policy_file)

        # Populate the descript_dict
        descript_dict.add('MatchPolicyFile', params.match.policy_file)
        descript_dict.add('MatchPolicyModuleFactoryMatchAttrs',
                          match_attrs_to_array(policy_module.factoryMatchAttrs))
        descript_dict.add('MatchPolicyModuleJobMatchAttrs',
                          match_attrs_to_array(policy_module.jobMatchAttrs))
        descript_dict.add('MatchPolicyModuleFactoryQueryExpr',
                          policy_module.factoryQueryExpr)
        descript_dict.add('MatchPolicyModuleJobQueryExpr',
                          policy_module.jobQueryExpr)

    for tel in (("factory","Factory"),("job","Job")):
        param_tname, str_tname = tel
        ma_arr = []
        qry_expr = params.match[param_tname]['query_expr']

        descript_dict.add('%sQueryExpr'%str_tname, qry_expr)
        ma_arr = match_attrs_to_array(params.match[param_tname]['match_attrs'])
        descript_dict.add('%sMatchAttrs'%str_tname, repr(ma_arr))

    if params.security.security_name is not None:
        descript_dict.add('SecurityName',params.security.security_name)

    collectors=[]
    for el in params.match.factory.collectors:
        if el['factory_identity'][-9:]=='@fake.org':
            raise RuntimeError, "factory_identity for %s not set! (i.e. it is fake)"%el['node']
        if el['my_identity'][-9:]=='@fake.org':
            raise RuntimeError, "my_identity for %s not set! (i.e. it is fake)"%el['node']
        cWDictFile.validate_node(el['node'])
        collectors.append((el['node'],el['factory_identity'],el['my_identity']))
    descript_dict.add('FactoryCollectors',repr(collectors))

    schedds=[]
    for el in params.match.job.schedds:
        cWDictFile.validate_node(el['fullname'])
        schedds.append(el['fullname'])
    descript_dict.add('JobSchedds',string.join(schedds,','))

    if params.security.proxy_selection_plugin is not None:
        descript_dict.add('ProxySelectionPlugin',params.security.proxy_selection_plugin)

    if len(params.security.credentials) > 0:
        proxies = []
        proxy_attrs=['security_class','trust_domain','type',
            'keyabsfname','pilotabsfname','vm_id','vm_type',
            'creation_script','update_frequency',
            'vm_id_fname', 'vm_type_fname', 'project_id']
        proxy_attr_names={'security_class':'ProxySecurityClasses',
            'trust_domain':'ProxyTrustDomains',
            'type':'ProxyTypes','keyabsfname':'ProxyKeyFiles',
            'pilotabsfname':'ProxyPilotFiles',
            'vm_id':'ProxyVMIds','vm_type':'ProxyVMTypes',
            'creation_script':'ProxyCreationScripts',
            'update_frequency':'ProxyUpdateFrequency',
            'vm_id_fname':'ProxyVMIdFname',
            'vm_type_fname':'ProxyVMTypeFname',
            'project_id':'ProxyProjectIds'}
        proxy_descript_values={}
        for attr in proxy_attrs:
            proxy_descript_values[attr]={}
        proxy_trust_domains = {}
        for pel in params.security.credentials:
            if pel['absfname'] is None:
                raise RuntimeError, "All proxies need a absfname!"
            if (pel['pool_idx_len'] is None) and (pel['pool_idx_list'] is None):
                # only one
                proxies.append(pel['absfname'])
                for attr in proxy_attrs:
                    if pel[attr] is not None:
                        proxy_descript_values[attr][pel['absfname']]=pel[attr]
            else: #pool
                pool_idx_list_expanded_strings = get_pool_list(pel)
                for idx in pool_idx_list_expanded_strings:
                    absfname = "%s%s" % (pel['absfname'], idx)
                    proxies.append(absfname)
                    for attr in proxy_attrs:
                        if pel[attr] is not None:
                            proxy_descript_values[attr][pel['absfname']]=pel[attr]

        descript_dict.add('Proxies', repr(proxies))
        for attr in proxy_attrs:
            if len(proxy_descript_values[attr].keys()) > 0:
                descript_dict.add(proxy_attr_names[attr], repr(proxy_descript_values[attr]))

    match_expr = params.match.match_expr
    descript_dict.add('MatchExpr', match_expr)
Exemplo n.º 8
0
def populate_common_descript(descript_dict, params):
    """
    Populate info in the common descript dict
    descript_dict will be modified in this function
    """

    if params.match.policy_file:
        policy_module = MatchPolicy(params.match.policy_file)

        # Populate the descript_dict
        descript_dict.add('MatchPolicyFile', params.match.policy_file)
        descript_dict.add('MatchPolicyModuleFactoryMatchAttrs',
                          match_attrs_to_array(policy_module.factoryMatchAttrs))
        descript_dict.add('MatchPolicyModuleJobMatchAttrs',
                          match_attrs_to_array(policy_module.jobMatchAttrs))
        descript_dict.add('MatchPolicyModuleFactoryQueryExpr',
                          policy_module.factoryQueryExpr)
        descript_dict.add('MatchPolicyModuleJobQueryExpr',
                          policy_module.jobQueryExpr)

    for tel in (("factory", "Factory"), ("job", "Job")):
        param_tname, str_tname = tel
        qry_expr = params.match[param_tname]['query_expr']
        descript_dict.add('%sQueryExpr' % str_tname, qry_expr)
        ma_arr = match_attrs_to_array(params.match[param_tname]['match_attrs'])
        descript_dict.add('%sMatchAttrs' % str_tname, repr(ma_arr))

    if params.security.security_name is not None:
        descript_dict.add('SecurityName', params.security.security_name)

    collectors = []
    for el in params.match.factory.collectors:
        if el['factory_identity'][-9:] == '@fake.org':
            raise RuntimeError("factory_identity for %s not set! (i.e. it is fake)" % el['node'])
        if el['my_identity'][-9:] == '@fake.org':
            raise RuntimeError("my_identity for %s not set! (i.e. it is fake)" % el['node'])
        cWDictFile.validate_node(el['node'])
        collectors.append((el['node'], el['factory_identity'], el['my_identity']))
    descript_dict.add('FactoryCollectors', repr(collectors))

    schedds = []
    for el in params.match.job.schedds:
        cWDictFile.validate_node(el['fullname'])
        schedds.append(el['fullname'])
    descript_dict.add('JobSchedds', string.join(schedds, ','))

    if params.security.proxy_selection_plugin is not None:
        descript_dict.add('ProxySelectionPlugin', params.security.proxy_selection_plugin)

    if len(params.security.credentials) > 0:
        proxies = []
        proxy_attr_names = {'security_class': 'ProxySecurityClasses',
                            'trust_domain': 'ProxyTrustDomains',
                            'type': 'ProxyTypes',
                            'keyabsfname': 'ProxyKeyFiles',
                            'pilotabsfname': 'ProxyPilotFiles',
                            'remote_username': '******',
                            'vm_id': 'ProxyVMIds',
                            'vm_type': 'ProxyVMTypes',
                            'creation_script': 'ProxyCreationScripts',
                            'project_id': 'ProxyProjectIds',
                            'update_frequency': 'ProxyUpdateFrequency'}
        # translation of attributes that can be added to the base type (name in list -> attribute name)
        proxy_attr_type_list = {'vm_id': 'vm_id',
                                'vm_type': 'vm_type',
                                'username': '******',
                                'project_id': 'project_id'}

        # TODO: this list is used in for loops, replace with "for i in proxy_attr_names"
        proxy_attrs = proxy_attr_names.keys()
        proxy_descript_values = {}
        for attr in proxy_attrs:
            proxy_descript_values[attr] = {}
        proxy_trust_domains = {}  # TODO: not used, remove
        # print params.security.credentials
        for pel in params.security.credentials:
            validate_credential_type(pel['type'])
            if pel['absfname'] is None:
                raise RuntimeError("All credentials need a absfname!")
            for i in pel['type'].split('+'):
                attr = proxy_attr_type_list.get(i)
                if attr and pel[attr] is None:
                    raise RuntimeError("Required attribute '%s' ('%s') missing in credential type '%s'" %
                                       (attr, i, pel['type']))
            if (pel['pool_idx_len'] is None) and (pel['pool_idx_list'] is None):
                # only one
                proxies.append(pel['absfname'])
                for attr in proxy_attrs:
                    if pel[attr] is not None:
                        proxy_descript_values[attr][pel['absfname']] = pel[attr]
            else:  # pool
                pool_idx_list_expanded_strings = get_pool_list(pel)
                for idx in pool_idx_list_expanded_strings:
                    absfname = "%s%s" % (pel['absfname'], idx)
                    proxies.append(absfname)
                    for attr in proxy_attrs:
                        if pel[attr] is not None:
                            proxy_descript_values[attr][pel['absfname']] = pel[attr]

        descript_dict.add('Proxies', repr(proxies))
        for attr in proxy_attrs:
            if len(proxy_descript_values[attr].keys()) > 0:
                descript_dict.add(proxy_attr_names[attr], repr(proxy_descript_values[attr]))

    match_expr = params.match.match_expr
    descript_dict.add('MatchExpr', match_expr)