mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Bulk autopep8 (modules)
As agreed in 2017-12-07 Core meeting bulk fix pep8 issues Generated using: autopep8 1.3.3 (pycodestyle: 2.3.1) autopep8 -r --max-line-length 160 --in-place --ignore E305,E402,E722,E741 lib/ansible/modules Manually fix issues that autopep8 has introduced
This commit is contained in:
parent
d13d7e9404
commit
c57a7f05e1
314 changed files with 3462 additions and 3383 deletions
|
@ -512,7 +512,7 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
|||
if self.wait_for_deployment_completion:
|
||||
deployment_result = self.get_poller_result(result)
|
||||
while deployment_result.properties is None or deployment_result.properties.provisioning_state not in ['Canceled', 'Failed', 'Deleted',
|
||||
'Succeeded']:
|
||||
'Succeeded']:
|
||||
time.sleep(self.wait_for_deployment_polling_period)
|
||||
deployment_result = self.rm_client.deployments.get(self.resource_group_name, self.deployment_name)
|
||||
except CloudError as exc:
|
||||
|
@ -535,7 +535,7 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
|||
"""
|
||||
try:
|
||||
result = self.rm_client.resource_groups.delete(self.resource_group_name)
|
||||
result.wait() # Blocking wait till the delete is finished
|
||||
result.wait() # Blocking wait till the delete is finished
|
||||
except CloudError as e:
|
||||
if e.status_code == 404 or e.status_code == 204:
|
||||
return
|
||||
|
@ -569,7 +569,7 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
|||
nested_deployment)
|
||||
except CloudError as exc:
|
||||
self.fail("List nested deployment operations failed with status code: %s and message: %s" %
|
||||
(exc.status_code, exc.message))
|
||||
(exc.status_code, exc.message))
|
||||
new_nested_operations = self._get_failed_nested_operations(nested_operations)
|
||||
new_operations += new_nested_operations
|
||||
return new_operations
|
||||
|
@ -642,10 +642,10 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
|||
|
||||
def _get_ip_dict(self, ip):
|
||||
ip_dict = dict(name=ip.name,
|
||||
id=ip.id,
|
||||
public_ip=ip.ip_address,
|
||||
public_ip_allocation_method=str(ip.public_ip_allocation_method)
|
||||
)
|
||||
id=ip.id,
|
||||
public_ip=ip.ip_address,
|
||||
public_ip_allocation_method=str(ip.public_ip_allocation_method)
|
||||
)
|
||||
if ip.dns_settings:
|
||||
ip_dict['dns_settings'] = {
|
||||
'domain_name_label': ip.dns_settings.domain_name_label,
|
||||
|
@ -657,9 +657,9 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
|||
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 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]]
|
||||
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]]
|
||||
|
||||
|
||||
def main():
|
||||
|
|
|
@ -154,6 +154,7 @@ def managed_disk_to_dict(managed_disk):
|
|||
|
||||
class AzureRMManagedDisk(AzureRMModuleBase):
|
||||
"""Configuration class for an Azure RM Managed Disk resource"""
|
||||
|
||||
def __init__(self):
|
||||
self.module_arg_spec = dict(
|
||||
resource_group=dict(
|
||||
|
|
|
@ -219,7 +219,7 @@ state:
|
|||
try:
|
||||
from msrestazure.azure_exceptions import CloudError
|
||||
from azure.mgmt.network.models import NetworkInterface, NetworkInterfaceIPConfiguration, Subnet, \
|
||||
PublicIPAddress, NetworkSecurityGroup
|
||||
PublicIPAddress, NetworkSecurityGroup
|
||||
except ImportError:
|
||||
# This is handled in azure_rm_common
|
||||
pass
|
||||
|
@ -442,7 +442,7 @@ class AzureRMNetworkInterface(AzureRMModuleBase):
|
|||
if not pip and self.public_ip:
|
||||
# create a default public_ip
|
||||
pip = self.create_default_pip(self.resource_group, self.location, self.name,
|
||||
self.public_ip_allocation_method)
|
||||
self.public_ip_allocation_method)
|
||||
|
||||
nic = NetworkInterface(
|
||||
location=self.location,
|
||||
|
@ -475,8 +475,7 @@ class AzureRMNetworkInterface(AzureRMModuleBase):
|
|||
tags=results['tags'],
|
||||
ip_configurations=[
|
||||
NetworkInterfaceIPConfiguration(
|
||||
private_ip_allocation_method=
|
||||
results['ip_configuration']['private_ip_allocation_method']
|
||||
private_ip_allocation_method=results['ip_configuration']['private_ip_allocation_method']
|
||||
)
|
||||
]
|
||||
)
|
||||
|
@ -496,7 +495,7 @@ class AzureRMNetworkInterface(AzureRMModuleBase):
|
|||
id=pip.id,
|
||||
location=pip.location,
|
||||
resource_guid=pip.resource_guid)
|
||||
#name=pip.name,
|
||||
# name=pip.name,
|
||||
|
||||
if results['network_security_group'].get('id'):
|
||||
nsg = self.get_security_group(results['network_security_group']['name'])
|
||||
|
@ -549,8 +548,8 @@ class AzureRMNetworkInterface(AzureRMModuleBase):
|
|||
subnet = self.network_client.subnets.get(self.resource_group, vnet_name, subnet_name)
|
||||
except Exception as exc:
|
||||
self.fail("Error: fetching subnet {0} in virtual network {1} - {2}".format(subnet_name,
|
||||
vnet_name,
|
||||
str(exc)))
|
||||
vnet_name,
|
||||
str(exc)))
|
||||
return subnet
|
||||
|
||||
def get_security_group(self, name):
|
||||
|
|
|
@ -193,7 +193,7 @@ class AzureRMPublicIPAddress(AzureRMModuleBase):
|
|||
if self.domain_name != results['dns_settings'].get('domain_name_label'):
|
||||
self.log('CHANGED: domain_name_label')
|
||||
changed = True
|
||||
results['dns_settings']['domain_name_label'] =self.domain_name
|
||||
results['dns_settings']['domain_name_label'] = self.domain_name
|
||||
|
||||
if self.allocation_method != results['public_ip_allocation_method']:
|
||||
self.log("CHANGED: allocation_method")
|
||||
|
|
|
@ -183,7 +183,6 @@ class AzureRMPublicIPFacts(AzureRMModuleBase):
|
|||
return results
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
AzureRMPublicIPFacts()
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ try:
|
|||
from azure.common import AzureMissingResourceHttpError
|
||||
from azure.mgmt.storage.models import ProvisioningState, SkuName, SkuTier, Kind
|
||||
from azure.mgmt.storage.models import StorageAccountUpdateParameters, CustomDomain, \
|
||||
StorageAccountCreateParameters, Sku
|
||||
StorageAccountCreateParameters, Sku
|
||||
except ImportError:
|
||||
# This is handled in azure_rm_common
|
||||
pass
|
||||
|
@ -226,7 +226,7 @@ class AzureRMStorageAccount(AzureRMModuleBase):
|
|||
self.account_dict = self.get_account()
|
||||
|
||||
if self.state == 'present' and self.account_dict and \
|
||||
self.account_dict['provisioning_state'] != AZURE_SUCCESS_STATE :
|
||||
self.account_dict['provisioning_state'] != AZURE_SUCCESS_STATE:
|
||||
self.fail("Error: storage account {0} has not completed provisioning. State is {1}. Expecting state "
|
||||
"to be {2}.".format(self.name, self.account_dict['provisioning_state'], AZURE_SUCCESS_STATE))
|
||||
|
||||
|
@ -280,7 +280,7 @@ class AzureRMStorageAccount(AzureRMModuleBase):
|
|||
resource_group=self.resource_group,
|
||||
type=account_obj.type,
|
||||
access_tier=(account_obj.access_tier.value
|
||||
if account_obj.access_tier is not None else None),
|
||||
if account_obj.access_tier is not None else None),
|
||||
sku_tier=account_obj.sku.tier.value,
|
||||
sku_name=account_obj.sku.name.value,
|
||||
provisioning_state=account_obj.provisioning_state.value,
|
||||
|
|
|
@ -132,7 +132,6 @@ except ImportError:
|
|||
pass
|
||||
|
||||
|
||||
|
||||
def subnet_to_dict(subnet):
|
||||
result = dict(
|
||||
id=subnet.id,
|
||||
|
|
|
@ -598,14 +598,14 @@ try:
|
|||
from msrestazure.azure_exceptions import CloudError
|
||||
from msrestazure.tools import parse_resource_id
|
||||
from azure.mgmt.compute.models import NetworkInterfaceReference, \
|
||||
VirtualMachine, HardwareProfile, \
|
||||
StorageProfile, OSProfile, OSDisk, DataDisk, \
|
||||
VirtualHardDisk, ManagedDiskParameters, \
|
||||
ImageReference, NetworkProfile, LinuxConfiguration, \
|
||||
SshConfiguration, SshPublicKey, VirtualMachineSizeTypes, \
|
||||
DiskCreateOptionTypes, Plan, SubResource
|
||||
VirtualMachine, HardwareProfile, \
|
||||
StorageProfile, OSProfile, OSDisk, DataDisk, \
|
||||
VirtualHardDisk, ManagedDiskParameters, \
|
||||
ImageReference, NetworkProfile, LinuxConfiguration, \
|
||||
SshConfiguration, SshPublicKey, VirtualMachineSizeTypes, \
|
||||
DiskCreateOptionTypes, Plan, SubResource
|
||||
from azure.mgmt.network.models import PublicIPAddress, NetworkSecurityGroup, NetworkInterface, \
|
||||
NetworkInterfaceIPConfiguration, Subnet
|
||||
NetworkInterfaceIPConfiguration, Subnet
|
||||
from azure.mgmt.storage.models import StorageAccountCreateParameters, Sku
|
||||
from azure.mgmt.storage.models import Kind, SkuTier, SkuName
|
||||
except ImportError:
|
||||
|
@ -659,7 +659,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
|||
open_ports=dict(type='list'),
|
||||
network_interface_names=dict(type='list', aliases=['network_interfaces']),
|
||||
remove_on_absent=dict(type='list', default=['all']),
|
||||
virtual_network_resource_group=dict(type = 'str'),
|
||||
virtual_network_resource_group=dict(type='str'),
|
||||
virtual_network_name=dict(type='str', aliases=['virtual_network']),
|
||||
subnet_name=dict(type='str', aliases=['subnet']),
|
||||
allocated=dict(type='bool', default=True),
|
||||
|
@ -1297,7 +1297,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
|||
nic_names = []
|
||||
pip_names = []
|
||||
|
||||
if self.remove_on_absent.intersection(set(['all','virtual_storage'])):
|
||||
if self.remove_on_absent.intersection(set(['all', 'virtual_storage'])):
|
||||
# store the attached vhd info so we can nuke it after the VM is gone
|
||||
if(vm.storage_profile.os_disk.managed_disk):
|
||||
self.log('Storing managed disk ID for deletion')
|
||||
|
@ -1319,7 +1319,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
|||
self.log("Managed disk IDs to delete: {0}".format(', '.join(managed_disk_ids)))
|
||||
self.results['deleted_managed_disk_ids'] = managed_disk_ids
|
||||
|
||||
if self.remove_on_absent.intersection(set(['all','network_interfaces'])):
|
||||
if self.remove_on_absent.intersection(set(['all', 'network_interfaces'])):
|
||||
# store the attached nic info so we can nuke them after the VM is gone
|
||||
self.log('Storing NIC names for deletion.')
|
||||
for interface in vm.network_profile.network_interfaces:
|
||||
|
@ -1327,7 +1327,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
|||
nic_names.append(id_dict['networkInterfaces'])
|
||||
self.log('NIC names to delete {0}'.format(', '.join(nic_names)))
|
||||
self.results['deleted_network_interfaces'] = nic_names
|
||||
if self.remove_on_absent.intersection(set(['all','public_ips'])):
|
||||
if self.remove_on_absent.intersection(set(['all', 'public_ips'])):
|
||||
# also store each nic's attached public IPs and delete after the NIC is gone
|
||||
for name in nic_names:
|
||||
nic = self.get_network_interface(name)
|
||||
|
@ -1349,18 +1349,18 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
|||
|
||||
# TODO: parallelize nic, vhd, and public ip deletions with begin_deleting
|
||||
# TODO: best-effort to keep deleting other linked resources if we encounter an error
|
||||
if self.remove_on_absent.intersection(set(['all','virtual_storage'])):
|
||||
if self.remove_on_absent.intersection(set(['all', 'virtual_storage'])):
|
||||
self.log('Deleting VHDs')
|
||||
self.delete_vm_storage(vhd_uris)
|
||||
self.log('Deleting managed disks')
|
||||
self.delete_managed_disks(managed_disk_ids)
|
||||
|
||||
if self.remove_on_absent.intersection(set(['all','network_interfaces'])):
|
||||
if self.remove_on_absent.intersection(set(['all', 'network_interfaces'])):
|
||||
self.log('Deleting network interfaces')
|
||||
for name in nic_names:
|
||||
self.delete_nic(name)
|
||||
|
||||
if self.remove_on_absent.intersection(set(['all','public_ips'])):
|
||||
if self.remove_on_absent.intersection(set(['all', 'public_ips'])):
|
||||
self.log('Deleting public IPs')
|
||||
for name in pip_names:
|
||||
self.delete_pip(name)
|
||||
|
@ -1461,6 +1461,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
|||
return ImageReference(id=vm_image.id)
|
||||
|
||||
self.fail("Error could not find image with name {0}".format(name))
|
||||
|
||||
def get_availability_set(self, resource_group, name):
|
||||
try:
|
||||
return self.compute_client.availability_sets.get(resource_group, name)
|
||||
|
|
|
@ -195,7 +195,7 @@ class AzureRMVirtualNetwork(AzureRMModuleBase):
|
|||
self.dns_servers = None
|
||||
self.purge_dns_servers = None
|
||||
|
||||
self.results=dict(
|
||||
self.results = dict(
|
||||
changed=False,
|
||||
state=dict()
|
||||
)
|
||||
|
@ -327,7 +327,6 @@ class AzureRMVirtualNetwork(AzureRMModuleBase):
|
|||
self.delete_virtual_network()
|
||||
self.results['state']['status'] = 'Deleted'
|
||||
|
||||
|
||||
return self.results
|
||||
|
||||
def create_or_update_vnet(self, vnet):
|
||||
|
|
|
@ -178,6 +178,7 @@ class AzureRMNetworkInterfaceFacts(AzureRMModuleBase):
|
|||
results.append(self.serialize_obj(item, AZURE_OBJECT_CLASS))
|
||||
return results
|
||||
|
||||
|
||||
def main():
|
||||
AzureRMNetworkInterfaceFacts()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue