Do not require user or project argument for event query

When we query for events by resource we do not need to
provide a user or project because the resource is only
owned by one entity.

Change-Id: I32b3d8a6ed9f1d9de58565b13c9de12f3658326d
Signed-off-by: Doug Hellmann <doug.hellmann@dreamhost.com>
This commit is contained in:
Doug Hellmann 2012-08-07 12:21:05 -04:00
parent 536488ae6b
commit 06f9bc8b74
3 changed files with 0 additions and 17 deletions

View File

@ -96,5 +96,3 @@ class EventFilter(object):
self.resource = resource
self.meter = meter
self.source = source
if not (self.user or self.project):
raise RuntimeError('Must provide one of "user" or "project".')

View File

@ -96,11 +96,6 @@ def make_query_from_filter(event_filter, require_meter=True):
q['user_id'] = event_filter.user
elif event_filter.project:
q['project_id'] = event_filter.project
else:
# NOTE(dhellmann): The EventFilter class should have detected
# this case already, but just in case someone passes something
# that isn't actually an EventFilter instance...
raise RuntimeError('One of "user" or "project" is required')
if event_filter.meter:
q['counter_name'] = event_filter.meter

View File

@ -391,13 +391,3 @@ class SumTest(MongoDBEngineTestBase):
for r in results)
assert counts['resource-id'] == 1
assert set(counts.keys()) == set(['resource-id'])
def test_make_query_without_user_or_project():
f = storage.EventFilter(user='set')
f.user = None # to bypass the check in the filter class
try:
impl_mongodb.make_query_from_filter(f)
except RuntimeError as err:
assert '"user"' in str(err)
assert '"project"' in str(err)