'Returns dictionary where keys are remote group names and values are
grp.struct_grp objects from the standard grp module
key_by_gid=True will use the integer gid as the returned dictionary\'s
keys instead of the group\'s name'

def get_group_map(self, key_by_gid=False):

    grp_file = self.ssh.remote_file('/etc/group', 'r')
    groups = [l.strip().split(':') for l in grp_file.readlines()]
    grp_file.close()
    grp_map = {}
    for group in groups:
        (name, passwd, gid, mems) = group
        gid = int(gid)
        mems = mems.split(',')
        key = name
        if key_by_gid:
            key = gid
        grp_map[key] = utils.struct_group([name, passwd, gid, mems])
    return grp_map
