'Handle SG removal events.
Free all conj_ids associated with the sg_id and clean up
obsolete entries from the self.conj_ids map.  Unlike the add
method, it also updates flows.'

def sg_removed(self, sg_id):

    id_list = self.conj_id_map.delete_sg(sg_id)
    unused_dict = collections.defaultdict(set)
    for (remote_sg_id, conj_id) in id_list:
        unused_dict[remote_sg_id].add(conj_id)
    for (vlan_tag, vlan_conj_id_map) in self.conj_ids.items():
        update = False
        for sg_conj_id_map in vlan_conj_id_map.values():
            for (remote_sg_id, unused) in unused_dict.items():
                if ((remote_sg_id in sg_conj_id_map) and (sg_conj_id_map[remote_sg_id] & unused)):
                    sg_conj_id_map[remote_sg_id] -= unused
                    if (not sg_conj_id_map[remote_sg_id]):
                        del sg_conj_id_map[remote_sg_id]
                    update = True
        if update:
            self.update_flows_for_vlan(vlan_tag)
