Remove cyclic import between export and utils

Because export imports utils and utils imports export
there is a cyclic import so pylint objects PEP8 R0401.

overcloud_deploy and overcloud_export need the function
export_overcloud which depends on export. The function
export_overcloud was added to utils for that import but
this created the cyclic import. To work around this,
redefine the export_overcloud function in export and
have overcloud_deploy and overcloud_export import it
from export, not utils. Then remove the utils import
of export.

Change-Id: I8bab41ee9af9729cd63ed7132928cfbc1770887a
(cherry picked from commit 3f6f67c106)
This commit is contained in:
John Fulton
2021-07-13 17:09:15 -04:00
committed by Francesco Pantano
parent 9e5aed468c
commit 9f3b27e389
5 changed files with 17 additions and 17 deletions

View File

@@ -199,3 +199,15 @@ def export_ceph(stack, cephx,
data['dashboard_enabled'] = False
return data
def export_overcloud(heat, stack, excludes, should_filter,
config_download_dir):
data = export_passwords(heat, stack, excludes)
data.update(export_stack(
heat, stack, should_filter, config_download_dir))
# do not add extra host entries for VIPs for stacks deployed off that
# exported data, since it already contains those entries
data.update({'AddVipsToEtcHosts': False})
data = dict(parameter_defaults=data)
return data

View File

@@ -88,6 +88,6 @@ class UtilsFixture(fixtures.Fixture):
'tripleoclient.utils.rm_heat')
).mock
self.mock_export_overcloud = self.useFixture(fixtures.MockPatch(
'tripleoclient.utils.export_overcloud')
'tripleoclient.export.export_overcloud')
).mock
self.mock_export_overcloud.return_value = {}

View File

@@ -69,7 +69,6 @@ from tripleo_common.utils import stack as stack_utils
from tripleo_common import update
from tripleoclient import constants
from tripleoclient import exceptions
from tripleoclient import export
from tripleoclient import heat_launcher
@@ -2666,18 +2665,6 @@ def get_default_working_dir(stack):
"overcloud-deploy", stack)
def export_overcloud(heat, stack, excludes, should_filter,
config_download_dir):
data = export.export_passwords(heat, stack, excludes)
data.update(export.export_stack(
heat, stack, should_filter, config_download_dir))
# do not add extra host entries for VIPs for stacks deployed off that
# exported data, since it already contains those entries
data.update({'AddVipsToEtcHosts': False})
data = dict(parameter_defaults=data)
return data
def is_network_data_v2(networks_file_path):
"""Parse the network data, if any network have 'ip_subnet' or
'ipv6_subnet' keys this is not a network-v2 format file.

View File

@@ -41,6 +41,7 @@ from tripleo_common.utils import plan as plan_utils
from tripleoclient import command
from tripleoclient import constants
from tripleoclient import exceptions
from tripleoclient import export
from tripleoclient import utils
from tripleoclient.workflows import deployment
from tripleoclient.workflows import parameters as workflow_params
@@ -1370,7 +1371,7 @@ class DeployOvercloud(command.Command):
if (parsed_args.heat_type != 'installed' and
parsed_args.config_download):
# Create overcloud export
data = utils.export_overcloud(
data = export.export_overcloud(
self.orchestration_client,
parsed_args.stack, True, False,
config_download_dir)

View File

@@ -19,7 +19,7 @@ from osc_lib.i18n import _
from osc_lib import utils as osc_utils
from tripleoclient import command
from tripleoclient import utils
from tripleoclient import export
class ExportOvercloud(command.Command):
@@ -87,7 +87,7 @@ class ExportOvercloud(command.Command):
# prepare clients to access the environment
clients = self.app.client_manager
heat = clients.orchestration
data = utils.export_overcloud(
data = export.export_overcloud(
heat, stack, excludes=not parsed_args.no_password_excludes,
should_filter=False, config_download_dir=config_download_dir)
# write the exported data