Remove wildcard imports

Made the following changes:

* Removed wildcard imports
* Replaced long form of GPL header with short form
* Removed get_exception usage
* Added from __future__ boilerplate
  * Adjust division operator to // where necessary

For the following files:

* web_infrastructure modules
* system modules
* linode, lxc, lxd, atomic, cloudscale, dimensiondata, ovh, packet,
  profitbricks, pubnub, smartos, softlayer, univention modules
* compat dirs (disabled as its used intentionally)
This commit is contained in:
Toshio Kuratomi 2017-07-27 22:55:24 -07:00
commit 4e6cce354e
185 changed files with 1657 additions and 3459 deletions

View file

@ -2,25 +2,16 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016 Dimension Data
#
# This module is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
#
# Authors:
# - Aimon Bustardo <aimon.bustardo@dimensiondata.com>
# - Bert Diwa <Lamberto.Diwa@dimensiondata.com>
# - Adam Friedman <tintoy@tintoy.io>
#
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'],
@ -117,11 +108,8 @@ network:
type: boolean
sample: false
'''
import traceback
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.dimensiondata import DimensionDataModule, DimensionDataAPIException
from ansible.module_utils.pycompat24 import get_exception
try:
from libcloud.compute.base import NodeLocation
@ -129,6 +117,10 @@ try:
except ImportError:
HAS_LIBCLOUD = False
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.dimensiondata import DimensionDataModule, DimensionDataAPIException
from ansible.module_utils._text import to_native
class DimensionDataNetworkModule(DimensionDataModule):
"""
@ -251,11 +243,10 @@ class DimensionDataNetworkModule(DimensionDataModule):
self.module.params['service_plan'],
description=self.description
)
except DimensionDataAPIException:
api_exception = get_exception()
except DimensionDataAPIException as e:
self.module.fail_json(
msg="Failed to create new network: %s" % str(api_exception)
msg="Failed to create new network: %s" % to_native(e), exception=traceback.format_exc()
)
return None
@ -282,11 +273,9 @@ class DimensionDataNetworkModule(DimensionDataModule):
"Unexpected failure deleting network with id %s", network.id
)
except DimensionDataAPIException:
api_exception = get_exception()
except DimensionDataAPIException as e:
self.module.fail_json(
msg="Failed to delete network: %s" % str(api_exception)
msg="Failed to delete network: %s" % to_native(e), exception=traceback.format_exc()
)
def _wait_for_network_state(self, net_id, state_to_wait_for):
@ -298,11 +287,10 @@ class DimensionDataNetworkModule(DimensionDataModule):
self.module.params['wait_time'],
net_id
)
except DimensionDataAPIException:
api_exception = get_exception()
except DimensionDataAPIException as e:
self.module.fail_json(
msg='Network did not reach % state in time: %s' % (state_to_wait_for, api_exception.msg)
msg='Network did not reach % state in time: %s' % (state_to_wait_for, to_native(e)),
exception=traceback.format_exc()
)