Example #1
0
def addGroupsByName(rhn, keyid, groupnames):
    """
    API:
    none, custom method

    usage:
    addGroupsByName(rhn, keyid, groupnames)

    description:
    Add a list of system groups by name. This involves calling out to rhnapi.systemgroup
    just passes this info to addServerGroups
    This skips groups that do not exist on the satellite.

    parameters:
    rhn                    - an authenticated rhn session
    keyid (str)            - the key identifier (long hex or human-readable name)
    groupnames (list/str)  - a list of system group names to add.
    """
    # handle being given a single groupname, too
    # import our local systemgroup module
    import systemgroup

    allgroups = systemgroup.listAllGroups(rhn)
    ids = [x["id"] for x in allgroups if x["name"] in groupnames]
    return addServerGroups(rhn, keyid, ids)
def removeGroupsByName(rhn, keyid, groupnames):
    """
    API:
    none, custom method

    usage:
    removeGroupsByName(rhn, keyid, groupnames)

    description:
    Add a list of system groups by name. This involves calling out to rhnapi.groups

    params:
    rhn                    - an authenticated rhn session
    keyid (str)            - the key identifier (long hex or human-readable name)
    groupnames (list)          - a list of group names to remove.
    """
    import systemgroup
    groupinfo = systemgroup.listAllGroups(rhn)
    ids = [ x['id'] for x in groupinfo if x['name'] in groupnames ]
    return removeServerGroups(rhn, keyid, ids)