Quantcast
Channel: TechCenter
Viewing all articles
Browse latest Browse all 2350

How to Build and Execute WSMAN Method Commands

$
0
0
Revision 8 posted to Systems Management - Wiki by DELL-Jim Sl on 1/4/2013 10:51:28 AM

How to Build and Execute WSMAN Method Commands

dcim, WSMan, Lifecycle Controller, CLI, idrac7, method, invoke

Overview

Thisdocument page explains how to build and execute wsman method (invoke) commands for Dell PowerEdge servers with iDRAC7. It also shows the syntax for winrm commands on Windows management stations and OpenWSMAN commands on Linux management stations.

"()" is used to denote a method in documentation. Methods are written in the format:

ClassName.MethodName()

Methods are documented in Chapter 8 of Dell profile documents. The Dell (DCIM) profile documents are posted here:

DCIM.Library.Profile

Example 1 - Single Parameter Method Command

The method tobetestedused in this example is from the DCIM BaseServer & Physical Asset profile. It is the RequestStateChange() method in the DCIM_ComputerSystem class and is written as DCIM_ComputerSystem.RequestStateChange().

Step 1 - Check the Profile Document

The following screenshot is from Chapter 8 of the DCIM Base Server & Physical Asset profile document:

Step 2 - Build the Invoke Command

1.       Enumerate the class associated with the method (DCIM_ComputerSystem) & find the keys using the epr switch:


WinRM syntax - Windows management station

winrm e cimv2/root/dcim/DCIM_ComputerSystem -u:root -p:calvin -r:https://172.23.200.117/wsman -SkipCNcheck -SkipCAcheck -encoding:utf-8 -a:basic -returntype:epr


OpenWSMAN syntax - Linux management station

wsman enumerate http://schemas.dell.com/wbem/wscim/1/cim-schema/2/root/dcim/DCIM_ComputerSystem -u root -p calvin -h 172.23.200.117 -P 443 -c Dummy -y basic -V –v –M epr

Note: The credentials (user name and password) and IP address used in all commands are those assigned to the iDRAC7 of the managed system.

The command above will return the keys: (can ignore the namespace key)

CreationClassName=DCIM_ComputerSystem, Name=srv:system

2.       Build a get command to confirm the syntax (not required, but recommended since the invoke command will be very similar) and syntax errors are easy to make here.


WinRM syntax:

winrm g cimv2/root/dcim/DCIM_ComputerSystem?CreationClassName=DCIM_ComputerSystem+Name=srv:system -u:root -p:calvin -r:https://172.23.200.117/wsman -SkipCNcheck -SkipCAcheck -encoding:utf-8 -a:basic


OpenWSMAN syntax:

wsman get http://schemas.dell.com/wbem/wscim/1/cim-schema/2/root/dcim/DCIM_ComputerSystem?CreationClassName="DCIM_ComputerSystem",Name="srv:system" -h 172.23.200.117 -P 443 -u root -p calvin -c Dummy -y basic -V –v


Run the get command to confirm the syntax is correct.

3.       Convert the get command to a method command by changing "get" to "invoke" ("g" to "i"), and add the method name, RequestStateChange. At the end of the command add the input parameter(s) and values per the profile document. Per Table 20 in the profile document (screenshot above) the parameter name is RequestedState and possible values are 2,3, or 11. The following example uses the value 2 (power on the system).


WinRM syntax:

winrm i RequestStateChange cimv2/root/dcim/DCIM_ComputerSystem?CreationClassName=DCIM_ComputerSystem+Name=srv:system  -u:root -p:calvin -r:https://172.23.200.117/wsman -SkipCNcheck -SkipCAcheck -encoding:utf-8 -a:basic @{RequestedState="2"}


OpenWSMAN syntax:

wsman invoke -a "RequestStateChange" http://schemas.dell.com/wbem/wscim/1/cim-schema/2/root/dcim/DCIM_ComputerSystem?CreationClassName="DCIM_ComputerSystem",Name="srv:system" -h 172.23.200.117 -P 443 -u root -p calvin -c Dummy -y basic -V –v -k "RequestedState=2"

Step 3 - Run the Command

The following screenshot shows the same invoke command using different parameter values and the output returned:


Example 2 - Multi-Parameter Invoke Commands

Some commands require or have the option to specify multiple parameters. This can be done by specifying all of the parameters in the command or using an .xml file as input. The following examples are from the RAID profile.  Follow the steps above to build the commands. These are examples of the syntax and .xml file that can be used.

Option 1 - Specifying All Parameters in the Command

 

WinRM syntax:

winrm i GetAvailableDisks cimv2/root/dcim/DCIM_RAIDService?SystemCreationClassName=DCIM_ComputerSystem+CreationClassName=DCIM_RAIDService+SystemName=DCIM:ComputerSystem+Name=DCIM:RAIDService -u:root -p:calvin -r:https://172.23.200.117/wsman -SkipCNcheck -SkipCAcheck -encoding:utf-8 -a:basic@{Target="RAID.Integrated.1-1";DiskType="0";DiskProtocol="0";DiskEncrypt="0";RAIDLevel="4"}


OpenWSMAN syntax:

wsman invoke -a "GetAvailableDisks"  http://schemas.dell.com/wbem/wscim/1/cim-schema/2/root/dcim/DCIM_RAIDService?SystemCreationClassName="DCIM_ComputerSystem",CreationClassName="DCIM_RAIDService",SystemName="DCIM:ComputerSystem",Name="DCIM:RAIDService" -h 172.23.200.117 -P 443 -u root -p calvin -c Dummy -y basic -V -v -k "Target=RAID.Integrated.1-1" -k "DiskType=0" -k "DiskProtocol=0" -k "DiskEncrypt=0" -k "RAIDLevel=4"

Option 2 - Putting the Parameters in an .xml File

WinRM Syntax:

winrm i GetAvailableDisks cimv2/root/dcim/DCIM_RAIDService?SystemCreationClassName=DCIM_ComputerSystem+CreationClassName=DCIM_RAIDService+SystemName=DCIM:ComputerSystem+Name=DCIM:RAIDService -u:root -p:calvin -r:https://172.23.200.117/wsman -SkipCNcheck -SkipCAcheck -encoding:utf-8 -a:basic -file:gad.xml

OpenWSMAN Syntax:

wsman invoke -a "GetAvailableDisks"  http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/root/dcim/DCIM_RAIDService?SystemCreationClassName="DCIM_ComputerSystem",CreationClassName="DCIM_RAIDService",SystemName="DCIM:ComputerSystem",Name="DCIM:RAIDService" -h 172.23.200.117 -P 443 -u root -p calvin -c Dummy -y basic -V -v -J gad.xml

gad.xml file contents:

 

<p:GetAvailableDisks_INPUT xmlns:p="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/root/dcim/DCIM_RAIDService">

<p:Target>RAID.Integrated.1-1</p:Target>

<p:DiskType>0</p:DiskType>

<p:Diskprotocol>0</p:Diskprotocol>

<p:DiskEncrypt>0</p:DiskEncrypt>

<p:RaidLevel>4</p:RaidLevel>

</p:GetAvailableDisks_INPUT>

 

Note: The schema specified in the .xml file must match the schema in the command.  For example, you can't use schemas.dell.com in the command and schemas.dmtf.org in the .xml file it references or the command will fail. Remember that for winrm, "cimv2" is an alias that contains schemas.dmtf.org.

Example 3 - Set Attribute Methods

The concept for SetAttribute methods is the same as other methods. However, these methods also involve jobs. This example will cover the DCIM_iDRACCardService.SetAttribute() method. Commands shown inthisexample will bewinrm WinRM only. (See examples above for conversion to OpenWSMAN syntax.)

In this example we will change the CurrentValue property of the DefaultCredentialMitigation attribute from Enabled to Disabled.

Check the Profile Document

Chapter 8 of the iDRACCardDCIM iDRACCard profile document shows the following table for the SetAttribute() method:


  • ·         We need to find out which class to enumerate to get the DefaultCredentialMitigation attribute info shown in the Description/Values column. Searching the profile doc for "credential" we find this section:


 

From the above, we see that we can get the information needed by enumerating DCIM_iDRACCardEnumeration, & finding instance with the AttributeName=DefaultCredentialMitigation. The possible values we can set are "Enabled""Enabled"& "Disabled"."Disabled".

Determine the Parameter Values

Enumerate DCIM_iDRACCardEnumeration with the following command:

winrm e cimv2/root/dcim/DCIM_iDRACCardEnumeration -u:root -p:calvin -r:https://172.23.200.117/wsman -SkipCNcheck -SkipCAcheck -encoding:utf-8 -a:basic > idrac_enum.txt

Since this command returns so much data, we sent the output to a .txttext file intheabovecommand.(idrac_enum.txt). This makes it easier to search for the instance we are looking for.  The instance we need is as follows:

DCIM_iDRACCardEnumeration

    AttributeDisplayName=DefaultCredentialMitigation

    AttributeName=DefaultCredentialMitigation

    CurrentValue=Enabled

    DefaultValue=Enabled

    Dependency=null

    DisplayOrder=1700

    FQDD=iDRAC.Embedded.1

    GroupDisplayName=DefaultCredentialMitigationConfiguration

    GroupID=DefaultCredentialMitigationConfigGroup.1

    InstanceID=iDRAC.Embedded.1#DefaultCredentialMitigationConfigGroup.1#DefaultCredentialMitigation

    IsReadOnly=false

    PendingValue=null

    PossibleValues=Disabled,Enabled



 

This output contains everything we need to build the invoke command. The items highlighted are the ones needed per the profile document.  

Build the Invoke command

1.       Enumerate the class that contains the method (DCIM_iDRACCardService per chapter 8) & find the keys using the -returntype: epr switch:

winrm e cimv2/root/dcim/DCIM_iDRACCardService -u:root -p:calvin -r:https://172.23.200.117/wsman -SkipCNcheck -SkipCAcheck -encoding:utf-8 -a:basic -returntype:epr

The command above will return the keys: (can ignore the __cimnamespace key)

Selector: __cimnamespace = root/dcim, SystemCreationClassName = DCIM_ComputerSystem, SystemName = DCIM:ComputerSystem, CreationClassName = DCIM_iDRACCardService, Name = DCIM:iDRACCardService

2.       Build a get command to confirm the syntax (not required, but recommended since the invoke command will be very similar) and syntax errors are easy to make here.

 

winrm g cimv2/root/dcim/DCIM_iDRACCardService?SystemCreationClassName=DCIM_ComputerSystem+SystemName=DCIM:ComputerSystem+CreationClassName=DCIM_iDRACCardService+Name=DCIM:iDRACCardService -u:root -p:calvin -r:https://172.23.200.117/wsman -SkipCNcheck -SkipCAcheck -encoding:utf-8 -a:basic

Runthegetcommandtoconfirmthesyntaxiscorrect.

3.       Convert the get command to a method command by changing "get" to "invoke" ("g" to "i"), and add the method name, SetAttribute. At the end of the command add the input parameter(s) and values per the profile document. Per Table 86 in the profile document (earlierscreenshot) we need:

a.       Target="iDRAC.Embedded.1" (the FQDD)

b.      AttributeName="DefaultCredentialMitigationConfigGroup.1#DefaultCredentialMitigation"  (The GroupID & AttributeName, separated by a #)

c.       AttributeValue="Disabled" (we are changing the CurrentValue property from Enabled to Disabled)

  • dDisabled).

The command is as follows:

winrm i SetAttribute cimv2/root/dcim/DCIM_iDRACCardService?SystemCreationClassName=DCIM_ComputerSystem+SystemName=DCIM:ComputerSystem+CreationClassName=DCIM_iDRACCardService+Name=DCIM:iDRACCardService -u:root -p:calvin -r:https://172.23.200.117/wsman -SkipCNcheck -SkipCAcheck -encoding:utf-8 -a:basic @{Target="iDRAC.Embedded.1";AttributeName="DefaultCredentialMitigationConfigGroup.1#DefaultCredentialMitigation";AttributeValue="Disabled"}

Execute the Method & Set the Pending Value

The command appears as follows when run:

Note that the SetResult indicates PendingValue was set, not the CurrentValue. This can be verified by running the command:

winrm e cimv2/root/dcim/DCIM_iDRACCardEnumeration -u:root -p:calvin -r:https://172.23.200.117/wsman -SkipCNcheck -SkipCAcheck -encoding:utf-8 -a:basic > idrac_enum.txt

The output for the instance we need is foundinidrac_enum.txtasfollows:

DCIM_iDRACCardEnumeration

    AttributeDisplayName=DefaultCredentialMitigation

    AttributeName=DefaultCredentialMitigation

    CurrentValue=Enabled

    DefaultValue=Enabled

    Dependency=null

    DisplayOrder=1700

    FQDD=iDRAC.Embedded.1

    GroupDisplayName=DefaultCredentialMitigationConfiguration

    GroupID=DefaultCredentialMitigationConfigGroup.1

    InstanceID=iDRAC.Embedded.1#DefaultCredentialMitigationConfigGroup.1#DefaultCredentialMitigation

    IsReadOnly=false

    PendingValue=Disabled

    PossibleValues=Disabled,Enabled


 


 

Create and Run a Job to Set the Current Value

To apply the PendingValue (and make it the CurrentValue) we must create and run a job. This is done with the CreateTargetedConfigJob() method. The following is also from Chapter 8 of the iDRACCard profile document:


 

The command to create the job and run it immediately is:

 

winrm i CreateTargetedConfigJob cimv2/root/dcim/DCIM_iDRACCardService?SystemCreationClassName=DCIM_ComputerSystem+SystemName=DCIM:ComputerSystem+CreationClassName=DCIM_iDRACCardService+Name=DCIM:iDRACCardService -u:root -p:calvin -r:https://172.23.200.117/wsman -SkipCNcheck -SkipCAcheck -encoding:utf-8 -a:basic @{Target="iDRAC.Embedded.1";ScheduledStartTime="TIME_NOW"}

The output appears as follows:



You can check the Job Status by enumerating DCIM_LifeCycleJob and looking for the Job ID.:


To verify the Pending Value of Disabled has been applied to the CurrentValue, enumerate DCIM_iDRACEnumerationDCIM_iDRACCardEnumeration again.:

winrm e cimv2/root/dcim/DCIM_iDRACCardEnumeration -u:root -p:calvin -r:https://172.23.200.117/wsman -SkipCNcheck -SkipCAcheck -encoding:utf-8 -a:basic > idrac_enum.txt

The output for the instance we need is now:

DCIM_iDRACCardEnumeration

    AttributeDisplayName = Default Credential Mitigation

    AttributeName = DefaultCredentialMitigation

    CurrentValue = Disabled

    DefaultValue = Enabled

    Dependency = null

    DisplayOrder = 1700

    FQDD = iDRAC.Embedded.1

    GroupDisplayName = Default Credential Mitigation Configuration

    GroupID = DefaultCredentialMitigationConfigGroup.1

    InstanceID = iDRAC.Embedded.1#DefaultCredentialMitigationConfigGroup.1#DefaultCredentialMitigation

    IsReadOnly = false

    PendingValue = null

    PossibleValues = Disabled, Enabled

 

The PendingValue has gone back to null & the CurrentValue is now set to Disabled.

Other Job Related Commands

Delete a Pending Configuration

winrm i DeletePendingConfiguration cimv2/root/dcim/DCIM_iDRACCardService?SystemCreationClassName=DCIM_ComputerSystem+SystemName=DCIM:ComputerSystem+CreationClassName=DCIM_iDRACCardService+Name=DCIM:iDRACCardService -u:root -p:calvin -r:https://172.23.200.117/wsman -SkipCNcheck -SkipCAcheck -encoding:utf-8 -a:basic @{Target="iDRAC.Embedded.1"}

Delete the Job Queue (from the Job Control profile)

winrm i DeleteJobQueue cimv2/root/dcim/DCIM_JobService?Name=JobService+CreationClassName=DCIM_JobService+SystemName=Idrac+SystemCreationClassName=DCIM_ComputerSystem -u:root -p:calvin -r:https://172.23.200.117/wsman -SkipCNcheck -SkipCAcheck -encoding:utf-8 -a:basic @{JobID="JID_CLEARALL"}


 

ThisarticlewrittenbyJimSlaughter.


Viewing all articles
Browse latest Browse all 2350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>