Skip to content

Commit

Permalink
feat(amt): adds execute support for general settings
Browse files Browse the repository at this point in the history
Co-authored-by: Mike <[email protected]>
  • Loading branch information
zaidusmani26 and rsdmike committed Sep 25, 2023
1 parent 6579c56 commit 5d2568e
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 46 deletions.
6 changes: 3 additions & 3 deletions pkg/amt/alarmclock/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsman"
)

const AMT_AlarmClockService = "AMT_AlarmClockService"

// INPUTS

// AlarmClockOccurrence represents a single alarm clock setting
Expand Down Expand Up @@ -75,7 +77,7 @@ type (
}
AddAlarmOutput struct {
// A reference to the created instance of IPS_AlarmClockOccurrence.
AlarmClock AlarmClock
AlarmClock AlarmClock
// Return code. 0 indicates success
ReturnValue int
}
Expand All @@ -94,8 +96,6 @@ func (w *Response) JSON() string {
return string(jsonOutput)
}

const AMT_AlarmClockService = "AMT_AlarmClockService"

type Service struct {
base message.Base
client wsman.WSManClient
Expand Down
133 changes: 90 additions & 43 deletions pkg/amt/general/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,59 @@
package general

import (
"encoding/json"
"encoding/xml"

"github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
"github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/models"
"github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/common"
"github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsman"
)

type Response struct {
XMLName xml.Name `xml:"Envelope"`
Header message.Header `xml:"Header"`
Body Body `xml:"Body"`
}

type Body struct {
XMLName xml.Name `xml:"Body"`
AMTGeneralSettings GeneralSettings `xml:"AMT_GeneralSettings"`
}

type GeneralSettings struct {
models.SettingData
XMLName xml.Name `xml:"AMT_GeneralSettings"`
NetworkInterfaceEnabled bool
DigestRealm string
IdleWakeTimeout int
HostName string
DomainName string
PingResponseEnabled bool
WsmanOnlyMode bool
PreferredAddressFamily PreferredAddressFamily
DHCPv6ConfigurationTimeout int
DDNSUpdateEnabled bool
DDNSUpdateByDHCPServerEnabled bool
SharedFQDN bool
HostOSFQDN string
DDNSTTL int
AMTNetworkEnabled AMTNetworkEnabled
RmcpPingResponseEnabled bool
DDNSPeriodicUpdateInterval int
PresenceNotificationInterval int
PrivacyLevel PrivacyLevel
PowerSource PowerSource
ThunderboltDockEnabled ThunderboltDockEnabled
OemID int
}
const AMT_GeneralSettings = "AMT_GeneralSettings"

// OUTPUTS
type (
Response struct {
*wsman.Message
XMLName xml.Name `xml:"Envelope"`
Header message.Header `xml:"Header"`
Body Body `xml:"Body"`
}
Body struct {
XMLName xml.Name `xml:"Body"`
AMTGeneralSettings GeneralSettings `xml:"AMT_GeneralSettings"`
EnumerateResponse common.EnumerateResponse
}
GeneralSettings struct {
models.SettingData
XMLName xml.Name `xml:"AMT_GeneralSettings"`
NetworkInterfaceEnabled bool
DigestRealm string
IdleWakeTimeout int
HostName string
DomainName string
PingResponseEnabled bool
WsmanOnlyMode bool
PreferredAddressFamily PreferredAddressFamily
DHCPv6ConfigurationTimeout int
DDNSUpdateEnabled bool
DDNSUpdateByDHCPServerEnabled bool
SharedFQDN bool
HostOSFQDN string
DDNSTTL int
AMTNetworkEnabled AMTNetworkEnabled
RmcpPingResponseEnabled bool
DDNSPeriodicUpdateInterval int
PresenceNotificationInterval int
PrivacyLevel PrivacyLevel
PowerSource PowerSource
ThunderboltDockEnabled ThunderboltDockEnabled
OemID int
}
)
type PreferredAddressFamily int

const AMT_GeneralSettings = "AMT_GeneralSettings"

const (
IPv4 PreferredAddressFamily = iota
IPv6
Expand All @@ -67,6 +72,14 @@ const (
PrivacyLevelExtreme
)

func (w *Response) JSON() string {
jsonOutput, err := json.Marshal(w.Body)
if err != nil {
return ""
}
return string(jsonOutput)
}

type PowerSource int

const (
Expand Down Expand Up @@ -99,13 +112,47 @@ func (GeneralSettings Settings) Get() string {
}

// Enumerates the instances of this class
func (GeneralSettings Settings) Enumerate() string {
return GeneralSettings.base.Enumerate()
func (GeneralSettings Settings) Enumerate() (response Response, err error) {
response = Response{
Message: &wsman.Message{
XMLInput: GeneralSettings.base.Enumerate(),
},
}
// send the message to AMT
err = GeneralSettings.base.Execute(response.Message)
if err != nil {
return
}

// put the xml response into the go struct
err = xml.Unmarshal([]byte(response.XMLOutput), &response)
if err != nil {
return
}

return
}

// Pulls instances of this class, following an Enumerate operation
func (GeneralSettings Settings) Pull(enumerationContext string) string {
return GeneralSettings.base.Pull(enumerationContext)
func (GeneralSettings Settings) Pull(enumerationContext string) (response Response, err error) {
response = Response{
Message: &wsman.Message{
XMLInput: GeneralSettings.base.Pull(enumerationContext),
},
}
// send the message to AMT
err = GeneralSettings.base.Execute(response.Message)
if err != nil {
return
}

// put the xml response into the go struct
err = xml.Unmarshal([]byte(response.XMLOutput), &response)
if err != nil {
return
}

return
}

// Put will change properties of the selected instance
Expand Down

0 comments on commit 5d2568e

Please sign in to comment.