Skip to content

Commit 6c36e5f

Browse files
committed
new-rubriksla support
1 parent 923b7d9 commit 6c36e5f

File tree

4 files changed

+333
-1
lines changed

4 files changed

+333
-1
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
function Get-RubrikRSCVolumeGroup {
2+
[CmdletBinding()]
3+
Param(
4+
# Name of the volume group
5+
[Parameter(Position = 0,ValueFromPipelineByPropertyName = $true)]
6+
[Alias('VolumeGroup')]
7+
[String]$name,
8+
# Filter results by hostname
9+
[String]$hostname,
10+
# Filter results to include only relic (removed) volume groups
11+
[Alias('is_relic')]
12+
[Switch]$Relic,
13+
# SLA Domain policy assigned to the volume group
14+
[String]$SLA,
15+
# Filter the summary information based on the primarycluster_id of the primary Rubrik cluster. Use local as the primary_cluster_id of the Rubrik cluster that is hosting the current REST API session.
16+
[Alias('primary_cluster_id')]
17+
[String]$PrimaryClusterID,
18+
# Volume group id
19+
[Parameter(ValueFromPipelineByPropertyName = $true)]
20+
[String]$id,
21+
# SLA id value
22+
[Alias('effective_sla_domain_id')]
23+
[String]$SLAID,
24+
# DetailedObject will retrieved the detailed VolumeGroup object, the default behavior of the API is to only retrieve a subset of the full VolumeGroup 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.
25+
[Switch]$DetailedObject,
26+
# Rubrik server IP or FQDN
27+
[String]$Server = $global:RubrikConnection.server,
28+
# API version
29+
[String]$api = $global:RubrikConnection.api
30+
)
31+
32+
$query = New-RscQuery -GqlQuery physicalHosts
33+
$query.Var.hostRoot = "WINDOWS_HOST_ROOT"
34+
$query.Var.sortBy = "NAME"
35+
$query.Var.sortOrder = "ASC"
36+
$query.Var
37+
$filter = New-Object System.Collections.ArrayList
38+
39+
40+
#TODO -=MWP=- figure out how to get volume group info into query
41+
$filter.Add(
42+
@{
43+
"field" = "CLUSTER_ID"
44+
"texts" = "$($global:rubrikConnection.clusterId)"
45+
}
46+
) | Out-Null
47+
$filter.Add(
48+
@{
49+
"field" = "IS_REPLICATED"
50+
"texts" = "$false"
51+
}
52+
) | Out-Null
53+
if ($PSBoundParameters.containsKey("Relic")) {
54+
if ($Relic -eq $true) {
55+
$filter.Add(
56+
@{
57+
"field" = "IS_RELIC"
58+
"texts" = "True"
59+
}
60+
) | out-null
61+
} elseif ($Relic -eq $false) {
62+
$filter.Add(
63+
@{
64+
"field" = "IS_RELIC"
65+
"texts" = "False"
66+
}
67+
) | out-null
68+
}
69+
}
70+
71+
if ($Name) {
72+
$filter.Add(
73+
@{
74+
"field" = "NAME_EXACT_MATCH"
75+
"texts" = "$Name"
76+
}
77+
) | Out-Null
78+
}
79+
Write-Verbose -Message "Adding filter to query"
80+
$query.var.filter = $filter
81+
82+
$response = (Invoke-Rsc $query).nodes
83+
return $response
84+
85+
}

Rubrik/Private/New-RubrikRSCSla.ps1

Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
function New-RubrikRSCSla {
2+
[CmdletBinding(SupportsShouldProcess = $true,ConfirmImpact = 'High')]
3+
Param(
4+
# SLA Domain Name, either the -Name parameter or its parameter alias -SLA can be used to specify the name of the SLA
5+
[Parameter(Mandatory = $true)]
6+
[ValidateNotNullOrEmpty()]
7+
[Alias('SLA')]
8+
[String]$Name,
9+
# Hourly frequency to take snapshots
10+
[int]$HourlyFrequency,
11+
# Number of days or weeks to retain the hourly snapshots. For CDM versions prior to 5.0 this value must be set in days
12+
[int]$HourlyRetention,
13+
# Retention type to apply to hourly snapshots when $AdvancedConfig is used. Does not apply to CDM versions prior to 5.0
14+
[ValidateSet('Daily','Weekly')]
15+
[String]$HourlyRetentionType='Daily',
16+
# Daily frequency to take snapshots
17+
[int]$DailyFrequency,
18+
# Number of days or weeks to retain the daily snapshots. For CDM versions prior to 5.0 this value must be set in days
19+
[int]$DailyRetention,
20+
# Retention type to apply to daily snapshots when $AdvancedConfig is used. Does not apply to CDM versions prior to 5.0
21+
[ValidateSet('Daily','Weekly')]
22+
[String]$DailyRetentionType='Daily',
23+
# Weekly frequency to take snapshots
24+
[int]$WeeklyFrequency,
25+
# Number of weeks to retain the weekly snapshots
26+
[int]$WeeklyRetention,
27+
# Day of week for the weekly snapshots when $AdvancedConfig is used. The default is Saturday. Does not apply to CDM versions prior to 5.0
28+
[ValidateSet('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday')]
29+
[String]$DayOfWeek='Saturday',
30+
# Monthly frequency to take snapshots
31+
[int]$MonthlyFrequency,
32+
# Number of months, quarters or years to retain the monthly backups. For CDM versions prior to 5.0, this value must be set in years
33+
[int]$MonthlyRetention,
34+
# Day of month for the monthly snapshots when $AdvancedConfig is used. The default is the last day of the month. Does not apply to CDM versions prior to 5.0
35+
[ValidateSet('FirstDay','Fifteenth','LastDay')]
36+
[String]$DayOfMonth='LastDay',
37+
# Retention type to apply to monthly snapshots. Does not apply to CDM versions prior to 5.0
38+
[ValidateSet('Monthly','Quarterly','Yearly')]
39+
[String]$MonthlyRetentionType='Monthly',
40+
# Quarterly frequency to take snapshots. Does not apply to CDM versions prior to 5.0
41+
[int]$QuarterlyFrequency,
42+
# Number of quarters or years to retain the monthly snapshots. Does not apply to CDM versions prior to 5.0
43+
[int]$QuarterlyRetention,
44+
# Day of quarter for the quarterly snapshots when $AdvancedConfig is used. The default is the last day of the quarter. Does not apply to CDM versions prior to 5.0
45+
[ValidateSet('FirstDay','LastDay')]
46+
[String]$DayOfQuarter='LastDay',
47+
# Month that starts the first quarter of the year for the quarterly snapshots when $AdvancedConfig is used. The default is January. Does not apply to CDM versions prior to 5.0
48+
[ValidateSet('January','February','March','April','May','June','July','August','September','October','November','December')]
49+
[String]$FirstQuarterStartMonth='January',
50+
# Retention type to apply to quarterly snapshots. The default is Quarterly. Does not apply to CDM versions prior to 5.0
51+
[ValidateSet('Quarterly','Yearly')]
52+
[String]$QuarterlyRetentionType='Quarterly',
53+
# Yearly frequency to take snapshots
54+
[int]$YearlyFrequency,
55+
# Number of years to retain the yearly snapshots
56+
[int]$YearlyRetention,
57+
# Day of year for the yearly snapshots when $AdvancedConfig is used. The default is the last day of the year. Does not apply to CDM versions prior to 5.0
58+
[ValidateSet('FirstDay','LastDay')]
59+
[String]$DayOfYear='LastDay',
60+
# Month that starts the first quarter of the year for the quarterly snapshots when $AdvancedConfig is used. The default is January. Does not apply to CDM versions prior to 5.0
61+
[ValidateSet('January','February','March','April','May','June','July','August','September','October','November','December')]
62+
[String]$YearStartMonth='January',
63+
# Whether to turn advanced SLA configuration on or off. Does not apply to CDM versions prior to 5.0
64+
[Parameter(
65+
ValueFromPipelineByPropertyName = $true)]
66+
[alias('showAdvancedUi')]
67+
[switch]$AdvancedConfig,
68+
[ValidateRange(0,23)]
69+
[int]$BackupStartHour,
70+
# Minute of hour from which backups are allowed to run
71+
[ValidateRange(0,59)]
72+
[int]$BackupStartMinute,
73+
# Number of hours during which backups are allowed to run
74+
[ValidateRange(1,23)]
75+
[int]$BackupWindowDuration,
76+
# Hour from which the first full backup is allowed to run. Uses the 24-hour clock
77+
[ValidateRange(0,23)]
78+
[int]$FirstFullBackupStartHour,
79+
# Minute of hour from which the first full backup is allowed to run
80+
[ValidateRange(0,59)]
81+
[int]$FirstFullBackupStartMinute,
82+
[ValidateSet('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','1','2','3','4','5','6','7')]
83+
[String]$FirstFullBackupDay,
84+
# Number of hours during which the first full backup is allowed to run
85+
[int]$FirstFullBackupWindowDuration,
86+
# Whether to enable archival, does not take any input and should be used in combination with -ArchivalLocationId
87+
[switch]$Archival,
88+
# Time in days to keep backup data locally on the cluster.
89+
[Parameter(
90+
ValueFromPipelineByPropertyName = $true)]
91+
[alias('localRetentionLimit')]
92+
[int]$LocalRetention,
93+
# ID of the archival location
94+
[ValidateNotNullOrEmpty()]
95+
[String]$ArchivalLocationId,
96+
# Polaris Managed ID
97+
[ValidateNotNullOrEmpty()]
98+
[String]$PolarisID,
99+
# Whether to enable Instant Archive
100+
[switch]$InstantArchive,
101+
# Whether a retention lock is active on this SLA, Does not apply to CDM versions prior to 5.2
102+
[alias('isRetentionLocked')]
103+
[switch]$RetentionLock,
104+
# Whether to enable replication
105+
[switch]$Replication,
106+
# ID of the replication target
107+
[ValidateNotNullOrEmpty()]
108+
[String]$ReplicationTargetId,
109+
# Time in days to keep data on the replication target.
110+
[int]$RemoteRetention,
111+
# Retrieves frequencies from Get-RubrikSLA via the pipeline
112+
[Parameter(
113+
ValueFromPipelineByPropertyName = $true)]
114+
[object[]] $Frequencies,
115+
# Retrieves the advanced UI configuration parameters from Get-RubrikSLA via the pipeline
116+
[Parameter(
117+
ValueFromPipelineByPropertyName = $true)]
118+
[alias('advancedUiConfig')]
119+
[object[]] $AdvancedFreq,
120+
# Retrieves the allowed backup windows from Get-RubrikSLA via the pipeline
121+
[Parameter(
122+
ValueFromPipelineByPropertyName = $true)]
123+
[alias('allowedBackupWindows')]
124+
[object[]] $BackupWindows,
125+
# Retrieves the allowed backup windows for the first full backup from Get-RubrikSLA via the pipeline
126+
[Parameter(
127+
ValueFromPipelineByPropertyName = $true)]
128+
[alias('firstFullAllowedBackupWindows')]
129+
[object[]] $FirstFullBackupWindows,
130+
# Retrieves the archical specifications from Get-RubrikSLA via the pipeline
131+
[Parameter(
132+
ValueFromPipelineByPropertyName = $true)]
133+
[object[]] $ArchivalSpecs,
134+
# Retrieves the replication specifications from Get-RubrikSLA via the pipeline
135+
[Parameter(
136+
ValueFromPipelineByPropertyName = $true)]
137+
[object[]] $ReplicationSpecs,
138+
# Rubrik server IP or FQDN
139+
[String]$Server = $global:RubrikConnection.server,
140+
# API version
141+
[String]$api = $global:RubrikConnection.api
142+
)
143+
144+
$RscParams = @{}
145+
146+
if ($Name) {
147+
$RscParams.Add("Name",$Name)
148+
}
149+
150+
if ($HourlyFrequency) {
151+
if ($HourlyRetentionType -eq "Weekly") {
152+
$RetentionUnit = "WEEKS"
153+
} else {
154+
$RetentionUnit = "DAYS"
155+
}
156+
$hourlySchedule = New-RscSlaSnapshotSchedule -Type Hourly -Frequency $HourlyFrequency -Retention $HourlyRetention -RetentionUnit $RetentionUnit
157+
$RscParams.Add("HourlySchedule", $hourlySchedule)
158+
}
159+
if ($DailyFrequency) {
160+
if ($DailyRetentionType -eq "Weekly") {
161+
$RetentionUnit = "WEEKS"
162+
} else {
163+
$RetentionUnit = "DAYS"
164+
}
165+
$dailySchedule = New-RscSlaSnapshotSchedule -Type Daily -Frequency $DailyFrequency -Retention $DailyRetention -RetentionUnit $RetentionUnit
166+
$RscParams.Add("DailySchedule",$dailySchedule)
167+
}
168+
if ($WeeklyFrequency) {
169+
if ($DayOfWeek) {
170+
$DayToTakeSnap = $DayOfWeek.toUpper()
171+
} else {
172+
$DayToTakeSnap = "MONDAY"
173+
}
174+
$weeklySchedule = New-RscSlaSnapshotSchedule -Type Weekly -Frequency $WeeklyFrequency -Retention $WeeklyRetention -DayOfWeek $DayToTakeSnap -RetentionUnit WEEKS
175+
Write-Host "Adding weekly"
176+
$RscParams.Add("WeeklySchedule",$weeklySchedule)
177+
}
178+
if ($MonthlyFrequency) {
179+
if ($DayOfMonth -eq "FirstDay") {
180+
$DayToTakeSnap = "FIRST_DAY"
181+
} elseif ($DayOfMonth -eq "Fifteenth") {
182+
$DayToTakeSnap = "FIFTEENTH"
183+
} else {
184+
$DayToTakeSnap = "LAST_DAY"
185+
}
186+
if ($MonthlyRetentionType -eq "Quarterly") {
187+
$RetentionUnit = "QUARTERS"
188+
} elseif ($MonthlyRetentionType -eq "Yearly") {
189+
$RetentionUnit = "YEARS"
190+
} else {
191+
$RetentionUnit = "MONTHS"
192+
}
193+
$monthlySchedule = New-RscSlaSnapshotSchedule -Type Monthly -Frequency $MonthlyFrequency -Retention $MonthlyRetention -DayOfMonth $DayToTakeSnap -RetentionUnit $RetentionUnit
194+
$RscParams.Add("MonthlySchedule",$monthlySchedule)
195+
}
196+
if ($QuarterlyFrequency) {
197+
if ($DayOfQuarter -eq "FirstDay") {
198+
$DayToTakeSnap = "FIRST_DAY"
199+
} else {
200+
$DayToTakeSnap = "LAST_DAY"
201+
}
202+
203+
if ($FirstQuarterStartMonth) {
204+
$QuarterStartMonth = $FirstQuarterStartMonth.toUpper()
205+
} else {
206+
$QuarterStartMonth = "JANUARY"
207+
}
208+
if ($QuarterlyRetentionType -eq "Yearly") {
209+
$RetentionUnit = "YEARS"
210+
} else {
211+
$RetentionUnit = "QUARTERS"
212+
}
213+
$quarterlySchedule = New-RscSlaSnapshotSchedule -Type Quarterly -Frequency $QuarterlyFrequency -Retention $QuarterlyRetention -DayOfQuarter $DayToTakeSnap -RetentionUnit $RetentionUnit -QuarterStartMonth $QuarterStartMonth
214+
$RscParams.Add("QuarterlySchedule",$quarterlySchedule)
215+
}
216+
if ($YearlyFrequency) {
217+
$RetentionUnit = "YEARS"
218+
if ($YearStartMonth) {
219+
$YearStart = [RubrikSecurityCloud.Types.Month] $YearStartMonth.ToUpper()
220+
} else {
221+
$YearStart = [RubrikSecurityCloud.Types.Month] "JANUARY"
222+
}
223+
if ($DayOfYear -eq "FirstDay") {
224+
$DayYear = "FIRST_DAY"
225+
} else {
226+
$DayYear = "LAST_DAY"
227+
}
228+
$yearlySchedule = New-RscSlaSnapshotSchedule -Type Yearly -Frequency $YearlyFrequency -Retention $YearlyRetention -RetentionUnit $RetentionUnit -YearStartMonth $YearStart -DayOfYear $DayYear
229+
$RscParams.Add("YearlySchedule",$yearlySchedule)
230+
}
231+
232+
$RscParams.Add("ObjectType","VSPHERE_OBJECT_TYPE")
233+
Write-Host @RscParams
234+
$response = New-RscSla @RscParams
235+
return $response
236+
}

Rubrik/Public/Get-RubrikVolumeGroup.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ function Get-RubrikVolumeGroup
9797

9898
Process {
9999

100+
# If connected to RSC, redirect to new GQL cmdlet
101+
if ($global:rubrikConnection.RSCInstance) {
102+
Write-Verbose -Message "Cluster connected to RSC instance, redirecting to Get-RubrikRSCVolumeGroup"
103+
$response = Get-RubrikRSCVolumeGroup @PSBoundParameters
104+
return $response
105+
}
100106
#region One-off
101107
# If SLA paramter defined, resolve SLAID
102108
If ($SLA) {

Rubrik/Public/New-RubrikSLA.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,12 @@ function New-RubrikSLA
236236
}
237237

238238
Process {
239-
239+
# If connected to RSC, redirect to new GQL cmdlet
240+
if ($global:rubrikConnection.RSCInstance) {
241+
Write-Verbose -Message "Cluster connected to RSC instance, redirecting to New-RubrikRSCSLA"
242+
$response = New-RubrikRSCSLA @PSBoundParameters
243+
return $response
244+
}
240245
$uri = New-URIString -server $Server -endpoint ($resources.URI) -id $id
241246
$uri = Test-QueryParam -querykeys ($resources.Query.Keys) -parameters ((Get-Command $function).Parameters.Values) -uri $uri
242247

0 commit comments

Comments
 (0)