Skip to content

Commit

Permalink
Enable GPU in Fabric.Admin (Azure#56)
Browse files Browse the repository at this point in the history
* Update PS for enable GPU in Fabric.Admin

* Format update

* Doc revise

* Add validation of cmd Set-ScaleUnit

* code refactoring

* Update PS for enable GPU in Fabric.Admin

* Format update

* Doc revise

* Add validation of cmd Set-ScaleUnit

* code refactoring

* Bug fix for Set-AzsScleUnit allowing 1 as valid input

* Regenerate recording file

* Add LoadEnvJson.ps for tests

* Add env.json

* Update test recording file

* Update recording file to use management.azure.com

* Rerecording failed tests

* Fix test issue

* Fix issue in Get-AzsLogicalSubnet.

* update test records

* Update test records

* Update to fix testing issue

* Separate ScaleUnit test cases

* Separate test case for Repair-ScaleUnit

* Test fix for add scaleunit and repair scaleunit

* Test fix

* Update common for skipped cases

* Update common.ps

* Test case separate for InfrusturctureInstance

* Add test cases for restart-AzsInfrastructureRole

* Fix for Infrastructure role instance test cases

* Clean up redondant file StorageCommon.ps1

Co-authored-by: Wei Shi <weishi9999@gmail.com>
  • Loading branch information
LingyunSu and TheOnlyWei authored Dec 7, 2020
1 parent e9aab6c commit d150756
Show file tree
Hide file tree
Showing 54 changed files with 8,840 additions and 4,677 deletions.
2 changes: 1 addition & 1 deletion src/Azs.Fabric.Admin/custom/Add-AzsScaleUnitNode.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ param(

process {

$NewNode = New-Object -TypeName Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Models.Api20160501.ScaleOutScaleUnitParameters
$NewNode = New-Object -TypeName Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Models.Api20201001.ScaleOutScaleUnitParameters
$NewNode.BmciPv4Address = ${BmciPv4Address}
$NewNode.ComputerName = ${ComputerName}
$PSBoundParameters['NodeList'] = $NewNode
Expand Down
9 changes: 9 additions & 0 deletions src/Azs.Fabric.Admin/custom/Get-AzsLogicalSubnet.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ process {
}
}

# Generated cmdlet does not support {prefix}/{LogicalNetwork} for LogicalNetwork name, so extract the {LogicalNetwork} part here
if ($PSBoundParameters.ContainsKey(('LogicalNetwork')))
{
if ($null -ne $LogicalNetwork -and $LogicalNetwork.Contains('/'))
{
$PSBoundParameters['LogicalNetwork'] = $LogicalNetwork.Split("/")[-1]
}
}

Azs.Fabric.Admin.internal\Get-AzsLogicalSubnet @PSBoundParameters
}
}
4 changes: 2 additions & 2 deletions src/Azs.Fabric.Admin/custom/Get-AzsScaleUnit.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ To view examples, please use the -Online parameter with Get-Help or navigate to:
.Inputs
Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Models.IFabricAdminIdentity
.Outputs
Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Models.Api20160501.IScaleUnit
Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Models.Api20201001.IScaleUnit
.Notes
COMPLEX PARAMETER PROPERTIES
To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables.
Expand Down Expand Up @@ -40,7 +40,7 @@ INPUTOBJECT <IFabricAdminIdentity>: Identity Parameter
https://docs.microsoft.com/en-us/powershell/module/azs.fabric.admin/get-azsscaleunit
#>
function Get-AzsScaleUnit {
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Models.Api20160501.IScaleUnit])]
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Models.Api20201001.IScaleUnit])]
[CmdletBinding(DefaultParameterSetName='List', PositionalBinding=$false)]
param(
[Parameter(ParameterSetName='Get')]
Expand Down
4 changes: 2 additions & 2 deletions src/Azs.Fabric.Admin/custom/Get-AzsScaleUnitNode.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ To view examples, please use the -Online parameter with Get-Help or navigate to:
.Inputs
Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Models.IFabricAdminIdentity
.Outputs
Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Models.Api20160501.IScaleUnitNode
Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Models.Api20201001.IScaleUnitNode
.Notes
COMPLEX PARAMETER PROPERTIES
To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables.
Expand Down Expand Up @@ -40,7 +40,7 @@ INPUTOBJECT <IFabricAdminIdentity>: Identity Parameter
https://docs.microsoft.com/en-us/powershell/module/azs.fabric.admin/get-azsscaleunitnode
#>
function Get-AzsScaleUnitNode {
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Models.Api20160501.IScaleUnitNode])]
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Models.Api20201001.IScaleUnitNode])]
[CmdletBinding(DefaultParameterSetName='List', PositionalBinding=$false)]
param(
[Parameter(ParameterSetName='Get')]
Expand Down
4 changes: 2 additions & 2 deletions src/Azs.Fabric.Admin/custom/Repair-AzsScaleUnitNode.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Repairs a node of the cluster.
.Example
To view examples, please use the -Online parameter with Get-Help or navigate to: https://docs.microsoft.com/en-us/powershell/module/azs.fabric.admin/repair-azsscaleunitnode
.Inputs
Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Models.Api20160501.IBareMetalNodeDescription
Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Models.Api20201001.IBareMetalNodeDescription
.Inputs
Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Models.IFabricAdminIdentity
.Outputs
Expand Down Expand Up @@ -98,7 +98,7 @@ param(
[Parameter(ParameterSetName='Repair', Mandatory, ValueFromPipeline)]
[Parameter(ParameterSetName='RepairViaIdentity', Mandatory, ValueFromPipeline)]
[Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Category('Body')]
[Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Models.Api20160501.IBareMetalNodeDescription]
[Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Models.Api20201001.IBareMetalNodeDescription]
# Description of a bare metal node used for ScaleOut operation on a cluster.
# To construct, see NOTES section for BAREMETALNODE properties and create a hash table.
${BareMetalNode},
Expand Down
171 changes: 171 additions & 0 deletions src/Azs.Fabric.Admin/custom/Set-AzsScaleUnit.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
<#
.Synopsis
Set GPU partition size.
.Description
Set GPU partition size.
.Example
To view examples, please use the -Online parameter with Get-Help or navigate to: https://docs.microsoft.com/en-us/powershell/module/azs.fabric.admin/set-azsscaleunit
.Inputs
Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Models.IFabricAdminIdentity
.Outputs
System.Boolean
.Notes
COMPLEX PARAMETER PROPERTIES
To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables.
GPUPARTITIONSIZEPARAMETER [NumberOfGPUPartition <Int32?>]: Number of GPU partitions
.Link
https://docs.microsoft.com/en-us/powershell/module/azs.fabric.admin/set-azsscaleunit
#>
function Set-AzsScaleUnit {
[OutputType([System.Boolean])]
[CmdletBinding(DefaultParameterSetName='SetExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
param(
[Parameter(Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Category('Path')]
[System.String]
# Name of the scale units.
${Name},

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Runtime.DefaultInfo(Script='(Get-AzLocation)[0].Location')]
[System.String]
# Location of the resource.
${Location},

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Runtime.DefaultInfo(Script='-join("System.",(Get-AzLocation)[0].Location)')]
[System.String]
# Name of the resource group.
${ResourceGroupName},

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
[System.String]
# Subscription credentials that uniquely identify Microsoft Azure subscription.
# The subscription ID forms part of the URI for every service call.
${SubscriptionId},

[Parameter(ParameterSetName='SetExpanded')]
[Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Category('Body')]
[ValidateSet('1','2','4','8')]
[System.Int32]
# Number of GPU partitions
${NumberOfGPUPartition},

[Parameter()]
[Alias('AzureRMContext', 'AzureCredential')]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Category('Azure')]
[System.Management.Automation.PSObject]
# The credentials, account, tenant, and subscription used for communication with Azure.
${DefaultProfile},

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Run the command as a job
${AsJob},

[Parameter(DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Wait for .NET debugger to attach
${Break},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Category('Runtime')]
[Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Runtime.SendAsyncStep[]]
# SendAsync Pipeline Steps to be appended to the front of the pipeline
${HttpPipelineAppend},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Category('Runtime')]
[Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Runtime.SendAsyncStep[]]
# SendAsync Pipeline Steps to be prepended to the front of the pipeline
${HttpPipelinePrepend},

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Run the command asynchronously
${NoWait},

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Returns true when the command succeeds
${PassThru},

[Parameter(DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Category('Runtime')]
[System.Uri]
# The URI for the proxy server to use
${Proxy},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Category('Runtime')]
[System.Management.Automation.PSCredential]
# Credentials for a proxy server to use for the remote call
${ProxyCredential},

[Parameter(DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.FabricAdmin.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Use the default credentials for the proxy
${ProxyUseDefaultCredentials},

[Parameter(Mandatory = $false)]
[switch]
$Force
)

process {
# Generated cmdlet does not support {prefix}/{name} for Gateway name, so extract the {name} part here
if ($PSBoundParameters.ContainsKey(('Name')))
{
if ($null -ne $Name -and $Name.Contains('/'))
{
$PSBoundParameters['Name'] = $Name.Split("/")[-1]
}
}

if ($PSCmdlet.ShouldProcess("$Name" , "Set ScaleUnit")) {
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Set GPU partitions for scale unit '$Name'?", "Performing operation Set GPU partitions for $Name")) {

if ($PSBoundParameters.ContainsKey(('Force'))){
$null = $PSBoundParameters.Remove('Force')
}


$scaleUnit = Get-AzsScaleUnit -Name $Name
if(-not $scaleUnit)
{
throw "Couldn't find scale unit '$Name'"
}

if($scaleUnit.GpuType -ne "GPUP")
{
throw "This operation is not supported for GPU type: " + $scaleUnit.GpuType
}


if($scaleUnit.GpuPartitionSize -eq $NumberOfGPUPartition)
{
Write-Host "Number of GPU partitions on '$Name' is already set to $NumberOfGPUPartition."
return
}

Azs.Fabric.Admin.internal\Set-AzsScaleUnit @PSBoundParameters

}
}
}
}
Loading

0 comments on commit d150756

Please sign in to comment.