Merge pull request #3651 from Sheile/ignore-sg-order
provider/openstack: Ignore order of security_groups in instance
This commit is contained in:
commit
beab5619e2
|
@ -93,10 +93,11 @@ func resourceComputeInstanceV2() *schema.Resource {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"security_groups": &schema.Schema{
|
"security_groups": &schema.Schema{
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeSet,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: false,
|
ForceNew: false,
|
||||||
Elem: &schema.Schema{Type: schema.TypeString},
|
Elem: &schema.Schema{Type: schema.TypeString},
|
||||||
|
Set: schema.HashString,
|
||||||
},
|
},
|
||||||
"availability_zone": &schema.Schema{
|
"availability_zone": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
|
@ -600,9 +601,8 @@ func resourceComputeInstanceV2Update(d *schema.ResourceData, meta interface{}) e
|
||||||
|
|
||||||
if d.HasChange("security_groups") {
|
if d.HasChange("security_groups") {
|
||||||
oldSGRaw, newSGRaw := d.GetChange("security_groups")
|
oldSGRaw, newSGRaw := d.GetChange("security_groups")
|
||||||
oldSGSlice, newSGSlice := oldSGRaw.([]interface{}), newSGRaw.([]interface{})
|
oldSGSet := oldSGRaw.(*schema.Set)
|
||||||
oldSGSet := schema.NewSet(func(v interface{}) int { return hashcode.String(v.(string)) }, oldSGSlice)
|
newSGSet := newSGRaw.(*schema.Set)
|
||||||
newSGSet := schema.NewSet(func(v interface{}) int { return hashcode.String(v.(string)) }, newSGSlice)
|
|
||||||
secgroupsToAdd := newSGSet.Difference(oldSGSet)
|
secgroupsToAdd := newSGSet.Difference(oldSGSet)
|
||||||
secgroupsToRemove := oldSGSet.Difference(newSGSet)
|
secgroupsToRemove := oldSGSet.Difference(newSGSet)
|
||||||
|
|
||||||
|
@ -807,7 +807,7 @@ func ServerV2StateRefreshFunc(client *gophercloud.ServiceClient, instanceID stri
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceInstanceSecGroupsV2(d *schema.ResourceData) []string {
|
func resourceInstanceSecGroupsV2(d *schema.ResourceData) []string {
|
||||||
rawSecGroups := d.Get("security_groups").([]interface{})
|
rawSecGroups := d.Get("security_groups").(*schema.Set).List()
|
||||||
secgroups := make([]string, len(rawSecGroups))
|
secgroups := make([]string, len(rawSecGroups))
|
||||||
for i, raw := range rawSecGroups {
|
for i, raw := range rawSecGroups {
|
||||||
secgroups[i] = raw.(string)
|
secgroups[i] = raw.(string)
|
||||||
|
|
Loading…
Reference in New Issue