'Create a mapping dict from secgroup id to its name.'

def _sg_name_dict(self, sg_id, rules):

    related_ids = set([sg_id])
    related_ids |= set(filter(None, [r['remote_group_id'] for r in rules]))
    related_sgs = self.client.list_security_groups(id=related_ids, fields=['id', 'name'])
    related_sgs = related_sgs.get('security_groups')
    return dict(((sg['id'], sg['name']) for sg in related_sgs))
