Start a Conversation

Solved!

Go to Solution

5.7K Posts

12035

December 21st, 2018 03:00

How do I retrieve host LUN ids using Powershell?

I'm trying to retrieve a list of LUNs attached to hosts on my Unitys and I need to know the host LUN ids, but I'm getting a lot of information (name, wwn, size), but no host LUN id. Does anyone know how to retrieve this from a Unity system using Powershell?

Moderator

 • 

239 Posts

December 21st, 2018 03:00

Hi RRR,

By powershell do you mean UEMCLI?

The command you are looking for might be:

uemcli -no /stor/prov/luns/lun show -detail

Check the line that reads "Host LUN IDs" and the line above that.

You can filter also for what you need only. Example:

uemcli -no /stor/prov/luns/lun show -filter "ID,Name,LUN access hosts,Host LUN IDs"

Sample output:

      ID               = sv_xx

      Name             = Test_LUN

      LUN access hosts = Host_13, Host_14, Host_9, Host_10

      Host LUN IDs     = 7, 7, 7, 7

So from here you get what hosts can see a LUN, along with the Host LUN ID they are mapped with.

If you need to see it the other way around (from the host side, not LUN), then try the host command:

uemcli -no /remote/host show -detail

The filter option can also be used here.

All these outputs are based on Unity OE 4.4.1, so if you are running dated versions, you may not have some options.

Hope this helps.

Andre @ Dell EMC

If this answered your question, please remember to mark this thread as resolved/answered, so it can help other users.

5.7K Posts

December 24th, 2018 02:00

No, I mean PowerShell.

If we cannot find the right Powershell command, I'll be forced to embed uemcli commands into powershell, which is not what I prefer, because I'm dependent on the installed uemcli version as well.

Moderator

 • 

239 Posts

December 26th, 2018 04:00

Hi RRR,

Got you now. We don't get asked about the Unity PowerShell module here a lot.

As far as I can see, there is no direct way. I would recommend that you talk to the devs via the GitHub page to request this functionality.

However, you can get the info if you just use the RestAPI docs/guidance. Here is what I mean:

From looking at the GitHub page, they list a way to query resources in a more generic way:

https://github.com/equelin/Unity-Powershell#query-resources

If you then go to the RestAPI reference guides under https:///apidocs/index.html, you can get all the info you need by just using normal RestAPI calls.

An example here would be:

- Get your hosts with: Get-UnityHost

- Get your LUNs with: Get-UnityLUN

- Get or extrapolate the hostLUN ID:

Extrapolate:

The hostLUN ID is a value in the format of "Host_X_sv_xxx_prod" (Host ID combined with the LUN ID). So for example for Hots16 and LUN sv_506, the hostLUN ID would be: Host_16_sv_506_prod

Get:

Get-UnityItem -URI '/api/instances/host/Host_16?fields=hostLUNs&compact=true' -JSON

This will give you all the hostLUN IDs associated with this host (Host_16 in this example).

You can also query by host name here.

You can then get the actual host LUN (hlu) info with something like:

Get-UnityItem -URI '/api/instances/hostLUN/Host_16_sv_506_prod?fields=hlu&compact=true'

Example:

Get-UnityItem -URI '/api/instances/host/Host_16?fields=hostLUNs&compact=true' -JSON

{"content":{"id":"Host_16","hostLUNs":[{"id":"Host_16_sv_506_prod"}]}}

Get-UnityItem -URI '/api/instances/hostLUN/Host_16_sv_506_prod?fields=hlu&compact=true'

...

@{id=Host_16_sv_506_prod; hlu=0}

It's not straight forward, and there is probably a better way of doing this. You have to go through the docs, and have a word with the module devs to see if this can be added (this seems easy to script).

Andre @ Dell EMC

If this answered your question, please remember to mark this thread as resolved/answered, so it can help other users.

5.7K Posts

January 4th, 2019 00:00

Thank you Andre,

we will test this in our environment and I'll mark the answer accordingly.

Moderator

 • 

239 Posts

January 14th, 2019 01:00

Hi @RRR,

Did it work?

Did you reach out to the powershell devs to have this added as well?

5.7K Posts

January 16th, 2019 01:00

we're still working on figuring out how to combine the various outputs we're getting so that I can see a list of LUNs that belong to a host including the HLU of each LUN. And the other way around too: a list of hosts with their HLU that have access to a LUN. I'll update this thread when I have a working solution.

Moderator

 • 

239 Posts

February 26th, 2019 00:00

Thanks for letting us know

5.7K Posts

February 26th, 2019 00:00

we ended up using the uemcli commands after all

No Events found!

Top