mblumberg

Powershell to map volume and clones

Blog Post created by mblumberg Employee on Aug 15, 2017

With the increase of zero copy cloning applicabilities usage I thought it will be nice to provide a quick method of monitoring clones parent volumes and base snapshot as they are all depended of each other.

 

This is a very quick script and the output is very powerfull, it will let you know which are the volumes are clones(name), what is the parent volume name and what is the base snapshot.

 

Here is the expected output:

 

PS C:\Users\Administrator\Desktop> .\ff.ps1

 

name                                    parent_vol_name          base_snap_name
----                                    ---------------          --------------
mb-vvol-mm-config-clone                 mb-vvol-mm               mb-vvol-mm-569e7fbad65b9423-0001-minutely-2016-09-28::12:57:00.000
mb-vvol-mm-clone.vmdk                   mb-vvol-mm.vmdk          mb-vvol-mm-569e7fbad65b9423-0001-minutely-2016-09-28::12:57:00.000
Clone-emea-vm-mb0002-v1.docker          emea-vm-mb0002-v1.docker BaseForemea-vm-mb0002-v1.docker:2016-10-13.17:33:58.808
Clone-Docker-volume1.docker             Docker-volume1.docker    BaseForDocker-volume1.docker:2016-10-13.17:39:32.999
importedSnap.docker                     Not-Docker-Volume        snapshot-Not-Docker-Volume
os-clone                                SRM-VM01                 os
SBVolSnap-Clone                         SB-Testvol1              SnapSB-Testvol1
VVolCloneForRecoveryOperationVVol-demo1 VVol-demo1-1.vmdk        VVol-demo1-569e7fbad65b9423-0002-minutely-2017-03-01::21:03:00.000

 

Here is the script:

 


###########################
# Enable HTTPS
###########################

 

[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}

 

###########################
# Get Token
###########################

 

$array = "<IP/FQDN>"
$username = "admin"
$password = "PASSWD"

 


$data = @{
    username = $username
    password = $password
}

 

$body = convertto-json (@{ data = $data })

 

$uri = "https://" + $array + ":5392/v1/tokens"
$token = Invoke-RestMethod -Uri $uri -Method Post -Body $body
$token = $token.data.session_token

 

$header = @{ "X-Auth-Token" = $token }
$uri = "https://" + $array + ":5392/v1/volumes"
$volume_list = Invoke-RestMethod -Uri $uri -Method Get -Header $header
$uri = "https://" + $array + ":5392/v1/volumes/detail?clone=true&fields=name,parent_vol_name,base_snap_name"
$volume = Invoke-RestMethod  -Uri $uri -Method Get -Header $header
$volume.data  | format-table -AutoSize

 

 

I've attached the script as a file if should you need to download it

 

Hope you find it useful.

Thanks,

@Moshe_Blumberg

Attachments

Outcomes