1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

subnet should in the virtual network resource group (#35038)

This commit is contained in:
Yuwei Zhou 2018-01-25 10:53:28 +08:00 committed by Jordan Borean
parent e0010f15e4
commit bec4dcd66c

View file

@ -1605,11 +1605,11 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
# Find a virtual network # Find a virtual network
no_vnets_msg = "Error: unable to find virtual network in resource group {0}. A virtual network " \ no_vnets_msg = "Error: unable to find virtual network in resource group {0}. A virtual network " \
"with at least one subnet must exist in order to create a NIC for the virtual " \ "with at least one subnet must exist in order to create a NIC for the virtual " \
"machine.".format(self.resource_group) "machine.".format(virtual_network_resource_group)
virtual_network_name = None virtual_network_name = None
try: try:
vnets = self.network_client.virtual_networks.list(self.resource_group) vnets = self.network_client.virtual_networks.list(virtual_network_resource_group)
except CloudError: except CloudError:
self.log('cloud error!') self.log('cloud error!')
self.fail(no_vnets_msg) self.fail(no_vnets_msg)
@ -1624,7 +1624,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
if self.subnet_name: if self.subnet_name:
try: try:
subnet = self.network_client.subnets.get(self.resource_group, virtual_network_name, self.subnet_name) subnet = self.network_client.subnets.get(virtual_network_resource_group, virtual_network_name, self.subnet_name)
subnet_id = subnet.id subnet_id = subnet.id
except Exception as exc: except Exception as exc:
self.fail("Error: fetching subnet {0} - {1}".format(self.subnet_name, str(exc))) self.fail("Error: fetching subnet {0} - {1}".format(self.subnet_name, str(exc)))