Skip to content

Commit

Permalink
Merge pull request #687 from rubrikinc/jaap-otherissues
Browse files Browse the repository at this point in the history
PR for a bunch of open issues
  • Loading branch information
shamsway authored Sep 11, 2020
2 parents 4cc1d0a + 5ff84b4 commit 3d0cd1e
Show file tree
Hide file tree
Showing 28 changed files with 775 additions and 130 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,30 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Changed

* Changed Get/Set Rubrik-Blackout to use correctly API version for Rubrik CDM 5.1 and later [Issue 679](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/679)
* Changed `Remove-RubrikUnmanagedObject` to use correct REST endpoint for Rubrik CDM 5.2 and later [Issue 671](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/671)

### Added

* Added `Get-RubrikBlackout` cmdlet as requested in [Issue 688](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/688)
* Added additional example to `New-RubrikVolumeGroupMount` [Issue 660](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/660)
* Added additional example to `Invoke-RubrikRESTCall` [Issue 655](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/655)
* Added new cmdlet `Set-RubrikReport` to allow for changing settings on Rubrik Reports, and added associated unit tests [Issue 654](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/654)
* Added `DetailedObject` parameter & updated documentation for: `Get-RubrikDatabaseMount`, `Get-RubrikHyperVVM`, `Get-RubrikMount`, `Get-RubrikNutanixVM`, `Get-RubrikReport`, `Get-RubrikSLA`, `Get-RubrikUser`, `Get-RubrikVCenter`, `Get-RubrikVMwareDatastore`, `Get-RubrikVMwareHost` [Issue 651](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/651)
* Added additional example to `Get-RubrikVolumeGroup` [Issue 647](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/647)
* New switch added to `Get-RubrikEvent` `-IncludeEventSeries` which determines if EventSeries events are included in the results [Issue 626](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/626)

### Fixed

* The `DynamicDNS` parameter of `New-RubrikLDAP` is no longer a mandatory parameter [Issue 662](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/662)
* Fixed `Test-RubrikSLA` internal function behaviour to no longer enforce `local` cluster ID when not supplied [Issue 659](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/659)
* WhatIf/Verbose messages for `Remove-RubrikSLA` will display SLA name and ID for additional clarification [Issue 653](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/653)
* Invoke-RubrikRestCall no longer takes Body object for Get Method [Issue 652](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/652)
* Created entries for 5.2 endpoints in `Get-RubrikAPIData` private function for `Get-RubrikEvent` & `Get-RubrikEventSeries` which caused these cmdlets to no longer work on Rubrik CDM 5.2 [Issue 626](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/626)

### Deprecated

* The `Remove-RubrikOrgAuthorization` & `Set-RubrikOrgAuthorization` cmdlets no longer work in 5.2 because of API changes [Issue 681](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/681)
* Functionality in `Get-RubrikEventSeries` is limited to only queries by specific EventSeries id on Rubrik CDM Clusters running versions higher than 5.2. Original functionality is still available for backwards compatibility with older versions of Rubrik CDM [Issue 626](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/626)

## [5.0.3](https://github.com/rubrikinc/rubrik-sdk-for-powershell/tree/5.0.3) - 2020-08-12
Expand Down
49 changes: 49 additions & 0 deletions Rubrik/ObjectDefinitions/Rubrik.VMwareVmMount.ps1xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
<ViewDefinitions>
<View>
<Name>Default</Name>
<ViewSelectedBy>
<TypeName>Rubrik.VMwareVmMount</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
<TableColumnHeader>
<Label>Name</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>Source Name</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>Snapshot Date</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>Mount Timestamp</Label>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<ScriptBlock>
(Get-RubrikVM -id $_.mountedVmId).name
</ScriptBlock>
</TableColumnItem>
<TableColumnItem>
<ScriptBlock>
(Get-RubrikVM -id $_.vmId).name
</ScriptBlock>
</TableColumnItem>
<TableColumnItem>
<PropertyName>snapshotDate</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>mountTimestamp</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
</ViewDefinitions>
</Configuration>
51 changes: 51 additions & 0 deletions Rubrik/Private/Get-RubrikAPIData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,28 @@ function Get-RubrikAPIData {
ObjectTName = 'Rubrik.AvailabilityGroup'
}
}
'Get-RubrikBlackout' = @{
'1.0' = @{
Description = 'Whether global blackout window is active.'
URI = '/api/internal/blackout_window'
Method = 'Get'
Body = ''
Query = ''
Result = ''
Filter = ''
Success = '200'
}
'5.1' = @{
Description = 'Whether global blackout window is active.'
URI = '/api/v1/blackout_window'
Method = 'Get'
Body = ''
Query = ''
Result = ''
Filter = ''
Success = '200'
}
}
'Get-RubrikClusterInfo' = @{
'4.2' = @{
Description = 'Retrieves advanced settings of the Rubrik cluster'
Expand Down Expand Up @@ -814,6 +836,7 @@ function Get-RubrikAPIData {
vmId = 'vmId'
}
Success = '200'
ObjectTName = 'Rubrik.VMwareVmMount'
}
}
'Get-RubrikNASShare' = @{
Expand Down Expand Up @@ -2661,6 +2684,22 @@ function Get-RubrikAPIData {
Filter = ''
Success = '204'
}
'5.2' = @{
Description = 'Bulk delete all unmanaged snapshots for the objects specified by objectId/objectType pairings.'
URI = '/api/v1/data_source/snapshot/bulk_delete'
Method = 'Post'
Body = @{
objectDefinitions = @(
@{
objectId = 'objectId'
}
)
}
Query = ''
Result = ''
Filter = ''
Success = '204'
}
}
'Remove-RubrikVCenter' = @{
'1.0' = @{
Expand Down Expand Up @@ -2773,6 +2812,18 @@ function Get-RubrikAPIData {
Filter = ''
Success = '200'
}
'5.1' = @{
Description = 'Whether to start or stop the global blackout window.'
URI = '/api/v1/blackout_window'
Method = 'Patch'
Body = @{
isGlobalBlackoutActive = 'isGlobalBlackoutActive'
}
Query = ''
Result = ''
Filter = ''
Success = '200'
}
}
'Set-RubrikDatabase' = @{
'1.0' = @{
Expand Down
5 changes: 5 additions & 0 deletions Rubrik/Private/Submit-Request.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ function Submit-Request {
$body
)

# Block to improve readiability of error messages created for issue #653
switch ($resources.Description) {
'Delete an SLA Domain from a Rubrik cluster' {$id = "$name $id"}
}

if ($PSCmdlet.ShouldProcess($id, $resources.Description)) {
try {
Write-Verbose -Message 'Submitting the request'
Expand Down
16 changes: 8 additions & 8 deletions Rubrik/Private/Test-RubrikSLA.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
The ID of the cluster to search
#>

# Determine the state of $PrimaryClusterID
Write-Verbose -Message "Primary cluster ID currently set to: $PrimaryClusterID"
if (!$PrimaryClusterID) {
$PrimaryClusterID = 'local'
Write-Verbose -Message "Null value found. Setting primary cluster ID to $PrimaryClusterID"
}

Write-Verbose -Message 'Determining the SLA Domain id'
if ($SLA) {
$slaid = (Get-RubrikSLA -SLA $SLA -PrimaryClusterID $PrimaryClusterID).id
$slaid = & {
$local:PSDefaultParameterValues = @{Disabled=$true}
if (-not [string]::IsNullOrWhiteSpace($PrimaryClusterID)) {
(Get-RubrikSLA -SLA $SLA -PrimaryClusterID $PrimaryClusterID).id
} else {
(Get-RubrikSLA -SLA $SLA).id
}
}
if ($slaid -eq $null) {
throw "No SLA Domains were found that match $SLA for $PrimaryClusterID"
}
Expand Down
65 changes: 65 additions & 0 deletions Rubrik/Public/Get-RubrikBlackout.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#Requires -Version 3
function Get-RubrikBlackout
{
<#
.SYNOPSIS
The Get-RubrikBlackout cmdlet will retrieve cluster blackout windows information
.DESCRIPTION
The Get-RubrikBlackout cmdlet will retrieve cluster blackout windows information
.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-rubrikblackout
.EXAMPLE
Get-RubrikBlackout
This will return whether or not Global Blackout is active on the currently connected cluster
#>

[CmdletBinding()]
Param(
# Rubrik server IP or FQDN
[String]$Server = $global:RubrikConnection.server,
# API version
[String]$api = $global:RubrikConnection.api
)

Begin {

# 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 {

$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
$body = New-BodyString -bodykeys ($resources.Body.Keys) -parameters ((Get-Command $function).Parameters.Values)
$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
} # End of function
26 changes: 24 additions & 2 deletions Rubrik/Public/Get-RubrikDatabaseMount.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,32 @@ function Get-RubrikDatabaseMount
.EXAMPLE
Get-RubrikDatabaseMount
This will return details on all mounted databases.
.EXAMPLE
Get-RubrikDatabaseMount -DetailedObject
This will return mounted databases with the full detailed objects.
.EXAMPLE
Get-RubrikDatabaseMount -id '11111111-2222-3333-4444-555555555555'
This will return details on mount id "11111111-2222-3333-4444-555555555555".
.EXAMPLE
Get-RubrikDatabaseMount -source_database_id (Get-RubrikDatabase -HostName FOO -Instance MSSQLSERVER -Database BAR).id
This will return details for any mounts found using the id value from a database named BAR on the FOO default instance.
.EXAMPLE
Get-RubrikDatabaseMount -source_database_name BAR
This returns any mounts where the source database is named BAR.
.EXAMPLE
Get-RubrikDatabaseMount -mounted_database_name BAR_LM
This returns any mounts with the name BAR_LM
#>

Expand All @@ -56,6 +66,8 @@ function Get-RubrikDatabaseMount
[Alias('mounted_database_name')]
[Parameter(Position = 0)]
[String]$MountedDatabaseName,
# DetailedObject will retrieved the detailed DatabaseMount object, the default behavior of the API is to only retrieve a subset of the full DatabaseMount object unless we query directly by ID. Using this parameter does affect performance as more data will be retrieved and more API-queries will be performed.
[Switch]$DetailedObject,
# Rubrik server IP or FQDN
[String]$Server = $global:RubrikConnection.server,
# API version
Expand Down Expand Up @@ -91,8 +103,18 @@ function Get-RubrikDatabaseMount
$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
$result = Set-ObjectTypeName -TypeName $resources.ObjectTName -result $result
return $result

if (($DetailedObject) -and (-not $PSBoundParameters.containskey('id'))) {
for ($i = 0; $i -lt @($result).Count; $i++) {
$Percentage = [int]($i/@($result).count*100)
Write-Progress -Activity "DetailedObject queries in Progress, $($i+1) out of $(@($result).count)" -Status "$Percentage% Complete:" -PercentComplete $Percentage
if ($result) {
Get-RubrikDatabaseMount -id $result[$i].id
}
}
} else {
$result = Set-ObjectTypeName -TypeName $resources.ObjectTName -result $result
return $result
}
} # End of process
} # End of function
26 changes: 22 additions & 4 deletions Rubrik/Public/Get-RubrikHyperVVM.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,22 @@ function Get-RubrikHyperVVM
.EXAMPLE
Get-RubrikHyperVVM -Name 'Server1'
This will return details on all Hyper-V virtual machines named "Server1".
.EXAMPLE
Get-RubrikHyperVVM -Name 'Server1' -SLA Gold
This will return details on all Hyper-V virtual machines named "Server1" that are protected by the Gold SLA Domain.
.EXAMPLE
Get-RubrikHyperVVM -Name 'Server1' -DetailedObject
This will return all Hyper-V virtual machines named "Server1" and returns the Detailed Objects of these VMs
.EXAMPLE
Get-RubrikHyperVVM -Relic
This will return all removed Hyper-V virtual machines that were formerly protected by Rubrik.
#>

Expand Down Expand Up @@ -65,6 +73,8 @@ function Get-RubrikHyperVVM
[Parameter(ParameterSetName='Query')]
[Alias('effective_sla_domain_id')]
[String]$SLAID,
# DetailedObject will retrieved the detailed Hyper-V VM object, the default behavior of the API is to only retrieve a subset of the full Hyper-V VM object unless we query directly by ID. Using this parameter does affect performance as more data will be retrieved and more API-queries will be performed.
[Switch]$DetailedObject,
# Rubrik server IP or FQDN
[Parameter(ParameterSetName='Query')]
[Parameter(ParameterSetName='ID')]
Expand Down Expand Up @@ -110,10 +120,18 @@ function Get-RubrikHyperVVM
$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
$result = Set-ObjectTypeName -TypeName $resources.ObjectTName -result $result


return $result

if (($DetailedObject) -and (-not $PSBoundParameters.containskey('id'))) {
for ($i = 0; $i -lt @($result).Count; $i++) {
$Percentage = [int]($i/@($result).count*100)
Write-Progress -Activity "DetailedObject queries in Progress, $($i+1) out of $(@($result).count)" -Status "$Percentage% Complete:" -PercentComplete $Percentage
if ($result) {
Get-RubrikHyperVVM -id $result[$i].id
}
}
} else {
$result = Set-ObjectTypeName -TypeName $resources.ObjectTName -result $result
return $result
}
} # End of process
} # End of function
Loading

0 comments on commit 3d0cd1e

Please sign in to comment.