Skip to content

Commit

Permalink
Update "datastore create" default parameters
Browse files Browse the repository at this point in the history
Previously the following input was accepted by the server:

```
{
  "name": "mclaren-ds19",
  "sizeInBytes": 17179869184,
  "storageSystemId": "126fd201-9e6e-5e31-9ffb-a766265b1fd3",
  "targetHypervisorClusterId": "",
  "volumeInfo": {
    "deduplication": false,
    "encryption": {
      "cipher": "None"
    },
    "qos": {
      "iopsLimit": -1,
      "mbpsLimit": -1
    }
  },
  "datastoreType": "VMFS"
}
```

But this now triggers a 400 response.

```
{
  "debugId": "df4c4f566584ca1fc4511d77fe668f0d",
  "errorCode": "HPE_GL_VIRTUALIZATION_BAD_REQUEST",
  "httpStatusCode": 400,
  "message": "input attributes name, type, sizeInBytes, storageSystemID and targetHypervisorClusterID are mandatory parameters. Error: Key: 'CreateDatastoreVirtRequest.TargetHypervisorClusterID' Error:Field validation for 'TargetHypervisorClusterID' failed on the 'required' tag"
}
```

In particular, providing `-1` to imply default values for limits
no longer seems to work.

Rather than specifying limits in this way, we now remove them
entirely. We also do the same for other parameters (eg encryption) to
pick up default values.

The create datastore POST request body will now look like:

```
{
  "name": "datastore-100",
  "sizeInBytes": 17179869184,
  "storageSystemId": "f9689284-0bbd-5bf1-981f-b9799bbc106c",
  "targetHypervisorClusterId": "",
  "datastoreType": "VMFS"
}
```
  • Loading branch information
stuart-mclaren-hpe committed Nov 11, 2024
1 parent 79b6746 commit da295e2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
34 changes: 17 additions & 17 deletions internal/resources/datastore/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,33 +350,33 @@ func doCreate(
prb.SetName(&name)

// TODO: (API) Allow setting cipher when FF-29512 is fixed
cipher := datastores.NONE_DATASTORESPOSTREQUESTBODY_VOLUMEINFO_ENCRYPTION_CIPHER
enc := virtualization.NewV1beta1DatastoresPostRequestBody_volumeInfo_encryption()
//cipher := datastores.NONE_DATASTORESPOSTREQUESTBODY_VOLUMEINFO_ENCRYPTION_CIPHER
//enc := virtualization.NewV1beta1DatastoresPostRequestBody_volumeInfo_encryption()

// TODO: should be able to use enum for cipher (bug in sdk or spec processing?)
cipherMap := map[string]any{
"cipher": cipher.String(),
}
//cipherMap := map[string]any{
// "cipher": cipher.String(),
//}

enc.SetAdditionalData(cipherMap)
qos := virtualization.NewV1beta1DatastoresPostRequestBody_volumeInfo_qos()
//enc.SetAdditionalData(cipherMap)
//qos := virtualization.NewV1beta1DatastoresPostRequestBody_volumeInfo_qos()
// TODO: (API) Allow setting iopsLimit when FF-29512 is fixed
var iopsLimit float64 = -1 // -1 implies no limit
qos.SetIopsLimit(&iopsLimit)
//var iopsLimit float64 = -1 // -1 implies no limit
//qos.SetIopsLimit(&iopsLimit)

// TODO: (API) Allow setting mbsLimit when FF-29512 is fixed
var mbpsLimit float64 = -1 // -1 implies no limit
qos.SetMbpsLimit(&mbpsLimit)
//var mbpsLimit float64 = -1 // -1 implies no limit
//qos.SetMbpsLimit(&mbpsLimit)

volInfo := virtualization.NewV1beta1DatastoresPostRequestBody_volumeInfo()
//volInfo := virtualization.NewV1beta1DatastoresPostRequestBody_volumeInfo()

// TODO: (API) Allow setting duplication when FF-29512 is fixed
False := false
volInfo.SetDeduplication(&False)
volInfo.SetEncryption(enc)
volInfo.SetQos(qos)
//False := false
//volInfo.SetDeduplication(&False)
//volInfo.SetEncryption(enc)
//volInfo.SetQos(qos)

prb.SetVolumeInfo(volInfo)
//prb.SetVolumeInfo(volInfo)

sizeInBytes := (*dataP).CapacityInBytes.ValueInt64()
prb.SetSizeInBytes(&sizeInBytes)
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"mclaren-ds19","sizeInBytes":17179869184,"storageSystemId":"126fd201-9e6e-5e31-9ffb-a766265b1fd3","targetHypervisorClusterId":"acd4daea-e5e3-5f35-8be3-ce4a4b6d946c","volumeInfo":{"deduplication":false,"encryption":{"cipher":"None"},"qos":{"iopsLimit":1000000,"mbpsLimit":1000000}},"datastoreType":"VMFS"}
{"name":"mclaren-ds19","sizeInBytes":17179869184,"storageSystemId":"126fd201-9e6e-5e31-9ffb-a766265b1fd3","targetHypervisorClusterId":"acd4daea-e5e3-5f35-8be3-ce4a4b6d946c","datastoreType":"VMFS"}

0 comments on commit da295e2

Please sign in to comment.