Change template list for config hosts and services
Change-Id: If5625f4d3e60db4004e8a17cb6e13f40dd32d1a0
This commit is contained in:
parent
7118acfdfa
commit
576dec152d
@ -35,6 +35,13 @@ class TestHosts(clienttest.ClientTest):
|
||||
[{u"host_name": u"host1"}]
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
json.loads(httpretty.last_request().body.decode()),
|
||||
{
|
||||
"filters": '{"isnot": {"register": ["0"]}}'
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_list_templates(self):
|
||||
httpretty.register_uri(
|
||||
|
@ -12,6 +12,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
import httpretty
|
||||
|
||||
from surveilclient.tests.v2_0 import clienttest
|
||||
@ -32,6 +34,12 @@ class TestServices(clienttest.ClientTest):
|
||||
services,
|
||||
[{"service_name": "service1"}]
|
||||
)
|
||||
self.assertEqual(
|
||||
json.loads(httpretty.last_request().body.decode()),
|
||||
{
|
||||
"filters": '{"isnot": {"register": ["0"]}}'
|
||||
}
|
||||
)
|
||||
|
||||
@httpretty.activate
|
||||
def test_list_templates(self):
|
||||
|
@ -23,16 +23,16 @@ class HostsManager(surveil_manager.SurveilManager):
|
||||
def list(self, query=None, templates=False):
|
||||
"""Get a list of hosts."""
|
||||
query = query or {}
|
||||
if templates:
|
||||
if not templates:
|
||||
if 'filters' not in query:
|
||||
query["filters"] = '{}'
|
||||
filters = json.loads(query["filters"])
|
||||
temp_filter = {"register": ["0"]}
|
||||
if 'is' not in filters:
|
||||
filters["is"] = temp_filter
|
||||
if 'isnot' not in filters:
|
||||
filters["isnot"] = temp_filter
|
||||
else:
|
||||
filters["is"].update(temp_filter)
|
||||
query['filters'] = json.dumps(query['filters'])
|
||||
filters["isnot"].update(temp_filter)
|
||||
query["filters"] = json.dumps(filters)
|
||||
|
||||
resp, body = self.http_client.json_request(
|
||||
HostsManager.base_url, 'POST',
|
||||
|
@ -23,16 +23,17 @@ class ServicesManager(surveil_manager.SurveilManager):
|
||||
def list(self, query=None, templates=False):
|
||||
"""Get a list of hosts."""
|
||||
query = query or {}
|
||||
if templates:
|
||||
if not templates:
|
||||
if 'filters' not in query:
|
||||
query["filters"] = '{}'
|
||||
filters = json.loads(query["filters"])
|
||||
temp_filter = {"register": ["0"]}
|
||||
if 'is' not in filters:
|
||||
filters["is"] = temp_filter
|
||||
if 'isnot' not in filters:
|
||||
filters["isnot"] = temp_filter
|
||||
else:
|
||||
filters["is"].update(temp_filter)
|
||||
query['filters'] = json.dumps(query['filters'])
|
||||
filters["isnot"].update(temp_filter)
|
||||
query['filters'] = json.dumps(filters)
|
||||
|
||||
resp, body = self.http_client.json_request(
|
||||
ServicesManager.base_url, 'POST',
|
||||
body=query
|
||||
|
Loading…
x
Reference in New Issue
Block a user