tonygent
Enthusiast
Enthusiast

Enable Mount and resignature of snap luns on vSphere

Hi all,

I've done some PS development work in the past (with all your assistance) to get my VI3.5 system to mount snaps from my NAS device and allow me to review the contents.

In the past (with VI3.5) all I had to do was use the powershell to change the LVM option value of the Esx host to "AllowSnapLun" and "EnableResignature" then rescan the esx storage. The LUN would appear (with a SNAP-xxx_lun name)

Great - all was well with the world.

Then we updated to vSphere and this has now put a spanner in the works.

Seems that vSphere no longer has the LVM option values to allow for the mounting of the LUN's. In theory, this is because vShpere allows you to mount snapped LUNs. However - the LUN appears but the datastore is invisible?? I can't find any way of allowing the powershell to mount the snapped datastores.

There seems to be some esx host Service console ESXCFG code for resiging a lun, but I can't launch that from the powershell can I, and if I could - it asks for a UUID for the storage? - how would I know what this is without manually looking each time? (not great for scripting).

Any ideas how I do this??

Also note - I'm still using the VItoolkit (NOT the NEW PowerCLI) as the PowerCLI breaks some of the code I used for mounting VMDK files on VM's. I anyone can confirm that the powerCLI is required and perhaps provide some code to prove the pointt - thats also worth a look, but I do not have time for a re-write at the mo so have shied away from the upgrade.

Any help would be much appreciated.

TG

0 Kudos
32 Replies
harkamal
Expert
Expert

Wait till LucD returns from hibernation Smiley Happy

0 Kudos
Saju_C
Enthusiast
Enthusiast

Did you try the esxcfg-volume command?

0 Kudos
LucD
Leadership
Leadership

Could you perhaps include the relevant code snippets that worked against API v2.5 ?


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

0 Kudos
tonygent
Enthusiast
Enthusiast

Hi all,

Thanks for the responses. Firstly - attached is an example of the functions I'm running to enable the process on ESX3.5. the code runs through all the esx hosts in a given cluster, and enables/disables (as required) the LVM settings for AllowSnapshotLUN and EnableResignature.

I did put in my original post that I am aware of the esxcfg command. But like I said - how can I run this from within the powershell and also - how can I tell the UUID it seems to require?? - I'm mounting several volumes and each is a unique snapshot, so I just need a blanket allow if it's possible.

Many thanks Smiley Happy

0 Kudos
tonygent
Enthusiast
Enthusiast

Hi All,

I've had a few mins to do some digging, and I've found something that seems useful in the vSphere API spec.

http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/index.html

There is a task called : ResignatureUnresolvedVmfsVolume_Task

(You can use the Quick Index search box to find it)

The description of this task seems to be just what I need, but I'm just not adept enough to figure out how it's supposed to be used with the PowerShell and VI toolkit. There are no examples of code so I'm a little lost on where to start.

Can anyone give me some pointers. You have seen the code I'm used too, from the examples I've provided, so I'm not a complete NEWB, but I just don't spend enough time doing this to hit the ground running.

Any assistance would be much appreciated.

Thanks

TG

0 Kudos
tonygent
Enthusiast
Enthusiast

Another Update in the hope someone if reading this 🐵

http://vinternals.com/powercli-mastery/

I've done a fair bit of reading with regard to this problem. I found an excellent article (above), that does a good job of explaining the object model used by the API's and this has helped my undestanding a fair bit. However - I'm still a long way from a solution.

I'm certain that the VI4 object model object, ResolveMultipleUnresolvedVmfsVolumes is where I need to be. It seems to tick all the boxes. However - it requires another object to work. The "HostUnresolvedVmfsResolutionSpec" object. This spec object in turn requires the extentDevicePath to be filled in, so again - I'm lost looking for where I find the exentDevicePath.

What also concerns me is, assuming it's asking for this path - does it allow for me to send the paths for all the LUNs on a host (including the ones that are already mounted and signatured), or will it ONLY accept LUN's that are currently NOT mounted?

If it will only accept LUNs that are currently NOT mounted (and thats not clear in the documentation), does that therefore mean do I need a multi stage process for something so simple?

1) Scan the currently mounted storage and take note of the currently presented ExtentDevicePaths.

2) Snap and Mount my Snapshot LUNs to all ESX hosts

3) Rescan and take a list of all currently presented extents

4) From this list and the list in step one define a list of newly added LUNS

5) Issue a ResolveMultipleUnresolvedVMFSVOlume tasks for each of new LUN's and ask the system to Resig and Mount?

This seems a little overkill, when I used to just say "Allow Mount" and the system would do the rest for me! 🐵 If this process is correct _ will also need to do it for each host in the cluster??

Sure someone out there must be better at this than me 🐵

Any assistance always appreciated!

TG

0 Kudos
LucD
Leadership
Leadership

I gave a general overview of how to call the _task methods in .

Is that sufficient to get you on the way with the ResignatureUnresolvedVmfsVolume_Task method ?

Or do you like to see how the different parameters should be done for this method ?


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

0 Kudos
tonygent
Enthusiast
Enthusiast

Hi LucD

Thanks for responding to the other query on the _Task element. It is usefull, but as you can see from my posts above, it's only half the story. I'm more concerned on how to run through the presented LUN's to each ESX host and Mount/Resignature only the snapped ones, while ignoring the already mounted one? It's not at all clear from the VI 4 API notes and your experience on this may save me days of trial and error.

Anything insights you can offer would be much appreciated.

Thanks

TG

0 Kudos
tonygent
Enthusiast
Enthusiast

Hi All,

I'm still no further forward this this query, despite hours of trying. Can anyone shed and light on how to rescan for Snapped LUN's on an ESX host in vSphere?? I need to use the power CLI to do this. Please review the post - any suggestions would be gratefully received. Smiley Happy

TG

0 Kudos
LucD
Leadership
Leadership

Tony, don't have a vSphere environment with snap-technology at my disposal right now.

But after reading a bit in the SDK Reference, did you try the following ?

Use the QueryUnresolvedVmfsVolumes to find the unbound VMFS volumes.

This method returns a HostUnresolvedVmfsVolume[], and I suspect that the extent[0].devicepath property is what you need in the extentDevicePath property to call the ResignatureUnresolvedVmfsVolume_Task method.


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

0 Kudos
LucD
Leadership
Leadership

And you apparently only need the head-extents.

There is a Boolean flag, called isHeadExtent, which you can use to filter them out.


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

0 Kudos
tonygent
Enthusiast
Enthusiast

With the Head Extents, are the HeadExtents going to be extents that are currently NOT mounted? - or do Head Extents represent a method to find out if a Datastore is made up of more than one extent bolted together, where the head extent represents the Original Datastore, before it was extended by adding new 'extents'?

I'll give it a try and attempt to use your other code to instigate the tasks etc.

Wish me luck ;o)

TG

0 Kudos
LucD
Leadership
Leadership

The HostUnresolvedVmfsVolume object states "Information about detected unbound, unresolved VMFS volume. An unresolved VMFS volume is reported when one or more device partitions of volume are detected to have copies of extents of the volume. Such copies can be created via replication or snapshots. ".

So it seems to be about snapshotted extends.

Good luck with your code Smiley Wink


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

0 Kudos
mike_lim
Contributor
Contributor

Hi,

I have been working with Tony on using the new method to resignature snaps using a call to the queryunresolvedvmfsvolumes method. I now have working code however I have come across another problem in the live environment which I have not figured a way round from the documentation. When calling this method I get an "Operation Timed Out" message after 100 Seconds. I have used the MOB from a browser to verify that the host does return info about the volumes but it does take 3.5 minutes and I have also played with client timeout settings on the host we are querying. Is this something we should open a call on as I noticed that someone else on the forum had a timeout issue obtaining the cluster view.

Any help always welcome.

MikeL

0 Kudos
Karth
Contributor
Contributor

Hi,

Can you share the steps you did to Mount the VMFS with the same signature?

Thanks

Karthick

0 Kudos
tonygent
Enthusiast
Enthusiast

Hi Smiley Happy - Sorry for the late reply (and even this is going to be a bit fast I'm afraid).

Firstly - I've not done the completion work on this - It's been handled by another guy in the team, but I thought I'd catch you up with the resolution.

Firstly - the VMware 3 model was to NOT mount or re-signature (rename) DataStores that were possibly snaps presented from your storage. Mounting two DataStores of the same name can cause issues with VM's mounting disks from the wrong store. In my environment, if I wanted to snap and present a historic copy of a DataStore from my SAN, I'd need to change the LVM>DisAllowSnap and AllowResig values on the host before the snapped DataStore would be visible.

I'd scripted this process with PowerShell and all was good. We'd enable the settings on each host - mount the LUNs, rescan to resig the DataStores, play with them, then disable the settings, and rescan to remove the LUNs. All good.

We then upgraded to VSphere.

With vSphere - the LVM settings mentioned do not work with PowerShell and do not appear in the client interface. In addition - there is a new model, where you can "on a LUN by LUN basis" decide if you want to mount. However - this process within the API still seems broken. This left me with no way of snapping and mounting several historic LUN's with the PowerShell.

In the end - we have had to bypass this issue with a cheat. While the VI Client Interface and PowerShell do not have settings to apply the original "Global - allow all" settings that previously existed. The ESX host still does have this setting. We are able to use the esxcfg command at the service console cli on each ESX host to set the host to allow snaps and allow resig. Once this is set - I can just add the LUN's rescan with the PowerShell and the resig'd LUN's appear. It's an "Always on" setting, but it's better than nothing. Smiley Happy

Hopefully that will assist. By all means reply if you need more info.

0 Kudos
Karth
Contributor
Contributor

Thanks u so much .It realy helpfull to me

did u use the following command to dothe resignature or some thing else?-- esxcfg-volume -r "Label name"

The problem is , i am trying to implement the "Force mount" operation in the ESX 4.0 using Vsphere SDK.

if i get any sample code related to this will be very helpful.

0 Kudos
tonygent
Enthusiast
Enthusiast

Hi.

Re-Signature happens automatically. The DataStore will appear with snap-xxxxxx- where xxxxx is a random set of chars, you don't define the new name yourself..

To enable Resig and try the following from the service console of the ESX host :

Run the following commands:

1. esxcfg-advcfg --get /LVM/EnableResignature It should be set to 0 - Resignaturing is OFF

2. Now set it to on.

esxcfg-advcfg -s 1 /LVM/EnableResignature

3. Issue a "refresh" in VI client storage view and the snapshot Luns of the same source LUN get re-signatured simultaneously:

4. Reset the enableResignature option:

esxcfg-advcfg -s 0 /LVM/EnableResignature

Thanks to Darragh Connolly for assistance with this issue.

Let me know how you get on. Smiley Happy

TG

0 Kudos
admin
Immortal
Immortal

Converted to PowerCLI that looks like:

Get-VMHost | Set-VMHostAdvancedConfiguration -Name LVM.EnableResignature -Value 1
Get-VMHost | Get-VMHostStorage -RescanAllHBA -RescanAllVMFS
Get-VMHost | Set-VMHostAdvancedConfiguration -Name LVM.EnableResignature -Value 0

That will do it across all hosts. To do it for a specific host give an argument to Get-VMHost.

=====

Carter Shanklin

Read the PowerCLI Blog
[Follow me on Twitter|http://twitter.com/cshanklin]

0 Kudos