-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from stmcginnis/actions
Add actions to more objects
- Loading branch information
Showing
10 changed files
with
465 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,8 @@ type Storage struct { | |
enclosures []string | ||
// EnclosuresCount is the number of enclosures. | ||
EnclosuresCount int | ||
// setEncryptionKeyTarget is the URL to send SetEncryptionKey requests. | ||
setEncryptionKeyTarget string | ||
} | ||
|
||
// UnmarshalJSON unmarshals a Storage object from the raw JSON. | ||
|
@@ -73,11 +75,17 @@ func (storage *Storage) UnmarshalJSON(b []byte) error { | |
Enclosures common.Links | ||
EnclosuresCount int `json:"[email protected]"` | ||
} | ||
type actions struct { | ||
SetEncryptionKey struct { | ||
Target string | ||
} `json:"#Storage.SetEncryptionKey"` | ||
} | ||
var t struct { | ||
temp | ||
Links links | ||
Drives common.Links | ||
Volumes common.Link | ||
Actions actions | ||
} | ||
|
||
err := json.Unmarshal(b, &t) | ||
|
@@ -92,6 +100,7 @@ func (storage *Storage) UnmarshalJSON(b []byte) error { | |
storage.EnclosuresCount = t.Links.EnclosuresCount | ||
storage.drives = t.Drives.ToStrings() | ||
storage.volumes = string(t.Volumes) | ||
storage.setEncryptionKeyTarget = t.Actions.SetEncryptionKey.Target | ||
|
||
return nil | ||
} | ||
|
@@ -170,6 +179,17 @@ func (storage *Storage) Volumes() ([]*Volume, error) { | |
return ListReferencedVolumes(storage.Client, storage.volumes) | ||
} | ||
|
||
// SetEncryptionKey shall set the encryption key for the storage subsystem. | ||
func (storage *Storage) SetEncryptionKey(key string) error { | ||
type temp struct { | ||
EncryptionKey string | ||
} | ||
t := temp{EncryptionKey: key} | ||
|
||
_, err := storage.Client.Post(storage.setEncryptionKeyTarget, t) | ||
return err | ||
} | ||
|
||
// StorageController is used to represent a resource that represents a | ||
// storage controller in the Redfish specification. | ||
type StorageController struct { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,6 +131,10 @@ type StorageGroup struct { | |
parentStorageGroups []string | ||
// ParentStorageGroupsCount is the number of parent storage groups. | ||
ParentStorageGroupsCount int | ||
// exposeVolumesTarget is the URL to for the ExposeVolumes action. | ||
exposeVolumesTarget string | ||
// hideVolumesTarget is the URL to for the HideVolumes action. | ||
hideVolumesTarget string | ||
} | ||
|
||
// UnmarshalJSON unmarshals a StorageGroup object from the raw JSON. | ||
|
@@ -143,10 +147,19 @@ func (storagegroup *StorageGroup) UnmarshalJSON(b []byte) error { | |
ParentStorageGroups common.Links | ||
ParentStorageGroupsCount int `json:"[email protected]"` | ||
} | ||
type actions struct { | ||
ExposeVolumes struct { | ||
Target string | ||
} `json:"#StorageGroup.ExposeVolumes"` | ||
HideVolumes struct { | ||
Target string | ||
} `json:"#StorageGroup.HideVolumes"` | ||
} | ||
var t struct { | ||
temp | ||
Links links | ||
ServerEndpointGroups common.Links | ||
Actions actions | ||
} | ||
|
||
err := json.Unmarshal(b, &t) | ||
|
@@ -161,6 +174,8 @@ func (storagegroup *StorageGroup) UnmarshalJSON(b []byte) error { | |
storagegroup.classOfService = string(t.Links.ClassOfService) | ||
storagegroup.parentStorageGroups = t.Links.ParentStorageGroups.ToStrings() | ||
storagegroup.ParentStorageGroupsCount = t.Links.ParentStorageGroupsCount | ||
storagegroup.exposeVolumesTarget = t.Actions.ExposeVolumes.Target | ||
storagegroup.hideVolumesTarget = t.Actions.HideVolumes.Target | ||
|
||
return nil | ||
} | ||
|
@@ -251,3 +266,28 @@ type MappedVolume struct { | |
// Volume shall reference a mapped Volume. | ||
Volume common.Link | ||
} | ||
|
||
// ExposeVolumes exposes the storage of this group via the target endpoints | ||
// named in the ServerEndpointGroups to the initiator endpoints named in the | ||
// ClientEndpointGroups. The property VolumesAreExposed shall be set to true | ||
// when this action is completed. | ||
func (storagegroup *StorageGroup) ExposeVolumes() error { | ||
_, err := storagegroup.Client.Post(storagegroup.exposeVolumesTarget, nil) | ||
if err == nil { | ||
// Only set to exposed if no error. Calling expose when already exposed | ||
// could fail so we don't want to indicate they are not exposed. | ||
storagegroup.VolumesAreExposed = true | ||
} | ||
return err | ||
} | ||
|
||
// HideVolumes hides the storage of this group from the initiator endpoints | ||
// named in the ClientEndpointGroups. The property VolumesAreExposed shall be | ||
// set to false when this action is completed. | ||
func (storagegroup *StorageGroup) HideVolumes() error { | ||
_, err := storagegroup.Client.Post(storagegroup.hideVolumesTarget, nil) | ||
if err == nil { | ||
storagegroup.VolumesAreExposed = false | ||
} | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.