Fix issues introduced by pylint/pep8 for dcmanager

This commit fixes some regressions caused by the merge with
master in the original commit.
1 - Small formatting changes to be more consistent with
    existing code;
2 - Removal of require_audit_flag that was mistakenly
    reintroduced during a rebase;
3 - Repositioning of eventlet.monkey_patch() so it
    happens before the other imports;
4 - Fix the admin IP conditional so it matches previous
    behavior;
5 - Change the determine_image_fields conditional so it
    matches previous behavior.

Related commit:
 https://review.opendev.org/c/starlingx/distcloud/+/893000

Test Plan:
1. Perform `tox` command
- Pass in py39, pylint, pep8:

Closes-bug: 2033294

Change-Id: Icea2a80e2e4eed79f37bf49878e6fdea0db13a56
Signed-off-by: rlima <Raphael.Lima@windriver.com>
This commit is contained in:
rlima 2024-01-19 10:42:23 -03:00
parent 4438b8fd55
commit 91c9d301d8
12 changed files with 21 additions and 27 deletions

View File

@ -609,8 +609,7 @@ class SubcloudsController(object):
consts.STATES_FOR_SUBCLOUD_RENAME):
msg = (
'Subcloud %s must be unmanaged and in a valid deploy state '
'for the subcloud rename operation.' %
subcloud.name
'for the subcloud rename operation.' % subcloud.name
)
pecan.abort(400, msg)

View File

@ -21,6 +21,8 @@ DC Manager Engine Server.
import eventlet
eventlet.monkey_patch()
# pylint: disable=wrong-import-position
from oslo_config import cfg # noqa: E402
from oslo_i18n import _lazy # noqa: E402
@ -33,7 +35,6 @@ from dcmanager.common import messaging # noqa: E402
from dcorch.common import messaging as dcorch_messaging # noqa: E402
# pylint: enable=wrong-import-position
eventlet.monkey_patch()
_lazy.enable_lazy()
config.register_options()
config.register_keystone_options()

View File

@ -379,10 +379,10 @@ def validate_admin_network_config(admin_subnet_str,
LOG.exception(e)
pecan.abort(400, _("admin_end_address invalid: %s") % e)
if admin_start_ip > admin_end_ip:
if admin_start_ip >= admin_end_ip:
pecan.abort(
400,
_("admin_start_address greater than "
_("admin_start_address greater than or equal to "
"admin_end_address"))
if len(netaddr.IPRange(admin_start_ip, admin_end_ip)) < \

View File

@ -1397,9 +1397,7 @@ def get_sw_version(release=None):
def validate_release_version_supported(release_version_to_check):
"""Given a release version, check whether it's supported by the current active
version.
"""Check if a release version is supported by the current active version.
:param release_version_to_check: version string to validate

View File

@ -161,7 +161,7 @@ class PeerGroupAuditManager(manager.Manager):
# get remote subclouds. For 'managed+online' subclouds,
# set 'unmanaged+secondary' to local on same subclouds
elif remote_peer_group.get("migration_status") == \
consts.PEER_GROUP_MIGRATION_COMPLETE or self.require_audit_flag:
consts.PEER_GROUP_MIGRATION_COMPLETE:
remote_subclouds = \
self._get_subclouds_by_peer_group_from_system_peer(
system_peer,

View File

@ -194,9 +194,7 @@ class PeerMonitor(object):
return msg
def _clean_peer_group_audit_threads(self):
for peer_group_id, _ in self.peer_group_audit_obj_map.items():
pgam_obj = \
self.peer_group_audit_obj_map[peer_group_id]
for pgam_obj in self.peer_group_audit_obj_map.values():
pgam_obj.stop()
self.peer_group_audit_obj_map.clear()

View File

@ -106,7 +106,7 @@ def determine_image_fields(image):
'bmc',
'retimer_included']
fields = dict((k, str(v)) for (k, v) in vars(image).items()
if k in field_list and v)
if k in field_list and v is not None)
return fields

View File

@ -42,8 +42,8 @@ class DeployStartState(BaseState):
# Find the max version deployed on the SystemController
max_version = None
for release_id, _ in deployed_releases.items():
release_sw_version = deployed_releases[release_id]['sw_version']
for deployed_releases_values in deployed_releases.values():
release_sw_version = deployed_releases_values['sw_version']
if max_version is None or release_sw_version > max_version:
max_version = release_sw_version

View File

@ -68,9 +68,8 @@ class FinishStrategyState(BaseState):
try:
software_client.delete(releases_to_delete)
except Exception:
message = \
("Cannot delete releases from subcloud. Please see logs for"
" details.")
message = ("Cannot delete releases from subcloud. Please see "
"logs for details.")
self.exception_log(strategy_step, message)
raise Exception(message)

View File

@ -136,8 +136,8 @@ class UploadState(BaseState):
potential_missing_patches)
if missing_patches:
message = \
(f"Release files {missing_patches} are missing")
message = (f"Release files {missing_patches} "
"are missing")
self.error_log(strategy_step, message)
raise Exception(message)
break
@ -150,8 +150,8 @@ class UploadState(BaseState):
else:
# No load was uploaded therefore the patches are really missing.
if potential_missing_patches:
message = \
(f"Release files {potential_missing_patches} are missing")
message = (f"Release files {potential_missing_patches} "
"are missing")
self.error_log(strategy_step, message)
raise Exception(message)

View File

@ -44,9 +44,8 @@ class PreCheckState(BaseState):
next_state=consts.STRATEGY_STATE_INSTALLING_LICENSE,
region_name=region_name)
def _check_health(
self, strategy_step, subcloud_sysinv_client, subcloud_fm_client,
host, upgrades):
def _check_health(self, strategy_step, subcloud_sysinv_client,
subcloud_fm_client, host, upgrades):
# Check system upgrade health
#

View File

@ -243,8 +243,8 @@ class UpgradingSimplexState(BaseState):
return upgrade_data_install
def _get_subcloud_upgrade_data(
self, strategy_step, subcloud_sysinv_client, subcloud_barbican_client):
def _get_subcloud_upgrade_data(self, strategy_step, subcloud_sysinv_client,
subcloud_barbican_client):
"""Get the subcloud data required for upgrades.
In case the subcloud is no longer reachable, get upgrade_data from