Skip to content

Commit

Permalink
Merge branch 'master' into jaap-374
Browse files Browse the repository at this point in the history
  • Loading branch information
shamsway authored Jul 16, 2019
2 parents 54bdf1e + 1f03d07 commit a16cc70
Show file tree
Hide file tree
Showing 28 changed files with 3,049 additions and 884 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## 2019-07-16

### Changed [New-RubrikSLA]

* Added ability to specify advanced SLA configuration settings introduced in 5.0 on New-RubrikSLA to address [Issue 304](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/354)
* Changed -HourlyFrequency to take input in days or weeks instead of hours

## 2019-07-15

### Added [Register-RubrikBackupService]

* Added new `Register-RubrikBackupService`cmdlet to register the Rubrik Backup Service installed on the specified VM with the Rubrik cluster. This addresses issue [219](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/219). Like in the UI, there is a delay between the successful execution of the command and the actual registration of RBS.

### Added [*-Bootstrap] functions

* Added new `New-RubrikBootstrap` function to send a Rubrik Bootstrap Request
* Added new `Get-RubrikBootstrap` function that Connects to the Rubrik cluster and retrieves the bootstrap process progress
* Created a templates folder with examples of Rubrik bootstrap

## 2019-07-14

### Changed [Connect-Rubrik] - Will validate if token is correct
Expand Down
77 changes: 73 additions & 4 deletions Rubrik/Private/Get-RubrikAPIData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1118,12 +1118,16 @@ function Get-RubrikAPIData($endpoint) {
URI = '/api/v2/sla_domain'
Method = 'Post'
Body = @{
name = 'name'
frequencies = @{
timeUnit = 'timeUnit'
name = 'name'
showAdvancedUi = 'showAdvancedUi'
frequencies = @{
frequency = 'frequency'
retention = 'retention'
}
advancedUiConfig = @{
timeUnit = 'timeUnit'
retentionType = 'retentionType'
}
}
Query = ''
Result = ''
Expand Down Expand Up @@ -1250,6 +1254,22 @@ function Get-RubrikAPIData($endpoint) {
Success = '200'
}
}
'Register-RubrikBackupService' = @{
'1.0' = @{
Description = 'Register the Rubrik Backup Service.'
URI = @{
VMware = '/api/v1/vmware/vm/{id}/register_agent'
HyperV = '/api/internal/hyperv/vm/{id}/register_agent'
Nutanix = '/api/internal/nutanix/vm/{id}/register_agent'
}
Method = 'Post'
Body = ''
Query = ''
Result = ''
Filter = ''
Success = '204'
}
}
'Remove-RubrikAPIToken' = @{
'5.0' = @{
Description = 'Deletes session tokens'
Expand Down Expand Up @@ -1965,7 +1985,56 @@ function Get-RubrikAPIData($endpoint) {
Success = '204'
}
}

'Get-RubrikBootStrap' = @{
'1.0' = @{
Description = 'Status of the bootstrap request'
URI = '/api/internal/cluster/{id}/bootstrap'
Method = 'Get'
Body = ''
Query = @{
request_id = 'request_id'
}
Result = ''
Filter = ''
Success = '200'
}
}
'New-RubrikBootStrap' = @{
'1.0' = @{
Description = 'New Bootstrap Request'
URI = '/api/internal/cluster/{id}/bootstrap'
Method = 'Post'
Body = @{
name = 'name'
dnsNameservers = 'dnsNameservers'
dnsSearchDomains = 'dnsSearchDomains'
ntpServerConfigs = @{
server = 'ntpServerConfigs'
}
enableSoftwareEncryptionAtRest = 'enableSoftwareEncryptionAtRest'
adminUserInfo = @{
emailAddress = 'emailAddress'
id = 'id'
password = 'password'
}
#change to a foreach loop and accept object
#needs to be depth 3 to work
nodeConfigs = @{
node1 = @{
managementIpConfig = @{
address = 'address'
gateway = 'management_gateway'
netmask = 'management_netmask'
}
}
}
}
Query = ''
Result = ''
Filter = ''
Success = '202'
}
}
} # End of API

# Determine which version of RCDM is running
Expand Down
65 changes: 65 additions & 0 deletions Rubrik/Public/Get-RubrikBootStrap.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#Requires -Version 3
function Get-RubrikBootStrap
{
<#
.SYNOPSIS
Connects to Rubrik cluster and retrieves the bootstrap process progress.
.DESCRIPTION
This function is created to pull the status of a cluster bootstrap request.
.NOTES
.LINK
https://github.com/nshores/rubrik-sdk-for-powershell/tree/bootstrap
.EXAMPLE
Get-RubrikBootStrap -server 169.254.11.25 -requestid 1
This will return the bootstrap status of the job with the requested ID.
#>

[CmdletBinding()]
Param(
# ID of the Rubrik cluster or me for self
[ValidateNotNullOrEmpty()]
[String] $id = 'me',
# Rubrik server IP or FQDN
[ValidateNotNullOrEmpty()]
[String] $Server,
# Bootstrap Request ID
[ValidateNotNullOrEmpty()]
[Alias('request_id')]
[string] $RequestId = '1'
)

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

# 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
2 changes: 1 addition & 1 deletion Rubrik/Public/Get-RubrikHost.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function Get-RubrikHost
# 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
Expand Down
152 changes: 152 additions & 0 deletions Rubrik/Public/New-RubrikBootStrap.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
#Requires -Version 3
function New-RubrikBootStrap
{
<#
.SYNOPSIS
Send a Rubrik Bootstrap Request
.DESCRIPTION
This will send a bootstrap request
.NOTES
#DNS Param must be an array even if only passing a single server
#NTP Must be an array than contains hash table for each server object
#Nodeconfigs Param must be a hash table object.
.LINK
https://github.com/nshores/rubrik-sdk-for-powershell/tree/bootstrap
.EXAMPLE
https://gist.github.com/nshores/104f069570740ea645d67a8aeab19759
New-RubrikBootStrap -Server 169.254.11.25
-name 'rubrik-edge'
-dnsNameservers @('192.168.11.1')
-dnsSearchDomains @('corp.us','branch.corp.us')
-ntpserverconfigs @(@{server = 'pool.ntp.org'})
-adminUserInfo @{emailAddress = '[email protected]'; id ='admin'; password = 'P@SSw0rd!'}
-nodeconfigs @{node1 = @{managementIpConfig = @{address = '192.168.11.1'; gateway = '192.168.11.100'; netmask = '255.255.255.0'}}}
#>

[CmdletBinding()]
Param(
# ID of the Rubrik cluster or me for self
[ValidateNotNullOrEmpty()]
[String] $id = 'me',
# Rubrik server IP or FQDN
[ValidateNotNullOrEmpty()]
[String] $Server,
# Admin User Info Hashtable
[Parameter(Mandatory = $true)]
[ValidateScript({
$requiredProperties = @("emailAddress","id","password")
ForEach($item in $requiredProperties) {
if(!$_.ContainsKey($item)) {
Throw "adminUserInfo missing property $($item)"
}
if([string]::IsNullOrEmpty($_[$item])) {
Throw "adminUserInfo $($item) is null or empty"
}
}
return $true
})]
[ValidateNotNullOrEmpty()]
[Object]
$adminUserInfo,
# Node Configuration Hashtable
[Parameter(Mandatory = $true)]
[ValidateScript({
$requiredProperties = @("address","gateway","netmask")
ForEach($node in $_.Keys) {
$ipConfig = $_[$node].managementIpConfig
ForEach($item in $requiredProperties) {
if(!$ipConfig.ContainsKey($item)) {
Throw "node configuration for $($node) missing property $($item)"
}
if([string]::IsNullOrEmpty($ipConfig[$item])) {
Throw "node configuration for $($node) value $($item) is null or empty"
}
}
}
return $true
})]
[ValidateNotNullOrEmpty()]
[System.Object]
$nodeConfigs,
# Software Encryption
[bool]
$enableSoftwareEncryptionAtRest = $false,
# Cluster/Edge Name
[ValidateNotNullOrEmpty()]
[string]
$name,
# NTP Servers
$ntpServerConfigs,
# DNS Servers
[String[]]
$dnsNameservers,
# DNS Search Domains
[String[]]
$dnsSearchDomains
)

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

# 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)"

#region One-off
# If there is more than node node, update the API data to contain all data for all nodes
if($nodeConfigs.Count -gt 1) {
ForEach($key in $nodeConfigs.Keys) {
$resources.Body.nodeConfigs[$key] = $nodeConfigs[$key]
}
}

# Default DNS servers to 8.8.8.8
if($dnsNameServers -eq '') {
$dnsNameServers = @(
'8.8.8.8'
)
}

# Default DNS search domains to an empty array
if($dnsSearchDomains -eq '') {
$dnsSearchDomains = @()
}

# Default NTP servers to pool.ntp.org
if($ntpServerConfigs.Length -lt 1) {
$ntpServerConfigs = @(
@{
server = 'pool.ntp.org'
}
)
}
#endregion
}

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 -Headers @{"content-type"="application/json"} -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
Loading

0 comments on commit a16cc70

Please sign in to comment.