Skip to content

Commit

Permalink
Merge pull request #5 from tasmiyafathima14/sprint-72-odim-7034
Browse files Browse the repository at this point in the history
Adding lib-dmtf managers model
  • Loading branch information
amar-shalgar authored May 25, 2023
2 parents cd3f174 + 6bb7cda commit 143d1c3
Show file tree
Hide file tree
Showing 5 changed files with 211 additions and 51 deletions.
16 changes: 15 additions & 1 deletion lib-dmtf/model/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type Redundancy struct {
RedundancySetCount int `json:"[email protected],omitempty"`
}

// Identifier redfish structure
//Identifier redfish structure
type Identifier struct {
DurableName string `json:"DurableName,omitempty"`
DurableNameFormat string `json:"DurableNameFormat,omitempty"`
Expand Down Expand Up @@ -124,6 +124,20 @@ type IOStatistics struct {
WriteIORequestTime string `json:"WriteIORequestTime,omitempty"`
}

// Conditions - This type shall contain the description and details of a
// condition that exists within this resource or a related resource that
// requires attention.
type Conditions struct {
LogEntry *Link `json:"LogEntry,omitempty"`
Message string `json:"Message,omitempty"`
MessageArgs []string `json:"MessageArgs,omitempty"`
MessageID string `json:"MessageId"`
OriginOfCondition *Link `json:"OriginOfCondition,omitempty"`
Resolution string `json:"Resolution,omitempty"`
Severity Health `json:"Severity,omitempty"`
Timestamp string `json:"Timestamp,omitempty"`
}

// Certificates redfish structure
type Certificates struct {
Oid string `json:"@odata.id"`
Expand Down
212 changes: 186 additions & 26 deletions lib-dmtf/model/manager.go
Original file line number Diff line number Diff line change
@@ -1,56 +1,130 @@
//(C) Copyright [2020] Hewlett Packard Enterprise Development LP
// (C) Copyright [2020] Hewlett Packard Enterprise Development LP
//
//Licensed under the Apache License, Version 2.0 (the "License"); you may
//not use this file except in compliance with the License. You may obtain
//a copy of the License at
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
//WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
//License for the specific language governing permissions and limitations
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.

package model

// GraphicalConnectTypesSupported - ConnectTypesSupported
type GraphicalConnectTypesSupported string
// ManagerType The type of manager that this resource represents.
type ManagerType string

// PowerState This property shall contain the power state of the manager
type PowerState string

// ConnectTypesSupported This property enumerates the graphical console
// connection types that the implementation allows.
type ConnectTypesSupported string

// AuthenticationModes This property shall contain an array consisting of the
// authentication modes allowed on this interface
type AuthenticationModes string

// HostInterfaceType This property shall contain an enumeration that describes
// the type of the interface
type HostInterfaceType string

const (

// ManagerTypeManagementController - "ManagementController": "A controller that primarily monitors or manages the operation of a device or system."
ManagerTypeManagementController ManagerType = "ManagementController"

// ManagerTypeEnclosureManager - "EnclosureManager": "A controller that provides management functions for a chassis or group of devices or systems."
ManagerTypeEnclosureManager ManagerType = "EnclosureManager"

// ManagerTypeBMC - "BMC": "A controller that provides management functions for a single computer system."
ManagerTypeBMC ManagerType = "BMC"

// ManagerTypeRackManager - "RackManager": "A controller that provides management functions for a whole or part of a rack."
ManagerTypeRackManager ManagerType = "RackManager"

//ManagerTypeAuxiliaryController - "AuxiliaryController": "A controller that provides management functions for a particular subsystem or group of devices."
ManagerTypeAuxiliaryController ManagerType = "AuxiliaryController"

// ManagerTypeService - "Service": "A software-based service that provides management functions."
ManagerTypeService ManagerType = "Service"
)

const (
// PowerStateOn - "On": "The resource is powered on."
PowerStateOn PowerState = "On"

// PowerStateOff - "Off": "The resource is powered off. The components within the resource might continue to have AUX power."
PowerStateOff PowerState = "Off"

// PowerStatePoweringOn - "PoweringOn": "A temporary state between off and on. The components within the resource can take time to process the power on action."
PowerStatePoweringOn PowerState = "PoweringOn"

// PowerStatePoweringOff - "PoweringOff": "A temporary state between on and off. The components within the resource can take time to process the power off action."
PowerStatePoweringOff PowerState = "PoweringOff"

// PowerStatePaused - "Paused": "The resource is paused."
PowerStatePaused PowerState = "Paused"
)

const (
// ConnectTypesSupportedKVMIP - "KVMIP": "The controller supports a graphical console connection through a KVM-IP (redirection of Keyboard, Video, Mouse over IP) protocol."
ConnectTypesSupportedKVMIP ConnectTypesSupported = "KVMIP"

// ConnectTypesSupportedOem - "Oem": "The controller supports a graphical console connection through an OEM-specific protocol."
ConnectTypesSupportedOem ConnectTypesSupported = "Oem"
)

const (
// HostInterfaceTypeNetworkHostInterface - "NetworkHostInterface": "This interface is a Network Host Interface."
HostInterfaceTypeNetworkHostInterface HostInterfaceType = "NetworkHostInterface"
)

const (
// GraphicalConnectTypesSupportedKVMIP - The information about the graphical console
GraphicalConnectTypesSupportedKVMIP GraphicalConnectTypesSupported = "KVMIP"
// GraphicalConnectTypesSupportedCOEM - The information about the graphical console
GraphicalConnectTypesSupportedCOEM GraphicalConnectTypesSupported = "OEM"
// AuthenticationModesAuthNone - "AuthNone": "Requests without any sort of authentication are allowed."
AuthenticationModesAuthNone AuthenticationModes = "AuthNone"

// AuthenticationModesBasicAuth - "BasicAuth": "Requests using HTTP Basic Authentication are allowed."
AuthenticationModesBasicAuth AuthenticationModes = "BasicAuth"

// AuthenticationModesRedfishSessionAuth - "RedfishSessionAuth": "Requests using Redfish Session Authentication are allowed."
AuthenticationModesRedfishSessionAuth AuthenticationModes = "RedfishSessionAuth"

// AuthenticationModesOemAuth - "OemAuth": "Requests using OEM authentication mechanisms are allowed."
AuthenticationModesOemAuth AuthenticationModes = "OemAuth"
)

// Manager is the redfish Manager model according to the 2020.3 release
// Refer to Manager.v1_17_0.json of the redfish spec for more details
type Manager struct {
ODataContext string `json:"@odata.context,omitempty"`
ODataEtag string `json:"@odata.etag,omitempty"`
ODataID string `json:"@odata.id"`
ODataType string `json:"@odata.type"`
Actions *OemActions `json:"Actions,omitempty"`
Actions *ManagerActions `json:"Actions,omitempty"`
Description string `json:"Description,omitempty"`
ID string `json:"Id"`
Links *ManagerLinks `json:"Links,omitempty"`
Name string `json:"Name"`
Oem *Oem `json:"Oem,omitempty"`
EthernetInterfaces *Link `json:"EthernetInterfaces,omitempty"`
FirmwareVersion string `json:"FirmwareVersion,omitempty"`
Status *Status `json:"Status,omitempty"`
Status *ManagerStatus `json:"Status,omitempty"`
AutoDSTEnabled bool `json:"AutoDSTEnabled,omitempty"`
DateTime string `json:"DateTime,omitempty"`
DateTimeLocalOffset string `json:"DateTimeLocalOffset,omitempty"`
HostInterfaces *Link `json:"HostInterfaces,omitempty"`
HostInterfaces *HostInterface `json:"HostInterfaces,omitempty"`
LastResetTime string `json:"LastResetTime,omitempty"`
LogServices *Link `json:"LogServices,omitempty"`
ManagerType string `json:"ManagerType,omitempty"`
ManagerType string `json:"ManagerType,omitempty"` //enum
Manufacturer string `json:"Manufacturer,omitempty"`
Model string `json:"Model,omitempty"`
NetworkProtocol *Link `json:"NetworkProtocol,omitempty"`
PartNumber string `json:"PartNumber,omitempty"`
PowerState string `json:"PowerState,omitempty"`
PowerState string `json:"PowerState,omitempty"` //enum
Redundancy []Redundancy `json:"Redundancy,omitempty"`
RemoteAccountService *Link `json:"RemoteAccountService,omitempty"`
RemoteRedfishServiceURI string `json:"RemoteRedfishServiceUri,omitempty"`
Expand All @@ -74,10 +148,11 @@ type Manager struct {

// AdditionalFirmwareVersions redfish structure
type AdditionalFirmwareVersions struct {
Bootloader string `json:"Bootloader,omitempty"`
Kernel string `json:"Kernel,omitempty"`
Microcode string `json:"Microcode,omitempty"`
Oem Oem `json:"Oem,omitempty"`
Bootloader string `json:"Bootloader,omitempty"`
Kernel string `json:"Kernel,omitempty"`
Microcode string `json:"Microcode,omitempty"`
OSDistribution string `json:"OSDistribution,omitempty"`
Oem Oem `json:"Oem,omitempty"`
}

// CommandShell redfish structure
Expand All @@ -88,12 +163,9 @@ type CommandShell struct {
}

// GraphicalConsole redfish structure
// The information about a graphical console service for this system.
// This type shall describe a graphical console service for a computer system.
type GraphicalConsole struct {
ConnectTypesSupported []string `json:"ConnectTypesSupported"` //enum
MaxConcurrentSessions int `json:"MaxConcurrentSessions"`
Port int `json:"Port,omitempty"`
ServiceEnabled bool `json:"ServiceEnabled"`
}

Expand Down Expand Up @@ -158,3 +230,91 @@ type VMActions struct {
type ActionTarget struct {
Target string `json:"target"`
}

// ManagerActions property shall contain the available actions for this resource.
type ManagerActions struct {
ManagerForceFailover *ForceFailover `json:"ManagerForceFailover,omitempty"`
ManagerModifyRedundancySet *ModifyRedundancySet `json:"ManagerModifyRedundancy,omitempty"`
ManagerReset *Reset `json:"ManagerReset,omitempty"`
ManagerResetToDefaults *ResetToDefaults `json:"ManagerResetToDefaults,omitempty"`
Oem *Oem `json:"Oem,omitempty"`
}

// ForceFailover action forces a failover of this manager to the manager
// used in the parameter
type ForceFailover struct {
Target string `json:"Target,omitempty"`
Title string `json:"Title,omitempty"`
}

// ModifyRedundancySet operation shall add members to or remove members from
// a redundant group of managers
type ModifyRedundancySet struct {
Target string `json:"Target,omitempty"`
Title string `json:"Title,omitempty"`
}

// ResetToDefaults resets the manager settings to factory defaults.
// This can cause the manager to reset
type ResetToDefaults struct {
Target string `json:"Target,omitempty"`
Title string `json:"Title,omitempty"`
}

// HostInterfaces link to a collection of host interfaces that this manager uses for local host communication.
// Clients can find host interface configuration options and settings in this navigation property
type HostInterfaces struct {
ODataContext string `json:"@odata.context,omitempty"`
ODataEtag string `json:"@odata.etag,omitempty"`
ODataID string `json:"@odata.id"`
ODataType string `json:"@odata.type"`
Descriptions string `json:"Descriptions,omitempty"`
Members *Members `json:"Members"`
MembersOdataCount int `json:"MembersOdataCount"`
MembersOdataNextLink string `json:"MembersOdataNextLink,omitempty"`
Name string `json:"Name"`
Oem *Oem `json:"Oem,omitempty"`
}

// Members property shall contain an array of links to the members of this collection
type Members struct {
ODataContext string `json:"@odata.context,omitempty"`
ODataEtag string `json:"@odata.etag,omitempty"`
ODataID string `json:"@odata.id"`
ODataType string `json:"@odata.type"`
Actions *OemActions `json:"actions,omitempty"`
AuthNoneRoleID string `json:"authNoneRoleId,omitempty"`
AuthenticationModes []string `json:"authenticationModes,omitempty"` //enum
CredentialBootstrapping *CredentialBootstrapping `json:"credentialBootstrapping,omitempty"`
Description string `json:"description,omitempty"`
ExternallyAccessible bool `json:"externallyAccessible,omitempty"`
FirmwareAuthEnabled bool `json:"firmwareAuthEnabled,omitempty"`
FirmwareAuthRoleID string `json:"firmwareAuthRoleId,omitempty"`
HostEthernetInterfaces *HostInterfaces `json:"hostEthernetInterfaces,omitempty"`
HostInterfaceType string `json:"hostInterfaceType,omitempty"` //enum
ID string `json:"id,omitempty"`
InterfaceEnabled bool `json:"interfaceEnabled,omitempty"`
KernelAuthEnabled bool `json:"kernelAuthEnabled,omitempty"`
KernelAuthRoleID string `json:"kernelAuthRoleId,omitempty"`
Links *Links `json:"links,omitempty"`
Name string `json:"name,omitempty"`
Oem *Oem `json:"Oem,omitempty"`
Status []*Conditions `json:"status,omitempty"`
}

// CredentialBootstrapping settings for this interface
type CredentialBootstrapping struct {
EnableAfterReset bool `json:"enableAfterReset,omitempty"`
Enabled bool `json:"enabled,omitempty"`
RoleID string `json:"roleId,omitempty"`
}

// ManagerStatus property shall contain any status or health properties of the resource
type ManagerStatus struct {
Conditions []*Conditions `json:"Conditions,omitempty"`
Name string `json:"Name,omitempty"`
Health string `json:"Health,omitempty"`
HealthRollup string `json:"HealthRollup,omitempty"`
State string `json:"State,omitempty"`
Oem *Oem `json:"Oem,omitempty"`
}
14 changes: 0 additions & 14 deletions lib-dmtf/model/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,17 +216,3 @@ type TaskServiceStatus struct {
Oem Oem `json:"Oem,omitempty"`
State State `json:"State,omitempty"`
}

// Conditions - This type shall contain the description and details of a
// condition that exists within this resource or a related resource that
// requires attention.
type Conditions struct {
LogEntry *Link `json:"LogEntry,omitempty"`
Message string `json:"Message,omitempty"`
MessageArgs []string `json:"MessageArgs,omitempty"`
MessageID string `json:"MessageId"`
OriginOfCondition *Link `json:"OriginOfCondition,omitempty"`
Resolution string `json:"Resolution,omitempty"`
Severity Health `json:"Severity,omitempty"`
Timestamp string `json:"Timestamp,omitempty"`
}
10 changes: 5 additions & 5 deletions plugin-lenovo/lphandler/managers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//License for the specific language governing permissions and limitations
// under the License.

//Package lphandler ...
// Package lphandler ...
package lphandler

import (
Expand All @@ -30,7 +30,7 @@ import (
log "github.com/sirupsen/logrus"
)

//GetManagersCollection Fetches details of the given resource from the device
// GetManagersCollection Fetches details of the given resource from the device
func GetManagersCollection(ctx iris.Context) {
//Get token from Request
token := ctx.GetHeader("X-Auth-Token")
Expand Down Expand Up @@ -74,7 +74,7 @@ func GetManagersCollection(ctx iris.Context) {

}

//GetManagersInfo Fetches details of the given resource from the device
// GetManagersInfo Fetches details of the given resource from the device
func GetManagersInfo(ctx iris.Context) {
//Get token from Request
token := ctx.GetHeader("X-Auth-Token")
Expand Down Expand Up @@ -104,7 +104,7 @@ func GetManagersInfo(ctx iris.Context) {
ID: pluginConfig.Data.RootServiceUUID,
UUID: pluginConfig.Data.RootServiceUUID,
FirmwareVersion: pluginConfig.Data.FirmwareVersion,
Status: &dmtf.Status{
Status: &dmtf.ManagerStatus{
State: "Enabled",
},
}
Expand Down Expand Up @@ -175,7 +175,7 @@ func getInfoFromDevice(uri string, deviceDetails lpmodel.Device, ctx iris.Contex
ctx.Write([]byte(respData))
}

//VirtualMediaActions performs insert and eject virtual media operations on the device based on the request
// VirtualMediaActions performs insert and eject virtual media operations on the device based on the request
func VirtualMediaActions(ctx iris.Context) {
uri := ctx.Request().RequestURI
//replacing the request url with south bound translation URL
Expand Down
Loading

0 comments on commit 143d1c3

Please sign in to comment.