'update group membership'

def group_update(self):

    rval = {'returncode': 0}
    cmd = ['get', 'groups', '-o', 'json']
    all_groups = self.openshift_cmd(cmd, output=True)
    for group in all_groups['results']['items']:
        if ((group['metadata']['name'] in self.groups) and ((group['users'] is None) or (self.config.username not in group['users']))):
            cmd = ['groups', 'add-users', group['metadata']['name'], self.config.username]
            rval = self.openshift_cmd(cmd, oadm=True)
            if (rval['returncode'] != 0):
                return rval
        elif ((group['users'] != None) and (self.config.username in group['users']) and (group['metadata']['name'] not in self.groups)):
            cmd = ['groups', 'remove-users', group['metadata']['name'], self.config.username]
            rval = self.openshift_cmd(cmd, oadm=True)
            if (rval['returncode'] != 0):
                return rval
    return rval
