Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5.3 release branch #730

Merged
merged 30 commits into from
Apr 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f1439dc
Added Test Snapshot Verification cmdlet 🧪
jaapbrasser Feb 4, 2021
c02e7dd
Updated for SnapshotVerification 📸
jaapbrasser Feb 4, 2021
b665f5e
Updated for SnapshotVerification 📸
jaapbrasser Feb 4, 2021
71137d5
Added new private function 🕴
jaapbrasser Feb 4, 2021
5282749
Added exception for Backup Verification 🎩
jaapbrasser Feb 4, 2021
0278249
Updated and closer to being complete🐙
jaapbrasser Feb 4, 2021
2f8f7c3
Merge branch 'devel' of https://www.github.com/rubrikinc/rubrik-sdk-f…
jaapbrasser Mar 8, 2021
02b04a3
Changed Tag to error out when no match #722 🐜
jaapbrasser Mar 8, 2021
fffc292
Added changelog for #722 📃
jaapbrasser Mar 8, 2021
ca60a42
Fixed spelling of help link 🖇
jaapbrasser Mar 8, 2021
25178ef
Added pipeline for SLAID, to simplify commands 😉
jaapbrasser Mar 10, 2021
f0649ee
Warning message added #733 ⚠
jaapbrasser Mar 11, 2021
8a4ff5b
Updated changelog with links to issues 🥷
jaapbrasser Mar 11, 2021
243f2ec
Added additional example as requested in #736 🧫
jaapbrasser Apr 8, 2021
8c5d003
Updated for issue #736 🐕‍🦺
jaapbrasser Apr 8, 2021
9cd4ed8
Updated Get-RubrikRequest for #733 🧪
jaapbrasser Apr 8, 2021
ec691b3
Updated cmdlet with functional example 👾
jaapbrasser Apr 8, 2021
2ae3eaf
Initialized tests for Snapshot ver 🆚
jaapbrasser Apr 8, 2021
85beec3
Jaapsvm 🖖Ⓜ
jaapbrasser Apr 8, 2021
c60f0d2
Updated tests to do something ™ #733
jaapbrasser Apr 8, 2021
36d04a6
Add Get-RubrikDebugInfo cmdlet #742 🐛🐜🪲
jaapbrasser Apr 8, 2021
5e52646
Added new cmdlet for debugging information #742 👾
jaapbrasser Apr 8, 2021
0b0ec77
Initial commit 1️⃣1️⃣
jaapbrasser Apr 8, 2021
662b882
Added unit tests for #742 🧪🦠
jaapbrasser Apr 8, 2021
1b5e933
Updated for #742 🎓
jaapbrasser Apr 8, 2021
99e3939
Added snapshot validation #733 🦠👾🪲🖖
jaapbrasser Apr 8, 2021
37fd4bd
Fixed unit test for DebugInfo 🪲👾
jaapbrasser Apr 8, 2021
b42159e
added module options and parameters
mwpreston Apr 9, 2021
a09ec0e
fixed description
mwpreston Apr 9, 2021
bb7e33a
fixed description
mwpreston Apr 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Changed

* Change the Quick Start Guide to links are pointing to working VMware pages [Issue 726](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/726)
### Added

### Fixed

## [5.3.0]() - 2021-04-08

### Changed

* Changed the Quick Start Guide to links are pointing to working VMware pages [Issue 726](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/726)
* Changed, parameter sets, `SLA_Name/SLA_ByID/SLA_Unprotected/SLA_Forever`, added to `Protect-RubrikFileset` & `New-RubrikSnapshot`, fixing [Issue 720](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/720)
* Added support for `WhatIf` & `Confirm` to the `Invoke-RubrikRESTCall` cmdlet fixing [Issue 713](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/713)
* Created 3 new parameter sets to `Invoke-RubrikRESTCall` : `BodyAsArray`, `BodyAsJson`, `General` fixing [Issue 711](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/711)
Expand All @@ -29,6 +37,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Added

* Added new cmdlet: `Get-RubrikDebugInfo`, that gathers essential information for troubleshooting [Issue 742](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/742)
* Added new cmdlet: `Test-RubrikSnapshotVerification`, that can test if a snapshot, or series of snapshots are recoverable [Issue 733](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/733)
* Added example in documentation for: `Invoke-RubrikGraphQLCall` [Issue 736](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/736)
* Added better warning message for `New-RubrikMount`, now displays warning when an object ID is specified instead of snapshot ID, [Issue 732](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/732)
* Added 5.3 endpoint for `Get-RubrikVolumeGroupMount`, resolving issue [Issue 729](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/729)
* Added support to `Get-RubrikUser` to work around all of the API endpoint changes in CDM 5.3 as per [Issue 723](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/723)
* Added new parameter, `SLAPrimaryClusterId`, to `Protect-RubrikFileset` & `New-RubrikSnapshot`, fixing [Issue 720](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/720)
Expand All @@ -44,6 +56,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Fixed

* Fixed bug in `Protect-RubrikTag` which could accidentally apply results to all VMs, [Issue 722](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/722)
* Fixed bug in `New-RubrikSLA` which could prevent correct SLA creation [Issue 706](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/706)
* Fixed bug in `Get-RubrikEvent` which caused `-Status` not to filter properly [Issue 705](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/705)
* Fixed documentation for `Invoke-RubrikGraphQLCall` multiline example changed to single line [Issue 685](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/685)
Expand Down
27 changes: 27 additions & 0 deletions Rubrik/Private/ConvertTo-UniversalZuluDateTime.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
function ConvertTo-UniversalZuluDateTime {
<#
.SYNOPSIS
Converts a datetime value to a epoch millisecond timestamp

.DESCRIPTION
Some API endpoints require the ISO 8601 notation for datetime stamps for more information about
this notation head over to Wikipedia: https://en.wikipedia.org/wiki/ISO_8601

.NOTES
Written by Jaap Brasser for community usage
Twitter: @jaap_brasser
GitHub: JaapBrasser

.EXAMPLE
ConvertTo-UniversalZuluDateTime -DateTimeValue (Get-Date)

2021-02-04T21:03:09.000Z
#>
[CmdletBinding()]
param(
[DateTime]$DateTimeValue
)

$return = $DateTimeValue.ToUniversalTime().ToString('o') -replace '\.\d*Z$','.000Z'
return $return
}
21 changes: 19 additions & 2 deletions Rubrik/Private/Get-RubrikAPIData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3392,8 +3392,8 @@ function Get-RubrikAPIData {
URI = '/api/internal/config/usersettable_volumeGroup'
Method = 'Patch'
Body = @{
migrateFastVirtualDiskBuild = 'migrateFastVirtualDiskBuild'
maxFullMigrationStoragePercentage = 'maxFullMigrationStoragePercentage'
migrateFastVirtualDiskBuild = 'migrateFastVirtualDiskBuild'
maxFullMigrationStoragePercentage = 'maxFullMigrationStoragePercentage'
}
Query = ''
Result = ''
Expand Down Expand Up @@ -3533,6 +3533,23 @@ function Get-RubrikAPIData {
Success = '202'
}
}
'Test-RubrikSnapshotVerification' = @{
'5.3' = @{
Description = 'Verifies the validity of a snapshot'
URI = '/api/v1/backup/verify'
Method = 'Post'
Body = @{
"objectId" = ''
"snapshotIdsOpt" = [System.Collections.ArrayList]@()
"locationIdOpt" = "locationIdOpt"
"shouldVerifyAfterOpt" = 'shouldVerifyAfterOpt'
}
Query = ''
Result = ''
Filter = ''
Success = '200'
}
}
'Update-RubrikVCenter' = @{
'1.0' = @{
Description = 'Refresh the metadata for the specified vCenter Server'
Expand Down
66 changes: 66 additions & 0 deletions Rubrik/Public/Get-RubrikDebugInfo.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#Requires -Version 3
function Get-RubrikDebugInfo
{
<#
.SYNOPSIS
Displays information about the Rubrik module and the PowerShell

.DESCRIPTION
The Get-RubrikDebugInfo cmdlet will retrieve the version of code that is actively running on the system. It will gather essential information that can be used for quickly troubleshooting issues

.NOTES
Written by Jaap Brasser for community usage
Twitter: @jaap_brasser
GitHub: JaapBrasser

.LINK
https://rubrik.gitbook.io/rubrik-sdk-for-powershell/command-documentation/reference/get-rubrikdebuginfo

.EXAMPLE
Get-RubrikDebugInfo

This will return information about the PowerShell version, the PowerShell client or console, and both the Rubrik cluster and Rubrik PowerShell module version numbers
#>

[CmdletBinding()]
Param(
)

Process {
# Initiate Hash
$HashProps = [ordered]@{}

# Add PSVersionTable
$PSVersionTable.Keys | ForEach-Object {
$HashProps.$_ = $PSVersionTable.$_
}

# Add Console Host information
$HashProps.HostConsoleName = $host.Name
$HashProps.HostConsoleVersion = $host.Version
$HashProps.HostCulture = $host.CurrentCulture
$HashProps.HostCultureUI = $host.CurrentUICulture

# Gather Rubrik Cluster information
if ($RubrikConnection) {
$HashProps.RubrikConnection = $true
$HashProps.UserAgentString = $RubrikConnection.header.'User-Agent'
$HashProps.RubrikAuthentication = $RubrikConnection.header.authorization.split(' ')[0].SubString(0, 6)
$HashProps.RubrikClusterVersion = $RubrikConnection.version
} else {
Write-Warning "This cmdlet can gather more information if you're connected to your Rubrik Cluster"
}

# Add module information
$HashProps.RubrikCurrentModuleVersion = (Get-Module -Name Rubrik) | ForEach-Object {'{0}-{1}' -f $_.Version,$_.PrivateData.PSData.Prerelease}
$HashProps.RubrikInstalledModule = ((Get-Module -Name Rubrik -ListAvailable) | ForEach-Object {if ($_.PrivateData.PSData.Prerelease -ne $null) {'{0}-{1}' -f $_.Version,$_.PrivateData.PSData.Prerelease} else {$_.version}}) -join ', '

# Add configured module options and default parameters
$HashProps.RubrikModuleOptions = Get-RubrikModuleOption
$HashProps.RubrikModuleDefaultParameters = Get-RubrikModuleDefaultParameter

# Output as object
return [pscustomobject]$HashProps

} # End of process
} # End of function
16 changes: 13 additions & 3 deletions Rubrik/Public/Get-RubrikRequest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ function Get-RubrikRequest {
'fileset', 'mssql', 'vmware/vm', 'hyperv/vm', 'hyperv/scvmm',
'managed_volume', 'volume_group', 'nutanix/vm', 'aws/ec2_instance',
'oracle','vcd/vapp', 'vcd/cluster', 'vmware/vcenter', 'cloud_on/azure',
'report', 'nutanix/cluster', 'vmware/compute_cluster', 'sla_domain'
'report', 'nutanix/cluster', 'vmware/compute_cluster', 'sla_domain',
'backup/verify'
)]
[String]$Type,
# Request
Expand Down Expand Up @@ -111,6 +112,8 @@ function Get-RubrikRequest {
$uri = $uri -replace 'v1', 'internal'
} elseif ($v2types -contains $Type) {
$uri = $uri -replace 'v1', 'v2'
} elseif ($Type -eq 'backup/verify') {
$uri = $uri -replace 'request/'
}

#endregion
Expand All @@ -121,8 +124,13 @@ function Get-RubrikRequest {
if ($Request) {
Write-Verbose "Using uri supplied by pipeline: $($Request.links.href)"
$uri = $Request.links.href

# Fix for 5.3
if ($uri -match 'backup_verification') {
$uri = $uri -replace 'backup_verification/request', 'backup/verify'
}
}

#We added new code that will now wait for the Rubrik Async Request to complete. Once completion has happened, we return back the request object.
#region WaitForCompletion
if ($WaitForCompletion) {
Expand All @@ -138,7 +146,9 @@ function Get-RubrikRequest {
else {
Write-Progress -Activity "$($result.id)" -status "Job Queued" -percentComplete (0)
}
Start-Sleep -Seconds 5
if ($result.status -notin $ExitList) {
Start-Sleep -Seconds 5
}
} while ($result.status -notin $ExitList)
}
#endregion
Expand Down
5 changes: 5 additions & 0 deletions Rubrik/Public/Invoke-RubrikGraphQLCall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ Returns all VMware VMs on the Rubrik Cluster and displays the individual objects
Invoke-RubrikGraphQLCall -ReturnNode -Body '{"query":"query OrganizationSummary(\n $name: String,\n $isGlobal: Boolean,\n $sortBy: String,\n $sortOrder: String,\n $first: Int,\n $after: String,\n) {\n organizationConnection(\n name: $name,\n isGlobal: $isGlobal,\n sortBy: $sortBy,\n sortOrder: $sortOrder,\n first: $first,\n after: $after\n ) {\n nodes {\n id\n name\n isGlobal\n exclusivenessLevel\n admins {\n id\n name\n }\n envoyStatus\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n}\n","variables":{"sortBy":"name","sortOrder":"asc","first":3,"name":"org","isGlobal":false}}'

Returns informations on Rubrik Organizations, filtered by name in ascending order and only including organizations with 'org' in their name property. Returns the individual organization objects using the -ReturnNode parameter

.EXAMPLE
(Invoke-RubrikGraphQLCall -Body '{"query":"query HostsWithSnappables(\n $effectiveSlaDomainId: String,\n $hostname: String,\n $operatingSystemType: String,\n $status: String,\n $primaryClusterId: String,\n $sortBy: String,\n $sortOrder: String,\n $templateId: String,\n $snappableStatus: String,\n $first: Int,\n $after: String,\n) {\n hostConnection(\n effectiveSlaDomainId: $effectiveSlaDomainId,\n hostname: $hostname,\n operatingSystemType: $operatingSystemType,\n status: $status,\n primaryClusterId: $primaryClusterId,\n sortBy: $sortBy,\n sortOrder: $sortOrder,\n templateId: $templateId,\n snappableStatus: $snappableStatus,\n first: $first,\n after: $after,\n )\n {\n nodes {\n id\n hostname\n primaryClusterId\n operatingSystem\n operatingSystemType\n status\n filesets\n {\n hostName\n operatingSystemType\n excludes\n configuredSlaDomainName\n effectiveSlaDomainId\n isEffectiveSlaDomainRetentionLocked\n primaryClusterId\n hostId\n includes\n configuredSlaDomainId\n configuredSlaDomainType\n templateId\n allowBackupNetworkMounts\n exceptions\n effectiveSlaDomainName\n allowBackupHiddenFoldersInNetworkMounts\n templateName\n useWindowsVss\n isRelic\n name\n id\n isPassthrough\n enableSymlinkResolution\n enableHardlinkSupport\n pendingSlaDomain {\n objectId,\n pendingSlaDomainId,\n pendingSlaDomainName,\n isPendingSlaDomainRetentionLocked\n }\n }\n hostVfdDriverState\n volumeGroup\n {\n isPaused\n configuredSlaDomainName\n effectiveSlaDomainId\n isEffectiveSlaDomainRetentionLocked\n primaryClusterId\n slaAssignment\n effectiveSlaSourceObjectId\n volumes {\n mountPoints\n isCurrentlyPresentOnSystem\n id\n size\n includeInSnapshots\n fileSystemType\n }\n effectiveSlaSourceObjectName\n hostId\n configuredSlaDomainId\n configuredSlaDomainType\n effectiveSlaDomainName\n hostname\n isRelic\n name\n volumeIdsIncludedInSnapshots\n id\n }\n storageArrayVolumeGroups\n {\n id\n name\n storageArrayId\n storageArrayName\n storageArrayType\n hostId\n hostname\n proxyHostId\n proxyHostname\n volumes {\n id\n serial\n name\n storageArrayId\n storageArrayType\n }\n configuredSlaDomainId\n configuredSlaDomainType\n configuredSlaDomainName\n effectiveSlaDomainId\n isEffectiveSlaDomainRetentionLocked\n effectiveSlaDomainName\n slaAssignment\n primaryClusterId\n }\n },\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n}\n","variables":{"first":50,"operatingSystemType":"Windows","primaryClusterId":"local","sortBy":"hostname","sortOrder":"asc","snappableStatus":"Protectable"}}').hostconnection.nodes | % {[pscustomobject]@{hostname=$_.Hostname;volumegroup=$_.volumegroup.name;volumegroupsla=$_.volumegroup.effectivesladomainname}}

Queries all hosts with volumegroups for the SLA set on that specific volumegroup. Returns 3 properties: hostname, volumegroup, volumegroupsla
#>

[cmdletbinding()]
Expand Down
4 changes: 4 additions & 0 deletions Rubrik/Public/New-RubrikMount.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ function New-RubrikMount
if(-not $PSBoundParameters.ContainsKey('DisableNetwork')) { $Resources.Body.Remove('disableNetwork') }
if(-not $PSBoundParameters.ContainsKey('RemoveNetworkDevices')) { $Resources.Body.Remove('removeNetworkDevices') }
if(-not $PSBoundParameters.ContainsKey('PowerOn')) { $Resources.Body.Remove('powerOn') }

if ($id -match ':') {
Write-Warning -Message ('"{0}" specified as ID, the ID should be a snapshot ID not an object ID' -f $Id)
}

$uri = New-URIString -server $Server -endpoint ($resources.URI) -id $id
$uri = Test-QueryParam -querykeys ($resources.Query.Keys) -parameters ((Get-Command $function).Parameters.Values) -uri $uri
Expand Down
16 changes: 10 additions & 6 deletions Rubrik/Public/New-RubrikSnapshot.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ function New-RubrikSnapshot
[CmdletBinding(SupportsShouldProcess = $true,ConfirmImpact = 'High')]
Param(
# Rubrik's id of the object
[Parameter(Mandatory = $true,ValueFromPipelineByPropertyName = $true)]
[Parameter(
Mandatory = $true,
ValueFromPipelineByPropertyName = $true)]
[String]$id,
# The SLA Domain in Rubrik
[Parameter(
Expand All @@ -73,8 +75,10 @@ function New-RubrikSnapshot
# SLA id value
[Parameter(
ParameterSetName = 'SLA_ByID',
ValueFromPipelineByPropertyName = $true,
Mandatory = $true
)]
[Alias('effectiveSlaDomainId')]
[String]$SLAID,
# Rubrik server IP or FQDN
[String]$Server = $global:RubrikConnection.server,
Expand All @@ -86,20 +90,20 @@ function New-RubrikSnapshot

# The Begin section is used to perform one-time loads of data necessary to carry out the function's purpose
# If a command needs to be run with each iteration or pipeline input, place it in the Process section

# Check to ensure that a session to the Rubrik cluster exists and load the needed header data for authentication
Test-RubrikConnection

# API data references the name of the function
# For convenience, that name is saved here to $function
$function = $MyInvocation.MyCommand.Name

# Retrieve all of the URI, method, body, query, result, filter, and success details for the API endpoint
Write-Verbose -Message "Gather API Data for $function"
$resources = Get-RubrikAPIData -endpoint $function
Write-Verbose -Message "Load API data for $($resources.Function)"
Write-Verbose -Message "Description: $($resources.Description)"

}

Process {
Expand Down Expand Up @@ -134,7 +138,7 @@ function New-RubrikSnapshot
$result = Submit-Request -uri $uri -header $Header -method $($resources.Method) -body $body
$result = Test-ReturnFormat -api $api -result $result -location $resources.Result
$result = Test-FilterObject -filter ($resources.Filter) -result $result

return $result
}
} # End of process
Expand Down
2 changes: 1 addition & 1 deletion Rubrik/Public/Protect-RubrikTag.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function Protect-RubrikTag
Write-Verbose -Message "Gathering a list of VMs associated with Category $Category and Tag $Tag"
try
{
$vmlist = Get-VM -Tag (Get-Tag -Name $Tag -Category $Category) | Get-View
$vmlist = Get-VM -Tag (Get-Tag -Name $Tag -Category $Category -ErrorAction Stop) | Get-View
# This will pull out the vCenter UUID assigned to the parent vCenter Server by Rubrik
# Reset switches to prevent Get-RubrikVM from picking them up (must be a better way?)
$DoNotProtect = $false
Expand Down
Loading