diff --git a/.changes/v2.15.0/435-bug-fixes.md b/.changes/v2.15.0/435-bug-fixes.md new file mode 100644 index 000000000..08be0a6f5 --- /dev/null +++ b/.changes/v2.15.0/435-bug-fixes.md @@ -0,0 +1 @@ +* Fix method `client.GetStorageProfileByHref` to return IOPS `IopsSettings` [GH-435] diff --git a/govcd/system.go b/govcd/system.go index f4426abfa..d4387111e 100644 --- a/govcd/system.go +++ b/govcd/system.go @@ -736,8 +736,9 @@ func (client *Client) GetStorageProfileByHref(url string) (*types.VdcStorageProf vdcStorageProfile := &types.VdcStorageProfile{} - _, err := client.ExecuteRequest(url, http.MethodGet, - "", "error retrieving storage profile: %s", nil, vdcStorageProfile) + // only from 35.0 API version IOPS settings are added to response + _, err := client.ExecuteRequestWithApiVersion(url, http.MethodGet, + "", "error retrieving storage profile: %s", nil, vdcStorageProfile, client.GetSpecificApiVersionOnCondition(">= 35.0", "35.0")) if err != nil { return nil, err } diff --git a/govcd/system_test.go b/govcd/system_test.go index 519a0c4dd..141e50bbb 100644 --- a/govcd/system_test.go +++ b/govcd/system_test.go @@ -612,8 +612,10 @@ func (vcd *TestVCD) Test_GetStorageProfileByHref(check *C) { // Get storage profile by href foundStorageProfile, err := vcd.client.Client.GetStorageProfileByHref(adminVdc.AdminVdc.VdcStorageProfiles.VdcStorageProfile[0].HREF) check.Assert(err, IsNil) - check.Assert(foundStorageProfile, Not(Equals), types.VdcStorageProfile{}) check.Assert(foundStorageProfile, NotNil) + check.Assert(foundStorageProfile.IopsSettings, NotNil) + check.Assert(foundStorageProfile, Not(Equals), types.VdcStorageProfile{}) + check.Assert(foundStorageProfile.IopsSettings, Not(Equals), types.VdcStorageProfileIopsSettings{}) } func (vcd *TestVCD) Test_GetOrgList(check *C) { diff --git a/types/v56/types.go b/types/v56/types.go index a75ae4fa5..41c2db36f 100644 --- a/types/v56/types.go +++ b/types/v56/types.go @@ -489,7 +489,7 @@ type VdcStorageProfile struct { Units string `xml:"Units"` Limit int64 `xml:"Limit"` Default bool `xml:"Default"` - IopsSettings *VdcStorageProfileIopsSettings `xml:"IopsSettingsint64"` + IopsSettings *VdcStorageProfileIopsSettings `xml:"IopsSettings"` StorageUsedMB int64 `xml:"StorageUsedMB"` IopsAllocated int64 `xml:"IopsAllocated"` ProviderVdcStorageProfile *Reference `xml:"ProviderVdcStorageProfile"` @@ -506,7 +506,7 @@ type AdminVdcStorageProfile struct { Units string `xml:"Units"` Limit int64 `xml:"Limit"` Default bool `xml:"Default"` - IopsSettings *VdcStorageProfileIopsSettings `xml:"IopsSettingsint64"` + IopsSettings *VdcStorageProfileIopsSettings `xml:"IopsSettings"` StorageUsedMB int64 `xml:"StorageUsedMB"` IopsAllocated int64 `xml:"IopsAllocated"` ProviderVdcStorageProfile *Reference `xml:"ProviderVdcStorageProfile"` @@ -517,11 +517,11 @@ type AdminVdcStorageProfile struct { // https://vdc-repo.vmware.com/vmwb-repository/dcr-public/71e12563-bc11-4d64-821d-92d30f8fcfa1/7424bf8e-aec2-44ad-be7d-b98feda7bae0/doc/doc/types/VdcStorageProfileIopsSettingsType.html type VdcStorageProfileIopsSettings struct { Xmlns string `xml:"xmlns,attr"` - Enabled bool `xml:"enabled"` - DiskIopsMax int64 `xml:"diskIopsMax,"` - DiskIopsDefault int64 `xml:"diskIopsDefault"` - StorageProfileIopsLimit int64 `xml:"storageProfileIopsLimit,omitempty"` - DiskIopsPerGbMax int64 `xml:"diskIopsPerGbMax"` + Enabled bool `xml:"Enabled"` + DiskIopsMax int64 `xml:"DiskIopsMax"` + DiskIopsDefault int64 `xml:"DiskIopsDefault"` + StorageProfileIopsLimit int64 `xml:"StorageProfileIopsLimit,omitempty"` + DiskIopsPerGbMax int64 `xml:"DiskIopsPerGbMax"` } // VdcConfiguration models the payload for creating a VDC.