VMware Cloud Community
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

Reply
0 Kudos
32 Replies
tonygent
Enthusiast
Enthusiast

Hi Carter,

Thanks for the response, but I think you have come to this a little late. The issue seems to be that the settings you are describing "The Advanced config" settings don't actually appear in vSphere. They DO appear in VI3 and the code you have described worked great in VI3, but in vSphere it seems not to work.

I've tested your code (in case you found a new and cool way to fix my issue :od) and I get the following error when attempting to run against a vSphere host :

Set-VMHostAdvancedConfiguration : Item has already been added. Key in dictionary: 'Misc.LogToFile' Key being added: 'M

isc.LogToFile' At C:\Documents and Settings\Administrator.SNS_AD\Desktop\tg_TestADVConfig.ps1:7 char:65

+ get-vmhost hydra3.SNSLTD.CO.UK | set-VMHostAdvancedConfiguration <<<< -Name LVM.EnableResignature -value 1

If I run the same code against a VI3 server - it works fine. Therefore - at present, I still have to conclude that there seems to be no way of effectively changing the settings for VI4 and as I state on the post (sorry it's a bit long winded - but there's a lot of info) vSphere does not seem to have a "One settings changes all LUN's" approach as adopted in VI3.

Hope this assists anyone else looking into this. I do recommend reading the whole post though as it's a long winded issue :smileygrin:

TG

Reply
0 Kudos
Michelle_Laveri
Virtuoso
Virtuoso

Hi. Using Oynx to find out the PowerCLI. I came up with this sample code:

  1. ------- QueryAvailableDisksForVmfs -------

$datastore = $null

$_this = Get-View -Id 'HostDatastoreSystem-datastoreSystem-25'

$_this.QueryAvailableDisksForVmfs($datastore)

  1. ------- QueryUnresolvedVmfsVolume -------

$_this = Get-View -Id 'HostStorageSystem-storageSystem-25'

$_this.QueryUnresolvedVmfsVolume()

  1. ------- RetrieveDiskPartitionInfo -------

$devicePath = New-Object System.String[] (1)

$devicePath[0] = "/vmfs/devices/disks/naa.6006048cc6c62ffdc29a13bf6bc650de"

$_this = Get-View -Id 'HostStorageSystem-storageSystem-25'

$_this.RetrieveDiskPartitionInfo($devicePath)

  1. ------- QueryVmfsDatastoreCreateOptions -------

$devicePath = "/vmfs/devices/disks/naa.6006048cc6c62ffdc29a13bf6bc650de"

$_this = Get-View -Id 'HostDatastoreSystem-datastoreSystem-25'

$_this.QueryVmfsDatastoreCreateOptions($devicePath)

  1. ------- ResignatureUnresolvedVmfsVolume_Task -------

$resolutionSpec = New-Object VMware.Vim.HostUnresolvedVmfsResignatureSpec

$resolutionSpec.extentDevicePath = New-Object System.String[] (1)

$resolutionSpec.extentDevicePath[0] = "/vmfs/devices/disks/naa.6006048cc6c62ffdc29a13bf6bc650de:1"

$_this = Get-View -Id 'HostDatastoreSystem-datastoreSystem-25'

$_this.ResignatureUnresolvedVmfsVolume_Task($resolutionSpec)

I feel like i"m close. The weird thing is - I originally started out with the esxcfg-volume and vicfg-volume commands to resigniture volumes on a UUID/Label basis. But now when ever I present a new volume it seems to get resignitured automatically...?

Regards

Mike Laverick

RTFM Education

http://www.rtfm-ed.co.uk

Author of the SRM Book:http://stores.lulu.com/rtfm

Free PDF or at-cost Hard Copy

Regards
Michelle Laverick
@m_laverick
http://www.michellelaverick.com
Reply
0 Kudos
tristanball
Contributor
Contributor

You say you're close? What part of your code doesn't work? It looks like it should to me?

My version:

---

$hostView = get-vmhost -name "esx1.local.names" | get-view

$dsView = get-view $hostView.ConfigManager.DatastoreSystem

$unBound = $dsView.QueryUnresolvedVmfsVolumes()

foreach ($ub in $UnBound) {

$extPaths = @()

$Extents = $ub.Extent;
foreach ($ex in $Extents) {

$extPaths = $extPaths + $ex.DevicePath

}
$res = New-Object VMware.Vim.HostUnresolvedVmfsResignatureSpec
$res.ExtentDevicePath = $extPaths
$dsView.ResignatureUnresolvedVmfsVolume($res)

}

---

This works, but only for VMFS volumes consisting of 1 extent on 1 lun. For some reason I can't resignature a vmfs volume that consists of multiple extents over multiple luns - and the error messages returned are not helpful! Smiley Wink

Reply
0 Kudos
MorDrakka
Contributor
Contributor

Hi all,

I am currently trying to Force Mount a Snaplun WITHOUT resignature. This is a DR lun in another vcenter. I do not wish to resignature because after a couple of hours the replication will be reversed again and the lun will be in the original site and vCenter, then I am able to to poweron the VM's which are still in the source vCenter.

This is the way our DR works in another environment which is ESX3.5u4.

The only way I am able to do this in vSphere 4.1 is to mount the volume to one ESX, then login in eachother ESX in the cluster and force mount it with the following commands:

esxcfg-volume -l

esxcfg-volume -M <id>

I already played with the SCSI.Comparelunnumber setting that works for us in the other environment, however this does not work(Because of the change in NAA id).

Any help is appreciated.

Reply
0 Kudos
MorDrakka
Contributor
Contributor

Hi thx to Onyx I resolved it myself:

$cluster =
$vcenter =
$user = "root"
$password =
Connect-VIServer $vcenter
Foreach($esxhost in (Get-VMHost -Location $cluster)){
    Connect-VIServer $esxhost -User $user -Password $password
    $hostView = get-vmhost -name $esxhost | get-view
    $dsView = get-view $hostView.ConfigManager.DatastoreSystem
    $unBound = $dsView.QueryUnresolvedVmfsVolumes()

    foreach ($ub in $UnBound) {
        $extPaths = @()
        $Extents = $ub.Extent;
        foreach ($ex in $Extents) {
        $extPaths = $extPaths + $ex.DevicePath
                                  }      
        $resolutionSpec = New-Object VMware.Vim.HostUnresolvedVmfsResolutionSpec[] (1)
        $resolutionSpec[0] = New-Object VMware.Vim.HostUnresolvedVmfsResolutionSpec
        $resolutionSpec[0].extentDevicePath = New-Object System.String[] (1)
        $resolutionSpec[0].extentDevicePath[0] = $extPaths
        $resolutionSpec[0].uuidResolution = "forceMount"

    $dsView = Get-View -Id 'HostStorageSystem-storageSystem'
    $dsView.ResolveMultipleUnresolvedVmfsVolumes($resolutionSpec)
    }
}

Reply
0 Kudos
avlieshout
VMware Employee
VMware Employee

The esx 3.x advanced setting also still works Smiley Wink

Arnim van Lieshout Blogging: http://www.van-lieshout.com Twitter: http://www.twitter.com/avlieshout If you find this information useful, please award points for "correct" or "helpful".
Reply
0 Kudos
habibalby
Hot Shot
Hot Shot

connecting directly to the host using vSphere Client / ViClient, and mount the VMFS with the exisiting signature. It will work. I have just encounter this issue on iSCSI Server  when I try to mount exisiting VMFS that was mounted on our production server. When I shiftted the server to the DR Site, and tried to mount it using vCenter, I got the error host unable to resolve VMFS datastore. I connected directly to the host and mount the VMFS and that works.

Best Regards, Hussain Al Sayed Consider awarding points for "correct" or "helpful".
Reply
0 Kudos
mikelleen
Contributor
Contributor

OK this is a NOOB issue, but  I have been trying to follow the thread above in order tor resolve my own resignature issues.

So, does anyone know why I am getting the following erro, I assume this is a configuration issue with the ESX host?:

PS C:\Documents and Settings\xxxxx> $dsView = get-view $hostView.ConfigManager.DatastoreSystem
PS C:\Documents and Settings\xxxxx> echo $dsView


Datastore    : {Datastore-datastore-327, Datastore-datastore-328, Datastore-datastore-329, Datastore-datastore-331...}
Capabilities : VMware.Vim.HostDatastoreSystemCapabilities
LinkedView   :
MoRef        : HostDatastoreSystem-datastoreSystem-1243
Client       : VMware.Vim.VimClient

PS C:\Documents and Settings\xxxxx> $unBound = $dsView.QueryUnresolvedVmfsVolumes()
PS C:\Documents and Settings\xxxxx> echo $unBound


Extent          : {4e7a68b4-5553c13d-389c-00215a4f605e}
VmfsLabel       : VM-Mike
VmfsUuid        : 4e7a68b4-5553c13d-389c-00215a4f605e
TotalBlocks     : 50944
ResolveStatus   : VMware.Vim.HostUnresolvedVmfsVolumeResolveStatus
DynamicType     :
DynamicProperty :

PS C:\Documents and Settings\xxxxx> Write-Host $scsi.ConsoleDeviceName
/vmfs/devices/disks/naa.6000d310000d02000000000000009a49
PS C:\Documents and Settings\xxxxx> $lunpath = $scsi.ConsoleDeviceName
PS C:\Documents and Settings\xxxxx> $res = New-Object VMware.Vim.HostUnresolvedVmfsResignatureSpec
PS C:\Documents and Settings\xxxxx> $res.ExtentDevicePath = $lunpath
PS C:\Documents and Settings\xxxxx> $dsView.ResignatureUnresolvedVmfsVolume($res)

Exception calling "ResignatureUnresolvedVmfsVolume" with "1" argument(s): "Cannot change the host configuration."
At line:1 char:40
+ $dsView.ResignatureUnresolvedVmfsVolume <<<< ($res)
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

PS C:\Documents and Settings\xxxxx>

Reply
0 Kudos
mossko
Contributor
Contributor

Hey MorDrakka Thanks for your previous code, i used this as a base for the Resignature code I'm attaching below

A few notes

  • To Resignature, you do not need to connect to each ESXi host
  • This works on CLARiiON CX4 and ESXi 4.1u1 in a Cluster with vCenter 4.1u1 with PowerCLI 4.1u1

function lun_find_and_resignature
    # This only needs to run on one ESXi host in the cluster
    PARAM (
        [string]$_esxhost
    )

    $hostView = get-vmhost -name $_esxhost | get-view
    $dsView = get-view $hostView.ConfigManager.DatastoreSystem
    $unBound = $dsView.QueryUnresolvedVmfsVolumes()

    foreach ($ub in $UnBound) {
        $extPaths = @()
        $Extents = $ub.Extent;
        foreach ($ex in $Extents) {
            $extPaths = $extPaths + $ex.DevicePath
        }

        $resolutionSpec = New-Object VMware.Vim.HostUnresolvedVmfsResignatureSpec
        $resolutionSpec.extentDevicePath = New-Object System.String[] (1)
        $resolutionSpec.extentDevicePath[0] = $extPaths

        $dsResig = Get-View -Id $hostView.ConfigManager.DatastoreSystem
        #$dsResig.ResignatureUnresolvedVmfsVolume_Task($resolutionSpec)    # This one runs a background task and continues
        $dsResig.ResignatureUnresolvedVmfsVolume($resolutionSpec)        # This one waits for the task to finish
    }

}

Reply
0 Kudos
patsrik
Contributor
Contributor

HI,

What about NFS Volumes. Are there vi java api available to query Unresolved NFS volumes ?? Am using Netapp storage network that has NFS volumes

Reply
0 Kudos
LucD
Leadership
Leadership

I suspect it would be better to raise your VI Java question in the their forums.


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

Reply
0 Kudos
patsrik
Contributor
Contributor

How do we mount the NFS volumes using vmware vsphere api / sdk ?? We have been searching a lot in the net to get some support on querying unresolved NFS volumes and mounting them to the datastore .

Reply
0 Kudos
bsti
Enthusiast
Enthusiast

Exception calling "ResignatureUnresolvedVmfsVolume" with "1" argument(s): "Cannot change the host configuration."
At line:1 char:40
+ $dsView.ResignatureUnresolvedVmfsVolume <<<< ($res)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException

This is a bit late but I thought I'd add my input here for anybody's benefit who gets this error in the future.  What I found causes it is if you have an invalid value for the ExtentDevicePath property on the VMware.Vim.HostUnresolvedVmfsResignatureSpec object.  In the example I quoted, the user is using $scsi.ConsoleDeviceName, which I don't think is the correct value to use.  I see other examples in this post that are more correct.

Basically, if you get this error, double-check the value of $res.ExtentDevicePath.

Reply
0 Kudos