mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-03-24 06:07:19 +00:00
replace batch of redundant to_native() occurrences (#11102)
* replace batch of redundant to_native() occurrences * add changelog frag * Update plugins/modules/idrac_redfish_config.py Co-authored-by: Felix Fontein <felix@fontein.de> * reformat * Apply suggestions from code review Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/dimensiondata_network.py Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
ec091060d7
commit
e5ee3eb88b
13 changed files with 42 additions and 42 deletions
|
|
@ -120,7 +120,6 @@ import traceback
|
|||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils.dimensiondata import HAS_LIBCLOUD, DimensionDataModule
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
|
||||
if HAS_LIBCLOUD:
|
||||
from libcloud.compute.base import NodeLocation
|
||||
|
|
@ -223,9 +222,7 @@ class DimensionDataNetworkModule(DimensionDataModule):
|
|||
self.location, self.name, self.module.params["service_plan"], description=self.description
|
||||
)
|
||||
except DimensionDataAPIException as e:
|
||||
self.module.fail_json(
|
||||
msg="Failed to create new network: %s" % to_native(e), exception=traceback.format_exc()
|
||||
)
|
||||
self.module.fail_json(msg=f"Failed to create new network: {e}", exception=traceback.format_exc())
|
||||
|
||||
if self.module.params["wait"] is True:
|
||||
network = self._wait_for_network_state(network.id, "NORMAL")
|
||||
|
|
@ -245,7 +242,7 @@ class DimensionDataNetworkModule(DimensionDataModule):
|
|||
self.module.fail_json("Unexpected failure deleting network with id %s" % network.id)
|
||||
|
||||
except DimensionDataAPIException as e:
|
||||
self.module.fail_json(msg="Failed to delete network: %s" % to_native(e), exception=traceback.format_exc())
|
||||
self.module.fail_json(msg=f"Failed to delete network: {e}", exception=traceback.format_exc())
|
||||
|
||||
def _wait_for_network_state(self, net_id, state_to_wait_for):
|
||||
try:
|
||||
|
|
@ -258,7 +255,7 @@ class DimensionDataNetworkModule(DimensionDataModule):
|
|||
)
|
||||
except DimensionDataAPIException as e:
|
||||
self.module.fail_json(
|
||||
msg="Network did not reach % state in time: %s" % (state_to_wait_for, to_native(e)),
|
||||
msg=f"Network did not reach {state_to_wait_for} state in time: {e}",
|
||||
exception=traceback.format_exc(),
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue