diff --git a/nfv/nfv-client/nfv_client/openstack/openstack.py b/nfv/nfv-client/nfv_client/openstack/openstack.py index fbdb4e60..bb22ead4 100755 --- a/nfv/nfv-client/nfv_client/openstack/openstack.py +++ b/nfv/nfv-client/nfv_client/openstack/openstack.py @@ -33,7 +33,8 @@ def get_token(auth_uri, project_name, project_domain_name, username, password, Ask OpenStack for a token """ try: - request_url = urllib.request.urlopen(auth_uri) + # handle auth_uri re-direct (300) + urllib.request.urlopen(auth_uri) except urllib.error.HTTPError as e: if e.code == 300: auth_uri = e.headers['location'] diff --git a/nfv/nfv-client/nfv_client/shell.py b/nfv/nfv-client/nfv_client/shell.py index 0dc96f3a..9cf3d4e2 100755 --- a/nfv/nfv-client/nfv_client/shell.py +++ b/nfv/nfv-client/nfv_client/shell.py @@ -210,7 +210,7 @@ def setup_fw_update_parser(commands): # define the create command # alarm restrictions, defaults to strict - create_strategy_cmd = setup_create_cmd( + _ = setup_create_cmd( sub_cmds, [sw_update.APPLY_TYPE_IGNORE], # controller supports ignore [sw_update.APPLY_TYPE_IGNORE], # storage supports ignore @@ -227,13 +227,13 @@ def setup_fw_update_parser(commands): # There are no additional create options for firmware update # define the delete command - delete_strategy_cmd = setup_delete_cmd(sub_cmds) + _ = setup_delete_cmd(sub_cmds) # define the apply command - apply_strategy_cmd = setup_apply_cmd(sub_cmds) + _ = setup_apply_cmd(sub_cmds) # define the abort command - abort_strategy_cmd = setup_abort_cmd(sub_cmds) + _ = setup_abort_cmd(sub_cmds) # define the show command - show_strategy_cmd = setup_show_cmd(sub_cmds) + _ = setup_show_cmd(sub_cmds) def setup_kube_rootca_update_parser(commands): @@ -283,13 +283,13 @@ def setup_kube_rootca_update_parser(commands): help='Path to a file to be used, otherwise system will generate one') # define the delete command - delete_strategy_cmd = setup_delete_cmd(sub_cmds) + _ = setup_delete_cmd(sub_cmds) # define the apply command - apply_strategy_cmd = setup_apply_cmd(sub_cmds) + _ = setup_apply_cmd(sub_cmds) # define the abort command - abort_strategy_cmd = setup_abort_cmd(sub_cmds) + _ = setup_abort_cmd(sub_cmds) # define the show command - show_strategy_cmd = setup_show_cmd(sub_cmds) + _ = setup_show_cmd(sub_cmds) def setup_kube_upgrade_parser(commands): @@ -332,13 +332,13 @@ def setup_kube_upgrade_parser(commands): help='The kubernetes version') # define the delete command - delete_strategy_cmd = setup_delete_cmd(sub_cmds) + _ = setup_delete_cmd(sub_cmds) # define the apply command - apply_strategy_cmd = setup_apply_cmd(sub_cmds) + _ = setup_apply_cmd(sub_cmds) # define the abort command - abort_strategy_cmd = setup_abort_cmd(sub_cmds) + _ = setup_abort_cmd(sub_cmds) # define the show command - show_strategy_cmd = setup_show_cmd(sub_cmds) + _ = setup_show_cmd(sub_cmds) def setup_patch_parser(commands): @@ -356,7 +356,7 @@ def setup_patch_parser(commands): # define the create command # alarm restrictions, defaults to strict - create_strategy_cmd = setup_create_cmd( + _ = setup_create_cmd( sub_cmds, [sw_update.APPLY_TYPE_SERIAL, # controller supports serial sw_update.APPLY_TYPE_IGNORE], @@ -375,13 +375,13 @@ def setup_patch_parser(commands): ) # define the delete command - delete_strategy_cmd = setup_delete_cmd(sub_cmds) + _ = setup_delete_cmd(sub_cmds) # define the apply command - apply_strategy_cmd = setup_apply_cmd(sub_cmds) + _ = setup_apply_cmd(sub_cmds) # define the abort command - abort_strategy_cmd = setup_abort_cmd(sub_cmds) + _ = setup_abort_cmd(sub_cmds) # define the show command - show_strategy_cmd = setup_show_cmd(sub_cmds) + _ = setup_show_cmd(sub_cmds) def setup_upgrade_parser(commands): @@ -428,13 +428,13 @@ def setup_upgrade_parser(commands): help=argparse.SUPPRESS) # define the delete command - delete_strategy_cmd = setup_delete_cmd(sub_cmds) + _ = setup_delete_cmd(sub_cmds) # define the apply command - apply_strategy_cmd = setup_apply_cmd(sub_cmds) + _ = setup_apply_cmd(sub_cmds) # define the abort command - abort_strategy_cmd = setup_abort_cmd(sub_cmds) + _ = setup_abort_cmd(sub_cmds) # define the show command - show_strategy_cmd = setup_show_cmd(sub_cmds) + _ = setup_show_cmd(sub_cmds) def process_main(argv=sys.argv[1:]): # pylint: disable=dangerous-default-value diff --git a/nfv/nfv-plugins/nfv_plugins/event_log_handlers/fm.py b/nfv/nfv-plugins/nfv_plugins/event_log_handlers/fm.py index 802918cd..27241f67 100755 --- a/nfv/nfv-plugins/nfv_plugins/event_log_handlers/fm.py +++ b/nfv/nfv-plugins/nfv_plugins/event_log_handlers/fm.py @@ -462,7 +462,6 @@ class EventLogManagement(event_log_handlers_v1.EventLogHandler): fm_probable_cause = fm_constants.ALARM_PROBABLE_CAUSE_65 fm_event_state = fm_constants.FM_ALARM_STATE_MSG fm_severity = _fm_event_importance_mapping[log_data.importance] - fm_uuid = None fm_reason_text = six.text_type(log_data.reason_text) format_log = fm_api.Fault(fm_event_id, fm_event_state, log_data.entity_type, log_data.entity, diff --git a/nfv/nfv-plugins/nfv_plugins/nfvi_plugins/nfvi_infrastructure_api.py b/nfv/nfv-plugins/nfv_plugins/nfvi_plugins/nfvi_infrastructure_api.py index 6158b8b6..eaa4f6cb 100755 --- a/nfv/nfv-plugins/nfv_plugins/nfvi_plugins/nfvi_infrastructure_api.py +++ b/nfv/nfv-plugins/nfv_plugins/nfvi_plugins/nfvi_infrastructure_api.py @@ -1365,7 +1365,9 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): future.work(sysinv.get_kube_host_upgrades, self._platform_token) future.result = (yield) if not future.result.is_complete(): - DLOG.error("Sysinv Get Kube Host Upgrades did not complete.") + error_string = "{} did not complete".format(activity) + DLOG.error(error_string) + response['reason'] = error_string return kube_host_upgrade_list = future.result.data["kube_host_upgrades"] diff --git a/nfv/nfv-plugins/nfv_plugins/nfvi_plugins/openstack/neutron.py b/nfv/nfv-plugins/nfv_plugins/nfvi_plugins/openstack/neutron.py index 2f3c699e..52aa9af0 100644 --- a/nfv/nfv-plugins/nfv_plugins/nfvi_plugins/openstack/neutron.py +++ b/nfv/nfv-plugins/nfv_plugins/nfvi_plugins/openstack/neutron.py @@ -590,7 +590,7 @@ def delete_network_agents(token, host_name): if (agent['host'] == host_name and agent['agent_type'] in supported_agents): api_cmd = url + "/v2.0/agents/%s" % agent['id'] - response = rest_api_request(token, "DELETE", api_cmd, + rest_api_request(token, "DELETE", api_cmd, api_cmd_headers) num_agents_found = num_agents_found + 1 diff --git a/nfv/nfv-tests/nfv_unit_tests/tests/test_dhcp_network_rebalance_randomized.py b/nfv/nfv-tests/nfv_unit_tests/tests/test_dhcp_network_rebalance_randomized.py index 4c0f5d91..e26d271a 100644 --- a/nfv/nfv-tests/nfv_unit_tests/tests/test_dhcp_network_rebalance_randomized.py +++ b/nfv/nfv-tests/nfv_unit_tests/tests/test_dhcp_network_rebalance_randomized.py @@ -66,7 +66,6 @@ def build_get_dhcp_agent_networks_response(agent_id, get_dhcp_agent_networks_response['result-data'] = list() for x in range(0, random.randint(0, MAX_NETWORKS - 1)): - host_name = "compute-" + str(x) net_idx = 0 net = "physnet0" if use_strange_networks: diff --git a/nfv/nfv-tests/nfv_unit_tests/tests/test_fw_update_strategy.py b/nfv/nfv-tests/nfv_unit_tests/tests/test_fw_update_strategy.py index 65ac0df7..7b7b15e1 100755 --- a/nfv/nfv-tests/nfv_unit_tests/tests/test_fw_update_strategy.py +++ b/nfv/nfv-tests/nfv_unit_tests/tests/test_fw_update_strategy.py @@ -1988,7 +1988,6 @@ class TestFwUpdateStrategy(sw_update_testcase.SwUpdateStrategyTestCase): default_instance_action=SW_UPDATE_INSTANCE_ACTION.STOP_START, max_parallel_worker_hosts=10) - fw_update_controller_host_list = [] fw_update_worker_host_list = [] for host in list(self._host_table.values()): if host._nfvi_host.admin_state == nfvi.objects.v1.HOST_ADMIN_STATE.UNLOCKED: diff --git a/nfv/nfv-tests/nfv_unit_tests/tests/test_network_rebalance_randomized.py b/nfv/nfv-tests/nfv_unit_tests/tests/test_network_rebalance_randomized.py index c081ae78..56c05a70 100644 --- a/nfv/nfv-tests/nfv_unit_tests/tests/test_network_rebalance_randomized.py +++ b/nfv/nfv-tests/nfv_unit_tests/tests/test_network_rebalance_randomized.py @@ -71,7 +71,6 @@ def build_get_agent_routers_response(agent_id): get_agent_routers_response['result-data'] = list() for x in range(0, random.randint(0, MAX_ROUTERS - 1)): - host_name = "compute-" + str(x) get_agent_routers_response_entry = \ {"id": agent_id + "_router_" + str(x)} get_agent_routers_response['result-data'].append( diff --git a/nfv/nfv-tests/nfv_unit_tests/tests/test_plugin_kubernetes_client.py b/nfv/nfv-tests/nfv_unit_tests/tests/test_plugin_kubernetes_client.py index ace6c329..93624fc7 100755 --- a/nfv/nfv-tests/nfv_unit_tests/tests/test_plugin_kubernetes_client.py +++ b/nfv/nfv-tests/nfv_unit_tests/tests/test_plugin_kubernetes_client.py @@ -90,7 +90,7 @@ class TestNFVPluginsK8SNodeTaint(testcase.NFVTestCase): try: kube_client = kubernetes_client.get_client() response = kube_client.read_node(node_name) - except ApiException as e: + except ApiException: return False taints = response.spec.taints diff --git a/nfv/nfv-vim/nfv_vim/strategy/_strategy_steps.py b/nfv/nfv-vim/nfv_vim/strategy/_strategy_steps.py index 8ceb8827..1dd65c9e 100755 --- a/nfv/nfv-vim/nfv_vim/strategy/_strategy_steps.py +++ b/nfv/nfv-vim/nfv_vim/strategy/_strategy_steps.py @@ -2352,7 +2352,7 @@ class FwUpdateHostsStep(strategy.StrategyStep): DLOG.error("failed to monitor firmware update ; no strategy") else: DLOG.error("get host request did not complete") - except Exception as e: + except Exception: DLOG.exception("Caught exception interpreting host info") DLOG.error("Response: %s" % response) diff --git a/nfv/tox.ini b/nfv/tox.ini index 60e1573e..cf0b6123 100644 --- a/nfv/tox.ini +++ b/nfv/tox.ini @@ -77,12 +77,9 @@ verbosity=2 # E127 continuation line over-indented for visual indent # E128 continuation line under-indented for visual indent # E129 visually indented line with same indent as next logical line -# flake8 -# F841 local variable 'e' is assigned to but never used ignore = H104,H404,H405,H501, W503,W504,W605, - E121,E122,E124,E126,E127,E128,E129, - F841 + E121,E122,E124,E126,E127,E128,E129 # H106 Don’t put vim configuration in source files (off by default). # H203 Use assertIs(Not)None to check for None (off by default). # TODO: enable: H904 Delay string interpolations at logging calls (off by default).