diff --git a/lib/ansible/modules/cloud/azure/azure.py b/lib/ansible/modules/cloud/azure/azure.py index 1a567a91a70..68c070872e3 100644 --- a/lib/ansible/modules/cloud/azure/azure.py +++ b/lib/ansible/modules/cloud/azure/azure.py @@ -192,9 +192,11 @@ EXAMPLES = ''' import base64 import datetime import os +import signal import time from urlparse import urlparse -from ansible.module_utils.facts import * # TimeoutError +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.facts.timeout import TimeoutError AZURE_LOCATIONS = ['South Central US', 'Central US', @@ -279,6 +281,7 @@ except ImportError: from types import MethodType import json + def _wait_for_completion(azure, promise, wait_timeout, msg): if not promise: return @@ -291,6 +294,7 @@ def _wait_for_completion(azure, promise, wait_timeout, msg): raise AzureException('Timed out waiting for async operation ' + msg + ' "' + str(promise.request_id) + '" to complete.') + def _delete_disks_when_detached(azure, wait_timeout, disk_names): def _handle_timeout(signum, frame): raise TimeoutError("Timeout reached while waiting for disks to become detached.") @@ -305,10 +309,11 @@ def _delete_disks_when_detached(azure, wait_timeout, disk_names): azure.delete_disk(disk.name, True) disk_names.remove(disk_name) except AzureException as e: - module.fail_json(msg="failed to get or delete disk %s, error was: %s" % (disk_name, str(e))) + raise AzureException("failed to get or delete disk %s, error was: %s" % (disk_name, str(e))) finally: signal.alarm(0) + def get_ssh_certificate_tokens(module, ssh_cert_path): """ Returns the sha1 fingerprint and a base64-encoded PKCS12 version of the certificate. @@ -376,7 +381,7 @@ def create_virtual_machine(module, azure): disable_ssh_password_authentication = not password vm_config = LinuxConfigurationSet(hostname, user, password, disable_ssh_password_authentication) else: - #Create Windows Config + # Create Windows Config vm_config = WindowsConfigurationSet(hostname, password, None, module.params.get('auto_updates'), None, user) vm_config.domain_join = None if module.params.get('enable_winrm'): @@ -620,6 +625,5 @@ class Wrapper(object): # import module snippets -from ansible.module_utils.basic import * if __name__ == '__main__': main() diff --git a/test/sanity/pep8/legacy-files.txt b/test/sanity/pep8/legacy-files.txt index 88334f81e7c..b5bfdf4afc7 100644 --- a/test/sanity/pep8/legacy-files.txt +++ b/test/sanity/pep8/legacy-files.txt @@ -66,7 +66,6 @@ lib/ansible/modules/cloud/amazon/sts_assume_role.py lib/ansible/modules/cloud/amazon/sts_session_token.py lib/ansible/modules/cloud/atomic/atomic_host.py lib/ansible/modules/cloud/atomic/atomic_image.py -lib/ansible/modules/cloud/azure/azure.py lib/ansible/modules/cloud/azure/azure_rm_deployment.py lib/ansible/modules/cloud/azure/azure_rm_networkinterface.py lib/ansible/modules/cloud/azure/azure_rm_networkinterface_facts.py