From 54882d4715a295103d98dfed40f6a90c5d624b20 Mon Sep 17 00:00:00 2001 From: Pilou Date: Wed, 7 Feb 2018 00:44:42 +0100 Subject: [PATCH] dimensiondata: fix broken import (#35634) * Fix broken import * Remove never reached statements exit_json and fail_json methods call sys.exit, subsequent statements can not be executed. --- lib/ansible/module_utils/dimensiondata.py | 6 ------ .../dimensiondata/dimensiondata_network.py | 21 +++++-------------- test/sanity/import/skip.txt | 1 - 3 files changed, 5 insertions(+), 23 deletions(-) diff --git a/lib/ansible/module_utils/dimensiondata.py b/lib/ansible/module_utils/dimensiondata.py index 09dce3b6111..0bc2e8c1971 100644 --- a/lib/ansible/module_utils/dimensiondata.py +++ b/lib/ansible/module_utils/dimensiondata.py @@ -71,8 +71,6 @@ class DimensionDataModule(object): if not HAS_LIBCLOUD: self.module.fail_json(msg='libcloud is required for this module.') - return - # Credentials are common to all Dimension Data modules. credentials = self.get_credentials() self.user_id = credentials['user_id'] @@ -125,8 +123,6 @@ class DimensionDataModule(object): if not HAS_LIBCLOUD: self.module.fail_json(msg='libcloud is required for this module.') - return None - user_id = None key = None @@ -137,8 +133,6 @@ class DimensionDataModule(object): msg='"mcp_user" parameter was specified, but not "mcp_password" (either both must be specified, or neither).' ) - return None - user_id = self.module.params['mcp_user'] key = self.module.params['mcp_password'] diff --git a/lib/ansible/modules/cloud/dimensiondata/dimensiondata_network.py b/lib/ansible/modules/cloud/dimensiondata/dimensiondata_network.py index 75ae740340e..d8b14a6aebe 100644 --- a/lib/ansible/modules/cloud/dimensiondata/dimensiondata_network.py +++ b/lib/ansible/modules/cloud/dimensiondata/dimensiondata_network.py @@ -110,17 +110,14 @@ network: ''' import traceback -try: - from libcloud.compute.base import NodeLocation - - HAS_LIBCLOUD = True -except ImportError: - HAS_LIBCLOUD = False - from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.dimensiondata import DimensionDataModule, DimensionDataAPIException +from ansible.module_utils.dimensiondata import HAS_LIBCLOUD, DimensionDataModule from ansible.module_utils._text import to_native +if HAS_LIBCLOUD: + from libcloud.compute.base import NodeLocation + from libcloud.common.dimensiondata import DimensionDataAPIException + class DimensionDataNetworkModule(DimensionDataModule): """ @@ -159,8 +156,6 @@ class DimensionDataNetworkModule(DimensionDataModule): network=self._network_to_dict(network) ) - return - network = self._create_network() self.module.exit_json( @@ -179,8 +174,6 @@ class DimensionDataNetworkModule(DimensionDataModule): network=self._network_to_dict(network) ) - return - self._delete_network(network) def _get_network(self): @@ -226,8 +219,6 @@ class DimensionDataNetworkModule(DimensionDataModule): msg='service_plan required when creating network and location is MCP 2.0' ) - return None - # Create network try: if self.mcp_version == '1.0': @@ -249,8 +240,6 @@ class DimensionDataNetworkModule(DimensionDataModule): msg="Failed to create new network: %s" % to_native(e), exception=traceback.format_exc() ) - return None - if self.module.params['wait'] is True: network = self._wait_for_network_state(network.id, 'NORMAL') diff --git a/test/sanity/import/skip.txt b/test/sanity/import/skip.txt index 66fa2187c76..50d24cb3d8e 100644 --- a/test/sanity/import/skip.txt +++ b/test/sanity/import/skip.txt @@ -1,4 +1,3 @@ -lib/ansible/modules/cloud/dimensiondata/dimensiondata_network.py lib/ansible/modules/cloud/webfaction/webfaction_app.py lib/ansible/modules/cloud/webfaction/webfaction_db.py lib/ansible/modules/cloud/webfaction/webfaction_domain.py