From cf1b391201315f6c06816e5562f651ca932af2a7 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 26 Apr 2016 12:46:41 -0400 Subject: [PATCH] several fixes: - removed actions feature as this should be global and not per module - removed default fields from return docs - moved tags docs to shared fragments - removed unused imports --- .../cloud/azure/azure_rm_networkinterface.py | 15 +---------- .../cloud/azure/azure_rm_publicipaddress.py | 22 ++-------------- .../cloud/azure/azure_rm_resourcegroup.py | 15 +---------- .../cloud/azure/azure_rm_securitygroup.py | 17 +++---------- .../cloud/azure/azure_rm_storageaccount.py | 18 +++---------- .../cloud/azure/azure_rm_storageblob.py | 25 +++---------------- .../modules/cloud/azure/azure_rm_subnet.py | 1 - .../cloud/azure/azure_rm_virtualmachine.py | 25 ++++++------------- .../cloud/azure/azure_rm_virtualnetwork.py | 14 +---------- 9 files changed, 21 insertions(+), 131 deletions(-) diff --git a/lib/ansible/modules/cloud/azure/azure_rm_networkinterface.py b/lib/ansible/modules/cloud/azure/azure_rm_networkinterface.py index 36b323135a9..78b2af5f32c 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_networkinterface.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_networkinterface.py @@ -136,20 +136,9 @@ options: type: list required: false default: null - tags: - description: - - "Dictionary of string:string pairs to assign as metadata to the object. Metadata tags on the object - will be updated with any provided values. To remove tags use the purge_tags option." - required: false - purge_tags: - description: - - Use to remove tags from an object. Any tags not found in the tags parameter will be removed from - the object's metadata. - default: false - required: false - extends_documentation_fragment: - azure + - azure_tags author: - "Chris Houseknecht (@chouseknecht)" @@ -238,10 +227,8 @@ from ansible.module_utils.azure_rm_common import * try: from msrestazure.azure_exceptions import CloudError - from azure.common import AzureMissingResourceHttpError from azure.mgmt.network.models import NetworkInterface, NetworkInterfaceIPConfiguration, Subnet, \ PublicIPAddress, NetworkSecurityGroup - from azure.mgmt.network.models.network_management_client_enums import IPAllocationMethod except ImportError: # This is handled in azure_rm_common pass diff --git a/lib/ansible/modules/cloud/azure/azure_rm_publicipaddress.py b/lib/ansible/modules/cloud/azure/azure_rm_publicipaddress.py index ffed931d66b..6e9a243e5ad 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_publicipaddress.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_publicipaddress.py @@ -71,21 +71,10 @@ options: - Valid azure location. Defaults to location of the resource group. default: resource_group location required: false - tags: - description: - - "Dictionary of string:string pairs to assign as metadata to the object. Metadata tags on the object - will be updated with any provided values. To remove tags use the purge_tags option." - required: false - default: null - purge_tags: - description: - - Use to remove tags from an object. Any tags not found in the tags parameter will be removed from - the object's metadata. - required: false - default: false extends_documentation_fragment: - azure + - azure_tags author: - "Chris Houseknecht (@chouseknecht)" @@ -108,11 +97,6 @@ EXAMPLES = ''' ''' RETURN = ''' -changed: - description: Whether or not the object was changed. - returned: always - type: bool - sample: True state: description: Facts about the current state of the object. returned: always @@ -136,9 +120,7 @@ from ansible.module_utils.azure_rm_common import * try: from msrestazure.azure_exceptions import CloudError - from azure.common import AzureMissingResourceHttpError from azure.mgmt.network.models import PublicIPAddress, PublicIPAddressDnsSettings - from azure.mgmt.network.models.network_management_client_enums import IPAllocationMethod except ImportError: # This is handled in azure_rm_common pass @@ -248,7 +230,7 @@ class AzureRMPublicIPAddress(AzureRMModuleBase): if self.check_mode: return results - + if changed: if self.state == 'present': if not pip: diff --git a/lib/ansible/modules/cloud/azure/azure_rm_resourcegroup.py b/lib/ansible/modules/cloud/azure/azure_rm_resourcegroup.py index 612c9a5b69a..4d028738a2d 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_resourcegroup.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_resourcegroup.py @@ -53,21 +53,9 @@ options: - absent - present required: false - tags: - description: - - "Dictionary of string:string pairs to assign as metadata to the object. Metadata tags on the object - will be updated with any provided values. To remove tags use the purge_tags option." - required: false - default: null - purge_tags: - description: - - Use to remove tags from an object. Any tags not found in the tags parameter will be removed from - the object's metadata. - default: false - required: false - extends_documentation_fragment: - azure + - azure_tags author: - "Chris Houseknecht (@chouseknecht)" @@ -116,7 +104,6 @@ from ansible.module_utils.azure_rm_common import * try: from msrestazure.azure_exceptions import CloudError - from azure.common import AzureMissingResourceHttpError from azure.mgmt.resource.resources.models import ResourceGroup except ImportError: pass diff --git a/lib/ansible/modules/cloud/azure/azure_rm_securitygroup.py b/lib/ansible/modules/cloud/azure/azure_rm_securitygroup.py index 394072fc482..2992debb81a 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_securitygroup.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_securitygroup.py @@ -118,21 +118,10 @@ options: choices: - absent - present - tags: - description: - - "Dictionary of string:string pairs to assign as metadata to the object. Metadata tags on the object - will be updated with any provided values. To remove tags use the purge_tags option." - required: false - default: null - purge_tags: - description: - - Use to remove tags from an object. Any tags not found in the tags parameter will be removed from - the object's metadata. - default: false - required: false extends_documentation_fragment: - azure + - azure_tags author: - "Chris Houseknecht (@chouseknecht)" @@ -340,8 +329,8 @@ from ansible.module_utils.azure_rm_common import * try: from msrestazure.azure_exceptions import CloudError - from azure.common import AzureMissingResourceHttpError, AzureHttpError - from azure.mgmt.network.models import NetworkSecurityGroup, SecurityRule, Subnet, NetworkInterface + from azure.common import AzureHttpError + from azure.mgmt.network.models import NetworkSecurityGroup, SecurityRule from azure.mgmt.network.models.network_management_client_enums import (SecurityRuleAccess, SecurityRuleDirection, SecurityRuleProtocol) diff --git a/lib/ansible/modules/cloud/azure/azure_rm_storageaccount.py b/lib/ansible/modules/cloud/azure/azure_rm_storageaccount.py index b9c99637307..ebcf8748ff6 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_storageaccount.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_storageaccount.py @@ -74,21 +74,10 @@ options: - Can be added to an existing storage account. Will be ignored during storage account creation. required: false default: null - tags: - description: - - "Dictionary of string:string pairs to assign as metadata to the object. Metadata tags on the object - will be updated with any provided values. To remove tags use the purge_tags option." - required: false - default: null - purge_tags: - description: - - Use to remove tags from an object. Any tags not found in the tags parameter will be removed from - the object's metadata. - default: false - required: false extends_documentation_fragment: - azure + - azure_tags author: - "Chris Houseknecht (@chouseknecht)" @@ -155,10 +144,9 @@ try: from azure.storage.cloudstorageaccount import CloudStorageAccount from azure.common import AzureMissingResourceHttpError, AzureHttpError from azure.mgmt.storage.models import AccountType,\ - AccountStatus, \ ProvisioningState, \ StorageAccountUpdateParameters,\ - CustomDomain, StorageAccountCreateParameters, KeyName + CustomDomain, StorageAccountCreateParameters except ImportError: # This is handled in azure_rm_common pass @@ -449,7 +437,7 @@ class AzureRMStorageAccount(AzureRMModuleBase): return False -def main(): + AzureRMStorageAccount() if __name__ == '__main__': diff --git a/lib/ansible/modules/cloud/azure/azure_rm_storageblob.py b/lib/ansible/modules/cloud/azure/azure_rm_storageblob.py index 3d7424c2b98..2479de71f78 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_storageblob.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_storageblob.py @@ -126,21 +126,10 @@ options: choices: - container - blob - tags: - description: - - "Dictionary of string:string pairs to assign as metadata to the object. Metadata tags on the object - will be updated with any provided values. To remove tags use the purge_tags option." - required: false - default: null - purge_tags: - description: - - Use to remove tags from an object. Any tags not found in the tags parameter will be removed from - the object's metadata. - required: false - default: false extends_documentation_fragment: - azure + - azure_tags author: - "Chris Houseknecht (@chouseknecht)" @@ -176,13 +165,6 @@ EXAMPLES = ''' ''' RETURN = ''' -actions: - description: List of descriptive actions taken by the module. - returned: always - type: list - sample: [ - "updated blob foo:graylog.png content settings." - ] blob: description: Facts about the current state of the blob. returned: when a blob is operated on @@ -214,8 +196,6 @@ container: ''' -import datetime -import hashlib import os from ansible.module_utils.basic import * @@ -224,7 +204,6 @@ from ansible.module_utils.azure_rm_common import * try: from azure.storage.blob.models import ContentSettings - from azure.storage.cloudstorageaccount import CloudStorageAccount from azure.common import AzureMissingResourceHttpError, AzureHttpError except ImportError: # This is handled in azure_rm_common @@ -347,6 +326,8 @@ class AzureRMStorageBlob(AzureRMModuleBase): # Delete blob self.delete_blob() + # until we sort out how we want to do this globally + del self.results['actions'] return self.results def get_container(self): diff --git a/lib/ansible/modules/cloud/azure/azure_rm_subnet.py b/lib/ansible/modules/cloud/azure/azure_rm_subnet.py index f9d0f6edd56..d2d41abe971 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_subnet.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_subnet.py @@ -115,7 +115,6 @@ from ansible.module_utils.azure_rm_common import * try: from msrestazure.azure_exceptions import CloudError - from azure.common import AzureMissingResourceHttpError from azure.mgmt.network.models import Subnet, NetworkSecurityGroup except ImportError: # This is handled in azure_rm_common diff --git a/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py b/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py index ff85208f033..ba4da543e45 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py @@ -227,21 +227,10 @@ options: - When removing a VM using state 'absent', also remove any public IP addresses associate with the VM. default: true required: false - tags: - description: - - "Dictionary of string:string pairs to assign as metadata to the object. Metadata tags on the object - will be updated with any provided values. To remove tags use the purge_tags option." - default: null - required: false - purge_tags: - description: - - Use to remove tags from an object. Any tags not found in the tags parameter will be removed from - the object's metadata. - default: false - required: false extends_documentation_fragment: - azure + - azure_tags author: - "Chris Houseknecht (@chouseknecht)" @@ -454,20 +443,17 @@ from ansible.module_utils.azure_rm_common import * try: from msrestazure.azure_exceptions import CloudError - from azure.common import AzureMissingResourceHttpError from azure.mgmt.compute.models import NetworkInterfaceReference, VirtualMachine, HardwareProfile, \ StorageProfile, OSProfile, OSDisk, VirtualHardDisk, ImageReference, NetworkProfile, LinuxConfiguration, \ SshConfiguration, SshPublicKey - from azure.mgmt.network.models import PublicIPAddress, NetworkSecurityGroup, SecurityRule, NetworkInterface, \ + from azure.mgmt.network.models import PublicIPAddress, NetworkSecurityGroup, NetworkInterface, \ NetworkInterfaceIPConfiguration, Subnet - from azure.mgmt.storage.models import AccountType, AccountStatus, StorageAccountCreateParameters - from azure.mgmt.compute.models.compute_management_client_enums import CachingTypes, DiskCreateOptionTypes, \ - VirtualMachineSizeTypes + from azure.mgmt.storage.models import StorageAccountCreateParameters + from azure.mgmt.compute.models.compute_management_client_enums import DiskCreateOptionTypes, VirtualMachineSizeTypes except ImportError: # This is handled in azure_rm_common pass - AZURE_OBJECT_CLASS = 'VirtualMachine' @@ -887,6 +873,9 @@ class AzureRMVirtualMachine(AzureRMModuleBase): self.results['state']['status'] = 'Deleted' self.delete_vm(vm) + # until we sort out how we want to do this globally + del self.results['actions'] + return self.results def get_vm(self): diff --git a/lib/ansible/modules/cloud/azure/azure_rm_virtualnetwork.py b/lib/ansible/modules/cloud/azure/azure_rm_virtualnetwork.py index d4b2d0b1964..574e3c257c8 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_virtualnetwork.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_virtualnetwork.py @@ -77,21 +77,10 @@ options: - absent - present required: false - tags: - description: - - "Dictionary of string:string pairs to assign as metadata to the object. Metadata tags on the object - will be updated with any provided values. To remove tags use the purge_tags option." - default: null - required: false - purge_tags: - description: - - Use to remove tags from an object. Any tags not found in the tags parameter will be removed from - the object's metadata. - default: false - required: false extends_documentation_fragment: - azure + - azure_tags author: - "Chris Houseknecht (@chouseknecht)" @@ -150,7 +139,6 @@ from ansible.module_utils.azure_rm_common import * try: from msrestazure.azure_exceptions import CloudError - from azure.common import AzureMissingResourceHttpError from azure.mgmt.network.models import VirtualNetwork, AddressSpace, DhcpOptions except ImportError: # This is handled in azure_rm_common