def check_address_group(context, ag_id, project_id=None): """Check if address group id exists for the given project""" if project_id: tmp_context_project_id = context.project_id context.project_id = project_id try: if not ag_obj.AddressGroup.objects_exist(context, id=ag_id): raise ag_exc.AddressGroupNotFound(address_group_id=ag_id) finally: if project_id: context.project_id = tmp_context_project_id
def _get_address_group(self, context, id): obj = ag_obj.AddressGroup.get_object(context, id=id) if obj is None: raise ag_exc.AddressGroupNotFound(address_group_id=id) return obj