General Discussion

Need help to create WFA to clone a LUN from snapshot

Hitesh123
2,650 Views

Hi , i am new to WFA and i need to create a work flow which can clone a LUN using a snapshot of parent volume and export it to a host. Until now i have created work flow with below steps and currently i am stuck on step 4. 

 

step 1 : - Cluster name --should be populated using mysql query  -- this is already done

step 2 : - vserver name - - should be populated using mysql query  -- this is already done

step 3 : - volume name -- - should be populated using mysql query  -- this is already done

step 4 : - snapshot list -- It should populate the list of snapshots for volume selected in step 3.  -- I am stuck here

 

my OCUM version is 7.2 and WFA version is 5.0 . While searching on google i found seems it is problem with schema cm_storage as there is no data for snapshot in it. But how i can fix it. I am sorry i am new to WFA so please excuse for basic questions. 

 

Thanks in advance. 

3 REPLIES 3

mbeattie
2,567 Views

Hi,

 

The cm_storage database does not contain snapshots. You need to configure a Data source for it (Scheme, Dictionary and Data Source Types).

 

  • Create a scheme called 'cm_snapshots'
  • Create a Dictionary in the cm_snapshot' scheme called 'snapshot'
  • Create a Data Source Type in the 'cm_snapshots' scheme

Here is an example of the dictionary:

 

snapshots.png

 

Here is the data source type:

 

#'------------------------------------------------------------------------------
#'Ensure that dates are always returned in English
#'------------------------------------------------------------------------------
[System.Threading.Thread]::CurrentThread.CurrentCulture="en-US"
#'------------------------------------------------------------------------------
#'Create the output file
#'------------------------------------------------------------------------------
$snapshotCsv = "./snapshot.csv"
New-Item -Path $snapshotCsv -type file -force
$clusterAddress = Get-WfaRestParameter "host"
Get-WFALogger -Info -Message "Enumerating Snapshots on Cluster ""$clusterAddress"""
#'------------------------------------------------------------------------------
#'Connect to the cluster
#'------------------------------------------------------------------------------
Try{
   Connect-WfaCluster $clusterAddress -Timeout 300000
   $c = Get-NcCluster -ErrorAction Stop
}Catch{
   Get-WFALogger -Error -Message $("Failed connecting to cluster ""$clusterAddress"". Error " + $_.Exception.Message)
   Throw "Failed connecting to cluster ""$clusterAddress"""
}
#'------------------------------------------------------------------------------
#'Create a query to filter snapshots
#'------------------------------------------------------------------------------
$query = @{
   Vserver = 'vs*';
   Name    = '!*snapmirror*';
}
#'------------------------------------------------------------------------------
#'Set the snapshot attributes to query.
#'------------------------------------------------------------------------------
$attributes =  @{
   AccessTime = "";
   Dependency = "";
   SnapshotInstanceUuid = "";
}
#'------------------------------------------------------------------------------
#'Enumerate the snapshots.
#'------------------------------------------------------------------------------
Try{
   $snapshots = Get-NcSnapshot -Query $query -Attributes $attributes -ErrorAction Stop
   Get-WFALogger -Info -Message "Enumerated snapshots on cluster ""$clusterAddress"""
}Catch{
   Get-WFALogger -Error -Message $("Failed connecting to cluster ""$clusterAddress"". Error " + $_.Exception.Message)
   Throw "Failed connecting to cluster ""$clusterAddress"""
}
#'------------------------------------------------------------------------------
#'Add each snapshot to the CSV file for importing.
#'------------------------------------------------------------------------------
ForEach($snapshot in $snapshots){
   $vserver      = $snapshot.Vserver
   $cluster      = $c.ClusterName
   $volume       = $snapshot.Volume
   $snapshotName = $snapshot.Name
   $dependency   = $snapshot.Dependency
   $snapshotID   = $snapshot.SnapshotInstanceUuid
   $timestamp    = ($snapshot.AccessTimeDT).ToString("yyyy-MM-dd HH:mm:ss")
   Add-Content $snapshotCsv ([byte[]][char[]] "\N`t$cluster`t$snapshotName`t$timestamp`t$volume`t$vserver`t$dependency`t$snapshotID`n") -Encoding Byte
}
#'------------------------------------------------------------------------------

 

Hope that helps

 

/Matt

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

mbeattie
2,564 Views

Also note that you can filter the query to meeting your requirements. In this example i've excluded snapmirror snapshots and filtered snapshots for volumes on vservers matching 'vs*' (EG vserver1, vserver2, vserver3 etc)

 

$query = @{
   Vserver = 'vs*';
   Name    = '!*snapmirror*';
}

 

Update to meet your requirements

 

/Matt

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

Hitesh123
2,522 Views

Hi Matt,

 

Many thanks for your help. Let me try this. I will get back to you with results soon. 

 

Thanks again.

 

Regards

Hitesh

 

Public