'Function to compare the host\'s current
groups against provided groups'

def _compare_groups(self, hostresp):

    self.module.debug('Running    Host._compare_groups')
    g = []
    fullpathinids = hostresp['fullPathInIds']
    self.module.debug('Building    list    of    groups')
    for path in fullpathinids:
        if (path != []):
            h = {'hostGroupId': path[(-1)]}
            hgresp = json.loads(self.rpc('getHostGroup', h))
            if ((hgresp['status'] == 200) and (hgresp['data']['appliesTo'] == '')):
                g.append(path[(-1)])
    if (self.groups is not None):
        self.module.debug('Comparing    group    lists')
        for group in self.groups:
            groupjson = self.get_group(group)
            if (groupjson is None):
                self.module.debug('Group    mismatch.    No    result.')
                return True
            elif (groupjson['id'] not in g):
                self.module.debug("Group    mismatch.    ID    doesn't    exist.")
                return True
            else:
                g.remove(groupjson['id'])
        if (g != []):
            self.module.debug('Group    mismatch.    New    ID    exists.')
            return True
        self.module.debug('Groups    match')
