'List Affinity Groups
:rtype ``list`` of :class:`CloudStackAffinityGroup`'

def ex_list_affinity_groups(self):

    result = self._sync_request(command='listAffinityGroups', method='GET')
    if (not result.get('count')):
        return []
    affinity_groups = []
    for ag in result['affinitygroup']:
        affinity_groups.append(self._to_affinity_group(ag))
    return affinity_groups
