VMware Cloud Community
Kiil
Contributor
Contributor

Question how to use powercli to unclaim, load and run new claimrules

Hi,

I'm with a customer where I'm changing the claim rule for their datastores.  Theres a lot of hosts and rebooting each and every host is not wanted (but if I have to, I'll do it).  Anyway, I don't want to log in to every host eighter to run the commands in shell to unclaim datastore/device, load and run the new rules.  So, I want to automate this with powercli, but I don't find any good examples how to - could anyone help ?

Claim rule added to hosts:

$esxcli.storage.nmp.satp.rule.add($null,"tpgs_on","HP 3PAR Custom iSCSI/FC/FCoE ALUA Rule",$null,$null,$null,"VV",$null,"VMW_PSP_RR","iops=1","VMW_SATP_ALUA",$null,$null,"3PARdata")

Unclaiming:

in esxi shell it's done like this: esxcli storage core claiming unclaim --type device  --device naa.xxxxxxxxxxxxxxxxxxxx

How to transform this into a powercli command ?

$esxcli.storage.core.claiming.unclaim(string adapter, long channel, string claimruleclass, string device, string driver, long lun, string model, string path, string plugin, long target, string type, string vendor)

Load and run:

$esxcli.storage.core.claimrule.load(string claimruleclass)

$esxcli.storage.core.claimrule.run(string adapter, long channel, string claimruleclass, string device, long lun, string path, long target, string type, boolean wait)

Thanks!

/BKiil

Bjørn-Ove Kiil
0 Kudos
5 Replies
LucD
Leadership
Leadership

You are on the right track.

The unclaim command via $esxcli looks like

$esxcli.storage.core.claimrule.remove($claimruleclass,$plugin,$rule)

The other commands are correct, but you have will have to fill in the parameters.

If there is a parameter that you don't want to set/change, use the $null value in that parameter position.

If you want to see which parameters are present, you can call the method without parameters.

For example

PS C:\> $esxcli.storage.core.claimrule.add

TypeNameOfValue     : VMware.VimAutomation.ViCore.Util10Ps.EsxCliExtensionMethod

OverloadDefinitions : {void add(string adapter, boolean autoassign, long channel, string claimruleclass, string device, string driver, boolean force, string ifunset, string iqn, long lun, string

                      model, string plugin, long rule, long target, string transport, string type, string vendor, string wwnn, string wwpn)}

MemberType          : CodeMethod

Value               : void add(string adapter, boolean autoassign, long channel, string claimruleclass, string device, string driver, boolean force, string ifunset, string iqn, long lun, string

                      model, string plugin, long rule, long target, string transport, string type, string vendor, string wwnn, string wwpn)

Name                : add

IsInstance          : True


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Kiil
Contributor
Contributor

Thanks for quick reply.  I'm aware that I have to fill in values (or $null), but which value represents the switches in the esxcli command line syntax.

What I need to figure out is how to transform the type and device into the powercli variables ?  Are there any papers explaining this ?

esxcli storage core claiming unclaim --type device  --device naa.xxxxxxxxxxxxxxxxxxxx

How to transform this into a powercli command...

$esxcli.storage.core.claiming.unclaim(string adapter, long channel, string claimruleclass, string device, string driver, long lun, string model, string path, string plugin, long target, string type, string vendor)

Bjørn-Ove Kiil
0 Kudos
LucD
Leadership
Leadership

Isn't the device the parameter the only one of those 2 you need ?

You can do

$esxcli.storage.core.device.list()

to get the device values


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Kiil
Contributor
Contributor

Hi,

hmm...I've tried this:

$esxcli.storage.core.claiming.unclaim($null, $null, $null, "naa.50002ac002b423f8", $null, $null, $null, $null, $null, $null, $null, "3PARdata")

and got this:

Message: Invalid data constraint for parameter 'type'. Expected a single value from the set  [locat

ion, path, driver, device, plugin, vendor] got '';

InnerText: Invalid data constraint for parameter 'type'. Expected a single value from the set  [loc

ation, path, driver, device, plugin, vendor] got ''EsxCLI.CLIFault.summary

At line:1 char:1

+ $esxcli.storage.core.claiming.unclaim($null, $null, $null, "naa.50002ac002b423f8 ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : OperationStopped: (:) [], ViError

    + FullyQualifiedErrorId : VMware.VimAutomation.Sdk.Types.V1.ErrorHandling.VimException.ViError


And this is the output of the command you posted:

AttachedFilters    :
DevfsPath          : /vmfs/devices/disks/naa.50002ac002b423f8
Device             : naa.50002ac002b423f8
DeviceType         : Direct-Access
DisplayName        : 3PARdata Fibre Channel Disk (naa.50002ac002b423f8)

HasSettableDisplayName : true

IsBootUSBDevice    : false
IsLocal            : false
IsLocalSASDevice   : false
IsOffline          : false

IsPerenniallyReserved  : false

IsPseudo           : false
IsRDMCapable       : true
IsRemovable        : false
IsSSD              : false
Model              : VV
MultipathPlugin    : NMP
OtherUIDs          : {vml.020001000050002ac002b423f8565620202020}
QueueFullSampleSize: 0
QueueFullThreshold : 0
Revision           : 3123
SCSILevel          : 6
Size               : 4194304
Status             : on

ThinProvisioningStatus : yes

VAAIStatus         : supported
Vendor             : 3PARdata
Bjørn-Ove Kiil
0 Kudos
TScalzott
Enthusiast
Enthusiast

This seems to work for me:

# Get a list of 3PAR devices and unclaim

$3parDevices = $esxcli.storage.nmp.device.list() | Where { $_.DeviceDisplayName -like "3PARdata*" }

$3parDevices | % {

   $esxcli.storage.core.claiming.unclaim($null, $null, $null, $_.device, $null, $null, $null, $null, $null, $null, "device", "3PARdata")

   }

  

# Reload all claim rules  

$esxcli.storage.claimrule.load()

0 Kudos