Skip to content

Commit

Permalink
Volume OperationApplyTimeSupport added
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel Sama committed Sep 22, 2020
1 parent 2e0a1d3 commit ecc60da
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
6 changes: 6 additions & 0 deletions redfish/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ func (storage *Storage) SetEncryptionKey(key string) error {
return err
}

// GetOperationApplyTimeValues returns the OperationApplyTime values applicable for this storage
func (storage *Storage) GetOperationApplyTimeValues() ([]common.OperationApplyTime, error) {
return AllowedVolumesUpdateApplyTimes(storage.Client, storage.volumes)

}

// StorageController is used to represent a resource that represents a
// storage controller in the Redfish specification.
type StorageController struct {
Expand Down
30 changes: 30 additions & 0 deletions redfish/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,15 @@ type Volume struct {
drives []string
}

// Volumes is used to represent the volumes information related to a Storage
type Volumes struct {
common.Entity
// OperationApplyTimeSupport contains, among other things, the types
// of apply times the client is allowed request when performing a Create,
// Delete, or Action operation.
OperationApplyTimeSupport common.OperationApplyTimeSupport `json:"@Redfish.OperationApplyTimeSupport"`
}

// UnmarshalJSON unmarshals a Volume object from the raw JSON.
func (volume *Volume) UnmarshalJSON(b []byte) error {
type temp Volume
Expand Down Expand Up @@ -273,3 +282,24 @@ func (volume *Volume) Drives() ([]*Drive, error) {

return result, nil
}

// AllowedVolumesUpdateApplyTimes returns the set of allowed apply times to request when setting the volumes values
func AllowedVolumesUpdateApplyTimes(c common.Client, link string) ([]common.OperationApplyTime, error) {
resp, err := c.Get(link)
if err != nil {
return nil, err
}
defer resp.Body.Close()
var volumes Volumes

err = json.NewDecoder(resp.Body).Decode(&volumes)
if err != nil {
return nil, err
}

var applyTimes []common.OperationApplyTime
for _, v := range volumes.OperationApplyTimeSupport.SupportedValues {
applyTimes = append(applyTimes, v)
}
return applyTimes, nil
}

0 comments on commit ecc60da

Please sign in to comment.