Remove obsolete object attributes

As we are about to version the Watcher objects, we need to make sure
that upcoming model/object modifications are additive in order to
avoid having to bump the major version of the API. Therefore,
this changeset removes 2 unused DB fields: extra in Audit Template
object and deadline in Audit object.

Change-Id: Ib9750d2dee8b565bd837341f826999b64c4e2cc3
Partially-Implements: blueprint watcher-versioned-objects
This commit is contained in:
David.T 2016-11-10 15:01:15 +01:00 committed by David TARDIVEL
parent 28acfe1535
commit c8bf47d72d
13 changed files with 15 additions and 169 deletions

View File

@ -1,51 +0,0 @@
.. toctree::
:maxdepth: 1
watcherclient._i18n.rst
watcherclient.client.rst
watcherclient.common.apiclient.base.rst
watcherclient.common.apiclient.exceptions.rst
watcherclient.common.base.rst
watcherclient.common.cliutils.rst
watcherclient.common.command.rst
watcherclient.common.http.rst
watcherclient.common.utils.rst
watcherclient.exceptions.rst
watcherclient.plugin.rst
watcherclient.shell.rst
watcherclient.tests.keystone_client_fixtures.rst
watcherclient.tests.test_client.rst
watcherclient.tests.test_http.rst
watcherclient.tests.test_import.rst
watcherclient.tests.test_utils.rst
watcherclient.tests.utils.rst
watcherclient.tests.v1.base.rst
watcherclient.tests.v1.test_action.rst
watcherclient.tests.v1.test_action_plan.rst
watcherclient.tests.v1.test_action_plan_shell.rst
watcherclient.tests.v1.test_action_shell.rst
watcherclient.tests.v1.test_audit.rst
watcherclient.tests.v1.test_audit_shell.rst
watcherclient.tests.v1.test_audit_template.rst
watcherclient.tests.v1.test_audit_template_shell.rst
watcherclient.tests.v1.test_goal.rst
watcherclient.tests.v1.test_goal_shell.rst
watcherclient.tests.v1.test_metric_collector.rst
watcherclient.tests.v1.test_strategy.rst
watcherclient.tests.v1.test_strategy_shell.rst
watcherclient.v1.action.rst
watcherclient.v1.action_plan.rst
watcherclient.v1.action_plan_shell.rst
watcherclient.v1.action_shell.rst
watcherclient.v1.audit.rst
watcherclient.v1.audit_shell.rst
watcherclient.v1.audit_template.rst
watcherclient.v1.audit_template_shell.rst
watcherclient.v1.client.rst
watcherclient.v1.goal.rst
watcherclient.v1.goal_shell.rst
watcherclient.v1.metric_collector.rst
watcherclient.v1.resource_fields.rst
watcherclient.v1.strategy.rst
watcherclient.v1.strategy_shell.rst
watcherclient.version.rst

View File

@ -15,8 +15,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import copy
import testtools
from testtools import matchers
@ -57,10 +55,6 @@ ACTION_PLAN1 = {
'state': 'RECOMMENDED'
}
UPDATED_ACTION1 = copy.deepcopy(ACTION1)
NEW_EXTRA = 'key1=val1'
UPDATED_ACTION1['extra'] = NEW_EXTRA
fake_responses = {
'/v1/actions':
{
@ -100,10 +94,6 @@ fake_responses = {
{},
None,
),
'PATCH': (
{},
UPDATED_ACTION1,
),
},
'/v1/actions/detail?action_plan_uuid=%s' % ACTION1['action_plan']:
{
@ -252,22 +242,3 @@ class ActionManagerTest(testtools.TestCase):
self.assertEqual(ACTION1['uuid'], action.uuid)
self.assertEqual(ACTION1['action_plan'], action.action_plan)
self.assertEqual(ACTION1['next'], action.next)
def test_delete(self):
action = self.mgr.delete(action_id=ACTION1['uuid'])
expect = [
('DELETE', '/v1/actions/%s' % ACTION1['uuid'], {}, None),
]
self.assertEqual(expect, self.api.calls)
self.assertIsNone(action)
def test_update(self):
patch = {'op': 'replace',
'value': NEW_EXTRA,
'path': '/extra'}
action = self.mgr.update(action_id=ACTION1['uuid'], patch=patch)
expect = [
('PATCH', '/v1/actions/%s' % ACTION1['uuid'], {}, patch),
]
self.assertEqual(expect, self.api.calls)
self.assertEqual(NEW_EXTRA, action.extra)

View File

@ -27,7 +27,6 @@ import watcherclient.v1.audit
AUDIT1 = {
'id': 1,
'uuid': '5869da81-4876-4687-a1ed-12cd64cf53d9',
'deadline': None,
'audit_type': 'ONE_SHOT',
'goal': 'fc087747-61be-4aad-8126-b701731ae836',
'strategy': '2cf86250-d309-4b81-818e-1537f3dba6e5',
@ -36,7 +35,6 @@ AUDIT1 = {
AUDIT2 = {
'id': 2,
'uuid': 'a5199d0e-0702-4613-9234-5ae2af8dafea',
'deadline': None,
'audit_type': 'ONE_SHOT',
'goal': 'fc087747-61be-4aad-8126-b701731ae836',
'strategy': None,

View File

@ -29,7 +29,6 @@ AUDIT_TEMPLATE_1 = {
'uuid': 'f8e47706-efcf-49a4-a5c4-af604eb492f2',
'name': 'at1',
'description': 'Audit Template 1 description',
'extra': {'automatic': False},
'goal_uuid': 'fc087747-61be-4aad-8126-b701731ae836',
'strategy_uuid': '2cf86250-d309-4b81-818e-1537f3dba6e5',
'created_at': datetime.datetime.now().isoformat(),
@ -58,7 +57,6 @@ STRATEGY_1 = {
AUDIT_1 = {
'uuid': '5869da81-4876-4687-a1ed-12cd64cf53d9',
'deadline': None,
'audit_type': 'ONESHOT',
'state': 'PENDING',
'audit_template_uuid': 'f8e47706-efcf-49a4-a5c4-af604eb492f2',
@ -75,7 +73,6 @@ AUDIT_1 = {
AUDIT_2 = {
'uuid': 'a5199d0e-0702-4613-9234-5ae2af8dafea',
'deadline': None,
'audit_type': 'ONESHOT',
'state': 'PENDING',
'audit_template_uuid': 'f8e47706-efcf-49a4-a5c4-af604eb492f2',
@ -92,7 +89,6 @@ AUDIT_2 = {
AUDIT_3 = {
'uuid': '43199d0e-0712-1213-9674-5ae2af8dhgte',
'deadline': None,
'audit_type': 'ONESHOT',
'state': 'PENDING',
'audit_template_uuid': 'f8e47706-efcf-49a4-a5c4-af604eb492f2',
@ -320,7 +316,7 @@ class AuditShellTest(base.CommandTestCase):
self.m_audit_mgr.create.assert_called_once_with(
goal='fc087747-61be-4aad-8126-b701731ae836',
audit_type='ONESHOT'
)
)
def test_do_audit_create_with_goal_and_strategy(self):
audit = resource.Audit(mock.Mock(), AUDIT_1)
@ -338,24 +334,7 @@ class AuditShellTest(base.CommandTestCase):
goal='fc087747-61be-4aad-8126-b701731ae836',
strategy='2cf86250-d309-4b81-818e-1537f3dba6e5',
audit_type='ONESHOT'
)
def test_do_audit_create_with_deadline(self):
audit = resource.Audit(mock.Mock(), AUDIT_1)
self.m_audit_mgr.create.return_value = audit
exit_code, result = self.run_cmd(
'audit create -g fc087747-61be-4aad-8126-b701731ae836 -d '
'2016-04-28T10:48:32.064802')
self.assertEqual(0, exit_code)
self.assertEqual(
self.resource_as_dict(audit, self.FIELDS, self.FIELD_LABELS),
result)
self.m_audit_mgr.create.assert_called_once_with(
goal='fc087747-61be-4aad-8126-b701731ae836',
audit_type='ONESHOT',
deadline='2016-04-28T10:48:32.064802')
)
def test_do_audit_create_with_type(self):
audit = resource.Audit(mock.Mock(), AUDIT_1)

View File

@ -28,7 +28,6 @@ AUDIT_TMPL1 = {
'uuid': 'f8e47706-efcf-49a4-a5c4-af604eb492f2',
'name': 'Audit Template 1',
'description': 'Audit Template 1 description',
'extra': {'automatic': False},
'goal_uuid': '7568667b-51fe-4087-9eb1-29b26891036f',
'goal_name': 'SERVER_CONSOLIDATION',
'strategy_uuid': 'bbe6b966-f98e-439b-a01a-17b9b3b8478b',
@ -40,7 +39,6 @@ AUDIT_TMPL2 = {
'uuid': 'a5199d0e-0702-4613-9234-5ae2af8dafea',
'name': 'Audit Template 2',
'description': 'Audit Template 2 description',
'extra': {'automatic': True},
'goal_uuid': 'e75ee410-b32b-465f-88b5-4397705f9473',
'goal_name': 'DUMMY',
'strategy_uuid': 'ae99a4a4-acbc-4c67-abe1-e37128fac45d',
@ -52,7 +50,6 @@ AUDIT_TMPL3 = {
'uuid': '770ef053-ecb3-48b0-85b5-d55a2dbc6588',
'name': 'Audit Template 3',
'description': 'Audit Template 3 description',
'extra': {'automatic': True},
'goal_uuid': '7568667b-51fe-4087-9eb1-29b26891036f',
'goal_name': 'SERVER_CONSOLIDATION',
}
@ -407,7 +404,6 @@ class AuditTemplateManagerTest(utils.BaseTestCase):
self.assertEqual(AUDIT_TMPL1['goal_uuid'], audit_template.goal_uuid)
self.assertEqual(AUDIT_TMPL1['strategy_uuid'],
audit_template.strategy_uuid)
self.assertEqual(AUDIT_TMPL1['extra'], audit_template.extra)
def test_audit_templates_show_by_name(self):
audit_template = self.mgr.get(urlparse.quote(AUDIT_TMPL1['name']))
@ -425,7 +421,6 @@ class AuditTemplateManagerTest(utils.BaseTestCase):
self.assertEqual(AUDIT_TMPL1['goal_uuid'], audit_template.goal_uuid)
self.assertEqual(AUDIT_TMPL1['strategy_uuid'],
audit_template.strategy_uuid)
self.assertEqual(AUDIT_TMPL1['extra'], audit_template.extra)
def test_create(self):
audit_template = self.mgr.create(**CREATE_AUDIT_TEMPLATE)

View File

@ -47,7 +47,6 @@ AUDIT_TEMPLATE_1 = {
'uuid': 'f8e47706-efcf-49a4-a5c4-af604eb492f2',
'name': 'at1',
'description': 'Audit Template 1 description',
'extra': {'automatic': False},
'goal_uuid': 'fc087747-61be-4aad-8126-b701731ae836',
'goal_name': 'SERVER_CONSOLIDATION',
'strategy_uuid': '2cf86250-d309-4b81-818e-1537f3dba6e5',
@ -62,7 +61,6 @@ AUDIT_TEMPLATE_2 = {
'uuid': '2a60ca9b-09b0-40ff-8674-de8a36fc4bc8',
'name': 'at2',
'description': 'Audit Template 2',
'extra': {'automatic': False},
'goal_uuid': 'fc087747-61be-4aad-8126-b701731ae836',
'goal_name': 'SERVER_CONSOLIDATION',
'strategy_uuid': None,
@ -356,20 +354,3 @@ class AuditTemplateShellTest(base.CommandTestCase):
self.m_audit_template_mgr.create.assert_called_once_with(
goal='fc087747-61be-4aad-8126-b701731ae836',
name='at1')
def test_do_audit_template_create_with_extra(self):
audit_template = resource.AuditTemplate(mock.Mock(), AUDIT_TEMPLATE_1)
self.m_audit_template_mgr.create.return_value = audit_template
exit_code, result = self.run_cmd(
'audittemplate create at1 fc087747-61be-4aad-8126-b701731ae836 '
'-e automatic=true')
self.assertEqual(0, exit_code)
self.assertEqual(self.resource_as_dict(audit_template, self.FIELDS,
self.FIELD_LABELS),
result)
self.m_audit_template_mgr.create.assert_called_once_with(
goal='fc087747-61be-4aad-8126-b701731ae836',
name='at1',
extra={'automatic': True})

View File

@ -82,9 +82,3 @@ class ActionManager(base.Manager):
return self._list(self._path(action_id))[0]
except IndexError:
return None
def delete(self, action_id):
return self._delete(self._path(action_id))
def update(self, action_id, patch):
return self._update(self._path(action_id), patch)

View File

@ -183,11 +183,6 @@ class CreateActionPlan(command.ShowOne):
dest='audit_template_uuid',
metavar='<audit_template>',
help=_('ActionPlan template used for this audit (name or uuid).'))
parser.add_argument(
'-d', '--deadline',
dest='deadline',
metavar='<deadline>',
help=_('Descrition of the audit.'))
parser.add_argument(
'-t', '--audit_type',
dest='audit_type',
@ -200,7 +195,7 @@ class CreateActionPlan(command.ShowOne):
def take_action(self, parsed_args):
client = getattr(self.app.client_manager, "infra-optim")
field_list = ['audit_template_uuid', 'audit_type', 'deadline']
field_list = ['audit_template_uuid', 'audit_type']
fields = dict((k, v) for (k, v) in vars(parsed_args).items()
if k in field_list and v is not None)
if fields.get('audit_template_uuid'):

View File

@ -19,8 +19,8 @@ from watcherclient.common import utils
from watcherclient import exceptions as exc
CREATION_ATTRIBUTES = ['audit_template_uuid', 'deadline', 'audit_type',
'interval', 'parameters', 'goal', 'strategy']
CREATION_ATTRIBUTES = ['audit_template_uuid', 'audit_type', 'interval',
'parameters', 'goal', 'strategy']
class Audit(base.Resource):

View File

@ -127,11 +127,6 @@ class CreateAudit(command.ShowOne):
def get_parser(self, prog_name):
parser = super(CreateAudit, self).get_parser(prog_name)
parser.add_argument(
'-d', '--deadline',
dest='deadline',
metavar='<deadline>',
help=_('Descrition of the audit.'))
parser.add_argument(
'-t', '--audit_type',
dest='audit_type',
@ -172,8 +167,8 @@ class CreateAudit(command.ShowOne):
def take_action(self, parsed_args):
client = getattr(self.app.client_manager, "infra-optim")
field_list = ['audit_template_uuid', 'audit_type', 'deadline',
'parameters', 'interval', 'goal', 'strategy']
field_list = ['audit_template_uuid', 'audit_type', 'parameters',
'interval', 'goal', 'strategy']
fields = dict((k, v) for (k, v) in vars(parsed_args).items()
if k in field_list and v is not None)

View File

@ -18,8 +18,7 @@ from watcherclient.common import base
from watcherclient.common import utils
from watcherclient import exceptions as exc
CREATION_ATTRIBUTES = ['description', 'name', 'extra', 'goal', 'strategy',
'scope']
CREATION_ATTRIBUTES = ['description', 'name', 'goal', 'strategy', 'scope']
class AuditTemplate(base.Resource):

View File

@ -156,12 +156,6 @@ class CreateAuditTemplate(command.ShowOne):
'-d', '--description',
metavar='<description>',
help=_('Descrition of the audit template.'))
parser.add_argument(
'-e', '--extra',
metavar='<key=value>',
action='append',
help=_("Record arbitrary key/value metadata. "
"Can be specified multiple times."))
parser.add_argument(
'--scope',
metavar='<path>',
@ -208,8 +202,7 @@ class CreateAuditTemplate(command.ShowOne):
def take_action(self, parsed_args):
client = getattr(self.app.client_manager, "infra-optim")
field_list = ['description', 'name', 'extra', 'goal', 'strategy',
'scope']
field_list = ['description', 'name', 'goal', 'strategy', 'scope']
fields = dict((k, v) for (k, v) in vars(parsed_args).items()
if k in field_list and v is not None)
@ -226,7 +219,6 @@ class CreateAuditTemplate(command.ShowOne):
fields['scope'] = common_utils.serialize_file_to_dict(
fields['scope'])
fields = common_utils.args_array_to_dict(fields, 'extra')
audit_template = client.audit_template.create(**fields)
columns = res_fields.AUDIT_TEMPLATE_FIELDS

View File

@ -19,11 +19,11 @@
# Audit Template
AUDIT_TEMPLATE_FIELDS = [
'uuid', 'created_at', 'updated_at', 'deleted_at',
'description', 'name', 'extra', 'goal_name', 'strategy_name', 'scope']
'description', 'name', 'goal_name', 'strategy_name', 'scope']
AUDIT_TEMPLATE_FIELD_LABELS = [
'UUID', 'Created At', 'Updated At', 'Deleted At',
'Description', 'Name', 'Extra', 'Goal', 'Strategy', 'Audit Scope']
'Description', 'Name', 'Goal', 'Strategy', 'Audit Scope']
AUDIT_TEMPLATE_SHORT_LIST_FIELDS = [
'uuid', 'name', 'goal_name', 'strategy_name']
@ -32,14 +32,12 @@ AUDIT_TEMPLATE_SHORT_LIST_FIELD_LABELS = ['UUID', 'Name', 'Goal', 'Strategy']
# Audit
AUDIT_FIELDS = ['uuid', 'created_at', 'updated_at', 'deleted_at',
'deadline', 'state', 'audit_type',
'parameters', 'interval', 'goal_name', 'strategy_name',
'scope']
'state', 'audit_type', 'parameters', 'interval', 'goal_name',
'strategy_name', 'scope']
AUDIT_FIELD_LABELS = ['UUID', 'Created At', 'Updated At', 'Deleted At',
'Deadline', 'State', 'Audit Type',
'Parameters', 'Interval', 'Goal', 'Strategy',
'Audit Scope']
'State', 'Audit Type', 'Parameters', 'Interval', 'Goal',
'Strategy', 'Audit Scope']
AUDIT_SHORT_LIST_FIELDS = ['uuid', 'audit_type',
'state', 'goal_name', 'strategy_name']