MadMax1980
Contributor
Contributor

Esx >4.x Communication with Storage changed

Jump to solution

Hi guys,

Maybe somebody of you already recognized the strange changes for >4.x.

i deleted last week a Lun, and requested for deleting the Storage Zoning. Until Zoning was finished i saw that errors where flooding that the esx tryes to contact this device.

i contacted Vmware and they told me that theire where special tasks to do with vmfs lun's

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=101508...

so but if i would have to delete >50 Lun's in case of Storage Box change. lol ;( i'am sitting a very long time only for this

- Unmask + Unclaim rules ;(

May anybody know if it is possible to script this manually methode? ;(

Many thx

Best Regards

Max

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

If I understand the question correctly, you want to split the runtimename in hba, channel, target and lun ?

If that is indeed the question, you could do it like this

$array = $RuntimeName.Split(':')

$hba = $array[0]

$channel = $array[1]

$target = $array[2]

$lun = $array[3]


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

View solution in original post

0 Kudos
21 Replies
LucD
Leadership
Leadership

Afaik these esxcli commands use private APIs.

So I'm afraid you're out of luck, no PowerCLI automation for this.

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos
MadMax1980
Contributor
Contributor

Hi LucD,

thx for the answer.

i found today an interesting information.

http://www.virtuallyghetto.com/2010/08/hidden-esxcli-apis.html

so claimings + masking is accessable through the vSphere Mob from 4.1

May i'am wrong - but is it not possible to create new functions manually to contact the VimEsxCLI from the MOB?

Many thx

Max

0 Kudos
ykalchev
VMware Employee
VMware Employee

Hi,

You can try Get-EsxCli cmdlet available in PowerCLI 4.1.1. Take a look at this blog post for more information.

Regards,

Yasen Kalchev

PowerCLI Dev Team

Yasen Kalchev, vSM Dev Team
MadMax1980
Contributor
Contributor

Hi guys,

I'am planning to manage a script with get-esxcli.  but it's little confusing to me.

i have some problems to set the rule for -A -C -T -L. for the claimrule

for example:

"

Connect-VIServer (

Read-Host "Please input Host")

$esxcli = Get-EsxCli

$naa = (Read-Host "Please input NAA Device Name")

$esxcli.nmp.path.list() |where {$_.Device -eq "$naa"}|select RuntimeName

"

therefore i get the Runtime names for the Devicenames which i would use for the Rules.

but i don't know how to set the rules for splitting the   "vmhba1:C0:T4:L1"

(get-esxcli $esx).corestorage.claimrule.add   >>> theire some value types.

May anybody knows how i could make it possible for each Runtime name so set the correct Rule?

for example:  --autoassign  --type location -A $hba -C $Channel -T $Target -L $Lun -P MASK_PATH

Many thx

Max

0 Kudos
LucD
Leadership
Leadership

If I understand the question correctly, you want to split the runtimename in hba, channel, target and lun ?

If that is indeed the question, you could do it like this

$array = $RuntimeName.Split(':')

$hba = $array[0]

$channel = $array[1]

$target = $array[2]

$lun = $array[3]


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

View solution in original post

0 Kudos
MadMax1980
Contributor
Contributor

Hi Lucd,

thx for your answer.

i tryed it for 1 runtime.

$array = $RuntimeName.Split(':')

$hba = $array[0]

$channel = $array[1].Split('C')

$target = $array[2].Split('T')

$lun = $array[3].Split('L')

So but how could i input the Claimrule rule code inside the syntax?

(get-esxcli $esx).corestorage.claimrule.add

theire seems to be it's possible to manage the rules.  but theire is no helpfile for that ;(

-----------

TypeNameOfValue     : VMware.VimAutomation.ViCore.Util10Ps.EsxCliExtensionMethod
OverloadDefinitions : {void add(string adapter, boolean autoassign, long channel, string claimruleclass, string device, string driver, boolean force, long lun, string model, string plugin, long rule,
                       long target, string transport, string type, string vendor)}
MemberType          : CodeMethod
Value               : void add(string adapter, boolean autoassign, long channel, string claimruleclass, string device, string driver, boolean force, long lun, string model, string plugin, long rule,
                      long target, string transport, string type, string vendor)
Name                : add
IsInstance          : True

------------

thx

max

0 Kudos
LucD
Leadership
Leadership

You have to pass the parameters to the add method.

See Arnim's post called ESXCLI the PowerCLI way.

The post shows how to pass parameters to the setpolicy method.

There is help available

PS C:\> $cli.corestorage.claimrule.help("add")

=========================================================================================================
vim.EsxCLI.corestorage.claimrule.add
---------------------------------------------------------------------------------------------------------
Add a claimrule to the set of claimrules on the system.

Param
---------------------------------------------------------------------------------------------------------
adapter              |  Indicate the adapter of the paths to use in this operation.
autoassign           |  The system will auto assign a rule id.
channel              |  Indicate the channel of the paths to use in this operation.
claimrule-class      |  Indicate the claim rule class to use in this operation.
device               |  Indicate the Device Uid to use for this operation.
driver               |  Indicate the driver of the paths to use in this operation.
force                |  Force claim rules to ignore validity checks and install the rule anyway.
lun                  |  Indicate the LUN of the paths to use in this operation.
model                |  Indicate the model of the paths to use in this operation.
plugin               |  Indicate which PSA plugin to use for this operation.
rule                 |  Indicate the rule ID to use for this operation.
target               |  Indicate the target of the paths to use in this operation.
transport            |  Indicate the transport of the paths to use in this operation.  Valid Values are:
[block, fc...
type                 |  Indicate which type of matching used for claim/unclaim or claimrule.  Valid value
s are:  [ve...
vendor               |  Indicate the vendor of the paths to user in this operation.


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

0 Kudos
MadMax1980
Contributor
Contributor

Hi Lucd,

yes i read this site already, but this belongs to other syntax.

if i proceed same syntax i would need start from first Parameter to last - if i'am right.?

(get-esxcli $esx).corestorage.claimrule.add($hba,'autoassign',$Channel,'file',$null,$null,$null,$lun,$null,'MASK_PATH',$null,$target,$null,'location',$null)

so i made $null for every parameter which i don't need.

therefore i get and "The remote server returned an error: (500) Internal Server Error."

the help is not 100% clear to me ;(

many thx

Max

0 Kudos
MadMax1980
Contributor
Contributor

ok, i got the next step.

i managed it with on low level.

$esxcli = get-esxcli $esx

$corestorageManageObjectInstance = $EsxCli.TypeManager.CreateDynamicManagedObject(“ha-cli-handler-corestorage-claimrule”)

   $parameters = @{

      "adapter" = $hba;

      "autoassign" = $true;

      "channel" = "0";

      "lun" = "1";

      "plugin" = "MASK_PATH";

      "target" = "2";

      "type" = "location";

   }

$corestorageManageObjectInstance.InvokeOperation("add",$parameters) |ft -auto

now i get no error, but only after i executed the $Parameters.

--------------

if i execute it on high lvl, then i get as last post the "internal error".

$esxcli.corestorage.claimrule.add($Parameters)   (>>>> don't know why theire i get the error ;()

best regards

Max

0 Kudos
LucD
Leadership
Leadership

That's a known bug I just remember, you used the bypass for the bug.


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

MadMax1980
Contributor
Contributor

Hi Smiley Wink

The Basic Version is ready for use.  only 1 esx + 1 naa.

How could i handly a loop   "Do you like to start the Script again?" so to avoid manually starting the script again.

i guess i have to clear the variables at the end or?

Many thx

Max

0 Kudos
LucD
Leadership
Leadership

Try it with a simple while loop


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

0 Kudos
MadMax1980
Contributor
Contributor

Hi Lucd,

thx for changing the script.

i tried to fit it for an input (get-content) to manage multiple naa's.

But i have a loop problem theire, which i don't find ;(

i tried this script with only 1 naa, and he made more then 4 file rules ;(

i have only 2 path's per hba.

something is multiple ;(

i would be glad if you could analyze my mistake ;(

many thx

Max

0 Kudos
LucD
Leadership
Leadership

Is this better ?


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

0 Kudos
MadMax1980
Contributor
Contributor

hi.

now i have following rules.

MP          5001   file     location   MASK_PATH  adapter=vmhba2 channel=0 target=1 lun=0
MP          5002   file     location   MASK_PATH  adapter=vmhba2 channel=0 target=0 lun=0
MP          5003   file     location   MASK_PATH  adapter=vmhba1 channel=0 target=1 lun=0
MP          5004   file     location   MASK_PATH  adapter=vmhba1 channel=0 target=0 lun=0
MP          5005   file     location   MASK_PATH  adapter=vmhba1 channel=0 target=0 lun=0
MP          5006   file     location   MASK_PATH  adapter=vmhba1 channel=0 target=0 lun=0
MP          5007   file     location   MASK_PATH  adapter=vmhba1 channel=0 target=0 lun=0
MP          5008   file     location   MASK_PATH  adapter=vmhba1 channel=0 target=0 lun=0

normally it should be:

MP          5001   file     location   MASK_PATH  adapter=vmhba2 channel=0 target=1 lun=0
MP          5002   file     location   MASK_PATH  adapter=vmhba2 channel=0 target=0 lun=0
MP          5003   file     location   MASK_PATH  adapter=vmhba1 channel=0 target=1 lun=0
MP          5004   file     location   MASK_PATH  adapter=vmhba1 channel=0 target=0 lun=0

Also the RESULTS Part loops 5 times,  and 4-5 are empty. only at first  RESULT i see  the path + device variable in the output.

Smiley Wink


0 Kudos
LucD
Leadership
Leadership

I suspect there might be a problem with your c:\naa.txt file.

Is there a naa on each line ?

Any blank lines at the end ?

Did you edit the file with notepad ?


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

0 Kudos
MadMax1980
Contributor
Contributor

Hi,

lol that's strange.  Smiley Wink

i created this file with notepad.

now i created it with notepad++   and it's working.

Pff damned stuff Smiley Wink

little later i will test with 2 naa's.

thx until now

max

0 Kudos
MadMax1980
Contributor
Contributor

Hello Lucd Smiley Wink

i tryed today do unmusk a lun over 2 Esx servers.

I get strange error after using the Loop.

I got  "null" back

Best regards

Max

0 Kudos
LucD
Leadership
Leadership

Does the Connect-VIServer works for each of the servers ?

Any error messages ?


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

0 Kudos