mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
azure_rm_networkinterface: don't query subnet as it's not necessary (#36826)
* don't query subnet as it's not necessary * fixed pep8? * another attempt to fix pep8 indentation
This commit is contained in:
parent
d5cd10c214
commit
9fb04d20e1
1 changed files with 7 additions and 10 deletions
|
@ -499,9 +499,13 @@ class AzureRMNetworkInterface(AzureRMModuleBase):
|
|||
|
||||
if changed:
|
||||
if self.state == 'present':
|
||||
subnet = self.get_subnet(virtual_network_resource_group, virtual_network_name, self.subnet_name)
|
||||
if not subnet:
|
||||
self.fail('subnet {0} is not exist'.format(self.subnet_name))
|
||||
subnet = self.network_models.SubResource(
|
||||
'/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/virtualNetworks/{2}/subnets/{3}'.format(
|
||||
self.subscription_id,
|
||||
virtual_network_resource_group,
|
||||
virtual_network_name,
|
||||
self.subnet_name))
|
||||
|
||||
nic_ip_configurations = [
|
||||
self.network_models.NetworkInterfaceIPConfiguration(
|
||||
private_ip_allocation_method=ip_config.get('private_ip_allocation_method'),
|
||||
|
@ -573,13 +577,6 @@ class AzureRMNetworkInterface(AzureRMModuleBase):
|
|||
except Exception as exc:
|
||||
return None
|
||||
|
||||
def get_subnet(self, resource_group, vnet_name, subnet_name):
|
||||
self.log("Fetching subnet {0} in virtual network {1}".format(subnet_name, vnet_name))
|
||||
try:
|
||||
return self.network_client.subnets.get(resource_group, vnet_name, subnet_name)
|
||||
except Exception as exc:
|
||||
return None
|
||||
|
||||
def get_security_group(self, name):
|
||||
self.log("Fetching security group {0}".format(name))
|
||||
try:
|
||||
|
|
Loading…
Reference in a new issue