Skip to content

Commit

Permalink
feat(oneclickrecovery_cim_bootservice): add RequestStateChange message
Browse files Browse the repository at this point in the history
  • Loading branch information
mjdivankoller committed Feb 19, 2025
1 parent ac50871 commit 30e777f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/cim/messages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ describe('CIM Tests', () => {
const response = cimClass.BootService.SetBootConfigRole(bootSource, role)
expect(response).toEqual(correctResponse)
})
it('should create a valid cim_BootService RequestStateChange wsman message', () => {
const correctResponse = `${xmlHeader}${envelope}http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootService/RequestStateChange</a:Action><a:To>/wsman</a:To><w:ResourceURI>http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootService</w:ResourceURI><a:MessageID>${(messageId++).toString()}</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>${operationTimeout}</w:OperationTimeout></Header><Body><h:RequestStateChange_INPUT xmlns:h="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootService"><h:RequestedState>3</h:RequestedState></h:RequestStateChange_INPUT></Body></Envelope>`
const response = cimClass.BootService.RequestStateChange(3)
expect(response).toEqual(correctResponse)
})

})
describe('cim_BootSourceSetting Tests', () => {
it('should return a valid cim_BootSourceSetting Get wsman message', () => {
Expand Down
15 changes: 13 additions & 2 deletions src/cim/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
* SPDX-License-Identifier: Apache-2.0
**********************************************************************/

import type { Selector } from '../WSMan'
import { Base, WSManMessageCreator } from '../WSMan'
import { Classes, Actions } from './'
import type { Types } from './'
import type { Selector } from '../WSMan'
import { Actions, Classes } from './'

class BIOSElement extends Base {
className = Classes.BIOS_ELEMENT
Expand Down Expand Up @@ -40,6 +40,17 @@ class BootService extends Base {
const body = `<Body><h:SetBootConfigRole_INPUT xmlns:h="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootService"><h:BootConfigSetting><Address xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing</Address><ReferenceParameters xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURI xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootConfigSetting</ResourceURI><SelectorSet xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><Selector Name="InstanceID">${bootSource}</Selector></SelectorSet></ReferenceParameters></h:BootConfigSetting><h:Role>${role}</h:Role></h:SetBootConfigRole_INPUT></Body>`
return this.wsmanMessageCreator.createXml(header, body)
}

/**
* Requests that the state of the element be changed to the value specified in the RequestedState parameter. When the requested state change takes place, the EnabledState and RequestedState of the element will be the same. Invoking the RequestStateChange method multiple times could result in earlier requests being overwritten or lost. If 0 is returned, then the task completed successfully and the use of ConcreteJob was not required. If 4096 (0x1000) is returned, then the task will take some time to complete, ConcreteJob will be created, and its reference returned in the output parameter Job. Any other return code indicates an error condition.
* @param requestedState The state requested for the element. This information will be placed into the RequestedState property of the instance if the return code of the RequestStateChange method is 0 ('Completed with No Error'), or 4096 (0x1000) ('Job Started'). Refer to the description of the EnabledState and RequestedState properties for the detailed explanations of the RequestedState values.
* @returns string
*/
RequestStateChange = (requestedState: Types.BootService.RequestedState): string =>
this.protectedRequestStateChange(
`http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/${this.className}/RequestStateChange`,
requestedState
)
}
class BootSourceSetting extends Base {
className = Classes.BOOT_SOURCE_SETTING
Expand Down
4 changes: 4 additions & 0 deletions src/cim/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,10 @@ export namespace Types {
* IsNext:0 | IsNextSingleUse:1 | IsDefault:2
*/
export type Role = 0 | 1 | 2
/**
* Enabled: 2 | Disabled: 3 | Shut Down: 4 | Offline: 6 | Test: 7 | Defer: 8 | Quiesce: 9 | Reboot: 10 | Reset: 11 | disable Intel One-Click Recovery and Intel RPE and enable all other boot options: 32768 | disable Intel RPE and enable Intel One-Click Recovery and all other boot options: 32769 | disable Intel One-Click Recovery and enable Intel RPE and all other boot options: 32770 | enable all boot options: 32771 | Vendor Reserved: 32772
*/
export type RequestedState = 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 32768 | 32769 | 32770 | 32771 | 32772
}

export namespace PowerManagementService {
Expand Down

0 comments on commit 30e777f

Please sign in to comment.