Ejemplo n.º 1
0
def duplicate_settings(l, setting_dn):
    new_uid = str(uuid.uuid1())
    new_orderedCimKeys = 'Symc_Setting.SettingID=%s' % new_uid
    # create new settings DN
    dn_suffix = re.match('.+?(,.+)', setting_dn)
    new_setting_dn = 'orderedCimKeys=' + new_orderedCimKeys.replace('=','\=') + dn_suffix.group(1)
    #new_setting_dn = new_setting_dn.replace('-','')
    # prepare new settings attributes
    add_record = [
                    ('dlmSettingID', new_uid),
                    ('symcSequenceName', new_uid),
                    ('orderedCimKeys', new_orderedCimKeys),
                 ]
    #get all attributes
    filter = '(objectclass=*)'
    raw_res = l.search_s( setting_dn, ldap.SCOPE_BASE, filter)
    search_result = ldaphelper.get_search_results( raw_res )[0]
    # add all attributes to new record
    for attr in search_result.get_attr_names():
        if attr not in SETTINGS_SPECIFIED_ATTRS:
            for value in search_result.get_attr_values(attr):
                add_record += [(attr, value)]
                
    l.add_s(new_setting_dn, add_record)
    
    return new_setting_dn
Ejemplo n.º 2
0
def get_query_groups(l, base_dn):
    filter = '(objectclass=*)'
    attrs = ['cn', 'member','dlmCaption','orderedCimKeys', 'dlmCreationClassName']
    raw_res = l.search_s( "cn=/,cn=Query Groups,cn=Queries,ou=Administration,"+base_dn, ldap.SCOPE_ONELEVEL, filter, attrs)
    search_result = ldaphelper.get_search_results( raw_res )
    list = [QueryGroupDef(item) for item in search_result]
    return list
Ejemplo n.º 3
0
def get_query(l, query_dn):
    filter = '(objectclass=symc1SettingInstance)'
    attrs = ['dlmSettingID','dlmCaption','binProperty', 'symcProductVersion']
    raw_res = l.search_s( query_dn, ldap.SCOPE_BASE, filter, attrs)
    search_result = ldaphelper.get_search_results( raw_res )
    query_def = QueryDef(search_result[0])
    return query_def.extract_query()
Ejemplo n.º 4
0
def client_products(l, base_dn):
    filter = '(objectclass=symc1SoftwareInstance)'
    attrs = ['symcProductIdentifyingNumber','dlmName','symcProductName', 'symcProductVersion']
    raw_res = l.search_s( base_dn, ldap.SCOPE_SUBTREE, filter, attrs)
    search_result = ldaphelper.get_search_results( raw_res )
    list = filter_pruducts([Product(item) for item in search_result])
    return list
Ejemplo n.º 5
0
def all(l, base_dn):
    filter = '(dlmSKUNumber=*)'
    attrs = ['dlmIdentifyingNumber','dlmName','dlmVersion', 'dlmSKUNumber']
    raw_res = l.search_s( "cn=Products,ou=Applications,"+base_dn, ldap.SCOPE_SUBTREE, filter, attrs)
    search_result = ldaphelper.get_search_results( raw_res )
    list = filter_pruducts([Product(item) for item in search_result])
    return list
Ejemplo n.º 6
0
def get_all_settings(l, config):
    all_settings = []
    filter = '(objectclass=*)'
    attrs = SETTINGS_ATTRS

    for item in config.settings:
        raw_res = l.search_s( item, ldap.SCOPE_BASE, filter, attrs)
        all_settings += [Settings(item) for item in ldaphelper.get_search_results( raw_res )]
    return all_settings
Ejemplo n.º 7
0
def get_archives(l, base_dn):
    filter = '(objectclass=*)'
    attrs = ['dlmCaption','dlmDescription','member']
    raw_res = l.search_s( "cn=Archiving,cn=Rule Groups,cn=Rule Engine,cn=SIM,ou=Administration,"+base_dn, ldap.SCOPE_ONELEVEL, filter, attrs)
    search_results = ldaphelper.get_search_results( raw_res )
    archive_def_containers = [ArchiveDefContainer(search_result) for search_result in search_results]
    #get ArchiveDefs by definition DN
    archives = []
    for archive_def_container in archive_def_containers:
        for archive_def_dn in archive_def_container.members:
            filter = '(objectclass=*)'
            attrs = ['dlmCaption','dlmDescription','symcMetaData']
            raw_res = l.search_s( archive_def_dn, ldap.SCOPE_BASE, filter, attrs)
            search_results = ldaphelper.get_search_results( raw_res )
            #should be only one search result
            archives += [ ArchiveDef(search_results[0]).archive ]

    return archives
Ejemplo n.º 8
0
def configurations(l, base_dn, productID):
    # get root config
    product_instance, config_root = get_config_root(l, base_dn, productID)
    if not product_instance:
        return None, None, None
    # get config list
    filter = '(objectclass=symc1ElementConfiguration)'
    attrs = CONFIGURATION_ATTRS
    raw_res = l.search_s( "cn=Configs,%s" % config_root, ldap.SCOPE_SUBTREE, filter, attrs)
    list = [Configuration(item) for item in ldaphelper.get_search_results( raw_res )]
    return product_instance, config_root, list
Ejemplo n.º 9
0
def pruduct_by_id(l, base_dn, productID):
    filter = '(dlmIdentifyingNumber=%s)' % productID
    attrs = ['dlmIdentifyingNumber','dlmName','dlmVersion']
    raw_res = l.search_s( "cn=Products,ou=Applications,"+base_dn, ldap.SCOPE_SUBTREE, filter, attrs)
    search_results = ldaphelper.get_search_results( raw_res )
    if  len(search_results) == 0:
        return None
    elif len(search_results) > 1:
        raise Exception, "LDAM return more then one product for provided ID(%s)" % productID

    return Product(search_results[0])
Ejemplo n.º 10
0
def all(l, base_dn, name_list = None):
    filter = '(objectclass=dlm1ComputerSystem)'
    if name_list and len(name_list) > 0:
        filter = '(&' + filter + '(|'
        for name in name_list:
            filter += '(dlmName=%s)' % name
        filter += '))'
    attrs = ['host','dlmInstallDate','dlmName', 'dlmCaption','symcIPAddresses']
    raw_res = l.search_s( "ou=Locations,"+base_dn, ldap.SCOPE_SUBTREE, filter, attrs)
    search_result = ldaphelper.get_search_results( raw_res )
    list = [Location(item) for item in search_result]
    return list
Ejemplo n.º 11
0
def get_config_root(l, base_dn, productID):
    # get product
    product_instance = product.pruduct_by_id(l, base_dn, productID)

    if not product_instance:
        return None, None
    # get config link
    filter = '(symcFeatureUses=SESA_CONFIGURING)'
    attrs = ['dlmName','symcAppSysSWFGroupComponentRef']
    raw_res = l.search_s( product_instance.dn, ldap.SCOPE_SUBTREE, filter, attrs)
    config_root = ldaphelper.get_search_results( raw_res )[0]
    config_root = config_root.get_attr_values('symcAppSysSWFGroupComponentRef')[0]
    return product_instance, config_root
Ejemplo n.º 12
0
def client_dn(l, base_dn, clientAddress):
    filter = '(symcIPAddresses=%s)' % clientAddress
    attrs = ['host','dlmInstallDate','dlmName', 'dlmCaption', 'symcIPAddresses']
    raw_res = l.search_s( "ou=Locations,"+base_dn, ldap.SCOPE_SUBTREE, filter, attrs)
    search_result = ldaphelper.get_search_results( raw_res )
    return search_result[0].get_dn()