Quantcast
Viewing all articles
Browse latest Browse all 2350

How to Build and Execute WSMAN Method Commands

Revision 10 posted to Systems Management - Wiki by DELL-Jim Sl on 1/4/2013 2:38:43 PM

How to Build and Execute WSMAN Method Commands

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

Overview

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

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

ClassName.MethodName()

MethodsaredocumentedinChapter8oftheDell(DCIM)profiledocuments.

The profile documents are posted here:

DCIM.Library.Profile

Example 1 - Single Parameter Method Command

The method used 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:

Image may be NSFW.
Clik here to view.

 

Step 2 - Build theInvoke Method Command

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


WinRM syntax - Windows management stationstations

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 stationstations

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: (canignorethenamespacekey)

Selector:__cimnamespace=root/dcim, CreationClassName=DCIM_ComputerSystem, Name=srv:system

2.       Build       Usingthekeys,build a get command to confirm the syntax(.Thisstepis not required, but recommended since the invoke command will beverysimilar)addtothiscommand and syntax errors are easy to makehere. The__cimnamespacekeyisnotrequired.


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 appropriateget command above 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:


Image may be NSFW.
Clik here to view.

Example 2 - Multi-ParameterInvoke Method 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 line or usingpointingto 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 optional .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. RememberthatforwinrmForWinRMcommands, "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 describedintheiDRACCardprofiledocument. Commands shown in this example will be WinRM only. (SeeexamplesaboveforFor conversion to OpenWSMAN syntax.)syntax,seetheexamplesabove.

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

Check the Profile Document


Chapter 8 of theDCIM iDRAC Card profile document shows the following table for the SetAttribute() method:


Image may be NSFW.
Clik here to view.

  • ·

     

     

    We need to find out which class to enumerate to get the DefaultCredentialMitigation attribute infoshownintheDescription/Valuescolumninformation. Searching the profile doc for "credential" we find this section:


    Image may be NSFW.
    Clik here to view.

    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" & "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 thiscommandreturnssomuchtheDCIM_iDRACCardEnumerationclasscontainsalotof data, we sent the output to a text file (idrac_enum.txt). This makes it easier to search for the instance we are looking for.  The instance we need is foundinthetextfileoutput as follows:


    Image may be NSFW.
    Clik here to view.

    Image may be NSFW.
    Clik here to view.

    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 SetAttribute() 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       Usingthekeys,build a get command to confirm the syntax(.Thisstepis not required, but recommended since the invoke command will beverysimilar)addtothiscommand and syntax errors are easy to makehere. The__cimnamespacekeyisnotrequired.

    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

    Run the appropriateget command above 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, SetAttribute. At the end of the command add the input parameter(s) and values per the profile document (optionally,an.xmlfilecouldbeusedasshownearlier). Per Table 86 in the profile document (earlier screenshot) we need:

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

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

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

    The resulting 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:

    Image may be NSFW.
    Clik here to view.


    Note that the SetResult indicates PendingValue was set, not the CurrentValue. This can be verified by runningenumerating the DCIM_iDRACCardEnumerationclasstoseethevalueswith 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 found in idrac_enum.txt as follows:


    Image may be NSFW.
    Clik here to view.

    NotethatthePendingValuehaschangedfromnulltoDisabled,andtheCurrentValueisstillsettoEnabled.


    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 iDRAC Card profile document:

    Image may be NSFW.
    Clik here to view.


    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:

    Image may be NSFW.
    Clik here to view.


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

    Image may be NSFW.
    Clik here to view.

    To verify the PendingValuePendingValue of Disabled has been applied to the CurrentValue, youmay enumerate DCIM_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:

    Image may be NSFW.
    Clik here to view.

    Image may be NSFW.
    Clik here to view.

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

    Other Job-Related Methods

    These additional two methods are useful when working with SetAttribute methods and jobs.

    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"}


    Clear the Job Queue (MethodThismethod is described in 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"}


     

    This article written by Jim Slaughter.


Viewing all articles
Browse latest Browse all 2350

Trending Articles



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