diff --git a/watcher/api/controllers/v1/audit.py b/watcher/api/controllers/v1/audit.py index aa258c390..83596c9dc 100644 --- a/watcher/api/controllers/v1/audit.py +++ b/watcher/api/controllers/v1/audit.py @@ -53,7 +53,7 @@ class AuditPostType(wtypes.Base): audit_template_uuid = wtypes.wsattr(types.uuid, mandatory=True) - type = wtypes.wsattr(wtypes.text, mandatory=True) + audit_type = wtypes.wsattr(wtypes.text, mandatory=True) deadline = wtypes.wsattr(datetime.datetime, mandatory=False) @@ -65,12 +65,12 @@ class AuditPostType(wtypes.Base): def as_audit(self): audit_type_values = [val.value for val in objects.audit.AuditType] - if self.type not in audit_type_values: - raise exception.AuditTypeNotFound(audit_type=self.type) + if self.audit_type not in audit_type_values: + raise exception.AuditTypeNotFound(audit_type=self.audit_type) return Audit( audit_template_id=self.audit_template_uuid, - type=self.type, + audit_type=self.audit_type, deadline=self.deadline, parameters=self.parameters, ) @@ -132,7 +132,7 @@ class Audit(base.APIBase): uuid = types.uuid """Unique UUID for this audit""" - type = wtypes.text + audit_type = wtypes.text """Type of this audit""" deadline = datetime.datetime @@ -184,7 +184,7 @@ class Audit(base.APIBase): @staticmethod def _convert_with_links(audit, url, expand=True): if not expand: - audit.unset_fields_except(['uuid', 'type', 'deadline', + audit.unset_fields_except(['uuid', 'audit_type', 'deadline', 'state', 'audit_template_uuid', 'audit_template_name']) @@ -209,7 +209,7 @@ class Audit(base.APIBase): @classmethod def sample(cls, expand=True): sample = cls(uuid='27e3153e-d5bf-4b7e-b517-fb518e17f34c', - type='ONESHOT', + audit_type='ONESHOT', state='PENDING', deadline=None, created_at=datetime.datetime.utcnow(), diff --git a/watcher/db/sqlalchemy/api.py b/watcher/db/sqlalchemy/api.py index 874e2c931..160292a4e 100644 --- a/watcher/db/sqlalchemy/api.py +++ b/watcher/db/sqlalchemy/api.py @@ -330,7 +330,7 @@ class Connection(api.BaseConnection): if filters is None: filters = {} - plain_fields = ['uuid', 'type', 'state', 'audit_template_id'] + plain_fields = ['uuid', 'audit_type', 'state', 'audit_template_id'] join_fieldmap = { 'audit_template_uuid': ("uuid", models.AuditTemplate), 'audit_template_name': ("name", models.AuditTemplate), diff --git a/watcher/db/sqlalchemy/models.py b/watcher/db/sqlalchemy/models.py index f2b38c25d..9b265ced4 100644 --- a/watcher/db/sqlalchemy/models.py +++ b/watcher/db/sqlalchemy/models.py @@ -171,7 +171,7 @@ class Audit(Base): ) id = Column(Integer, primary_key=True) uuid = Column(String(36)) - type = Column(String(20)) + audit_type = Column(String(20)) state = Column(String(20), nullable=True) deadline = Column(DateTime, nullable=True) audit_template_id = Column(Integer, ForeignKey('audit_templates.id'), diff --git a/watcher/objects/audit.py b/watcher/objects/audit.py index ac236ead6..422d93519 100644 --- a/watcher/objects/audit.py +++ b/watcher/objects/audit.py @@ -81,7 +81,7 @@ class Audit(base.WatcherObject): fields = { 'id': int, 'uuid': obj_utils.str_or_none, - 'type': obj_utils.str_or_none, + 'audit_type': obj_utils.str_or_none, 'state': obj_utils.str_or_none, 'deadline': obj_utils.datetime_or_str_or_none, 'audit_template_id': obj_utils.int_or_none, diff --git a/watcher/tests/api/v1/test_audits.py b/watcher/tests/api/v1/test_audits.py index d661aa8cb..415051656 100644 --- a/watcher/tests/api/v1/test_audits.py +++ b/watcher/tests/api/v1/test_audits.py @@ -74,7 +74,7 @@ class TestListAudit(api_base.FunctionalTest): self.assertEqual([], response['audits']) def _assert_audit_fields(self, audit): - audit_fields = ['type', 'deadline', 'state'] + audit_fields = ['audit_type', 'deadline', 'state'] for field in audit_fields: self.assertIn(field, audit) diff --git a/watcher/tests/common/test_nova_helper.py b/watcher/tests/common/test_nova_helper.py index da522f743..dcc1b9904 100644 --- a/watcher/tests/common/test_nova_helper.py +++ b/watcher/tests/common/test_nova_helper.py @@ -107,9 +107,9 @@ class TestNovaHelper(base.TestCase): instance = mock.MagicMock(id=self.instance_uuid) setattr(instance, 'OS-EXT-SRV-ATTR:host', self.source_hypervisor) addresses = mock.MagicMock() - type = mock.MagicMock() + network_type = mock.MagicMock() networks = [] - networks.append(("lan", type)) + networks.append(("lan", network_type)) addresses.items.return_value = networks attached_volumes = mock.MagicMock() setattr(instance, 'addresses', addresses) diff --git a/watcher/tests/db/test_action_plan.py b/watcher/tests/db/test_action_plan.py index 290505af6..717b68116 100644 --- a/watcher/tests/db/test_action_plan.py +++ b/watcher/tests/db/test_action_plan.py @@ -252,7 +252,7 @@ class DbActionPlanTestCase(base.DbTestCase): def test_get_action_plan_list_with_filters(self): audit = self._create_test_audit( id=1, - type='ONESHOT', + audit_type='ONESHOT', uuid=w_utils.generate_uuid(), deadline=None, state='ONGOING') diff --git a/watcher/tests/db/test_audit.py b/watcher/tests/db/test_audit.py index 06138a228..cd46127c6 100644 --- a/watcher/tests/db/test_audit.py +++ b/watcher/tests/db/test_audit.py @@ -267,23 +267,23 @@ class DbAuditTestCase(base.DbTestCase): def test_get_audit_list_with_filters(self): audit1 = self._create_test_audit( id=1, - type='ONESHOT', + audit_type='ONESHOT', uuid=w_utils.generate_uuid(), deadline=None, state='ONGOING') audit2 = self._create_test_audit( id=2, - type='CONTINUOUS', + audit_type='CONTINUOUS', uuid=w_utils.generate_uuid(), deadline=None, state='PENDING') res = self.dbapi.get_audit_list(self.context, - filters={'type': 'ONESHOT'}) + filters={'audit_type': 'ONESHOT'}) self.assertEqual([audit1['id']], [r.id for r in res]) res = self.dbapi.get_audit_list(self.context, - filters={'type': 'bad-type'}) + filters={'audit_type': 'bad-type'}) self.assertEqual([], [r.id for r in res]) res = self.dbapi.get_audit_list( @@ -331,7 +331,7 @@ class DbAuditTestCase(base.DbTestCase): ) audit = self._create_test_audit( - type='ONESHOT', + audit_type='ONESHOT', uuid=w_utils.generate_uuid(), deadline=None, state='ONGOING', @@ -357,7 +357,7 @@ class DbAuditTestCase(base.DbTestCase): ) audit = self._create_test_audit( - type='ONESHOT', + audit_type='ONESHOT', uuid=w_utils.generate_uuid(), deadline=None, state='ONGOING', diff --git a/watcher/tests/db/utils.py b/watcher/tests/db/utils.py index 793914d03..0d0c43857 100644 --- a/watcher/tests/db/utils.py +++ b/watcher/tests/db/utils.py @@ -54,7 +54,7 @@ def get_test_audit(**kwargs): return { 'id': kwargs.get('id', 1), 'uuid': kwargs.get('uuid', '10a47dd1-4874-4298-91cf-eff046dbdb8d'), - 'type': kwargs.get('type', 'ONESHOT'), + 'audit_type': kwargs.get('audit_type', 'ONESHOT'), 'state': kwargs.get('state'), 'deadline': kwargs.get('deadline'), 'audit_template_id': kwargs.get('audit_template_id', 1), diff --git a/watcher_tempest_plugin/tests/api/admin/base.py b/watcher_tempest_plugin/tests/api/admin/base.py index 87cdfe2d9..104c08b42 100644 --- a/watcher_tempest_plugin/tests/api/admin/base.py +++ b/watcher_tempest_plugin/tests/api/admin/base.py @@ -155,7 +155,7 @@ class BaseInfraOptimTest(test.BaseTestCase): # ### AUDITS ### # @classmethod - def create_audit(cls, audit_template_uuid, type='ONESHOT', + def create_audit(cls, audit_template_uuid, audit_type='ONESHOT', state=None, deadline=None): """Wrapper utility for creating a test audit @@ -166,7 +166,7 @@ class BaseInfraOptimTest(test.BaseTestCase): :return: A tuple with The HTTP response and its body """ resp, body = cls.client.create_audit( - audit_template_uuid=audit_template_uuid, type=type, + audit_template_uuid=audit_template_uuid, audit_type=audit_type, state=state, deadline=deadline) cls.created_audits.add(body['uuid']) diff --git a/watcher_tempest_plugin/tests/api/admin/test_audit.py b/watcher_tempest_plugin/tests/api/admin/test_audit.py index 6d7991842..679253095 100644 --- a/watcher_tempest_plugin/tests/api/admin/test_audit.py +++ b/watcher_tempest_plugin/tests/api/admin/test_audit.py @@ -41,7 +41,7 @@ class TestCreateUpdateDeleteAudit(base.BaseInfraOptimTest): audit_params = dict( audit_template_uuid=audit_template['uuid'], - type='ONESHOT', + audit_type='ONESHOT', ) _, body = self.create_audit(**audit_params) @@ -57,7 +57,7 @@ class TestCreateUpdateDeleteAudit(base.BaseInfraOptimTest): audit_params = dict( audit_template_uuid=audit_template['uuid'], - type='CONTINUOUS', + audit_type='CONTINUOUS', ) _, body = self.create_audit(**audit_params) @@ -70,7 +70,7 @@ class TestCreateUpdateDeleteAudit(base.BaseInfraOptimTest): def test_create_audit_with_wrong_audit_template(self): audit_params = dict( audit_template_uuid='INVALID', - type='ONESHOT', + audit_type='ONESHOT', ) self.assertRaises( diff --git a/watcher_tempest_plugin/tests/api/admin/test_audit_template.py b/watcher_tempest_plugin/tests/api/admin/test_audit_template.py index 6b0b2edb5..a882affcc 100644 --- a/watcher_tempest_plugin/tests/api/admin/test_audit_template.py +++ b/watcher_tempest_plugin/tests/api/admin/test_audit_template.py @@ -58,7 +58,7 @@ class TestCreateDeleteAuditTemplate(base.BaseInfraOptimTest): @test.attr(type='smoke') def test_create_audit_template_unicode_description(self): - goal_name = "DUMMY" + goal_name = "dummy" _, goal = self.client.show_goal(goal_name) # Use a unicode string for testing: params = { diff --git a/watcher_tempest_plugin/tests/scenario/base.py b/watcher_tempest_plugin/tests/scenario/base.py index 26df64de0..1484d7889 100644 --- a/watcher_tempest_plugin/tests/scenario/base.py +++ b/watcher_tempest_plugin/tests/scenario/base.py @@ -111,7 +111,7 @@ class BaseInfraOptimScenarioTest(manager.ScenarioTest): # ### AUDITS ### # - def create_audit(self, audit_template_uuid, type='ONESHOT', + def create_audit(self, audit_template_uuid, audit_type='ONESHOT', state=None, deadline=None): """Wrapper utility for creating a test audit @@ -120,7 +120,7 @@ class BaseInfraOptimScenarioTest(manager.ScenarioTest): :return: A tuple with The HTTP response and its body """ resp, body = self.client.create_audit( - audit_template_uuid=audit_template_uuid, type=type, + audit_template_uuid=audit_template_uuid, audit_type=audit_type, state=state, deadline=deadline) self.addCleanup(self.delete_audit, audit_uuid=body["uuid"])