diff --git a/.pylintrc b/.pylintrc index 187710d1f3..b310ea0231 100644 --- a/.pylintrc +++ b/.pylintrc @@ -101,7 +101,9 @@ disable= invalid-overridden-method, raising-format-tuple, comparison-with-callable, - consider-using-with + consider-using-with, + unused-private-member, + arguments-renamed, [BASIC] # Variable names can be 1 to 31 characters long, with lowercase and underscores diff --git a/vmware_nsx/api_replay/client.py b/vmware_nsx/api_replay/client.py index 0dc5f5d74c..f5c64cbfb4 100644 --- a/vmware_nsx/api_replay/client.py +++ b/vmware_nsx/api_replay/client.py @@ -450,10 +450,10 @@ class ApiReplayClient(utils.PrepareObjectForMigration): # Create the rules after all security groups are created to allow # dependencies in remote_group_id - for sg_id in rules_dict: + for sg_id, sg in rules_dict.items(): try: rules = self.dest_neutron.create_security_group_rule( - {'security_group_rules': rules_dict[sg_id]}) + {'security_group_rules': sg}) LOG.info("Created %d security group rules for SG %s: %s", len(rules), sg_id, ",".join([rule.get('id') for rule in diff --git a/vmware_nsx/plugins/nsx/plugin.py b/vmware_nsx/plugins/nsx/plugin.py index b3b32284b3..b53cd87aaa 100644 --- a/vmware_nsx/plugins/nsx/plugin.py +++ b/vmware_nsx/plugins/nsx/plugin.py @@ -197,15 +197,15 @@ class NsxTVDPlugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, def init_extensions(self): # Support all the extensions supported by any of the plugins extensions = [] - for plugin in self.plugins: - extensions.extend(self.plugins[plugin].supported_extension_aliases) + for plugin in self.plugins.values(): + extensions.extend(plugin.supported_extension_aliases) self.supported_extension_aliases.extend(list(set(extensions))) # mark extensions which are supported by only one of the plugins self._unsupported_fields = {} - for plugin in self.plugins: + for plugin in self.plugins.values(): # TODO(asarfaty): add other resources here - plugin_type = self.plugins[plugin].plugin_type() + plugin_type = plugin.plugin_type() self._unsupported_fields[plugin_type] = {'router': [], 'port': [], 'security_group': []} @@ -290,8 +290,7 @@ class NsxTVDPlugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, def start_rpc_listeners(self): # Run the start_rpc_listeners of one of the sub-plugins - for plugin_type in self.plugins: - plugin = self.plugins[plugin_type] + for plugin in self.plugins.values(): if plugin.rpc_workers_supported(): return plugin.start_rpc_listeners() diff --git a/vmware_nsx/plugins/nsx_p/plugin.py b/vmware_nsx/plugins/nsx_p/plugin.py index df7b966c60..7b45789fdf 100644 --- a/vmware_nsx/plugins/nsx_p/plugin.py +++ b/vmware_nsx/plugins/nsx_p/plugin.py @@ -453,20 +453,20 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base): NO_SLAAC_NDRA_PROFILE_ID: policy_constants.IPV6_RA_MODE_DISABLED } - for profile in ndra_profiles: + for profile_key, profile_value in ndra_profiles.items(): try: - self.nsxpolicy.ipv6_ndra_profile.get(profile, silent=True) + self.nsxpolicy.ipv6_ndra_profile.get(profile_key, silent=True) except nsx_lib_exc.ResourceNotFound: try: self.nsxpolicy.ipv6_ndra_profile.create_or_overwrite( - profile, - profile_id=profile, - ra_mode=ndra_profiles[profile], + profile_key, + profile_id=profile_key, + ra_mode=profile_value, tags=self.nsxpolicy.build_v3_api_version_tag()) except nsx_lib_exc.StaleRevision as e: # This means that another controller is also creating this LOG.info("Failed to configure ipv6_ndra_profile %s: %s", - profile, e) + profile_key, e) self.client_ssl_profile = None diff --git a/vmware_nsx/plugins/nsx_v/vshield/tasks/tasks.py b/vmware_nsx/plugins/nsx_v/vshield/tasks/tasks.py index 2b01442899..ec76a2cb46 100644 --- a/vmware_nsx/plugins/nsx_v/vshield/tasks/tasks.py +++ b/vmware_nsx/plugins/nsx_v/vshield/tasks/tasks.py @@ -217,12 +217,11 @@ class TaskManager(object): def _check_pending_tasks(self): """Check all pending tasks status.""" - for resource_id in self._tasks.keys(): + for resource_id, tasks in self._tasks.items(): if self._stopped: # Task manager is stopped, return now return - tasks = self._tasks[resource_id] # only the first task is executed and pending task = tasks[0] try: diff --git a/vmware_nsx/services/ipam/common/driver.py b/vmware_nsx/services/ipam/common/driver.py index d5aaced4dd..a614fa72c1 100644 --- a/vmware_nsx/services/ipam/common/driver.py +++ b/vmware_nsx/services/ipam/common/driver.py @@ -108,7 +108,8 @@ class NsxAbstractIpamDriver(subnet_alloc.SubnetAllocator, NsxIpamBase): # override the OOB factory to add the network ID return NsxSubnetRequestFactory - @abc.abstractproperty + @property + @abc.abstractmethod def _subnet_class(self): """Return the class of the subnet that should be used.""" pass diff --git a/vmware_nsx/services/lbaas/nsx_p/implementation/listener_mgr.py b/vmware_nsx/services/lbaas/nsx_p/implementation/listener_mgr.py index 09a7249d68..e3864787ec 100644 --- a/vmware_nsx/services/lbaas/nsx_p/implementation/listener_mgr.py +++ b/vmware_nsx/services/lbaas/nsx_p/implementation/listener_mgr.py @@ -424,8 +424,8 @@ def stats_getter(context, core_plugin, ignore_list=None): stats['id'] = p_utils.path_to_id( vs['virtual_server_path']) stats['request_errors'] = 0 # currently unsupported - for stat in lb_const.LB_STATS_MAP: - lb_stat = lb_const.LB_STATS_MAP[stat] + for stat, stat_value in lb_const.LB_STATS_MAP.items(): + lb_stat = stat_value stats[stat] += vs_stats[lb_stat] stat_list.append(stats) diff --git a/vmware_nsx/services/lbaas/nsx_v3/implementation/listener_mgr.py b/vmware_nsx/services/lbaas/nsx_v3/implementation/listener_mgr.py index f69967e468..31195eb6a6 100644 --- a/vmware_nsx/services/lbaas/nsx_v3/implementation/listener_mgr.py +++ b/vmware_nsx/services/lbaas/nsx_v3/implementation/listener_mgr.py @@ -431,8 +431,8 @@ def stats_getter(context, core_plugin, ignore_list=None): stats = copy.copy(lb_const.LB_EMPTY_STATS) stats['id'] = vs_bind.listener_id stats['request_errors'] = 0 # currently unsupported - for stat in lb_const.LB_STATS_MAP: - lb_stat = lb_const.LB_STATS_MAP[stat] + for stat, stat_value in lb_const.LB_STATS_MAP.items(): + lb_stat = stat_value stats[stat] += vs_stats[lb_stat] stat_list.append(stats) diff --git a/vmware_nsx/shell/admin/plugins/nsxv/resources/backup_edges.py b/vmware_nsx/shell/admin/plugins/nsxv/resources/backup_edges.py index 5d5a032ea7..af459d6e59 100644 --- a/vmware_nsx/shell/admin/plugins/nsxv/resources/backup_edges.py +++ b/vmware_nsx/shell/admin/plugins/nsxv/resources/backup_edges.py @@ -28,7 +28,7 @@ from vmware_nsx.plugins.nsx_v.vshield import edge_utils from vmware_nsx.shell.admin.plugins.common import constants from vmware_nsx.shell.admin.plugins.common import formatters import vmware_nsx.shell.admin.plugins.common.utils as admin_utils -import vmware_nsx.shell.admin.plugins.nsxv.resources.utils as utils +from vmware_nsx.shell.admin.plugins.nsxv.resources import utils import vmware_nsx.shell.resources as shell diff --git a/vmware_nsx/shell/admin/plugins/nsxv/resources/dhcp_binding.py b/vmware_nsx/shell/admin/plugins/nsxv/resources/dhcp_binding.py index 9e77dd6043..5b9810b4d7 100644 --- a/vmware_nsx/shell/admin/plugins/nsxv/resources/dhcp_binding.py +++ b/vmware_nsx/shell/admin/plugins/nsxv/resources/dhcp_binding.py @@ -21,7 +21,7 @@ from oslo_log import log as logging from vmware_nsx.shell.admin.plugins.common import constants import vmware_nsx.shell.admin.plugins.common.utils as admin_utils -import vmware_nsx.shell.admin.plugins.nsxv.resources.utils as utils +from vmware_nsx.shell.admin.plugins.nsxv.resources import utils import vmware_nsx.shell.resources as shell from neutron_lib.callbacks import registry diff --git a/vmware_nsx/shell/admin/plugins/nsxv/resources/routers.py b/vmware_nsx/shell/admin/plugins/nsxv/resources/routers.py index 4b5dfdb9df..e114081d09 100644 --- a/vmware_nsx/shell/admin/plugins/nsxv/resources/routers.py +++ b/vmware_nsx/shell/admin/plugins/nsxv/resources/routers.py @@ -16,7 +16,7 @@ from vmware_nsx.shell.admin.plugins.common import constants from vmware_nsx.shell.admin.plugins.common import formatters import vmware_nsx.shell.admin.plugins.common.utils as admin_utils -import vmware_nsx.shell.admin.plugins.nsxv.resources.utils as utils +from vmware_nsx.shell.admin.plugins.nsxv.resources import utils import vmware_nsx.shell.resources as shell from neutron_lib.callbacks import registry diff --git a/vmware_nsx/shell/admin/plugins/nsxv/resources/spoofguard_policy.py b/vmware_nsx/shell/admin/plugins/nsxv/resources/spoofguard_policy.py index 8165206baf..022644176e 100644 --- a/vmware_nsx/shell/admin/plugins/nsxv/resources/spoofguard_policy.py +++ b/vmware_nsx/shell/admin/plugins/nsxv/resources/spoofguard_policy.py @@ -17,7 +17,7 @@ from vmware_nsx.shell.admin.plugins.common import constants from vmware_nsx.shell.admin.plugins.common import formatters import vmware_nsx.shell.admin.plugins.common.utils as admin_utils -import vmware_nsx.shell.admin.plugins.nsxv.resources.utils as utils +from vmware_nsx.shell.admin.plugins.nsxv.resources import utils import vmware_nsx.shell.resources as shell from neutron_lib.callbacks import registry