Removed host_aggregate filter for Audit Template
Although it was proposed via python-watcherclient, the feature was not implemented on the Watcher API. As the notion of host aggregate is currently unused in Watcher, decision was made to only implement the filtering of goal within the Watcher API whilst removing the host_aggregate filter from the Watcher client. Thus, this patchset removes the 'host_aggregate' parameter from the client. Change-Id: I014e4b0d5e734ea9ef869c3ad33908a2c0d2aa40 Related-Bug: #1510189
This commit is contained in:
parent
b30fad9965
commit
9699fc5f70
|
@ -19,7 +19,7 @@ import copy
|
|||
|
||||
from six.moves.urllib import parse as urlparse
|
||||
import testtools
|
||||
from testtools.matchers import HasLength
|
||||
from testtools import matchers
|
||||
|
||||
from watcherclient.tests import utils
|
||||
import watcherclient.v1.audit_template
|
||||
|
@ -41,7 +41,7 @@ AUDIT_TMPL2 = {
|
|||
'description': 'Audit Template 2 description',
|
||||
'host_aggregate': 8,
|
||||
'extra': {'automatic': True},
|
||||
'goal': 'SERVERS_CONSOLIDATION'
|
||||
'goal': 'BASIC_CONSOLIDATION'
|
||||
}
|
||||
|
||||
AUDIT_TMPL3 = {
|
||||
|
@ -176,6 +176,16 @@ fake_responses_sorting = {
|
|||
},
|
||||
}
|
||||
|
||||
fake_responses_filter_by_goal = {
|
||||
'/v1/audit_templates/?goal=BASIC_CONSOLIDATION':
|
||||
{
|
||||
'GET': (
|
||||
{},
|
||||
{"audit_templates": [AUDIT_TMPL2]}
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class AuditTemplateManagerTest(testtools.TestCase):
|
||||
|
||||
|
@ -202,6 +212,18 @@ class AuditTemplateManagerTest(testtools.TestCase):
|
|||
self.assertEqual(expect, self.api.calls)
|
||||
self.assertEqual(1, len(audit_templates))
|
||||
|
||||
def test_audit_templates_list_by_goal(self):
|
||||
self.api = utils.FakeAPI(fake_responses_filter_by_goal)
|
||||
self.mgr = watcherclient.v1.audit_template.AuditTemplateManager(
|
||||
self.api)
|
||||
audit_templates = self.mgr.list(goal="BASIC_CONSOLIDATION")
|
||||
expect = [
|
||||
('GET', '/v1/audit_templates/?goal=%s' % AUDIT_TMPL2['goal'],
|
||||
{}, None),
|
||||
]
|
||||
self.assertEqual(expect, self.api.calls)
|
||||
self.assertEqual(1, len(audit_templates))
|
||||
|
||||
def test_audit_templates_list_detail(self):
|
||||
audit_templates = self.mgr.list(detail=True)
|
||||
expect = [
|
||||
|
@ -230,7 +252,7 @@ class AuditTemplateManagerTest(testtools.TestCase):
|
|||
('GET', '/v1/audit_templates/?limit=1', {}, None),
|
||||
]
|
||||
self.assertEqual(expect, self.api.calls)
|
||||
self.assertThat(audit_templates, HasLength(1))
|
||||
self.assertThat(audit_templates, matchers.HasLength(1))
|
||||
|
||||
def test_audit_templates_list_pagination_no_limit(self):
|
||||
self.api = utils.FakeAPI(fake_responses_pagination)
|
||||
|
@ -242,7 +264,7 @@ class AuditTemplateManagerTest(testtools.TestCase):
|
|||
('GET', '/v1/audit_templates/?limit=1', {}, None)
|
||||
]
|
||||
self.assertEqual(expect, self.api.calls)
|
||||
self.assertThat(audit_templates, HasLength(2))
|
||||
self.assertThat(audit_templates, matchers.HasLength(2))
|
||||
|
||||
def test_audit_templates_list_sort_key(self):
|
||||
self.api = utils.FakeAPI(fake_responses_sorting)
|
||||
|
|
|
@ -34,7 +34,7 @@ class AuditTemplateManager(base.Manager):
|
|||
def _path(id=None):
|
||||
return '/v1/audit_templates/%s' % id if id else '/v1/audit_templates'
|
||||
|
||||
def list(self, name=None, limit=None, sort_key=None,
|
||||
def list(self, name=None, goal=None, limit=None, sort_key=None,
|
||||
sort_dir=None, detail=False):
|
||||
"""Retrieve a list of audit template.
|
||||
|
||||
|
@ -65,6 +65,8 @@ class AuditTemplateManager(base.Manager):
|
|||
filters = utils.common_filters(limit, sort_key, sort_dir)
|
||||
if name is not None:
|
||||
filters.append('name=%s' % name)
|
||||
if goal is not None:
|
||||
filters.append("goal=%s" % goal)
|
||||
|
||||
path = ''
|
||||
if detail:
|
||||
|
|
Loading…
Reference in New Issue