mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-06 16:34:02 -07:00
Update conventions in azure modules
* Remove wildcard imports * Update GPL header to the one-line form * Add from __future__ imports
This commit is contained in:
parent
3a2670e0fd
commit
30a688d8d3
19 changed files with 137 additions and 365 deletions
|
@ -1,19 +1,12 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible 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.
|
||||
#
|
||||
# Ansible 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 Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# Copyright (c) Ansible Project
|
||||
# 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'],
|
||||
'supported_by': 'curated'}
|
||||
|
@ -374,18 +367,9 @@ deployment:
|
|||
returned: always
|
||||
'''
|
||||
|
||||
PREREQ_IMPORT_ERROR = None
|
||||
import time
|
||||
|
||||
try:
|
||||
import time
|
||||
import yaml
|
||||
except ImportError as exc:
|
||||
IMPORT_ERROR = "Error importing module prerequisites: %s" % exc
|
||||
|
||||
from ansible.module_utils.azure_rm_common import *
|
||||
|
||||
try:
|
||||
from itertools import chain
|
||||
from azure.common.credentials import ServicePrincipalCredentials
|
||||
from azure.common.exceptions import CloudError
|
||||
from azure.mgmt.resource.resources.models import (DeploymentProperties,
|
||||
|
@ -401,6 +385,8 @@ except ImportError:
|
|||
# This is handled in azure_rm_common
|
||||
pass
|
||||
|
||||
from ansible.module_utils.azure_rm_common import AzureRMModuleBase
|
||||
|
||||
|
||||
class AzureRMDeploymentManager(AzureRMModuleBase):
|
||||
|
||||
|
@ -448,9 +434,6 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
|||
|
||||
def exec_module(self, **kwargs):
|
||||
|
||||
if PREREQ_IMPORT_ERROR:
|
||||
self.fail(PREREQ_IMPORT_ERROR)
|
||||
|
||||
for key in list(self.module_arg_spec.keys()) + ['tags']:
|
||||
setattr(self, key, kwargs[key])
|
||||
|
||||
|
@ -647,15 +630,15 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
|||
)
|
||||
if ip.dns_settings:
|
||||
ip_dict['dns_settings'] = {
|
||||
'domain_name_label':ip.dns_settings.domain_name_label,
|
||||
'fqdn':ip.dns_settings.fqdn
|
||||
'domain_name_label': ip.dns_settings.domain_name_label,
|
||||
'fqdn': ip.dns_settings.fqdn
|
||||
}
|
||||
return ip_dict
|
||||
|
||||
def _nic_to_public_ips_instance(self, nics):
|
||||
return [self.network_client.public_ip_addresses.get(public_ip_id.split('/')[4], public_ip_id.split('/')[-1])
|
||||
for nic_obj in [self.network_client.network_interfaces.get(self.resource_group_name,
|
||||
nic['dep'].resource_name) for nic in nics]
|
||||
for nic_obj in (self.network_client.network_interfaces.get(self.resource_group_name,
|
||||
nic['dep'].resource_name) for nic in nics)
|
||||
for public_ip_id in [ip_conf_instance.public_ip_address.id
|
||||
for ip_conf_instance in nic_obj.ip_configurations
|
||||
if ip_conf_instance.public_ip_address]]
|
||||
|
@ -664,7 +647,6 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
|||
def main():
|
||||
AzureRMDeploymentManager()
|
||||
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue