@@ -58,10 +58,11 @@ func schemaHostVirtualSwitchBondBridge() map[string]*schema.Schema {
58
58
59
59
// HostVirtualSwitchBondBridge
60
60
"network_adapters" : {
61
- Type : schema .TypeList ,
62
- Required : true ,
63
- Description : "The list of network adapters to bind to this virtual switch." ,
64
- Elem : & schema.Schema {Type : schema .TypeString },
61
+ Type : schema .TypeList ,
62
+ Required : true ,
63
+ Description : "The list of network adapters to bind to this virtual switch." ,
64
+ Elem : & schema.Schema {Type : schema .TypeString },
65
+ DiffSuppressFunc : networkAdaptersSupressDiff ,
65
66
},
66
67
}
67
68
}
@@ -199,3 +200,39 @@ func splitHostVirtualSwitchID(raw string) (string, string, error) {
199
200
func virtualSwitchIDsFromResourceID (d * schema.ResourceData ) (string , string , error ) {
200
201
return splitHostVirtualSwitchID (d .Id ())
201
202
}
203
+
204
+ // networkAdaptersSupressDiff checks if the 'network_adapters' set has changed, ignoring and difference
205
+ // in the order of elements.
206
+ func networkAdaptersSupressDiff (_ , _ , _ string , d * schema.ResourceData ) bool {
207
+ o , n := d .GetChange ("network_adapters" )
208
+ oldAdapters := o .([]interface {})
209
+ newAdapters := n .([]interface {})
210
+
211
+ if len (oldAdapters ) != len (newAdapters ) {
212
+ return false
213
+ }
214
+
215
+ for _ , oldAdapter := range oldAdapters {
216
+ if found := isAdapterFound (oldAdapter , newAdapters ); ! found {
217
+ return false
218
+ }
219
+ }
220
+
221
+ for _ , newAdapter := range newAdapters {
222
+ if found := isAdapterFound (newAdapter , oldAdapters ); ! found {
223
+ return false
224
+ }
225
+ }
226
+
227
+ return true
228
+ }
229
+
230
+ func isAdapterFound (adapter interface {}, set []interface {}) bool {
231
+ for _ , v := range set {
232
+ if adapter == v {
233
+ return true
234
+ }
235
+ }
236
+
237
+ return false
238
+ }
0 commit comments