Ejemplo n.º 1
0
def ldap_provider_configure_group_rules(handle,
                                        ldap_provider_name=None,
                                        authorization=None,
                                        traversal=None,
                                        use_primary_group=None,
                                        target_attr=None,
                                        name=None,
                                        descr=None):

    from ucsmsdk.mometa.aaa.AaaLdapGroupRule import AaaLdapGroupRule

    dn = "sys/ldap-ext/provider-" + ldap_provider_name
    obj = handle.query_dn(dn)
    if obj is None:
        raise ValueError("Ldap Provider does not exist.")

    mo = AaaLdapGroupRule(parent_mo_or_dn=obj)
    if ldap_provider_name is not None:
        mo.ldap_provider_name = ldap_provider_name
    if authorization is not None:
        mo.authorization = authorization
    if traversal is not None:
        mo.traversal = traversal
    if use_primary_group is not None:
        mo.use_primary_group = use_primary_group
    if target_attr is not None:
        mo.target_attr = target_attr
    if name is not None:
        mo.name = name
    if descr is not None:
        mo.descr = descr

    handle.add_mo(mo, True)
    handle.commit()
Ejemplo n.º 2
0
def ldap_provider_group_rules_configure(handle,
                                        ldap_provider_name,
                                        authorization="enable",
                                        traversal="recursive",
                                        target_attr="memberOf",
                                        use_primary_group="no",
                                        name=None,
                                        descr=None,
                                        **kwargs):
    """
    configures group rules of a ldap provider

    Args:
        handle (UcsHandle)
        ldap_provider_name (string): name of ldap provider
        authorization (string): group authorization
         valid values are "disable", "enable"
        traversal (string): group recursion
         valid values are "non-recursive", "recursive"
        target_attr (string): target atribute
        use_primary_group (string): valid values are "yes", "no"
        name (string): name
        descr (string): description
        **kwargs: Any additional key-value pair of managed object(MO)'s
                  property and value, which are not part of regular args.
                  This should be used for future version compatibility.
    Returns:
        AaaLdapGroupRule : managed object

    Raises:
        UcsOperationError: if AaaLdapProvider is not present

    Example:
        ldap_provider_group_rules_configure( handle,
                                        ldap_provider_name="test_ldap_prov",
                                        authorization="enable")
    """
    from ucsmsdk.mometa.aaa.AaaLdapGroupRule import AaaLdapGroupRule

    obj = ldap_provider_get(handle, ldap_provider_name,
                            "ldap_provider_group_rules_configure")

    mo = AaaLdapGroupRule(parent_mo_or_dn=obj,
                          authorization=authorization,
                          traversal=traversal,
                          target_attr=target_attr,
                          use_primary_group=use_primary_group,
                          name=name,
                          descr=descr)

    mo.set_prop_multiple(**kwargs)
    handle.add_mo(mo, modify_present=True)
    handle.commit()
    return mo
Ejemplo n.º 3
0
def ldap_provider_configure_group_rules(handle, ldap_provider_name=None,
                                        authorization=None, traversal=None,
                                        use_primary_group=None,
                                        target_attr=None, name=None,
                                        descr=None):

    from ucsmsdk.mometa.aaa.AaaLdapGroupRule import AaaLdapGroupRule

    dn = "sys/ldap-ext/provider-" + ldap_provider_name
    obj = handle.query_dn(dn)
    if obj is None:
        raise ValueError("Ldap Provider does not exist.")

    mo = AaaLdapGroupRule(parent_mo_or_dn=obj)
    if ldap_provider_name is not None:
        mo.ldap_provider_name = ldap_provider_name
    if authorization is not None:
        mo.authorization = authorization
    if traversal is not None:
        mo.traversal = traversal
    if use_primary_group is not None:
        mo.use_primary_group = use_primary_group
    if target_attr is not None:
        mo.target_attr = target_attr
    if name is not None:
        mo.name = name
    if descr is not None:
        mo.descr = descr

    handle.add_mo(mo, True)
    handle.commit()
Ejemplo n.º 4
0
def ldap_provider_configure_group_rules(handle,
                                        ldap_provider_name,
                                        authorization=None,
                                        traversal=None,
                                        use_primary_group=None,
                                        target_attr=None,
                                        name=None,
                                        descr=None):
    """
    configures group rules of a ldap provider

    Args:
        handle (UcsHandle)
        ldap_provider_name (string): name of ldap provider
        authorization (string): authorization
        traversal (string): traversal
        use_primary_group (string): use_primary_group
        target_attr (string): target_attr
        name (string): name
        descr (string): descr

    Returns:
        AaaLdapGroupRule : Managed Object

    Example:
        ldap_provider_configure_group_rules(handle, name="test_ldap_provider")
    """

    from ucsmsdk.mometa.aaa.AaaLdapGroupRule import AaaLdapGroupRule

    dn = "sys/ldap-ext/provider-" + ldap_provider_name
    obj = handle.query_dn(dn)
    if not obj:
        raise ValueError("Ldap Provider does not exist.")

    mo = AaaLdapGroupRule(parent_mo_or_dn=obj)
    if authorization is not None:
        mo.authorization = authorization
    if traversal is not None:
        mo.traversal = traversal
    if use_primary_group is not None:
        mo.use_primary_group = use_primary_group
    if target_attr is not None:
        mo.target_attr = target_attr
    if name is not None:
        mo.name = name
    if descr is not None:
        mo.descr = descr

    handle.add_mo(mo, True)
    handle.commit()
    return mo
Ejemplo n.º 5
0
def ldap_provider_configure_group_rules(handle, ldap_provider_name,
                                        authorization=None, traversal=None,
                                        use_primary_group=None,
                                        target_attr=None, name=None,
                                        descr=None):
    """
    configures group rules of a ldap provider

    Args:
        handle (UcsHandle)
        ldap_provider_name (string): name of ldap provider
        authorization (string): authorization
        traversal (string): traversal
        use_primary_group (string): use_primary_group
        target_attr (string): target_attr
        name (string): name
        descr (string): descr

    Returns:
        AaaLdapGroupRule : Managed Object

    Example:
        ldap_provider_configure_group_rules(handle, name="test_ldap_provider")
    """

    from ucsmsdk.mometa.aaa.AaaLdapGroupRule import AaaLdapGroupRule

    dn = "sys/ldap-ext/provider-" + ldap_provider_name
    obj = handle.query_dn(dn)
    if not obj:
        raise ValueError("Ldap Provider does not exist.")

    mo = AaaLdapGroupRule(parent_mo_or_dn=obj)
    if authorization is not None:
        mo.authorization = authorization
    if traversal is not None:
        mo.traversal = traversal
    if use_primary_group is not None:
        mo.use_primary_group = use_primary_group
    if target_attr is not None:
        mo.target_attr = target_attr
    if name is not None:
        mo.name = name
    if descr is not None:
        mo.descr = descr

    handle.add_mo(mo, True)
    handle.commit()
    return mo