Skip to content

Commit 12c5f98

Browse files
authored
Merge pull request #522 from vmware/fix-cloud-account-update
Fix update for vSphere/VMC/NSX-T/NSX-V cloud accounts
2 parents 385e5c7 + 6bd100b commit 12c5f98

File tree

4 files changed

+33
-12
lines changed

4 files changed

+33
-12
lines changed

vra/resource_cloud_account_nsxt.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,14 @@ func resourceCloudAccountNSXTUpdate(ctx context.Context, d *schema.ResourceData,
191191
WithAPIVersion(IaaSAPIVersion).
192192
WithID(id).
193193
WithBody(&models.UpdateCloudAccountNsxTSpecification{
194-
Description: d.Get("description").(string),
195-
Tags: expandTags(d.Get("tags").(*schema.Set).List()),
194+
AcceptSelfSignedCertificate: d.Get("accept_self_signed_cert").(bool),
195+
Dcid: withString(d.Get("dc_id").(string)),
196+
Description: d.Get("description").(string),
197+
HostName: withString(d.Get("hostname").(string)),
198+
Name: d.Get("name").(string),
199+
Password: withString(d.Get("password").(string)),
200+
Tags: expandTags(d.Get("tags").(*schema.Set).List()),
201+
Username: withString(d.Get("username").(string)),
196202
}))
197203
if err != nil {
198204
return diag.FromErr(err)

vra/resource_cloud_account_nsxv.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,12 @@ func resourceCloudAccountNSXVUpdate(ctx context.Context, d *schema.ResourceData,
173173
WithAPIVersion(IaaSAPIVersion).
174174
WithID(id).
175175
WithBody(&models.UpdateCloudAccountNsxVSpecification{
176-
Description: d.Get("description").(string),
177-
Tags: expandTags(d.Get("tags").(*schema.Set).List()),
176+
AcceptSelfSignedCertificate: d.Get("accept_self_signed_cert").(bool),
177+
Dcid: withString(d.Get("dc_id").(string)),
178+
HostName: withString(d.Get("hostname").(string)),
179+
Name: d.Get("name").(string),
180+
Password: withString(d.Get("password").(string)),
181+
Username: withString(d.Get("username").(string)),
178182
}))
179183
if err != nil {
180184
return diag.FromErr(err)

vra/resource_cloud_account_vmc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ func resourceCloudAccountVMCUpdate(ctx context.Context, d *schema.ResourceData,
229229
WithBody(&models.UpdateCloudAccountSpecification{
230230
CreateDefaultZones: false,
231231
Description: d.Get("description").(string),
232+
Name: d.Get("name").(string),
232233
Regions: regions,
233234
Tags: expandTags(d.Get("tags").(*schema.Set).List()),
234235
}))

vra/resource_cloud_account_vsphere.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,18 @@ func resourceCloudAccountVsphereRead(_ context.Context, d *schema.ResourceData,
213213
}
214214

215215
func resourceCloudAccountVsphereUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
216+
var associatedCloudAccountIDs []string
216217
var regions []*models.RegionSpecification
217218

218219
apiClient := m.(*Client).apiClient
219220

221+
if v, ok := d.GetOk("associated_cloud_account_ids"); ok {
222+
if !compareUnique(v.(*schema.Set).List()) {
223+
return diag.FromErr(errors.New("specified associated cloud account ids are not unique"))
224+
}
225+
associatedCloudAccountIDs = expandStringList(v.(*schema.Set).List())
226+
}
227+
220228
if v, ok := d.GetOk("regions"); ok {
221229
if !compareUnique(v.(*schema.Set).List()) {
222230
return diag.FromErr(errors.New("specified regions are not unique"))
@@ -230,14 +238,16 @@ func resourceCloudAccountVsphereUpdate(ctx context.Context, d *schema.ResourceDa
230238
WithAPIVersion(IaaSAPIVersion).
231239
WithID(id).
232240
WithBody(&models.UpdateCloudAccountVsphereSpecification{
233-
CreateDefaultZones: false,
234-
Description: d.Get("description").(string),
235-
HostName: withString(d.Get("hostname").(string)),
236-
Name: d.Get("name").(string),
237-
Password: d.Get("password").(string),
238-
Regions: regions,
239-
Tags: expandTags(d.Get("tags").(*schema.Set).List()),
240-
Username: d.Get("username").(string),
241+
AcceptSelfSignedCertificate: d.Get("accept_self_signed_cert").(bool),
242+
AssociatedCloudAccountIds: associatedCloudAccountIDs,
243+
CreateDefaultZones: false,
244+
Description: d.Get("description").(string),
245+
HostName: withString(d.Get("hostname").(string)),
246+
Name: d.Get("name").(string),
247+
Password: d.Get("password").(string),
248+
Regions: regions,
249+
Tags: expandTags(d.Get("tags").(*schema.Set).List()),
250+
Username: d.Get("username").(string),
241251
}))
242252
if err != nil {
243253
return diag.FromErr(err)

0 commit comments

Comments
 (0)