-
Notifications
You must be signed in to change notification settings - Fork 4k
[AzureStack] Update Fabric Admin Powershell cmdlet #7762
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1682d70
Add and update cmdlet scripts
zyxyoshine 3c3da94
Add and update tests
zyxyoshine 8087870
Update SessionRecords
zyxyoshine 61f6b14
Merge branch 'preview' into Oct2018FRP
zyxyoshine c544ff5
fix comments
zyxyoshine 6b1188b
Add negative tests
zyxyoshine 17cf1c1
Update SessionRecords
zyxyoshine c5b0167
Merge branch 'Oct2018FRP' of https://github.com/zyxyoshine/azure-powe…
zyxyoshine d273b81
Update change log
zyxyoshine eeaac2d
Add alias support for Get- AzsInfrastructureVolume cmdlet
zyxyoshine 38daeb2
Merge branch 'preview' into Oct2018FRP
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.