diff --git a/samples/mgmt_driver/kubernetes/kubernetes_mgmt.py b/samples/mgmt_driver/kubernetes/kubernetes_mgmt.py index 6d55b604e..6072daaef 100644 --- a/samples/mgmt_driver/kubernetes/kubernetes_mgmt.py +++ b/samples/mgmt_driver/kubernetes/kubernetes_mgmt.py @@ -719,7 +719,7 @@ class KubernetesMgmtDriver(vnflcm_abstract_driver.VnflcmMgmtAbstractDriver): stderr = result[1] unnecessary_msg = "WARNING! Using --password via the CLI" err_info = ( - [line for line in stderr if not(unnecessary_msg in line)]) + [line for line in stderr if not (unnecessary_msg in line)]) err_msg = ("Failed to login Docker private registry. " "ErrInfo:{}".format(err_info)) LOG.error(err_msg) diff --git a/tacker/api/v1/attributes.py b/tacker/api/v1/attributes.py index eec521ea8..6e7285611 100644 --- a/tacker/api/v1/attributes.py +++ b/tacker/api/v1/attributes.py @@ -291,10 +291,11 @@ def _validate_ip_address_or_none(data, valid_values=None): return _validate_ip_address(data, valid_values) -def _validate_subnet(data, valid_values=None): +def _validate_subnet(data, valid_values=None, expand_partial_value=False): msg = None try: - net = netaddr.IPNetwork(_validate_no_whitespace(data)) + net = netaddr.IPNetwork(_validate_no_whitespace(data), + expand_partial=expand_partial_value) if '/' not in data: msg = _("'%(data)s' isn't a recognized IP subnet cidr," " '%(cidr)s' is recommended") % {"data": data, @@ -308,7 +309,8 @@ def _validate_subnet(data, valid_values=None): return msg -def _validate_subnet_list(data, valid_values=None): +def _validate_subnet_list(data, valid_values=None, + expand_partial_value=False): if not isinstance(data, list): msg = _("'%s' is not a list") % data LOG.debug(msg) @@ -320,15 +322,16 @@ def _validate_subnet_list(data, valid_values=None): return msg for item in data: - msg = _validate_subnet(item) + msg = _validate_subnet(item, valid_values, expand_partial_value) if msg: return msg -def _validate_subnet_or_none(data, valid_values=None): +def _validate_subnet_or_none(data, valid_values=None, + expand_partial_value=False): if data is None: return - return _validate_subnet(data, valid_values) + return _validate_subnet(data, valid_values, expand_partial_value) def _validate_regex(data, valid_values=None): diff --git a/tacker/api/vnflcm/v1/controller.py b/tacker/api/vnflcm/v1/controller.py index 6035276c7..f430bdf13 100644 --- a/tacker/api/vnflcm/v1/controller.py +++ b/tacker/api/vnflcm/v1/controller.py @@ -553,7 +553,7 @@ class VnfLcmController(wsgi.Controller): except nfvo.VimDefaultNotDefined as exc: raise webob.exc.HTTPBadRequest(explanation=str(exc)) - except(sqlexc.SQLAlchemyError, Exception) as exc: + except (sqlexc.SQLAlchemyError, Exception) as exc: raise webob.exc.HTTPInternalServerError( explanation=str(exc)) except webob.exc.HTTPNotFound as e: diff --git a/tacker/auth.py b/tacker/auth.py index e04c62230..4f9021b57 100644 --- a/tacker/auth.py +++ b/tacker/auth.py @@ -516,7 +516,7 @@ class _AuthValidateManager: class AuthValidatorExecution(base.ConfigurableMiddleware): - @ webob.dec.wsgify + @webob.dec.wsgify def __call__(self, req): auth_validator_manager.auth_main(req, self.application) return self.application diff --git a/tacker/conductor/conductor_server.py b/tacker/conductor/conductor_server.py index cf925e925..a115320db 100644 --- a/tacker/conductor/conductor_server.py +++ b/tacker/conductor/conductor_server.py @@ -912,9 +912,9 @@ class Conductor(manager.Manager, v2_hook.ConductorV2Hook): except Exception as ex: # with excutils.save_and_reraise_exception(): - error_msg = "Failed to add additional vnf info to vnf {}. Details -\ - {}".format( - vnf_instance.id, str(ex)) + error_msg = ( + "Failed to add additional vnf info to vnf {}. Details - {}". + format(vnf_instance.id, str(ex))) LOG.error("_add_additional_vnf_info error {}".format(error_msg)) raise exceptions.TackerException(message=error_msg) @@ -1784,7 +1784,7 @@ class Conductor(manager.Manager, v2_hook.ConductorV2Hook): 'href': self._get_vnf_lcm_op_occs_href( vnf_lcm_op_occs_id)}}} - if(operation_state == fields.LcmOccsOperationState.COMPLETED or + if (operation_state == fields.LcmOccsOperationState.COMPLETED or operation_state == fields.LcmOccsOperationState.FAILED_TEMP or operation_state == fields.LcmOccsOperationState.FAILED): affected_resources = vnflcm_utils._get_affected_resources( diff --git a/tacker/context.py b/tacker/context.py index ce9ab5a44..bf21f867b 100644 --- a/tacker/context.py +++ b/tacker/context.py @@ -132,7 +132,7 @@ class ContextBase(oslo_context.RequestContext): return context def can(self, action, target=None, fatal=True): - """Verifies that the given action is valid on the target in this context. + """Verifies that the given action is valid on the target. :param action: string representing the action to be checked. :param target: dictionary representing the object of the action diff --git a/tacker/db/vnfm/vnfm_db.py b/tacker/db/vnfm/vnfm_db.py index bc6a0d407..141de2d9e 100644 --- a/tacker/db/vnfm/vnfm_db.py +++ b/tacker/db/vnfm/vnfm_db.py @@ -273,7 +273,7 @@ class VNFMPluginDb(vnfm.VNFMPluginBase, db_base.CommonDbMixin): "is not permitted. Please contact your " "Administrator.") raise vnfm.VNFDeleteFailed(reason=error_reason) - if(vnf_db.status in [constants.PENDING_UPDATE, + if (vnf_db.status in [constants.PENDING_UPDATE, constants.PENDING_HEAL]): raise vnfm.VNFInUse(vnf_id=vnf_id) return True diff --git a/tacker/hacking/checks.py b/tacker/hacking/checks.py index 00a7e584d..991997571 100644 --- a/tacker/hacking/checks.py +++ b/tacker/hacking/checks.py @@ -37,11 +37,11 @@ log_translation = re.compile( @core.flake8ext -def validate_log_translations(physical_line, logical_line, filename): +def validate_log_translations(logical_line, filename): # Translations are not required in the test directory if "tacker/tests" in filename: return - if pycodestyle.noqa(physical_line): + if pycodestyle.noqa(logical_line): return msg = "N320: Log messages require translations!" if log_translation.match(logical_line): diff --git a/tacker/objects/vnf_lcm_op_occs.py b/tacker/objects/vnf_lcm_op_occs.py index d1e483123..a5c9348b9 100644 --- a/tacker/objects/vnf_lcm_op_occs.py +++ b/tacker/objects/vnf_lcm_op_occs.py @@ -94,7 +94,7 @@ def _make_vnf_lcm_op_occs_list(context, op_occ_list, op_occ_list.objects = [] for db_op_occ in db_op_occ_list: - if(db_op_occ['changed_info'] and + if (db_op_occ['changed_info'] and isinstance(db_op_occ['changed_info'], str)): db_op_occ['changed_info'] = jsonutils.loads( db_op_occ['changed_info']) diff --git a/tacker/tests/functional/common/fake_server.py b/tacker/tests/functional/common/fake_server.py index 8f8dea5b1..86c27623a 100644 --- a/tacker/tests/functional/common/fake_server.py +++ b/tacker/tests/functional/common/fake_server.py @@ -45,7 +45,7 @@ def PrepareRequestHandler(manager): for objChkUrl in func_uri_list: # Check which requested path is in our list. LOG.debug('path for check:%s' % objChkUrl) - if(self.path.startswith(objChkUrl)): + if (self.path.startswith(objChkUrl)): return True return False diff --git a/tacker/tests/functional/sol_kubernetes_v2/test_threshold_prometheus_plugin.py b/tacker/tests/functional/sol_kubernetes_v2/test_threshold_prometheus_plugin.py index 307ccd8cb..9e421ca59 100644 --- a/tacker/tests/functional/sol_kubernetes_v2/test_threshold_prometheus_plugin.py +++ b/tacker/tests/functional/sol_kubernetes_v2/test_threshold_prometheus_plugin.py @@ -48,7 +48,7 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test): response_headers={"Content-Type": "text/plain"}) def test_pm_threshold_autoscaling_min(self): - """Test PM Threshold operations with omitting except for required attributes + """Test PM Threshold operations with omitting except for required attr * About attributes: Omit except for required attributes. diff --git a/tacker/tests/unit/api/v1/test_attributes.py b/tacker/tests/unit/api/v1/test_attributes.py index 303f174ac..b2a316ff7 100644 --- a/tacker/tests/unit/api/v1/test_attributes.py +++ b/tacker/tests/unit/api/v1/test_attributes.py @@ -455,7 +455,9 @@ class TestAttributes(base.BaseTestCase): # Valid - abbreviated ipv4 address cidr = "10/24" - msg = validator(cidr, None) + # Note: It is necessary to specify "expand_partial=True" for "10/24" + # from netaddr 1.3.0. + msg = validator(cidr, None, True) self.assertIsNone(msg) # Invalid - IPv4 missing mask diff --git a/tacker/tests/unit/conductor/test_conductor_server.py b/tacker/tests/unit/conductor/test_conductor_server.py index cf48229e9..8ef42e1c9 100644 --- a/tacker/tests/unit/conductor/test_conductor_server.py +++ b/tacker/tests/unit/conductor/test_conductor_server.py @@ -230,8 +230,8 @@ class TestConductor(SqlTestCase, unit_base.FixturedTestCase): mock_prepare): mock_prepare.return_value = self.cctxt_mock address_information = "http://test.zip" - mock_store.return_value = 'location', 0, 'checksum',\ - 'multihash', 'loc_meta' + mock_store.return_value = ( + 'location', 0, 'checksum', 'multihash', 'loc_meta') self.conductor.upload_vnf_package_from_uri(self.context, self.vnf_package, address_information, diff --git a/tacker/tests/unit/vnflcm/test_sync_resource.py b/tacker/tests/unit/vnflcm/test_sync_resource.py index 905f0714c..1c2f9ed9a 100644 --- a/tacker/tests/unit/vnflcm/test_sync_resource.py +++ b/tacker/tests/unit/vnflcm/test_sync_resource.py @@ -61,8 +61,8 @@ class TestSyncVnfPackage(base.TestCase): mock_glance_store): # glance_store mock Settings - mock_glance_store.return_value = 'location', 0, 'checksum',\ - 'multihash', 'loc_meta' + mock_glance_store.return_value = ( + 'location', 0, 'checksum', 'multihash', 'loc_meta') updates = {'additionalArtifacts': [ { @@ -254,8 +254,8 @@ class TestSyncVnfPackage(base.TestCase): mock_glance_store): # glance_store mock Settings - mock_glance_store.return_value = 'location', 0, 'checksum',\ - 'multihash', 'loc_meta' + mock_glance_store.return_value = ( + 'location', 0, 'checksum', 'multihash', 'loc_meta') # vnf_package mock Settings mock_save_vnf_package.side_effect = Exception @@ -291,8 +291,8 @@ class TestSyncVnfPackage(base.TestCase): mock_glance_store): # glance_store mock Settings - mock_glance_store.return_value = 'location', 0, 'checksum',\ - 'multihash', 'loc_meta' + mock_glance_store.return_value = ( + 'location', 0, 'checksum', 'multihash', 'loc_meta') mock_upload_vnf_package_content.side_effect = Exception # SyncVnfPackage.create_package @@ -327,8 +327,8 @@ class TestSyncVnfPackage(base.TestCase): mock_glance_store): # glance_store mock Settings - mock_glance_store.return_value = 'location', 0, 'checksum',\ - 'multihash', 'loc_meta' + mock_glance_store.return_value = ( + 'location', 0, 'checksum', 'multihash', 'loc_meta') # vnf_package_vnfd mock Settings mock_get_by_id.side_effect = Exception diff --git a/tacker/tests/unit/vnfpkgm/test_controller.py b/tacker/tests/unit/vnfpkgm/test_controller.py index 9480daeff..a0cac4ac1 100644 --- a/tacker/tests/unit/vnfpkgm/test_controller.py +++ b/tacker/tests/unit/vnfpkgm/test_controller.py @@ -735,8 +735,8 @@ class TestController(base.TestCase): vnf_package_obj = objects.VnfPackage(**vnf_package_dict) mock_vnf_by_id.return_value = vnf_package_obj mock_vnf_pack_save.return_value = vnf_package_obj - mock_glance_store.return_value = 'location', 0, 'checksum',\ - 'multihash', 'loc_meta' + mock_glance_store.return_value = ( + 'location', 0, 'checksum', 'multihash', 'loc_meta') req.headers['Content-Type'] = 'application/zip' req.method = 'PUT' req.body = jsonutils.dump_as_bytes({'dummy': {'val': 'foo'}}) diff --git a/tacker/vnfm/infra_drivers/kubernetes/kubernetes_driver.py b/tacker/vnfm/infra_drivers/kubernetes/kubernetes_driver.py index 90e8995dd..01058bbd0 100644 --- a/tacker/vnfm/infra_drivers/kubernetes/kubernetes_driver.py +++ b/tacker/vnfm/infra_drivers/kubernetes/kubernetes_driver.py @@ -1250,13 +1250,13 @@ class Kubernetes(abstract_driver.VnfAbstractDriver, if not additional_params: return False use_helm = additional_params.get('use_helm') - if type(use_helm) == str: + if isinstance(use_helm, str): return use_helm.lower() == 'true' return bool(use_helm) def _is_exthelmchart(self, helm_install_params): exthelmchart = helm_install_params.get('exthelmchart') - if type(exthelmchart) == str: + if isinstance(exthelmchart, str): return exthelmchart.lower() == 'true' return bool(exthelmchart) diff --git a/test-requirements.txt b/test-requirements.txt index c56cde1a6..4a1eca6f1 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.9.0 # Apache-2.0 fixtures>=3.0.0 # Apache-2.0/BSD -hacking>=4.0.0,<4.1.0 # Apache-2.0 +hacking>=7.0.0,<7.1.0 # Apache-2.0 python-subunit>=1.0.0 # Apache-2.0/BSD python-tackerclient>=0.8.0 # Apache-2.0 python-cinderclient>=8.0.0 # Apache-2.0