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

Issue 358 - NAS Direct Archive support #555

Merged
merged 5 commits into from
Jan 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
* Added QUEUED as a value in the status ValidateSet within Get-RubrikEvent and updated Unit Tests. Addresses [Issue 539](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/539)
* Added Get-RubrikVMwareDatacenter and Get-RubrikVMwareCluster along with associated Unit Tests. Addresses [Issue 463](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/463)
* Added Object TypeNames for VCD Servers and vCD vApps as specified in [Issue 462](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/462)
* Added DirectArchive switch parameter and associated code to New-RubrikFileSet allowing the isPassthrough attribute to be set to enable NAS Direct Archive. Addresses [Issue 358](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/358) Updated Unit tests for cmdlets to reflect new parametersets.

### Changed

Expand Down
2 changes: 1 addition & 1 deletion Rubrik/Private/Get-RubrikAPIData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1673,7 +1673,7 @@ function Get-RubrikAPIData($endpoint) {
templateId = 'templateId'
}
Query = ''
Result = ''
Result = 'data'
Filter = ''
Success = '202'
}
Expand Down
44 changes: 35 additions & 9 deletions Rubrik/Public/New-RubrikFileset.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,29 @@ function New-RubrikFileset
New-RubrikFileset -TemplateID (Get-RubrikFilesetTemplate -Name 'FOO').id -ShareID (Get-RubrikNASShare -name 'BAR').id

Creates a new fileset for the BAR NAS, using the FOO template.

.EXAMPLE
New-RubrikFileset -TemplateID (Get-RubrikFilesetTemplate -Name 'FOO').id -ShareID (Get-RubrikNASShare -name 'BAR').id -DirectArchive

Creates a new fileset for the BAR NAS, using the FOO template. Enables the NAS Direct Archive functionality on the share.
#>

[CmdletBinding()]
Param(
#Fileset Template ID to use for the new fileset
[Parameter(Mandatory=$true)]
[Parameter(ParameterSetName='Host',Mandatory=$true)]
[Parameter(ParameterSetName='NAS',Mandatory=$true)]
[String]$TemplateID,
# HostID - Used for Windows or Linux Filesets
[Parameter(ParameterSetName='Host',Mandatory=$true)]
[String]$HostID,
# ShareID - used for NAS shares
[String]$ShareID,
[Parameter(ParameterSetName='NAS',Mandatory=$true)]
[String]$ShareID,
[Parameter(ParameterSetName='NAS')]
# DirectArchive - used to specify if data should be directly sent to archive (bypassing Rubrik Cluster)
[Alias('isPassThrough')]
[Switch]$DirectArchive ,
# Rubrik server IP or FQDN
[String]$Server = $global:RubrikConnection.server,
# API version
Expand Down Expand Up @@ -65,13 +77,27 @@ function New-RubrikFileset

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

if ($DirectArchive) {
$uri = New-URIString -server $server -endpoint ('/api/internal/fileset/bulk')
$body = @{
templateId = $TemplateId
shareId = $ShareId
isPassthrough = $true
}
$body = ConvertTo-Json @($body)
Write-Verbose "Body is: $body"
$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
}
else {
$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
Expand Down
6 changes: 5 additions & 1 deletion Tests/New-RubrikFileset.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ Describe -Name 'Public/New-RubrikFileset' -Tag 'Public', 'New-RubrikFileset' -Fi
It -Name 'HostId missing' -Test {
{ New-RubrikFileset -TemplateID 'Foo' -HostId } |
Should -Throw "Missing an argument for parameter 'HostId'."
}
}
It -Name 'Test ParameterSets' -Test {
{ New-RubrikFileset -TemplateId 'Foo' -HostId 'bar1' -shareId 'bar2' } |
Should -Throw "Parameter set cannot be resolved using the specified named parameters."
}
}
}