Beispiel #1
0
def init_object(module, lo, pos, dn='', attrs=None):
    module = _get_module(module, lo, pos)
    obj = udm_objects.get(module, None, lo, pos, dn)
    udm_objects.open(obj)
    if attrs:
        if 'policies' in attrs:
            obj.policies = attrs.pop('policies')
        for key, value in attrs.iteritems():
            obj[key] = value
    return obj
Beispiel #2
0
def search_objects(module, lo, pos, base='', **kwargs):
    module = _get_module(module, lo, pos)
    filter_str = ''
    for key, value in kwargs.iteritems():
        filter_str = '%s=%s' % (key, escape_filter_chars(value))
    try:
        objs = module.lookup(None, lo, filter_str, base=base)
    except udm_errors.noObject:
        objs = []
    for obj in objs:
        udm_objects.open(obj)
    return objs
def search_objects(_module, _lo, _pos, _base='', **kwargs):
    module = _get_module(_module, _lo, _pos)
    expressions = []
    conj = udm_filter.conjunction('&', expressions)
    for key, value in kwargs.iteritems():
        expressions.append(
            udm_filter.expression(key, escape_filter_chars(value), '='))
    try:
        objs = module.lookup(None, _lo, str(conj), base=_base)
    except udm_errors.noObject:
        objs = []
    for obj in objs:
        udm_objects.open(obj)
    return objs