Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7762 from zyxyoshine/Oct2018FRP
[AzureStack] Update Fabric Admin Powershell cmdlet
- Loading branch information
Showing
24 changed files
with
4,112 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
248 changes: 248 additions & 0 deletions
248
...odule/Azs.Fabric.Admin/Generated.PowerShell.Commands/SwaggerPathCommands/Get-AzsDrive.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,248 @@ | ||
<# | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the MIT License. See License.txt in the project root for license information. | ||
#> | ||
|
||
<# | ||
.SYNOPSIS | ||
Returns a list of all storage drives for a given cluster. | ||
.DESCRIPTION | ||
Returns a list of all storage drives for a given cluster. | ||
.PARAMETER Name | ||
Name of the storage drive. | ||
.PARAMETER StorageSubSystem | ||
Storage subsystem in which the drive is located. | ||
.PARAMETER ScaleUnit | ||
Name of the scale unit. | ||
.PARAMETER Location | ||
Location of the resource. | ||
.PARAMETER ResourceGroupName | ||
Resource group in which the resource provider has been registered. | ||
.PARAMETER ResourceId | ||
The resource id. | ||
.PARAMETER Filter | ||
OData filter parameter. | ||
.PARAMETER Skip | ||
Skip the first N items as specified by the parameter value. | ||
.PARAMETER Top | ||
Return the top N items as specified by the parameter value. Applies after the -Skip parameter. | ||
.EXAMPLE | ||
PS C:\> Get-AzsDrive -ScaleUnit S-Cluster -StorageSubSystem S-Cluster.azurestack.local | ||
Get a list of all storage drives for a given cluster. | ||
.EXAMPLE | ||
PS C:\> Get-AzsDrive -ScaleUnit S-Cluster -StorageSubSystem S-Cluster.azurestack.local -Name a654528c-60bb-18e1-457c-51b7cdb7e14a | ||
Get a storage drive by name for a given cluster. | ||
#> | ||
function Get-AzsDrive { | ||
[OutputType([Microsoft.AzureStack.Management.Fabric.Admin.Models.Drive])] | ||
[CmdletBinding(DefaultParameterSetName = 'List')] | ||
param( | ||
[Parameter(Mandatory = $true, ParameterSetName = 'Get')] | ||
[ValidateNotNullOrEmpty()] | ||
[System.String] | ||
$Name, | ||
|
||
[Parameter(Mandatory = $true, ParameterSetName = 'Get')] | ||
[Parameter(Mandatory = $true, ParameterSetName = 'List')] | ||
[ValidateNotNullOrEmpty()] | ||
[System.String] | ||
$StorageSubSystem, | ||
|
||
[Parameter(Mandatory = $true, ParameterSetName = 'Get')] | ||
[Parameter(Mandatory = $true, ParameterSetName = 'List')] | ||
[ValidateNotNullOrEmpty()] | ||
[System.String] | ||
$ScaleUnit, | ||
|
||
[Parameter(Mandatory = $false, ParameterSetName = 'Get')] | ||
[Parameter(Mandatory = $false, ParameterSetName = 'List')] | ||
[System.String] | ||
$Location, | ||
|
||
[Parameter(Mandatory = $false, ParameterSetName = 'Get')] | ||
[Parameter(Mandatory = $false, ParameterSetName = 'List')] | ||
[ValidateLength(1, 90)] | ||
[System.String] | ||
$ResourceGroupName, | ||
|
||
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'ResourceId')] | ||
[Alias('id')] | ||
[ValidateNotNullOrEmpty()] | ||
[System.String] | ||
$ResourceId, | ||
|
||
[Parameter(Mandatory = $false, ParameterSetName = 'List')] | ||
[System.String] | ||
$Filter, | ||
|
||
[Parameter(Mandatory = $false, ParameterSetName = 'List')] | ||
[int] | ||
$Skip = -1, | ||
|
||
[Parameter(Mandatory = $false, ParameterSetName = 'List')] | ||
[int] | ||
$Top = -1 | ||
) | ||
|
||
Begin { | ||
Initialize-PSSwaggerDependencies -Azure | ||
$tracerObject = $null | ||
if (('continue' -eq $DebugPreference) -or ('inquire' -eq $DebugPreference)) { | ||
$oldDebugPreference = $global:DebugPreference | ||
$global:DebugPreference = "continue" | ||
$tracerObject = New-PSSwaggerClientTracing | ||
Register-PSSwaggerClientTracing -TracerObject $tracerObject | ||
} | ||
} | ||
|
||
Process { | ||
|
||
$StorageSubSystem = Get-ResourceNameSuffix -ResourceName $StorageSubSystem | ||
$ScaleUnit = Get-ResourceNameSuffix -ResourceName $ScaleUnit | ||
|
||
$NewServiceClient_params = @{ | ||
FullClientTypeName = 'Microsoft.AzureStack.Management.Fabric.Admin.FabricAdminClient' | ||
} | ||
|
||
$GlobalParameterHashtable = @{} | ||
$NewServiceClient_params['GlobalParameterHashtable'] = $GlobalParameterHashtable | ||
|
||
$GlobalParameterHashtable['SubscriptionId'] = $null | ||
if ($PSBoundParameters.ContainsKey('SubscriptionId')) { | ||
$GlobalParameterHashtable['SubscriptionId'] = $PSBoundParameters['SubscriptionId'] | ||
} | ||
|
||
$FabricAdminClient = New-ServiceClient @NewServiceClient_params | ||
|
||
$oDataQuery = "" | ||
if ($Filter) { | ||
$oDataQuery += "&`$Filter=$Filter" | ||
} | ||
$oDataQuery = $oDataQuery.Trim("&") | ||
|
||
if ('ResourceId' -eq $PsCmdlet.ParameterSetName) { | ||
$GetArmResourceIdParameterValue_params = @{ | ||
IdTemplate = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric.Admin/fabricLocations/{location}/scaleUnits/{scaleUnit}/storageSubSystems/{storageSubSystem}/drives/{drive}' | ||
} | ||
|
||
$GetArmResourceIdParameterValue_params['Id'] = $ResourceId | ||
$ArmResourceIdParameterValues = Get-ArmResourceIdParameterValue @GetArmResourceIdParameterValue_params | ||
|
||
$ResourceGroupName = $ArmResourceIdParameterValues['resourceGroupName'] | ||
$location = $ArmResourceIdParameterValues['location'] | ||
$ScaleUnit = $ArmResourceIdParameterValues['scaleUnit'] | ||
$StorageSubSystem = $ArmResourceIdParameterValues['storageSubSystem'] | ||
$Name = $ArmResourceIdParameterValues['drive'] | ||
} else { | ||
if ([System.String]::IsNullOrEmpty($Location)) { | ||
$Location = (Get-AzureRMLocation).Location | ||
} | ||
if ([System.String]::IsNullOrEmpty($ResourceGroupName)) { | ||
$ResourceGroupName = "System.$Location" | ||
} | ||
} | ||
|
||
$filterInfos = @( | ||
@{ | ||
'Type' = 'powershellWildcard' | ||
'Value' = $Name | ||
'Property' = 'Name' | ||
}) | ||
$applicableFilters = Get-ApplicableFilters -Filters $filterInfos | ||
if ($applicableFilters | Where-Object { $_.Strict }) { | ||
Write-Verbose -Message 'Performing server-side call ''Get-AzsDrive -''' | ||
$serverSideCall_params = @{ | ||
|
||
} | ||
|
||
$serverSideResults = Get-AzsDrive @serverSideCall_params | ||
foreach ($serverSideResult in $serverSideResults) { | ||
$valid = $true | ||
foreach ($applicableFilter in $applicableFilters) { | ||
if (-not (Test-FilteredResult -Result $serverSideResult -Filter $applicableFilter.Filter)) { | ||
$valid = $false | ||
break | ||
} | ||
} | ||
|
||
if ($valid) { | ||
$serverSideResult | ||
} | ||
} | ||
return | ||
} | ||
if ('Get' -eq $PsCmdlet.ParameterSetName -or 'ResourceId' -eq $PsCmdlet.ParameterSetName) { | ||
$Name = Get-ResourceNameSuffix -ResourceName $Name | ||
Write-Verbose -Message 'Performing operation GetWithHttpMessagesAsync on $FabricAdminClient.' | ||
$TaskResult = $FabricAdminClient.Drives.GetWithHttpMessagesAsync($ResourceGroupName, $Location, $ScaleUnit, $StorageSubSystem, $Name) | ||
} elseif ('List' -eq $PsCmdlet.ParameterSetName) { | ||
Write-Verbose -Message 'Performing operation ListWithHttpMessagesAsync on $FabricAdminClient.' | ||
$TaskResult = $FabricAdminClient.Drives.ListWithHttpMessagesAsync($ResourceGroupName, $Location, $ScaleUnit, $StorageSubSystem, $(if ($oDataQuery) { | ||
New-Object -TypeName "Microsoft.Rest.Azure.OData.ODataQuery``1[Microsoft.AzureStack.Management.Fabric.Admin.Models.Drive]" -ArgumentList $oDataQuery | ||
} else { | ||
$null | ||
})) | ||
} else { | ||
Write-Verbose -Message 'Failed to map parameter set to operation method.' | ||
throw 'Module failed to find operation to execute.' | ||
} | ||
|
||
if ($TaskResult) { | ||
$GetTaskResult_params = @{ | ||
TaskResult = $TaskResult | ||
} | ||
|
||
$TopInfo = @{ | ||
'Count' = 0 | ||
'Max' = $Top | ||
} | ||
$GetTaskResult_params['TopInfo'] = $TopInfo | ||
$SkipInfo = @{ | ||
'Count' = 0 | ||
'Max' = $Skip | ||
} | ||
$GetTaskResult_params['SkipInfo'] = $SkipInfo | ||
$PageResult = @{ | ||
'Result' = $null | ||
} | ||
$GetTaskResult_params['PageResult'] = $PageResult | ||
$GetTaskResult_params['PageType'] = 'Microsoft.Rest.Azure.IPage[Microsoft.AzureStack.Management.Fabric.Admin.Models.Drive]' -as [Type] | ||
Get-TaskResult @GetTaskResult_params | ||
|
||
Write-Verbose -Message 'Flattening paged results.' | ||
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))) { | ||
Write-Debug -Message "Retrieving next page: $($PageResult.Page.'nextPageLink')" | ||
$TaskResult = $FabricAdminClient.Drives.ListNextWithHttpMessagesAsync($PageResult.Page.'nextPageLink') | ||
$PageResult.Page = $null | ||
$GetTaskResult_params['TaskResult'] = $TaskResult | ||
$GetTaskResult_params['PageResult'] = $PageResult | ||
Get-TaskResult @GetTaskResult_params | ||
} | ||
} | ||
} | ||
|
||
End { | ||
if ($tracerObject) { | ||
$global:DebugPreference = $oldDebugPreference | ||
Unregister-PSSwaggerClientTracing -TracerObject $tracerObject | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.