ffrancisco
Contributor
Contributor

Resignature a VMFS Datastore Copy

Jump to solution

anyone know of or seen a powercli script to mount a new disk/lun and "assign a new signature" on the same time?  it works well on the gui, but I'm trying to automate the process.  any help is appreciated.

https://docs.vmware.com/en/VMware-vSphere/5.5/com.vmware.vsphere.hostclient.doc/GUID-5A4E2248-12CB-4...

Procedure

  1. Log in to the vSphere Client and select the server from the inventory panel.
  2. Click the Configuration tab and click Storage in the Hardware panel.
  3. Click Add Storage.
  4. Select the Disk/LUN storage type and click Next.
  5. From the list of LUNs, select the LUN that has a datastore name displayed in the VMFS Label column and click Next.   The name present in the VMFS Label column indicates that the LUN is a copy that contains a copy of an existing VMFS datastore.
  6. Under Mount Options, select Assign a New Signature and click Next.
  7. In the Ready to Complete page, review the datastore configuration information and click Finish.
0 Kudos
1 Solution

Accepted Solutions
ffrancisco
Contributor
Contributor

thanks LucD. I figured out the rest.  appreciate the help

$volumelabel = "Volume Name"

$esxcli = Get-EsxCli -VMhost esxhost

$esxcli.storage.vmfs.snapshot.resignature($volumelabel)

View solution in original post

0 Kudos
9 Replies
LucD
Leadership
Leadership

Try something like this.

The volume will be mounted after the resignature.

You can also use the volumeuuid instead of the volumenlabel

$esxcli = Get-EsxCli -VMhost MyEsx -V2

$resig = @{

    volumelabel = 'VMFS-Snap'

}

$esxcli.storage.vmfs.snapshot.resignature.Invoke($resig)


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

0 Kudos
ffrancisco
Contributor
Contributor

Hi LucD - I got an error.  thx for the assistance.

PowerCLI H:\powershell\shadowimage_clone> .\resignature.ps1
Get-EsxCli : A parameter cannot be found that matches parameter name 'V2'.
At H:\powershell\shadowimage_clone\resignature.ps1:1 char:55
+ $esxcli = Get-EsxCli -VMhost usdenvsp102.corp.hds.com -V2
+                                                       ~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-EsxCli], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetEsxCli

You cannot call a method on a null-valued expression.
At H:\powershell\shadowimage_clone\resignature.ps1:5 char:1
+ $esxcli.storage.vmfs.snapshot.resignature.Invoke($resig)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

##then I removed the V2###

PowerCLI H:\powershell\shadowimage_clone> .\resignature.ps1

Exception calling "Invoke" with "1" argument(s): "Message: No unresolved VMFS snapshots with volume label 'System.Collections.Hashtable' found.;

InnerText: No unresolved VMFS snapshots with volume label 'System.Collections.Hashtable' found.EsxCLI.CLIFault.summary"

At H:\powershell\shadowimage_clone\resignature.ps1:5 char:1

+ $esxcli.storage.vmfs.snapshot.resignature.Invoke($resig)

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

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : ViError

0 Kudos
ffrancisco
Contributor
Contributor

thanks LucD. I figured out the rest.  appreciate the help

$volumelabel = "Volume Name"

$esxcli = Get-EsxCli -VMhost esxhost

$esxcli.storage.vmfs.snapshot.resignature($volumelabel)

View solution in original post

0 Kudos
LucD
Leadership
Leadership

That's strange, look slike you are using the Get-EsxCli V2 version, but the resignature is not a V2 command.

Could it be that you are on a somewhat older PowerCLI version? Do a Get-PowerCLIVersion.


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

0 Kudos
ffrancisco
Contributor
Contributor

thx again for your help.

here is the version.

PowerCLI H:\powershell\shadowimage_clone> get-powercliversion

PowerCLI Version
----------------
   VMware vSphere PowerCLI 6.0 Release 3 build 3205540
---------------
Component Versions
---------------
   VMWare AutoDeploy PowerCLI Component 6.0 build 2358282
   VMWare ImageBuilder PowerCLI Component 6.0 build 2358282
   VMware vSphere PowerCLI Component 6.0 build 3205541

0 Kudos
LucD
Leadership
Leadership

Ok, that one doesn't have the V2 option yet.

You should perhaps consider upgrading your PowerCLI version.


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

0 Kudos
v3mattia
Contributor
Contributor

Hi LucD,

I'd like to look at the definitions of this method with its parameters but I didn't find any useful link to doc.

Have you one ?

 

I fall into this thread because I used to launch a similar method, vmfs mount, but this way

$esxcli.storage.vmfs.snapshot.mount.Invoke("DATASTORELABELNAME")

But I got this error:

You cannot call a method on a null-valued expression.
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
+ PSComputerName : localhost

 

Only after trying to create an Has Table like this way the method worked

$vols = @{ volumelabel = "DATASTORELABELNAME" }
$esxcli.storage.vmfs.snapshot.mount.Invoke($vols)

 

But this is the only place where I found any useful advice about how to use the invoke() command..

Hope anybody could help

 

 

0 Kudos
LucD
Leadership
Leadership

The Get-EsxCli cmdlet is nothing more than a PowerCLI front for the esxcli command.
See PowerCLI 6.3 R1: Get-ESXCLI Why the V2? for info on the Get-EsxCli cmdlet and how it maps to the esxcli commands.

The esxcli command, and all its parameters, is available in the esxcli documentation.

The error you listed seems to indicate that you didn't do the Get-EsxCli to populate the $esxcli variable (correctly).


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

0 Kudos
v3mattia
Contributor
Contributor

Thank you !

This makes a lot of sense now.

0 Kudos