Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Bugs #8227, #11226 - subnet info lost on vNet update #2

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion builtin/providers/azurerm/resource_arm_virtual_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ func resourceAzureSubnetHash(v interface{}) int {
}
return hashcode.String(subnet)
}

func getExistingSubnet(resGroup string, vnetName string, subnetName string, meta interface{}) network.Subnet {
//attempt to retrieve existing subnet from the server
existingSubnet := network.Subnet{}
Expand Down Expand Up @@ -328,3 +327,41 @@ func getExistingSubnet(resGroup string, vnetName string, subnetName string, meta

return existingSubnet
}

func expandAzureRmVirtualNetworkVirtualNetworkSecurityGroupNames(d *schema.ResourceData) ([]string, error) {
nsgNames := make([]string, 0)

if v, ok := d.GetOk("subnet"); ok {
subnets := v.(*schema.Set).List()
for _, subnet := range subnets {
subnet, ok := subnet.(map[string]interface{})
if !ok {
return nil, fmt.Errorf("[ERROR] Subnet should be a Hash - was '%+v'", subnet)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"map" seems less ambiguous than "hash"

}

networkSecurityGroupId := subnet["security_group"].(string)
if networkSecurityGroupId != "" {
nsgName, err := parseNetworkSecurityGroupName(networkSecurityGroupId)
if err != nil {
return nil, err
}

nsgNames = append(nsgNames, nsgName)
}
}
}

return nsgNames, nil
}

func azureRMVirtualNetworkUnlockNetworkSecurityGroups(networkSecurityGroupNames *[]string) {
for _, networkSecurityGroupName := range *networkSecurityGroupNames {
armMutexKV.Unlock(networkSecurityGroupName)
}
}

func azureRMVirtualNetworkLockNetworkSecurityGroups(networkSecurityGroupNames *[]string) {
for _, networkSecurityGroupName := range *networkSecurityGroupNames {
armMutexKV.Lock(networkSecurityGroupName)
}
}
You are viewing a condensed version of this merge commit. You can view the full changes here.