Add filter defined in live_query
Change-Id: If356e21200acd35fa1828855668d0d87159885f1
This commit is contained in:
parent
1f4ef360a0
commit
2f42f02ee8
@ -56,6 +56,9 @@ class LiveQuery(types.Base):
|
||||
},
|
||||
"is": {
|
||||
"event_type": ["ALERT"]
|
||||
},
|
||||
"defined": {
|
||||
"name": True
|
||||
}
|
||||
})
|
||||
)
|
||||
|
@ -47,6 +47,7 @@ def build_mongoengine_query(live_query):
|
||||
def _get_mongoengine_filter(field_name, filter_name, value):
|
||||
filters = {
|
||||
"is": field_name + "__in",
|
||||
"isnot": field_name + "__nin"
|
||||
"isnot": field_name + "__nin",
|
||||
"defined": field_name + "__exists"
|
||||
}
|
||||
return {filters[filter_name]: value}
|
@ -32,6 +32,9 @@ class MongoliveQueryTest(base.BaseTestCase):
|
||||
},
|
||||
"is": {
|
||||
"event_type": ["ALERT"]
|
||||
},
|
||||
"defined": {
|
||||
"name": True
|
||||
}
|
||||
}),
|
||||
paging=paging.Paging(
|
||||
@ -53,7 +56,8 @@ class MongoliveQueryTest(base.BaseTestCase):
|
||||
query,
|
||||
{"state__nin": ["0", "1"],
|
||||
"host_state__nin": ["2"],
|
||||
"event_type__in": ["ALERT"]},
|
||||
"event_type__in": ["ALERT"],
|
||||
"name__exists": True, }
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
|
@ -107,12 +107,14 @@ class TestHostController(functionalTest.FunctionalTest):
|
||||
"contact_groups": ["router-admins"],
|
||||
"notification_interval": 30,
|
||||
"notification_period": "24x7",
|
||||
"name": "Template",
|
||||
"register": "0",
|
||||
"custom_fields": {},
|
||||
"use": []}
|
||||
)
|
||||
)
|
||||
post_lq = {"filters": '{"is":{"register": "0"}}'}
|
||||
post_lq = {"filters": '{"is":{"register": "0"},'
|
||||
'"defined":{"name": "True"}}'}
|
||||
response = self.post_json('/v2/config/hosts', params=post_lq)
|
||||
|
||||
self.assert_count_equal_backport(
|
||||
@ -125,6 +127,7 @@ class TestHostController(functionalTest.FunctionalTest):
|
||||
"contact_groups": ["router-admins"],
|
||||
"notification_interval": 30,
|
||||
"notification_period": "24x7",
|
||||
"name": "Template",
|
||||
"register": "0",
|
||||
"custom_fields": {},
|
||||
"use": []}]
|
||||
|
@ -100,13 +100,15 @@ class TestServiceController(functionalTest.FunctionalTest):
|
||||
"notification_interval": 30,
|
||||
"notification_period": "24x7",
|
||||
"contacts": ["surveil-ptl", "surveil-bob"],
|
||||
"name": "Template",
|
||||
"register": "0",
|
||||
"contact_groups": ["linux-admins"],
|
||||
"use": []}
|
||||
)
|
||||
)
|
||||
|
||||
post_lq = {"filters": '{"is":{"register": "0"}}'}
|
||||
post_lq = {"filters": '{"is":{"register": "0"},'
|
||||
'"defined":{"name": "True"}}'}
|
||||
response = self.post_json('/v2/config/services', params=post_lq)
|
||||
|
||||
self.assert_count_equal_backport(
|
||||
@ -121,6 +123,7 @@ class TestServiceController(functionalTest.FunctionalTest):
|
||||
"notification_interval": 30,
|
||||
"notification_period": "24x7",
|
||||
"contacts": ["surveil-ptl", "surveil-bob"],
|
||||
"name": "Template",
|
||||
"register": "0",
|
||||
"contact_groups": ["linux-admins"],
|
||||
"use":[]}]
|
||||
|
Loading…
x
Reference in New Issue
Block a user