Skip to content

Commit 622034f

Browse files
author
Maddie Clayton
authored
Merge pull request #7762 from zyxyoshine/Oct2018FRP
[AzureStack] Update Fabric Admin Powershell cmdlet
2 parents 477ec6a + 38daeb2 commit 622034f

24 files changed

+4112
-275
lines changed

src/StackAdmin/Azs.Fabric.Admin/Module/Azs.Fabric.Admin.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
<Prefer32Bit>false</Prefer32Bit>
4141
</PropertyGroup>
4242
<ItemGroup>
43-
<Reference Include="Microsoft.AzureStack.Management.Fabric.Admin, Version=0.2.0-preview">
44-
<HintPath>..\..\..\packages\Microsoft.AzureStack.Management.Fabric.Admin.0.2.0-preview\lib\net452\Microsoft.AzureStack.Management.Fabric.Admin.dll</HintPath>
43+
<Reference Include="Microsoft.AzureStack.Management.Fabric.Admin, Version=1.8.0-preview">
44+
<HintPath>..\..\..\packages\Microsoft.AzureStack.Management.Fabric.Admin.1.8.0-preview\lib\net452\Microsoft.AzureStack.Management.Fabric.Admin.dll</HintPath>
4545
</Reference>
4646
</ItemGroup>
4747
<ItemGroup>

src/StackAdmin/Azs.Fabric.Admin/Module/Azs.Fabric.Admin/Azs.Fabric.Admin.psd1

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Licensed under the MIT License. See License.txt in the project root for license
1717
RootModule = 'Azs.Fabric.Admin.psm1'
1818

1919
# Version number of this module.
20-
ModuleVersion = '0.2.1'
20+
ModuleVersion = '0.3.0'
2121

2222
# Supported PSEditions
2323
# CompatiblePSEditions = @()
@@ -81,14 +81,15 @@ Licensed under the MIT License. See License.txt in the project root for license
8181
'Get-AzsSlbMuxInstance', 'Get-AzsScaleUnit', 'New-AzsIpPool',
8282
'Start-AzsInfrastructureRoleInstance', 'Get-AzsMacAddressPool',
8383
'Get-AzsEdgeGatewayPool', 'Restart-AzsInfrastructureRole',
84-
'Get-AzsInfrastructureVolume', 'Enable-AzsScaleUnitNode',
84+
'Get-AzsVolume', 'Enable-AzsScaleUnitNode',
8585
'Get-AzsInfrastructureRole', 'Get-AzsIpPool', 'Get-AzsLogicalSubnet',
8686
'Get-AzsEdgeGateway', 'Get-AzsInfrastructureLocation',
8787
'Get-AzsStoragePool', 'Suspend-AzsInfrastructureRoleInstance',
8888
'Start-AzsScaleUnitNode', 'Get-AzsInfrastructureRoleInstance',
8989
'Repair-AzsScaleUnitNode', 'Stop-AzsInfrastructureRoleInstance',
9090
'Stop-AzsScaleUnitNode', 'Add-AzsScaleUnitNode',
91-
'New-AzsScaleUnitNodeObject'
91+
'New-AzsScaleUnitNodeObject', 'Get-AzsDrive',
92+
'Get-AzsStorageSubSystem'
9293

9394
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
9495
CmdletsToExport = @()
@@ -97,7 +98,9 @@ Licensed under the MIT License. See License.txt in the project root for license
9798
# VariablesToExport = @()
9899

99100
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
100-
AliasesToExport = @()
101+
AliasesToExport = @(
102+
'Get-AzsInfrastructureVolume'
103+
)
101104

102105
# DSC resources to export from this module
103106
# DscResourcesToExport = @()
@@ -126,9 +129,13 @@ Licensed under the MIT License. See License.txt in the project root for license
126129
# IconUri = ''
127130

128131
# ReleaseNotes of this module
129-
ReleaseNotes = '## 2018.10.28
130-
* Bug fixes
131-
* Fixed a bug in Add-AzsScaleUnitNode
132+
ReleaseNotes = '## 2018.11.5
133+
* New cmdlet (The features are supported by Azure Stack 1811+)
134+
* Get-AzsDrive
135+
* Get-AzsVolume
136+
* Get-AzsStorageSubSystem
137+
* Deprecation
138+
* Get-AzsInfrastructureVolume is an alias now to the cmdlet Get-AzsVolume
132139
'
133140

134141
} # End of PSData hashtable

src/StackAdmin/Azs.Fabric.Admin/Module/Azs.Fabric.Admin/ChangeLog.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,48 @@
1919
-->
2020
## Current Release
2121

22+
## Version 0.3.0
23+
* New cmdlet (The features are supported by Azure Stack 1811+)
24+
* Get-AzsDrive
25+
* Get-AzsVolume
26+
* Get-AzsStorageSubSystem
27+
* Deprecation
28+
* Get-AzsInfrastructureVolume is an alias now to the cmdlet Get-AzsVolume
29+
2230
## Version 0.2.1
2331
* Bug fixes
2432
* Fixed a bug in Add-AzsScaleUnitNode
33+
34+
## Version 0.2.0
35+
* New Module dependencies
36+
* AzureRM.Profile
37+
* AzureRM.Resources
38+
* New cmdlet
39+
* Add-AzsScaleUnitNode
40+
* New-AzsScaleUnitNodeObject
41+
* Support handling names of nested resources
42+
* Add-AzsScaleUnitNode
43+
* Disable-AzsScaleUnitNode
44+
* Enable-AzsScaleUnitNode
45+
* Get-AzsEdgeGateway
46+
* Get-AzsEdgeGatewayPool
47+
* Get-AzsInfrastructureRole
48+
* Get-AzsInfrastructureRoleInstance
49+
* Get-AzsInfrastructureShare
50+
* Get-AzsInfrastructureVolume
51+
* Get-AzsIpPool
52+
* Get-AzsLogicalNetwork
53+
* Get-AzsLogicalSubnet
54+
* Get-AzsMacAddressPool
55+
* Get-AzsScaleUnit
56+
* Get-AzsScaleUnitNode
57+
* Get-AzsSlbMuxInstance
58+
* Get-AzsStoragePool
59+
* Get-AzsStorageSystem
60+
* Repair-AzsScaleUnitNode
61+
* Restart-AzsInfrastructureRole
62+
* Restart-AzsInfrastructureRoleInstance
63+
* Start-AzsInfrastructureRoleInstance
64+
* Start-AzsScaleUnitNode
65+
* Stop-AzsInfrastructureRoleInstance
66+
* Stop-AzsScaleUnitNode
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
<#
2+
Copyright (c) Microsoft Corporation. All rights reserved.
3+
Licensed under the MIT License. See License.txt in the project root for license information.
4+
#>
5+
6+
<#
7+
.SYNOPSIS
8+
Returns a list of all storage drives for a given cluster.
9+
10+
.DESCRIPTION
11+
Returns a list of all storage drives for a given cluster.
12+
13+
.PARAMETER Name
14+
Name of the storage drive.
15+
16+
.PARAMETER StorageSubSystem
17+
Storage subsystem in which the drive is located.
18+
19+
.PARAMETER ScaleUnit
20+
Name of the scale unit.
21+
22+
.PARAMETER Location
23+
Location of the resource.
24+
25+
.PARAMETER ResourceGroupName
26+
Resource group in which the resource provider has been registered.
27+
28+
.PARAMETER ResourceId
29+
The resource id.
30+
31+
.PARAMETER Filter
32+
OData filter parameter.
33+
34+
.PARAMETER Skip
35+
Skip the first N items as specified by the parameter value.
36+
37+
.PARAMETER Top
38+
Return the top N items as specified by the parameter value. Applies after the -Skip parameter.
39+
40+
.EXAMPLE
41+
42+
PS C:\> Get-AzsDrive -ScaleUnit S-Cluster -StorageSubSystem S-Cluster.azurestack.local
43+
44+
Get a list of all storage drives for a given cluster.
45+
46+
.EXAMPLE
47+
48+
PS C:\> Get-AzsDrive -ScaleUnit S-Cluster -StorageSubSystem S-Cluster.azurestack.local -Name a654528c-60bb-18e1-457c-51b7cdb7e14a
49+
50+
Get a storage drive by name for a given cluster.
51+
52+
#>
53+
function Get-AzsDrive {
54+
[OutputType([Microsoft.AzureStack.Management.Fabric.Admin.Models.Drive])]
55+
[CmdletBinding(DefaultParameterSetName = 'List')]
56+
param(
57+
[Parameter(Mandatory = $true, ParameterSetName = 'Get')]
58+
[ValidateNotNullOrEmpty()]
59+
[System.String]
60+
$Name,
61+
62+
[Parameter(Mandatory = $true, ParameterSetName = 'Get')]
63+
[Parameter(Mandatory = $true, ParameterSetName = 'List')]
64+
[ValidateNotNullOrEmpty()]
65+
[System.String]
66+
$StorageSubSystem,
67+
68+
[Parameter(Mandatory = $true, ParameterSetName = 'Get')]
69+
[Parameter(Mandatory = $true, ParameterSetName = 'List')]
70+
[ValidateNotNullOrEmpty()]
71+
[System.String]
72+
$ScaleUnit,
73+
74+
[Parameter(Mandatory = $false, ParameterSetName = 'Get')]
75+
[Parameter(Mandatory = $false, ParameterSetName = 'List')]
76+
[System.String]
77+
$Location,
78+
79+
[Parameter(Mandatory = $false, ParameterSetName = 'Get')]
80+
[Parameter(Mandatory = $false, ParameterSetName = 'List')]
81+
[ValidateLength(1, 90)]
82+
[System.String]
83+
$ResourceGroupName,
84+
85+
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'ResourceId')]
86+
[Alias('id')]
87+
[ValidateNotNullOrEmpty()]
88+
[System.String]
89+
$ResourceId,
90+
91+
[Parameter(Mandatory = $false, ParameterSetName = 'List')]
92+
[System.String]
93+
$Filter,
94+
95+
[Parameter(Mandatory = $false, ParameterSetName = 'List')]
96+
[int]
97+
$Skip = -1,
98+
99+
[Parameter(Mandatory = $false, ParameterSetName = 'List')]
100+
[int]
101+
$Top = -1
102+
)
103+
104+
Begin {
105+
Initialize-PSSwaggerDependencies -Azure
106+
$tracerObject = $null
107+
if (('continue' -eq $DebugPreference) -or ('inquire' -eq $DebugPreference)) {
108+
$oldDebugPreference = $global:DebugPreference
109+
$global:DebugPreference = "continue"
110+
$tracerObject = New-PSSwaggerClientTracing
111+
Register-PSSwaggerClientTracing -TracerObject $tracerObject
112+
}
113+
}
114+
115+
Process {
116+
117+
$StorageSubSystem = Get-ResourceNameSuffix -ResourceName $StorageSubSystem
118+
$ScaleUnit = Get-ResourceNameSuffix -ResourceName $ScaleUnit
119+
120+
$NewServiceClient_params = @{
121+
FullClientTypeName = 'Microsoft.AzureStack.Management.Fabric.Admin.FabricAdminClient'
122+
}
123+
124+
$GlobalParameterHashtable = @{}
125+
$NewServiceClient_params['GlobalParameterHashtable'] = $GlobalParameterHashtable
126+
127+
$GlobalParameterHashtable['SubscriptionId'] = $null
128+
if ($PSBoundParameters.ContainsKey('SubscriptionId')) {
129+
$GlobalParameterHashtable['SubscriptionId'] = $PSBoundParameters['SubscriptionId']
130+
}
131+
132+
$FabricAdminClient = New-ServiceClient @NewServiceClient_params
133+
134+
$oDataQuery = ""
135+
if ($Filter) {
136+
$oDataQuery += "&`$Filter=$Filter"
137+
}
138+
$oDataQuery = $oDataQuery.Trim("&")
139+
140+
if ('ResourceId' -eq $PsCmdlet.ParameterSetName) {
141+
$GetArmResourceIdParameterValue_params = @{
142+
IdTemplate = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric.Admin/fabricLocations/{location}/scaleUnits/{scaleUnit}/storageSubSystems/{storageSubSystem}/drives/{drive}'
143+
}
144+
145+
$GetArmResourceIdParameterValue_params['Id'] = $ResourceId
146+
$ArmResourceIdParameterValues = Get-ArmResourceIdParameterValue @GetArmResourceIdParameterValue_params
147+
148+
$ResourceGroupName = $ArmResourceIdParameterValues['resourceGroupName']
149+
$location = $ArmResourceIdParameterValues['location']
150+
$ScaleUnit = $ArmResourceIdParameterValues['scaleUnit']
151+
$StorageSubSystem = $ArmResourceIdParameterValues['storageSubSystem']
152+
$Name = $ArmResourceIdParameterValues['drive']
153+
} else {
154+
if ([System.String]::IsNullOrEmpty($Location)) {
155+
$Location = (Get-AzureRMLocation).Location
156+
}
157+
if ([System.String]::IsNullOrEmpty($ResourceGroupName)) {
158+
$ResourceGroupName = "System.$Location"
159+
}
160+
}
161+
162+
$filterInfos = @(
163+
@{
164+
'Type' = 'powershellWildcard'
165+
'Value' = $Name
166+
'Property' = 'Name'
167+
})
168+
$applicableFilters = Get-ApplicableFilters -Filters $filterInfos
169+
if ($applicableFilters | Where-Object { $_.Strict }) {
170+
Write-Verbose -Message 'Performing server-side call ''Get-AzsDrive -'''
171+
$serverSideCall_params = @{
172+
173+
}
174+
175+
$serverSideResults = Get-AzsDrive @serverSideCall_params
176+
foreach ($serverSideResult in $serverSideResults) {
177+
$valid = $true
178+
foreach ($applicableFilter in $applicableFilters) {
179+
if (-not (Test-FilteredResult -Result $serverSideResult -Filter $applicableFilter.Filter)) {
180+
$valid = $false
181+
break
182+
}
183+
}
184+
185+
if ($valid) {
186+
$serverSideResult
187+
}
188+
}
189+
return
190+
}
191+
if ('Get' -eq $PsCmdlet.ParameterSetName -or 'ResourceId' -eq $PsCmdlet.ParameterSetName) {
192+
$Name = Get-ResourceNameSuffix -ResourceName $Name
193+
Write-Verbose -Message 'Performing operation GetWithHttpMessagesAsync on $FabricAdminClient.'
194+
$TaskResult = $FabricAdminClient.Drives.GetWithHttpMessagesAsync($ResourceGroupName, $Location, $ScaleUnit, $StorageSubSystem, $Name)
195+
} elseif ('List' -eq $PsCmdlet.ParameterSetName) {
196+
Write-Verbose -Message 'Performing operation ListWithHttpMessagesAsync on $FabricAdminClient.'
197+
$TaskResult = $FabricAdminClient.Drives.ListWithHttpMessagesAsync($ResourceGroupName, $Location, $ScaleUnit, $StorageSubSystem, $(if ($oDataQuery) {
198+
New-Object -TypeName "Microsoft.Rest.Azure.OData.ODataQuery``1[Microsoft.AzureStack.Management.Fabric.Admin.Models.Drive]" -ArgumentList $oDataQuery
199+
} else {
200+
$null
201+
}))
202+
} else {
203+
Write-Verbose -Message 'Failed to map parameter set to operation method.'
204+
throw 'Module failed to find operation to execute.'
205+
}
206+
207+
if ($TaskResult) {
208+
$GetTaskResult_params = @{
209+
TaskResult = $TaskResult
210+
}
211+
212+
$TopInfo = @{
213+
'Count' = 0
214+
'Max' = $Top
215+
}
216+
$GetTaskResult_params['TopInfo'] = $TopInfo
217+
$SkipInfo = @{
218+
'Count' = 0
219+
'Max' = $Skip
220+
}
221+
$GetTaskResult_params['SkipInfo'] = $SkipInfo
222+
$PageResult = @{
223+
'Result' = $null
224+
}
225+
$GetTaskResult_params['PageResult'] = $PageResult
226+
$GetTaskResult_params['PageType'] = 'Microsoft.Rest.Azure.IPage[Microsoft.AzureStack.Management.Fabric.Admin.Models.Drive]' -as [Type]
227+
Get-TaskResult @GetTaskResult_params
228+
229+
Write-Verbose -Message 'Flattening paged results.'
230+
while ($PageResult -and ($PageResult.ContainsKey('Page')) -and (Get-Member -InputObject $PageResult.Page -Name 'nextPageLink') -and $PageResult.Page.'nextPageLink' -and (($TopInfo -eq $null) -or ($TopInfo.Max -eq -1) -or ($TopInfo.Count -lt $TopInfo.Max))) {
231+
Write-Debug -Message "Retrieving next page: $($PageResult.Page.'nextPageLink')"
232+
$TaskResult = $FabricAdminClient.Drives.ListNextWithHttpMessagesAsync($PageResult.Page.'nextPageLink')
233+
$PageResult.Page = $null
234+
$GetTaskResult_params['TaskResult'] = $TaskResult
235+
$GetTaskResult_params['PageResult'] = $PageResult
236+
Get-TaskResult @GetTaskResult_params
237+
}
238+
}
239+
}
240+
241+
End {
242+
if ($tracerObject) {
243+
$global:DebugPreference = $oldDebugPreference
244+
Unregister-PSSwaggerClientTracing -TracerObject $tracerObject
245+
}
246+
}
247+
}
248+

0 commit comments

Comments
 (0)