Quantcast
Channel: Systems Management - Wiki
Viewing all articles
Browse latest Browse all 1292

How to Build and Execute WSMAN Method Commands

$
0
0
Revision 2 posted to Systems Management - Wiki by DELL-Jim Sl on 1/4/2013 9:17:34 AM

Overview

This document explains how to build and execute method (invoke) commands. It also shows the syntaxfor winrm commands on Windows and wsman commands on Linux workstations.

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

Methods are documented in Chapter 8 of all profile documents.

Example 1 - Single Parameter Invoke Command

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

Check the Profile Document

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

Build the Invoke Command

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

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

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

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

CreationClassName=DCIM_ComputerSystem, Name=srv:system

  1. 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_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

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

  1. 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. We are going to use the value 2, which will power on the system.

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

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"

Example Commands and Output

The following screenshot shows the invoke commands with different parameter values used and the output returned.

Example 2 - Multi-Parameter Invoke Commands

Some commands require 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 Simple RAID profile.  Follow the steps above to build the commands. These are just examples of the syntax and .xml file that can be used.

Option 1 - Specifying All Parameters in the Command

 

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

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

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 so I've added this example. This example will cover the DCIM_iDRACCardService.SetAttribute() method. Commands shown will be winrm only. (See examples above for conversion to openwsman syntax.)

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

Check the Profile Document

Chapter 8 of the 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" & "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 .txt file in the above command. This makes it easier to search for the instance we are looking for.  The instance we need is as follows:

DCIM_iDRACCardEnumeration

    AttributeDisplayName = Default Credential Mitigation

    AttributeName = DefaultCredentialMitigation

    CurrentValue = Enabled

    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

 

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. 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

  1. 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

  1. 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 we need:
    1. a.       Target="iDRAC.Embedded.1" (the FQDD)
    2. b.      AttributeName="DefaultCredentialMitigationConfigGroup.1#DefaultCredentialMitigation"  (The GroupID & AttributeName, separated by a #)
    3. c.       AttributeValue="Disabled" (we are changing the CurrentValue property from Enabled to Disabled)
    4. d.      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:

DCIM_iDRACCardEnumeration

    AttributeDisplayName = Default Credential Mitigation

    AttributeName = DefaultCredentialMitigation

    CurrentValue = Enabled

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


Viewing all articles
Browse latest Browse all 1292

Trending Articles



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