From c8bf47d72dc25e385d7923d8e3f8ad1d204d82ab Mon Sep 17 00:00:00 2001
From: "David.T" <David.TARDIVEL@b-com.com>
Date: Thu, 10 Nov 2016 15:01:15 +0100
Subject: [PATCH] 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
---
 doc/source/api/autoindex.rst                  | 51 -------------------
 watcherclient/tests/v1/test_action.py         | 29 -----------
 watcherclient/tests/v1/test_audit.py          |  2 -
 watcherclient/tests/v1/test_audit_shell.py    | 25 +--------
 watcherclient/tests/v1/test_audit_template.py |  5 --
 .../tests/v1/test_audit_template_shell.py     | 19 -------
 watcherclient/v1/action.py                    |  6 ---
 watcherclient/v1/action_plan_shell.py         |  7 +--
 watcherclient/v1/audit.py                     |  4 +-
 watcherclient/v1/audit_shell.py               |  9 +---
 watcherclient/v1/audit_template.py            |  3 +-
 watcherclient/v1/audit_template_shell.py      | 10 +---
 watcherclient/v1/resource_fields.py           | 14 +++--
 13 files changed, 15 insertions(+), 169 deletions(-)
 delete mode 100644 doc/source/api/autoindex.rst

diff --git a/doc/source/api/autoindex.rst b/doc/source/api/autoindex.rst
deleted file mode 100644
index 7421277..0000000
--- a/doc/source/api/autoindex.rst
+++ /dev/null
@@ -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
diff --git a/watcherclient/tests/v1/test_action.py b/watcherclient/tests/v1/test_action.py
index a2fda61..7d330b2 100644
--- a/watcherclient/tests/v1/test_action.py
+++ b/watcherclient/tests/v1/test_action.py
@@ -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)
diff --git a/watcherclient/tests/v1/test_audit.py b/watcherclient/tests/v1/test_audit.py
index 96d9cdc..5a1e6bd 100644
--- a/watcherclient/tests/v1/test_audit.py
+++ b/watcherclient/tests/v1/test_audit.py
@@ -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,
diff --git a/watcherclient/tests/v1/test_audit_shell.py b/watcherclient/tests/v1/test_audit_shell.py
index aeac4f1..5b83eb2 100644
--- a/watcherclient/tests/v1/test_audit_shell.py
+++ b/watcherclient/tests/v1/test_audit_shell.py
@@ -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)
diff --git a/watcherclient/tests/v1/test_audit_template.py b/watcherclient/tests/v1/test_audit_template.py
index a628180..6dc871d 100644
--- a/watcherclient/tests/v1/test_audit_template.py
+++ b/watcherclient/tests/v1/test_audit_template.py
@@ -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)
diff --git a/watcherclient/tests/v1/test_audit_template_shell.py b/watcherclient/tests/v1/test_audit_template_shell.py
index ce93c60..60d80b4 100644
--- a/watcherclient/tests/v1/test_audit_template_shell.py
+++ b/watcherclient/tests/v1/test_audit_template_shell.py
@@ -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})
diff --git a/watcherclient/v1/action.py b/watcherclient/v1/action.py
index 6a2f03d..66c6089 100644
--- a/watcherclient/v1/action.py
+++ b/watcherclient/v1/action.py
@@ -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)
diff --git a/watcherclient/v1/action_plan_shell.py b/watcherclient/v1/action_plan_shell.py
index 2f2387e..9cd0ec0 100644
--- a/watcherclient/v1/action_plan_shell.py
+++ b/watcherclient/v1/action_plan_shell.py
@@ -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'):
diff --git a/watcherclient/v1/audit.py b/watcherclient/v1/audit.py
index ad19b0e..28c2573 100644
--- a/watcherclient/v1/audit.py
+++ b/watcherclient/v1/audit.py
@@ -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):
diff --git a/watcherclient/v1/audit_shell.py b/watcherclient/v1/audit_shell.py
index f1bf65c..3767e84 100644
--- a/watcherclient/v1/audit_shell.py
+++ b/watcherclient/v1/audit_shell.py
@@ -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)
diff --git a/watcherclient/v1/audit_template.py b/watcherclient/v1/audit_template.py
index 7909c8b..60dad1e 100644
--- a/watcherclient/v1/audit_template.py
+++ b/watcherclient/v1/audit_template.py
@@ -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):
diff --git a/watcherclient/v1/audit_template_shell.py b/watcherclient/v1/audit_template_shell.py
index 01ff3ee..c386d1b 100644
--- a/watcherclient/v1/audit_template_shell.py
+++ b/watcherclient/v1/audit_template_shell.py
@@ -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
diff --git a/watcherclient/v1/resource_fields.py b/watcherclient/v1/resource_fields.py
index 138b718..eb7b31b 100644
--- a/watcherclient/v1/resource_fields.py
+++ b/watcherclient/v1/resource_fields.py
@@ -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']