diff --git a/sysinv/sysinv/sysinv/pylint.rc b/sysinv/sysinv/sysinv/pylint.rc index fd25b77f49..7964fb941c 100755 --- a/sysinv/sysinv/sysinv/pylint.rc +++ b/sysinv/sysinv/sysinv/pylint.rc @@ -34,7 +34,6 @@ load-plugins= # The following warnings should be fixed: # fixme (todo, xxx, fixme) # W0101: unreachable -# W0102: dangerous-default-value # W0105: pointless-string-statement # W0106: expression-not-assigned # W0107: unnecessary-pass @@ -80,7 +79,7 @@ load-plugins= # E1124: redundant-keyword-arg # E1136: unsubscriptable-object # E1205: logging-too-many-args -disable=C, R, fixme, W0101, W0102, W0105, W0106, W0107, W0108, W0110, W0123, W0150, +disable=C, R, fixme, W0101, W0105, W0106, W0107, W0108, W0110, W0123, W0150, W0201, W0211, W0212, W0221, W0223, W0231, W0235, W0311, W0402, W0403, W0404, W0603, W0612, W0613, W0621, W0622, W0631, W0632, W0701, W0703, W1113, W1201, W1401, W1505, diff --git a/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/cluster.py b/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/cluster.py index 345c0d3538..8952e9be5f 100644 --- a/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/cluster.py +++ b/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/cluster.py @@ -336,9 +336,11 @@ class ClusterController(rest.RestController): @wsme_pecan.wsexpose(ClusterCollection, [Query], types.uuid, types.uuid, int, wtypes.text, wtypes.text) - def get_all(self, q=[], parent_uuid=None, + def get_all(self, q=None, parent_uuid=None, marker=None, limit=None, sort_key='id', sort_dir='asc'): """Retrieve a list of Clusters.""" + if q is None: + q = [] return self._get_cluster_collection(parent_uuid, marker, limit, sort_key, sort_dir, q=q) diff --git a/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/kube_app.py b/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/kube_app.py index c4341d9ae1..1929605277 100644 --- a/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/kube_app.py +++ b/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/kube_app.py @@ -455,7 +455,9 @@ class KubeAppHelper(object): "state of the patch(es).")) return response - def _patch_report_app_dependencies(self, name, patches=[]): + def _patch_report_app_dependencies(self, name, patches=None): + if patches is None: + patches = [] try: system = self._dbapi.isystem_get_one() patch_api.patch_report_app_dependencies( diff --git a/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/service_parameter.py b/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/service_parameter.py index 77e05e04af..ecea2ff88d 100644 --- a/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/service_parameter.py +++ b/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/service_parameter.py @@ -198,9 +198,11 @@ class ServiceParameterController(rest.RestController): @wsme_pecan.wsexpose(ServiceParameterCollection, [Query], types.uuid, wtypes.text, wtypes.text, wtypes.text, wtypes.text) - def get_all(self, q=[], marker=None, limit=None, + def get_all(self, q=None, marker=None, limit=None, sort_key='id', sort_dir='asc'): """Retrieve a list of service parameters.""" + if q is None: + q = [] sort_key = ['section', 'name'] return self._get_service_parameter_collection(marker, limit, sort_key, diff --git a/sysinv/sysinv/sysinv/sysinv/api/middleware/auth_token.py b/sysinv/sysinv/sysinv/sysinv/api/middleware/auth_token.py index cb581fc1ec..ca367fb73a 100644 --- a/sysinv/sysinv/sysinv/sysinv/api/middleware/auth_token.py +++ b/sysinv/sysinv/sysinv/sysinv/api/middleware/auth_token.py @@ -33,9 +33,11 @@ class AuthTokenMiddleware(auth_token.AuthProtocol): for public routes in the API. """ - def __init__(self, app, conf, public_api_routes=[]): + def __init__(self, app, conf, public_api_routes=None): self._sysinv_app = app route_pattern_tpl = '%s(\.json|\.xml)?$' + if public_api_routes is None: + public_api_routes = [] try: self.public_api_routes = [re.compile(route_pattern_tpl % route_tpl) diff --git a/sysinv/sysinv/sysinv/sysinv/common/extension_manager.py b/sysinv/sysinv/sysinv/sysinv/common/extension_manager.py index b2be0cac65..c70c0b0751 100644 --- a/sysinv/sysinv/sysinv/sysinv/common/extension_manager.py +++ b/sysinv/sysinv/sysinv/sysinv/common/extension_manager.py @@ -57,7 +57,7 @@ class ActivatedExtensionManager(enabled.EnabledExtensionManager): """ def __init__(self, namespace, enabled_names, invoke_on_load=True, - invoke_args=(), invoke_kwds={}): + invoke_args=(), invoke_kwds=None): def local_check_func(ext): return should_use_extension(namespace, ext, enabled_names) @@ -67,5 +67,5 @@ class ActivatedExtensionManager(enabled.EnabledExtensionManager): check_func=local_check_func, invoke_on_load=invoke_on_load, invoke_args=invoke_args, - invoke_kwds=invoke_kwds, + invoke_kwds=invoke_kwds if invoke_kwds is not None else {}, ) diff --git a/sysinv/sysinv/sysinv/sysinv/common/health.py b/sysinv/sysinv/sysinv/sysinv/common/health.py index e3cee2a414..5969a2fe1b 100755 --- a/sysinv/sysinv/sysinv/sysinv/common/health.py +++ b/sysinv/sysinv/sysinv/sysinv/common/health.py @@ -121,11 +121,13 @@ class Health(object): return success, allowed, affecting - def get_alarms_degrade(self, context, alarm_ignore_list=[], + def get_alarms_degrade(self, context, alarm_ignore_list=None, entity_instance_id_filter=""): """Return all the alarms that cause the degrade""" db_alarms = fmclient(context).alarm.list(include_suppress=True) degrade_alarms = [] + if alarm_ignore_list is None: + alarm_ignore_list = [] for db_alarm in db_alarms: if isinstance(db_alarm, tuple): diff --git a/sysinv/sysinv/sysinv/sysinv/common/service.py b/sysinv/sysinv/sysinv/sysinv/common/service.py index 2c8d994b67..f7007e7d6c 100644 --- a/sysinv/sysinv/sysinv/sysinv/common/service.py +++ b/sysinv/sysinv/sysinv/sysinv/common/service.py @@ -55,7 +55,9 @@ class PeriodicService(rpc_service.Service, periodic_task.PeriodicTasks): context=admin_context) -def prepare_service(argv=[]): +def prepare_service(argv=None): + if argv is None: + argv = [] rpc.set_defaults(control_exchange='sysinv') cfg.set_defaults(log.log_opts, default_log_levels=['amqplib=WARN', diff --git a/sysinv/sysinv/sysinv/sysinv/conductor/kube_app.py b/sysinv/sysinv/sysinv/sysinv/conductor/kube_app.py index 2d365ff5c4..03f17b1873 100644 --- a/sysinv/sysinv/sysinv/sysinv/conductor/kube_app.py +++ b/sysinv/sysinv/sysinv/sysinv/conductor/kube_app.py @@ -2462,11 +2462,14 @@ class DockerHelper(object): return None def make_armada_request(self, request, manifest_file='', overrides_str='', - app_releases=[], logfile=None): + app_releases=None, logfile=None): if logfile is None: logfile = request + '.log' + if app_releases is None: + app_releases = [] + rc = True # Instruct Armada to use the tiller service since it does not properly diff --git a/sysinv/sysinv/sysinv/sysinv/conductor/manager.py b/sysinv/sysinv/sysinv/sysinv/conductor/manager.py index 9913125af7..d6b119df49 100644 --- a/sysinv/sysinv/sysinv/sysinv/conductor/manager.py +++ b/sysinv/sysinv/sysinv/sysinv/conductor/manager.py @@ -741,7 +741,9 @@ class ConductorManager(service.PeriodicService): return line def _dnsmasq_addn_host_entry_to_string(self, ip_addr, hostname, - aliases=[]): + aliases=None): + if aliases is None: + aliases = [] line = "%s %s" % (ip_addr, hostname) for alias in aliases: line = "%s %s" % (line, alias) @@ -10109,7 +10111,7 @@ class ConductorManager(service.PeriodicService): """ return self._helm.get_helm_application_overrides(app_name, cnamespace) - def merge_overrides(self, context, file_overrides=[], set_overrides=[]): + def merge_overrides(self, context, file_overrides=None, set_overrides=None): """Merge the file and set overrides into a single chart overrides. :param context: request context. diff --git a/sysinv/sysinv/sysinv/sysinv/conductor/rpcapi.py b/sysinv/sysinv/sysinv/sysinv/conductor/rpcapi.py index 7b284ed50b..54e98cd2fb 100644 --- a/sysinv/sysinv/sysinv/sysinv/conductor/rpcapi.py +++ b/sysinv/sysinv/sysinv/sysinv/conductor/rpcapi.py @@ -1692,7 +1692,7 @@ class ConductorAPI(sysinv.openstack.common.rpc.proxy.RpcProxy): app_name=app_name, cnamespace=cnamespace)) - def merge_overrides(self, context, file_overrides=[], set_overrides=[]): + def merge_overrides(self, context, file_overrides=None, set_overrides=None): """Merge the file and set overrides into a single chart overrides. :param context: request context. @@ -1701,6 +1701,10 @@ class ConductorAPI(sysinv.openstack.common.rpc.proxy.RpcProxy): :returns: merged overrides string """ + if file_overrides is None: + file_overrides = [] + if set_overrides is None: + set_overrides = [] return self.call(context, self.make_msg('merge_overrides', file_overrides=file_overrides, diff --git a/sysinv/sysinv/sysinv/sysinv/helm/helm.py b/sysinv/sysinv/sysinv/sysinv/helm/helm.py index 94087b8445..9dda08a4f0 100644 --- a/sysinv/sysinv/sysinv/sysinv/helm/helm.py +++ b/sysinv/sysinv/sysinv/sysinv/helm/helm.py @@ -377,7 +377,7 @@ class HelmOperator(object): LOG.debug("Chart %s can be found in repo: %s" % (chart_name, repo)) return metadata_name, repo, chart_tarfile - def merge_overrides(self, file_overrides=[], set_overrides=[]): + def merge_overrides(self, file_overrides=None, set_overrides=None): """ Merge helm overrides together. :param values: A dict of different types of user override values, @@ -385,6 +385,10 @@ class HelmOperator(object): 'set' (which generally specify one override). """ + if file_overrides is None: + file_overrides = [] + if set_overrides is None: + set_overrides = [] # At this point we have potentially two separate types of overrides # specified by system or user, values from files and values passed in # via --set . We need to ensure that we call helm using the same diff --git a/sysinv/sysinv/sysinv/sysinv/helm/openstack.py b/sysinv/sysinv/sysinv/sysinv/helm/openstack.py index b90c37c907..5d6dd315ff 100644 --- a/sysinv/sysinv/sysinv/sysinv/helm/openstack.py +++ b/sysinv/sysinv/sysinv/sysinv/helm/openstack.py @@ -409,7 +409,7 @@ class OpenstackBaseHelm(base.BaseHelm): return newprivatekey, newpublickey - def _oslo_multistring_override(self, name=None, values=[]): + def _oslo_multistring_override(self, name=None, values=None): """ Generate helm multistring dictionary override for specified option name with multiple values. diff --git a/sysinv/sysinv/sysinv/sysinv/openstack/common/db/exception.py b/sysinv/sysinv/sysinv/sysinv/openstack/common/db/exception.py index 95f4485dba..2dc92794b6 100644 --- a/sysinv/sysinv/sysinv/sysinv/openstack/common/db/exception.py +++ b/sysinv/sysinv/sysinv/sysinv/openstack/common/db/exception.py @@ -28,8 +28,11 @@ class DBError(Exception): class DBDuplicateEntry(DBError): """Wraps an implementation specific exception.""" - def __init__(self, columns=[], inner_exception=None): - self.columns = columns + def __init__(self, columns=None, inner_exception=None): + if columns is None: + self.columns = [] + else: + self.columns = columns super(DBDuplicateEntry, self).__init__(inner_exception) diff --git a/sysinv/sysinv/sysinv/sysinv/openstack/common/rootwrap/filters.py b/sysinv/sysinv/sysinv/sysinv/openstack/common/rootwrap/filters.py index 0372c79556..395991b075 100644 --- a/sysinv/sysinv/sysinv/sysinv/openstack/common/rootwrap/filters.py +++ b/sysinv/sysinv/sysinv/sysinv/openstack/common/rootwrap/filters.py @@ -29,7 +29,7 @@ class CommandFilter(object): self.args = args self.real_exec = None - def get_exec(self, exec_dirs=[]): + def get_exec(self, exec_dirs=None): """Returns existing executable, or empty string if none found.""" if self.real_exec is not None: return self.real_exec @@ -37,7 +37,7 @@ class CommandFilter(object): if self.exec_path.startswith('/'): if os.access(self.exec_path, os.X_OK): self.real_exec = self.exec_path - else: + elif exec_dirs is not None: for binary_path in exec_dirs: expanded_path = os.path.join(binary_path, self.exec_path) if os.access(expanded_path, os.X_OK): @@ -49,7 +49,7 @@ class CommandFilter(object): """Only check that the first argument (command) matches exec_path.""" return os.path.basename(self.exec_path) == userargs[0] - def get_command(self, userargs, exec_dirs=[]): + def get_command(self, userargs, exec_dirs=None): """Returns command to execute (with sudo -u if run_as != root).""" to_exec = self.get_exec(exec_dirs=exec_dirs) or self.exec_path if (self.run_as != 'root'): @@ -122,7 +122,9 @@ class PathFilter(CommandFilter): args_equal_or_pass and paths_are_within_base_dirs) - def get_command(self, userargs, exec_dirs=[]): + def get_command(self, userargs, exec_dirs=None): + if exec_dirs is None: + exec_dirs = [] command, arguments = userargs[0], userargs[1:] # convert path values to canonical ones; copy other args as is @@ -146,7 +148,9 @@ class DnsmasqFilter(CommandFilter): return True return False - def get_command(self, userargs, exec_dirs=[]): + def get_command(self, userargs, exec_dirs=None): + if exec_dirs is None: + exec_dirs = [] to_exec = self.get_exec(exec_dirs=exec_dirs) or self.exec_path dnsmasq_pos = userargs.index('dnsmasq') return [to_exec] + userargs[dnsmasq_pos + 1:] diff --git a/sysinv/sysinv/sysinv/sysinv/openstack/common/rootwrap/wrapper.py b/sysinv/sysinv/sysinv/sysinv/openstack/common/rootwrap/wrapper.py index a32025b24f..df882bdf0a 100644 --- a/sysinv/sysinv/sysinv/sysinv/openstack/common/rootwrap/wrapper.py +++ b/sysinv/sysinv/sysinv/sysinv/openstack/common/rootwrap/wrapper.py @@ -121,7 +121,7 @@ def load_filters(filters_path): return filterlist -def match_filter(filter_list, userargs, exec_dirs=[]): +def match_filter(filter_list, userargs, exec_dirs=None): """ Checks user command and arguments through command filters and returns the first matching filter. @@ -130,6 +130,8 @@ def match_filter(filter_list, userargs, exec_dirs=[]): best filter match. """ first_not_executable_filter = None + if exec_dirs is None: + exec_dirs = [] for f in filter_list: if f.match(userargs): diff --git a/sysinv/sysinv/sysinv/sysinv/openstack/common/setup.py b/sysinv/sysinv/sysinv/sysinv/openstack/common/setup.py index 8916bd085e..cc8e90a0a6 100644 --- a/sysinv/sysinv/sysinv/sysinv/openstack/common/setup.py +++ b/sysinv/sysinv/sysinv/sysinv/openstack/common/setup.py @@ -68,9 +68,10 @@ def get_reqs_from_files(requirements_files): return [] -def parse_requirements(requirements_files=['requirements.txt', - 'tools/pip-requires']): +def parse_requirements(requirements_files=None): requirements = [] + if requirements_files is None: + requirements_files = ['requirements.txt', 'tools/pip-requires'] for line in get_reqs_from_files(requirements_files): # For the requirements list, we need to inject only the portion # after egg= so that distutils knows the package it's looking for @@ -97,8 +98,9 @@ def parse_requirements(requirements_files=['requirements.txt', return requirements -def parse_dependency_links(requirements_files=['requirements.txt', - 'tools/pip-requires']): +def parse_dependency_links(requirements_files=None): + if requirements_files is None: + requirements_files = ['requirements.txt', 'tools/pip-requires'] dependency_links = [] # dependency_links inject alternate locations to find packages listed # in requirements