From 4a2fd6c292b2bcc273eaee3ef797f90ad9eed652 Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Wed, 1 Apr 2020 20:15:00 +0200 Subject: [PATCH] Update hacking for Python3 The repo is Python 3 now, so update hacking to version 3.0 which supports Python 3. Fix problems found by updated hacking version. Update local hacking checks for new flake8. Remove hacking and friends from lower-constraints, they are not needed in installations. Change-Id: If787d610315be6c973b4335e047242c3aa3caf2a --- lower-constraints.txt | 4 -- tacker/api/v1/attributes.py | 4 +- tacker/api/v1/base.py | 17 +++---- tacker/common/config.py | 2 + tacker/common/utils.py | 4 +- ...000632983ada_add_template_source_column.py | 2 + ...ce1c18_create_of_network_service_tables.py | 2 + .../0ae5b1ce3024_unique_constraint_name.py | 2 + .../versions/12a57080b277_add_service_db.py | 2 + .../versions/12a57080b278_alter_devices.py | 2 + .../13c0e0661015_add_descrition_to_vnf.py | 2 + ...dd6f7f_change_nullable_value_of_path_id.py | 2 + .../1c6b0d82afcd_servicevm_framework.py | 2 + .../22f5385a3d3f_add_status_to_vims.py | 2 + .../versions/22f5385a3d4f_remove_proxydb.py | 2 + .../versions/22f5385a3d50_rename_devicedb.py | 2 + ...5f211c7_alter_value_in_deviceattributes.py | 2 + .../2774a42c7163_remove_service_related.py | 2 + .../versions/2ff0a0e360f1_audit_support.py | 2 + ...299_change_vim_shared_property_to_false.py | 2 + ...e64ba129_set_mandatory_columns_not_null.py | 2 + ...26b9c6_add_support_vnffg_to_ns_database.py | 2 + .../4ee19c8a6d0a_audit_support_events.py | 2 + .../versions/507122918800_adds_vnffg.py | 2 + .../versions/5246a6bd410f_multisite_vim.py | 2 + .../5958429bcb3c_modify_datatype_of_value.py | 2 + .../5d490546290c_add_name_to_classifiers.py | 2 + ...6b35c7_make_vnfd_vnf_vim_name_mandatory.py | 2 + .../versions/81ffa86020d_rpc_proxy.py | 2 + ...8f7145914cb0_remove_infra_driver_column.py | 2 + .../941b5a6fff9e_enable_soft_delete.py | 2 + ...8392888_add_unique_key_vnf_package_vnfd.py | 4 +- .../versions/985e28392890_add_vnflcm_db.py | 2 + .../versions/9d425296f2c3_add_vnfpkgm_db.py | 2 + ...ue_constraint_on_vnf_packages_user_data.py | 2 +- ...acf941e54075_add_error_reason_to_device.py | 2 + ...bb8654_set_status_type_tenant_id_length.py | 2 + ...8ed37c_unique_constraint_on_name_and_id.py | 2 + .../c7cde2f45f82_set_description_to_text.py | 2 + ...d04a8335c18_mgmt_url_to_mgmt_ip_address.py | 2 + .../d4f265e8eb9d_add_default_to_vim.py | 2 + ...af1_add_unique_constraint_on_deleted_at.py | 2 + .../e8918cda6433_add_attributes_to_vnffg.py | 2 + ..._source_status_to_vnffgtemplate_and_nsd.py | 2 + ...7_add_default_onboarded_template_source.py | 2 + ...b0f6b4_set_default_value_for_deleted_at.py | 2 + .../versions/f958f58e5daa_uuid_consistency.py | 6 ++- tacker/db/vnfm/vnfm_db.py | 14 +++--- tacker/glance_store/store.py | 2 +- tacker/hacking/checks.py | 12 +++-- tacker/keymgr/barbican_key_manager.py | 8 ++-- tacker/nfvo/drivers/vim/openstack_driver.py | 44 +++++++++---------- .../drivers/workflow/workflow_generator.py | 2 - tacker/nfvo/nfvo_plugin.py | 2 +- tacker/objects/vnf_package.py | 3 +- tacker/objects/vnf_software_image.py | 2 +- tacker/policy.py | 2 +- tacker/tests/common/helpers.py | 1 + tacker/tests/functional/base.py | 12 ++--- tacker/tests/functional/nfvo/test_nfvo.py | 24 +++++----- tacker/tests/unit/api/test_extensions.py | 20 ++++----- tacker/tests/unit/api/v2/test_api_v2.py | 24 +++++----- tacker/tests/unit/db/utils.py | 35 +-------------- tacker/tests/unit/objects/fakes.py | 1 + tacker/tests/unit/test_wsgi.py | 2 +- tacker/tosca/utils.py | 20 ++++----- .../vnfm/infra_drivers/openstack/openstack.py | 10 ++--- tacker/vnfm/monitor.py | 7 ++- .../monitor_drivers/ceilometer/ceilometer.py | 1 + tacker/vnfm/monitor_drivers/zabbix/zabbix.py | 16 +++---- tacker/vnfm/vim_client.py | 2 +- tacker/wsgi.py | 3 +- test-requirements.txt | 2 +- tox.ini | 10 ++++- 74 files changed, 227 insertions(+), 175 deletions(-) diff --git a/lower-constraints.txt b/lower-constraints.txt index 12ba20200..223383722 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -30,13 +30,11 @@ eventlet==0.22.0 extras==1.0.0 fasteners==0.14.1 fixtures==3.0.0 -flake8==2.5.5 future==0.16.0 futurist==1.6.0 glance-store==0.26.1 google-auth==1.4.1 greenlet==0.4.13 -hacking==0.12.0 heat-translator==2.0.0 idna==2.6 imagesize==1.0.0 @@ -92,7 +90,6 @@ paramiko==2.0.0 Paste==2.0.2 PasteDeploy==1.5.0 pbr==2.0.0 -pep8==1.5.7 pkg-resources==0.0.0 prettytable==0.7.2 psutil==5.4.3 @@ -100,7 +97,6 @@ pyasn1-modules==0.2.1 pyasn1==0.4.2 pycadf==2.7.0 pycparser==2.18 -pyflakes==0.8.1 Pygments==2.2.0 pyinotify==0.9.6 PyNaCl==1.2.1 diff --git a/tacker/api/v1/attributes.py b/tacker/api/v1/attributes.py index 148b362f8..fa3af273a 100644 --- a/tacker/api/v1/attributes.py +++ b/tacker/api/v1/attributes.py @@ -545,8 +545,8 @@ def convert_to_list(data): return [data] -HOSTNAME_PATTERN = ("(?=^.{1,254}$)(^(?:(?!\d+\.|-)[a-zA-Z0-9_\-]" - "{1,63}(?'.format(node), 'break-on': '<% $.status_{0} = "ERROR"' ' %>'.format(node), 'continue-on': '<% $.status_{0} = "PENDING_CREATE" ' diff --git a/tacker/nfvo/nfvo_plugin.py b/tacker/nfvo/nfvo_plugin.py index 636cb2b9a..cf99af104 100644 --- a/tacker/nfvo/nfvo_plugin.py +++ b/tacker/nfvo/nfvo_plugin.py @@ -580,7 +580,7 @@ class NfvoPlugin(nfvo_db_plugin.NfvoPluginDb, vnffg_db.VnffgPluginDbMixin, LOG.debug('Attempting to open key file for vim id %s', vim_id) try: with open(key_file, 'r') as f: - return f.read() + return f.read() except Exception: LOG.warning('VIM id invalid or key not found for %s', vim_id) raise nfvo.VimKeyNotFoundException(vim_id=vim_id) diff --git a/tacker/objects/vnf_package.py b/tacker/objects/vnf_package.py index 153bb0a65..f3b8f22ab 100644 --- a/tacker/objects/vnf_package.py +++ b/tacker/objects/vnf_package.py @@ -69,7 +69,8 @@ def _add_user_defined_data(context, package_uuid, user_data, def _vnf_package_user_data_get_query(context, package_uuid, model): - return api.model_query(context, model, read_deleted="no", project_only=True).\ + return api.model_query(context, model, read_deleted="no", + project_only=True).\ filter_by(package_uuid=package_uuid) diff --git a/tacker/objects/vnf_software_image.py b/tacker/objects/vnf_software_image.py index 78c187626..8dea9b62d 100644 --- a/tacker/objects/vnf_software_image.py +++ b/tacker/objects/vnf_software_image.py @@ -207,7 +207,7 @@ class VnfSoftwareImage(base.TackerObject, base.TackerPersistentObject): for field in self.fields: if field in software_image and field not in self: - setattr(self, field, getattr(software_image, field)) + setattr(self, field, getattr(software_image, field)) @base.remotable def create(self): diff --git a/tacker/policy.py b/tacker/policy.py index c5cfb4305..1435440ad 100644 --- a/tacker/policy.py +++ b/tacker/policy.py @@ -316,7 +316,7 @@ class FieldCheck(policy.Check): attr = attributes.RESOURCE_ATTRIBUTE_MAP[resource][field] conv_func = attr['convert_to'] except KeyError: - conv_func = lambda x: x + conv_func = lambda x: x # noqa: E731 self.field = field self.value = conv_func(value) diff --git a/tacker/tests/common/helpers.py b/tacker/tests/common/helpers.py index fb705ac3b..4728d758d 100644 --- a/tacker/tests/common/helpers.py +++ b/tacker/tests/common/helpers.py @@ -26,6 +26,7 @@ def requires_py2(testcase): def requires_py3(testcase): return testtools.skipUnless(six.PY3, "requires python 3.x")(testcase) + if sys.version_info < (3,): def compact_byte(x): return x diff --git a/tacker/tests/functional/base.py b/tacker/tests/functional/base.py index 91dd159eb..b79830f64 100644 --- a/tacker/tests/functional/base.py +++ b/tacker/tests/functional/base.py @@ -196,12 +196,12 @@ class BaseTackerTest(base.BaseTestCase): sleep_interval): start_time = int(time.time()) while True: - vnf_result = self.client.show_vnf(vnf_id) - status = vnf_result['vnf']['status'] - if (status == target_status) or ( - (int(time.time()) - start_time) > timeout): - break - time.sleep(sleep_interval) + vnf_result = self.client.show_vnf(vnf_id) + status = vnf_result['vnf']['status'] + if (status == target_status) or ( + (int(time.time()) - start_time) > timeout): + break + time.sleep(sleep_interval) self.assertEqual(status, target_status, "vnf %(vnf_id)s with status %(status)s is" diff --git a/tacker/tests/functional/nfvo/test_nfvo.py b/tacker/tests/functional/nfvo/test_nfvo.py index b9f4989c1..b7650ee95 100644 --- a/tacker/tests/functional/nfvo/test_nfvo.py +++ b/tacker/tests/functional/nfvo/test_nfvo.py @@ -54,7 +54,7 @@ class NsdTestCreate(base.BaseTackerTest): try: self.client.delete_nsd(nsd_id) except Exception: - assert False, "nsd Delete failed" + assert False, "nsd Delete failed" def _test_delete_vnfd(self, vnfd_id, timeout=constants.NS_DELETE_TIMEOUT): start_time = int(time.time()) @@ -76,12 +76,12 @@ class NsdTestCreate(base.BaseTackerTest): sleep_interval): start_time = int(time.time()) while True: - ns_result = self.client.show_ns(ns_id) - status = ns_result['ns']['status'] - if (status == target_status) or ( - (int(time.time()) - start_time) > timeout): - break - time.sleep(sleep_interval) + ns_result = self.client.show_ns(ns_id) + status = ns_result['ns']['status'] + if (status == target_status) or ( + (int(time.time()) - start_time) > timeout): + break + time.sleep(sleep_interval) self.assertEqual(status, target_status, "ns %(ns_id)s with status %(status)s is" @@ -222,11 +222,11 @@ class NsdTestCreate(base.BaseTackerTest): timeout=60, sleep_interval=2): start_time = int(time.time()) while True: - server_info = self.novaclient().servers.get(server_id) - if (server_info.status == target_status) or ( - (int(time.time()) - start_time) > timeout): - break - time.sleep(sleep_interval) + server_info = self.novaclient().servers.get(server_id) + if (server_info.status == target_status) or ( + (int(time.time()) - start_time) > timeout): + break + time.sleep(sleep_interval) def test_create_delete_ns_vnffg(self): net = self.neutronclient().list_networks() diff --git a/tacker/tests/unit/api/test_extensions.py b/tacker/tests/unit/api/test_extensions.py index fa64fb578..40cd08342 100644 --- a/tacker/tests/unit/api/test_extensions.py +++ b/tacker/tests/unit/api/test_extensions.py @@ -106,20 +106,20 @@ class ResourceExtensionTest(base.BaseTestCase): return {'collection': 'value'} class DummySvcPlugin(wsgi.Controller): - def get_plugin_type(self): - return constants.DUMMY + def get_plugin_type(self): + return constants.DUMMY - def index(self, request, **kwargs): - return "resource index" + def index(self, request, **kwargs): + return "resource index" - def custom_member_action(self, request, **kwargs): - return {'member_action': 'value'} + def custom_member_action(self, request, **kwargs): + return {'member_action': 'value'} - def collection_action(self, request, **kwargs): - return {'collection': 'value'} + def collection_action(self, request, **kwargs): + return {'collection': 'value'} - def show(self, request, id): - return {'data': {'id': id}} + def show(self, request, id): + return {'data': {'id': id}} def test_exceptions_notimplemented(self): controller = self.ResourceExtensionController() diff --git a/tacker/tests/unit/api/v2/test_api_v2.py b/tacker/tests/unit/api/v2/test_api_v2.py index 9e9391a06..0b1c4d98d 100644 --- a/tacker/tests/unit/api/v2/test_api_v2.py +++ b/tacker/tests/unit/api/v2/test_api_v2.py @@ -1359,22 +1359,22 @@ class ExtensionTestCase(base.BaseTestCase): class TestSubresourcePlugin(object): - def get_network_dummies(self, context, network_id, - filters=None, fields=None): - return [] + def get_network_dummies(self, context, network_id, + filters=None, fields=None): + return [] - def get_network_dummy(self, context, id, network_id, - fields=None): - return {} + def get_network_dummy(self, context, id, network_id, + fields=None): + return {} - def create_network_dummy(self, context, network_id, dummy): - return {} + def create_network_dummy(self, context, network_id, dummy): + return {} - def update_network_dummy(self, context, id, network_id, dummy): - return {} + def update_network_dummy(self, context, id, network_id, dummy): + return {} - def delete_network_dummy(self, context, id, network_id): - return + def delete_network_dummy(self, context, id, network_id): + return class ListArgsTestCase(base.BaseTestCase): diff --git a/tacker/tests/unit/db/utils.py b/tacker/tests/unit/db/utils.py index de84d08cc..728dcbd10 100644 --- a/tacker/tests/unit/db/utils.py +++ b/tacker/tests/unit/db/utils.py @@ -29,6 +29,7 @@ def _get_template(name): f = codecs.open(filename, encoding='utf-8', errors='strict') return f.read() + tosca_cvnf_vnfd = _get_template('test_tosca_cvnf.yaml') tosca_vnfd_openwrt = _get_template('test_tosca_openwrt.yaml') tosca_vnfd_openwrt_param = _get_template('test_tosca_openwrt_param.yaml') @@ -164,24 +165,6 @@ def get_dummy_vnf_invalid_param_type_obj(): return {'vnf': {u'attributes': {u'param_values': 'dummy_param'}}} -def get_dummy_vnf_invalid_config_type_obj(): - return {'vnf': {u'attributes': {u'config': 'dummy_config'}}} - - -def get_dummy_vnf_invalid_param_content(): - return {'vnf': {u'attributes': {u'param_values': {}}}} - - -def get_dummy_vnf_param_obj(): - return {'vnf': {u'attributes': {u'param_values': - {'flavor': 'm1.tiny', - 'reservation_id': '99999999-3925-4c9e-9074-239a902b68d7'}}}} - - -def get_dummy_vnf_invalid_param_type_obj(): - return {'vnf': {u'attributes': {u'param_values': 'dummy_param'}}} - - def get_dummy_vnf(status='PENDING_CREATE', scaling_group=False, instance_id=None): dummy_vnf = {'status': status, 'instance_id': instance_id, 'name': @@ -264,22 +247,6 @@ def get_dummy_vnf_update_empty_param(): return {'vnf': {'attributes': {'param_values': {}}}} -def get_dummy_vnf_update_param(): - return {'vnf': {'attributes': {'param_values': update_param_data}}} - - -def get_dummy_vnf_update_new_param(): - return {'vnf': {'attributes': {'param_values': update_new_param_data}}} - - -def get_dummy_vnf_update_invalid_param(): - return {'vnf': {'attributes': {'param_values': update_invalid_param_data}}} - - -def get_dummy_vnf_update_empty_param(): - return {'vnf': {'attributes': {'param_values': {}}}} - - def get_vim_obj(): return {'vim': {'type': 'openstack', 'auth_url': 'http://localhost/identity', diff --git a/tacker/tests/unit/objects/fakes.py b/tacker/tests/unit/objects/fakes.py index 783bd9bd1..9b960bca3 100644 --- a/tacker/tests/unit/objects/fakes.py +++ b/tacker/tests/unit/objects/fakes.py @@ -284,6 +284,7 @@ def get_instantiated_vnf_info(): } return instantiated_vnf_info + instantiated_vnf_info = { 'ext_cp_info': [vnf_ext_cp_info], 'flavour_id': uuidsentinel.flavour_id, diff --git a/tacker/tests/unit/test_wsgi.py b/tacker/tests/unit/test_wsgi.py index be679f0a8..5923a8b5a 100644 --- a/tacker/tests/unit/test_wsgi.py +++ b/tacker/tests/unit/test_wsgi.py @@ -567,7 +567,7 @@ class ResourceTest(base.BaseTestCase): @staticmethod def my_fault_body_function(): - return 'off' + return 'off' class Controller(object): def index(self, request, index=None): diff --git a/tacker/tosca/utils.py b/tacker/tosca/utils.py index c2aa84263..56d5708ac 100644 --- a/tacker/tosca/utils.py +++ b/tacker/tosca/utils.py @@ -349,7 +349,7 @@ def get_volumes(template): for prop_name, prop_value in block_properties.items(): if prop_name == 'size': prop_value = \ - re.compile('(\d+)\s*(\w+)').match(prop_value).groups()[0] + re.compile(r'(\d+)\s*(\w+)').match(prop_value).groups()[0] volume_dict[node_name][prop_name] = prop_value del node_tpl[node_name] return volume_dict @@ -447,14 +447,14 @@ def convert_unsupported_res_prop(heat_dict, unsupported_res_prop): unsupported_prop = set(prop_dict.keys()) & set( unsupported_prop_dict.keys()) for prop in unsupported_prop: - # some properties are just punted to 'value_specs' - # property if they are incompatible - new_prop = unsupported_prop_dict[prop] - if new_prop == 'value_specs': - prop_dict.setdefault(new_prop, {})[ - prop] = prop_dict.pop(prop) - else: - prop_dict[new_prop] = prop_dict.pop(prop) + # some properties are just punted to 'value_specs' + # property if they are incompatible + new_prop = unsupported_prop_dict[prop] + if new_prop == 'value_specs': + prop_dict.setdefault(new_prop, {})[ + prop] = prop_dict.pop(prop) + else: + prop_dict[new_prop] = prop_dict.pop(prop) @log.log @@ -1145,7 +1145,7 @@ def get_resources_dict(template, flavor_extra_input=None): res_dict = dict() for res, method in (OS_RESOURCES).items(): res_method = getattr(sys.modules[__name__], method) - if res is 'flavor': + if res == 'flavor': res_dict[res] = res_method(template, flavor_extra_input) else: res_dict[res] = res_method(template) diff --git a/tacker/vnfm/infra_drivers/openstack/openstack.py b/tacker/vnfm/infra_drivers/openstack/openstack.py index ca48afbf5..81807c780 100644 --- a/tacker/vnfm/infra_drivers/openstack/openstack.py +++ b/tacker/vnfm/infra_drivers/openstack/openstack.py @@ -799,7 +799,7 @@ class OpenStack(abstract_driver.VnfAbstractDriver, for vnf_vl_resource_info in vnf_virtual_link_resource_info: if (vnf_vl_resource_info.vnf_virtual_link_desc_id != vnf_virtual_link_desc_id): - continue + continue vl_resource_data = pop_resources.pop( vnf_virtual_link_desc_id, None) @@ -886,7 +886,7 @@ class OpenStack(abstract_driver.VnfAbstractDriver, for vnf_vl_resource_info in vnf_virtual_link_resource_info: if (vnf_vl_resource_info.vnf_virtual_link_desc_id != ext_managed_vl_info.vnf_virtual_link_desc_id): - continue + continue for vl_port in vnf_vl_resource_info.vnf_link_ports: _update_link_port(vl_port) @@ -982,9 +982,9 @@ class OpenStack(abstract_driver.VnfAbstractDriver, for resource in vdu_resources: for stack_uuid, resources in stack_resources.items(): res_details = resources.get(resource['resource_name']) - if res_details and res_details['physical_resource_id'] == \ - resource['physical_resource_id']: - yield stack_uuid, resource['resource_name'] + if (res_details and res_details['physical_resource_id'] == + resource['physical_resource_id']): + yield stack_uuid, resource['resource_name'] def _resource_mark_unhealthy(): vnfc_resources = self._get_vnfc_resources_from_heal_request( diff --git a/tacker/vnfm/monitor.py b/tacker/vnfm/monitor.py index 2b9b5dfb4..2363806b3 100644 --- a/tacker/vnfm/monitor.py +++ b/tacker/vnfm/monitor.py @@ -174,10 +174,9 @@ class VNFMonitor(object): vdu_delay = params.get('monitoring_delay', vnf_delay) - if not timeutils.is_older_than( - hosting_vnf['boot_at'], - vdu_delay): - continue + if not timeutils.is_older_than(hosting_vnf['boot_at'], + vdu_delay): + continue actions = policy[driver].get('actions', {}) params['mgmt_ip'] = mgmt_ips[vdu] diff --git a/tacker/vnfm/monitor_drivers/ceilometer/ceilometer.py b/tacker/vnfm/monitor_drivers/ceilometer/ceilometer.py index 32bfd8ff1..2e91eef0a 100644 --- a/tacker/vnfm/monitor_drivers/ceilometer/ceilometer.py +++ b/tacker/vnfm/monitor_drivers/ceilometer/ceilometer.py @@ -37,6 +37,7 @@ cfg.CONF.register_opts(OPTS, group='ceilometer') def config_opts(): return [('ceilometer', OPTS)] + ALARM_INFO = ( ALARM_ACTIONS, OK_ACTIONS, REPEAT_ACTIONS, ALARM, INSUFFICIENT_DATA_ACTIONS, DESCRIPTION, ENABLED, TIME_CONSTRAINTS, diff --git a/tacker/vnfm/monitor_drivers/zabbix/zabbix.py b/tacker/vnfm/monitor_drivers/zabbix/zabbix.py index 9b1ce17e5..88ff03e2c 100644 --- a/tacker/vnfm/monitor_drivers/zabbix/zabbix.py +++ b/tacker/vnfm/monitor_drivers/zabbix/zabbix.py @@ -90,14 +90,14 @@ class VNFMonitorZabbix(abstract_driver.VNFMonitorAbstractDriver): LOG.error('Cannot request error : %s', response['error']['data']) def create_graph(self, itemid, name, nodename): - temp_graph_api = copy.deepcopy(zapi.dGRAPH_CREATE_API) - gitems = [{'itemid': itemid, 'color': '00AA00'}] - temp_graph_api['auth'] = \ - self.hostinfo[nodename]['zbx_info']['zabbix_token'] - temp_graph_api['params']['gitems'] = gitems - temp_graph_api['params']['name'] = name - response = self.send_post(temp_graph_api) - VNFMonitorZabbix.check_error(response) + temp_graph_api = copy.deepcopy(zapi.dGRAPH_CREATE_API) + gitems = [{'itemid': itemid, 'color': '00AA00'}] + temp_graph_api['auth'] = \ + self.hostinfo[nodename]['zbx_info']['zabbix_token'] + temp_graph_api['params']['gitems'] = gitems + temp_graph_api['params']['name'] = name + response = self.send_post(temp_graph_api) + VNFMonitorZabbix.check_error(response) def create_action(self): for vdu in self.vduname: diff --git a/tacker/vnfm/vim_client.py b/tacker/vnfm/vim_client.py index 8573c184d..4cb4ea475 100644 --- a/tacker/vnfm/vim_client.py +++ b/tacker/vnfm/vim_client.py @@ -131,7 +131,7 @@ class VimClient(object): LOG.debug('Attempting to open key file for vim id %s', vim_id) try: with open(key_file, 'r') as f: - return f.read() + return f.read() except Exception: LOG.warning('VIM id invalid or key not found for %s', vim_id) raise nfvo.VimKeyNotFoundException(vim_id=vim_id) diff --git a/tacker/wsgi.py b/tacker/wsgi.py index 9209ae9a6..9cf9c751c 100644 --- a/tacker/wsgi.py +++ b/tacker/wsgi.py @@ -83,6 +83,7 @@ CONF.register_opts(socket_opts) def config_opts(): return [(None, socket_opts)] + LOG = logging.getLogger(__name__) @@ -1038,7 +1039,7 @@ class Resource(Application): action_result = self.dispatch(request, action, args) except Fault as ex: response = ex - except Exception as ex: + except Exception: raise Fault(webob.exc.HTTPInternalServerError()) if not response: diff --git a/test-requirements.txt b/test-requirements.txt index e4547ccee..7a6111811 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -8,7 +8,7 @@ coverage!=4.4,>=4.0 # Apache-2.0 ddt>=1.0.1 # MIT doc8>=0.6.0 # Apache-2.0 fixtures>=3.0.0 # Apache-2.0/BSD -hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0 +hacking>=3.0,<3.1.0 # Apache-2.0 mock>=3.0.0 # BSD python-subunit>=1.0.0 # Apache-2.0/BSD python-tackerclient>=0.8.0 # Apache-2.0 diff --git a/tox.ini b/tox.ini index 60e7f343a..5ebf2118e 100644 --- a/tox.ini +++ b/tox.ini @@ -85,14 +85,20 @@ commands = {posargs} [flake8] # E128 continuation line under-indented for visual indent # N320 log messages does not translate -ignore = E128,N320 +# W503 line break before binary operator +# W504 line break after binary operator +ignore = E128,N320,W503,W504 show-source = true builtins = _ exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools,.ropeproject [hacking] import_exceptions = tacker._i18n -local-check-factory = tacker.hacking.checks.factory + +[flake8:local-plugins] +extension = + N320 = checks:validate_log_translations +paths = ./tacker/hacking [testenv:config-gen] commands =