Skip to content

Commit

Permalink
Add Move-RubrikMountVMDK to public functions
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Wahl <github@wahlnetwork.com>
  • Loading branch information
chriswahl committed Jan 12, 2017
1 parent 231697a commit 4cd0c94
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 23 deletions.
@@ -1,4 +1,4 @@
#Requires -Version 3
#Requires -Version 3 -Module VMware.VimAutomation.Core
function Move-RubrikMountVMDK
{
<#
Expand Down Expand Up @@ -43,7 +43,7 @@ function Move-RubrikMountVMDK
The file contains the TargetVM name, MountID value, and a list of all presented disks
#>

[CmdletBinding()]
[CmdletBinding(SupportsShouldProcess = $true,ConfirmImpact = 'High')]
Param(
# Source virtual machine to use as a Live Mount based on a previous backup
[Parameter(Mandatory = $true,Position = 0,ValueFromPipeline = $true,ParameterSetName = 'Create')]
Expand Down Expand Up @@ -75,6 +75,10 @@ function Move-RubrikMountVMDK

Process {

TestRubrikConnection

ConnectTovCenter -vCenter $vCenter

if (!$Cleanup)
{
if (!$Date)
Expand Down Expand Up @@ -114,30 +118,33 @@ function Move-RubrikMountVMDK
$TargetHost = Get-VMHost -VM $TargetVM

Write-Verbose -Message 'Migrating the Mount VMDKs to VM'
[array]$MountVMdisk = Get-HardDisk $MountVM.name
$MountedVMdiskFileNames = @()
[int]$j = 0
foreach ($_ in $MountVMdisk)
if ($PSCmdlet.ShouldProcess($TargetVM,'Migrating Live Mount VMDK(s)'))
{
if ($ExcludeDisk -contains $j)
{
Write-Verbose -Message "Skipping Disk $j" -Verbose
}
else
[array]$MountVMdisk = Get-HardDisk $MountVM.name
$MountedVMdiskFileNames = @()
[int]$j = 0
foreach ($_ in $MountVMdisk)
{
try
if ($ExcludeDisk -contains $j)
{
$null = Remove-HardDisk -HardDisk $_ -DeletePermanently:$false -Confirm:$false
$null = New-HardDisk -VM $TargetVM -DiskPath $_.Filename
$MountedVMdiskFileNames += $_.Filename
Write-Verbose -Message "Migrated $($_.Filename) to $TargetVM"
Write-Verbose -Message "Skipping Disk $j" -Verbose
}
catch
else
{
throw $_
try
{
$null = Remove-HardDisk -HardDisk $_ -DeletePermanently:$false -Confirm:$false
$null = New-HardDisk -VM $TargetVM -DiskPath $_.Filename
$MountedVMdiskFileNames += $_.Filename
Write-Verbose -Message "Migrated $($_.Filename) to $TargetVM"
}
catch
{
throw $_
}
}
$j++
}
$j++
}

$Diskfile = "$Home\Documents\"+$SourceVM+'_to_'+$TargetVM+'-'+(Get-Date).Ticks+'.txt'
Expand Down
2 changes: 1 addition & 1 deletion Rubrik/Public/New-RubrikMount.ps1
Expand Up @@ -25,7 +25,7 @@ function New-RubrikMount
This will create a new Live Mount for the virtual machine named Server1 based on the first snapshot that is equal to or older the current time (now)
#>

[CmdletBinding(SupportsShouldProcess = $true,ConfirmImpact = 'Low')]
[CmdletBinding(SupportsShouldProcess = $true,ConfirmImpact = 'High')]
Param(
# Name of the virtual machine
[Parameter(Mandatory = $true,Position = 0,ValueFromPipelineByPropertyName = $true)]
Expand Down
2 changes: 1 addition & 1 deletion Rubrik/Rubrik.psd1
Expand Up @@ -66,7 +66,7 @@ FormatsToProcess = @()
# NestedModules = @()

# Functions to export from this module
FunctionsToExport = @('Connect-Rubrik','Get-RubrikMount','Get-RubrikSLA','Get-RubrikVersion','New-RubrikMount','New-RubrikSnapshot','Remove-RubrikMount','Remove-RubrikSLA','Protect-RubrikVM','Sync-RubrikTag','New-RubrikReport','Get-RubrikVM','Get-RubrikSnapshot','Protect-RubrikTag','Stop-RubrikVM','Start-RubrikVM','Get-RubrikJob','Set-RubrikVM','New-RubrikSLA','Get-RubrikRequest')
FunctionsToExport = @('Connect-Rubrik','Get-RubrikMount','Get-RubrikSLA','Get-RubrikVersion','New-RubrikMount','New-RubrikSnapshot','Remove-RubrikMount','Remove-RubrikSLA','Protect-RubrikVM','Sync-RubrikTag','New-RubrikReport','Get-RubrikVM','Get-RubrikSnapshot','Protect-RubrikTag','Stop-RubrikVM','Start-RubrikVM','Get-RubrikJob','Set-RubrikVM','New-RubrikSLA','Get-RubrikRequest','Move-RubrikMountVMDK')

# Cmdlets to export from this module
CmdletsToExport = @()
Expand Down
3 changes: 2 additions & 1 deletion docs/index.rst
Expand Up @@ -24,7 +24,7 @@ Below is a quick YouTube video that explains how to begin using the module.
requirements
installation
getting_started
module_architecture
project_architecture
support
contribution
licensing
Expand All @@ -37,6 +37,7 @@ Below is a quick YouTube video that explains how to begin using the module.

cmd_connect
cmd_get
cmd_move
cmd_new
cmd_protect
cmd_remove
Expand Down
@@ -1,4 +1,4 @@
Module Architecture
Project Architecture
========================

This page contains details on the artifacts found within the repository.
Expand Down

0 comments on commit 4cd0c94

Please sign in to comment.