@@ -100,7 +100,7 @@ func resourceNetworkIPRange() *schema.Resource {
100
100
}
101
101
102
102
func resourceNetworkIPRangeCreate (ctx context.Context , d * schema.ResourceData , m interface {}) diag.Diagnostics {
103
- log .Printf ("Starting to create vra_network_profile resource" )
103
+ log .Printf ("Starting to create vra_network_ip_range resource" )
104
104
apiClient := m .(* Client ).apiClient
105
105
106
106
name := d .Get ("name" ).(string )
@@ -129,7 +129,7 @@ func resourceNetworkIPRangeCreate(ctx context.Context, d *schema.ResourceData, m
129
129
networkIPRangeSpecification .Description = v .(string )
130
130
}
131
131
132
- log .Printf ("[DEBUG] create network ip rangee : %#v" , networkIPRangeSpecification )
132
+ log .Printf ("[DEBUG] Creating vra_network_ip_range with specification : %#v" , networkIPRangeSpecification )
133
133
134
134
createNetworkIPRangeCreated , err := apiClient .NetworkIPRange .CreateInternalNetworkIPRange (network_ip_range .NewCreateInternalNetworkIPRangeParams ().WithBody (& networkIPRangeSpecification ))
135
135
if err != nil {
@@ -144,7 +144,7 @@ func resourceNetworkIPRangeCreate(ctx context.Context, d *schema.ResourceData, m
144
144
}
145
145
146
146
func resourceNetworkIPRangeRead (_ context.Context , d * schema.ResourceData , m interface {}) diag.Diagnostics {
147
- log .Printf ("Reading the vra_network_profile resource with name %s" , d .Get ("name" ))
147
+ log .Printf ("Reading the vra_network_ip_range resource with name %s" , d .Get ("name" ))
148
148
apiClient := m .(* Client ).apiClient
149
149
150
150
id := d .Id ()
@@ -171,6 +171,9 @@ func resourceNetworkIPRangeRead(_ context.Context, d *schema.ResourceData, m int
171
171
fabricNetworkIds = append (fabricNetworkIds , strings .TrimPrefix (fabricNetworkLink , "/iaas/api/fabric-networks/" ))
172
172
}
173
173
d .Set ("fabric_network_ids" , fabricNetworkIds )
174
+ } else if fabricNetworkLink , ok := networkIPRange .Links ["fabric-network" ]; ok {
175
+ fabricNetworkIds := []string {strings .TrimPrefix (fabricNetworkLink .Href , "/iaas/api/fabric-networks/" )}
176
+ d .Set ("fabric_network_ids" , fabricNetworkIds )
174
177
}
175
178
176
179
if err := d .Set ("links" , flattenLinks (networkIPRange .Links )); err != nil {
@@ -187,15 +190,15 @@ func resourceNetworkIPRangeRead(_ context.Context, d *schema.ResourceData, m int
187
190
}
188
191
189
192
func resourceNetworkIPRangeUpdate (ctx context.Context , d * schema.ResourceData , m interface {}) diag.Diagnostics {
190
- log .Printf ("Starting to Update vra_network_profile resource" )
193
+ log .Printf ("Starting to update the vra_network_ip_range resource with name %s" , d . Get ( "name" ) )
191
194
apiClient := m .(* Client ).apiClient
192
195
193
196
id := d .Id ()
194
197
name := d .Get ("name" ).(string )
195
198
endIPAddress := d .Get ("end_ip_address" ).(string )
196
199
startIPAddress := d .Get ("start_ip_address" ).(string )
197
200
fabricNetworkIDs := []string {}
198
- if v , ok := d .GetOk ("fabricNetworkIDs " ); ok {
201
+ if v , ok := d .GetOk ("fabric_network_ids " ); ok {
199
202
if ! compareUnique (v .(* schema.Set ).List ()) {
200
203
return diag .FromErr (errors .New ("specified fabric_network_ids are not unique" ))
201
204
}
@@ -216,13 +219,13 @@ func resourceNetworkIPRangeUpdate(ctx context.Context, d *schema.ResourceData, m
216
219
if v , ok := d .GetOk ("description" ); ok {
217
220
networkIPRangeSpecification .Description = v .(string )
218
221
}
219
- log .Printf ("[DEBUG] update network ip range : %#v" , networkIPRangeSpecification )
222
+ log .Printf ("[DEBUG] Updating vra_network_ip_range resource with specification : %#v" , networkIPRangeSpecification )
220
223
221
224
_ , err := apiClient .NetworkIPRange .UpdateInternalNetworkIPRange (network_ip_range .NewUpdateInternalNetworkIPRangeParams ().WithID (id ).WithBody (& networkIPRangeSpecification ))
222
225
if err != nil {
223
226
return diag .FromErr (err )
224
227
}
225
- log .Printf ("finished Updating vra_network_profile resource" )
228
+ log .Printf ("Finished updating the vra_network_ip_range resource with name %s" , d . Get ( "name" ) )
226
229
return resourceNetworkIPRangeRead (ctx , d , m )
227
230
228
231
}
0 commit comments