Skip to content

Commit

Permalink
Added EnableGPUDriver param (#719)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolehaugen committed Dec 2, 2020
1 parent bd47f83 commit d8553f7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
9 changes: 8 additions & 1 deletion samples/ClassroomLabs/Modules/Library/Az.LabServices.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,10 @@ function New-AzLab {
[parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "Size for template VM")]
[ValidateNotNullOrEmpty()]
$Size,

[parameter(mandatory = $false, ValueFromPipelineByPropertyName = $true)]
[switch]
$InstallGpuDriverEnabled = $false,

[parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "User name if shared password is enabled")]
[string]
Expand All @@ -669,6 +673,7 @@ function New-AzLab {
[parameter(mandatory = $false, ValueFromPipelineByPropertyName = $true)]
[switch]
$SharedPasswordEnabled = $false,

[parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = "Idle Shutdown Grace Period (0 is off)")]
[int]
$idleGracePeriod = 15,
Expand Down Expand Up @@ -697,6 +702,7 @@ function New-AzLab {
$sharedPassword = if ($SharedPasswordEnabled) { "Enabled" } else { "Disabled" }
$imageType = if ($image.id -match '/galleryimages/') { 'galleryImageResourceId' } else { 'sharedImageResourceId' }
if ($LinuxRdpEnabled) {$linuxRdpState = 'Enabled'} else { $linuxRdpState = 'Disabled' }
if ($InstallGpuDriverEnabled) {$gpuDriverState = 'Enabled'} else { $gpuDriverState = 'Disabled' }
if ($SkipTemplateCreation) {$hasTemplateVm = 'Disabled' } else { $hasTemplateVm = 'Enabled' }
if ($idleGracePeriod -eq 0) {$idleShutdownMode = "None"} else {$idleShutdownMode = "OnDisconnect"}
if ($idleOsGracePeriod -eq 0) {$enableDisconnectOnIdle = "Disabled"} else {$enableDisconnectOnIdle = "Enabled"}
Expand All @@ -714,7 +720,7 @@ function New-AzLab {
vmSize = $Size
sharedPasswordState = $sharedPassword
templateVmState = $hasTemplateVm

installGpuDriverEnabled = $gpuDriverState
}
} | ConvertTo-Json) | Out-Null
} else {
Expand All @@ -736,6 +742,7 @@ function New-AzLab {
idleOsGracePeriod = "PT$($idleOsGracePeriod.ToString())M"
enableNoConnectShutdown = $enableNoConnectShutdown
idleNoConnectGracePeriod = "PT$($idleNoConnectGracePeriod.ToString())M"
installGpuDriverEnabled = $gpuDriverState
}
} | ConvertTo-Json) | Out-Null
}
Expand Down
35 changes: 26 additions & 9 deletions samples/ClassroomLabs/Modules/Library/Tools/LabCreator.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ $init = {
[parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
$Size,

[parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
[bool]
$GpuDriverEnabled,

[parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
[string]
$Title,
Expand All @@ -75,7 +79,7 @@ $init = {
[string]
$Password,

[parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
[parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
[bool]
$LinuxRdp,

Expand Down Expand Up @@ -106,7 +110,6 @@ $init = {
Write-Host "Start creation of $LabName"

$la = Get-AzLabAccount -ResourceGroupName $ResourceGroupName -LabAccountName $LabAccountName

$lab = $la | Get-AzLab -LabName $LabName

if ($lab) {
Expand All @@ -116,14 +119,18 @@ $init = {
else {
# Try to load shared image and then gallery image
$img = $la | Get-AzLabAccountSharedImage | Where-Object { $_.name -like $ImageName }

if(-not $img) {
$img = $la | Get-AzLabAccountGalleryImage | Where-Object { $_.name -like $ImageName }
if (-not $img -or $img.Count -ne 1) { Write-Error "$ImageName pattern doesn't match just one gallery image." }

if (-not $img -or @($img).Count -ne 1) { Write-Error "$ImageName pattern doesn't match just one gallery image." }
}
Write-Host "Image $ImageName found."

Write-Host "Linux $LinuxRdp***"

$lab = $la `
| New-AzLab -LabName $LabName -Image $img -Size $Size -UserName $UserName -Password $Password -LinuxRdpEnabled:$LinuxRdp -UsageQuotaInHours $UsageQuota `
| New-AzLab -LabName $LabName -Image $img -Size $Size -UserName $UserName -Password $Password -LinuxRdpEnabled:$LinuxRdp -InstallGpuDriverEnabled:$GpuDriverEnabled -UsageQuotaInHours $UsageQuota `
-idleGracePeriod $idleGracePeriod -idleOsGracePeriod $idleOsGracePeriod -idleNoConnectGracePeriod $idleNoConnectGracePeriod `
| Publish-AzLab `
| Set-AzLab -MaxUsers $MaxUsers -UserAccessMode $UsageMode -SharedPasswordEnabled:$SharedPassword
Expand Down Expand Up @@ -187,8 +194,8 @@ function New-Accounts {

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$modulePath = Join-Path $path '..' 'Az.LabServices.psm1'

$modulePath = Join-Path $path '..\Az.LabServices.psm1'
Import-Module $modulePath

if ((Get-AzLabAccount -ResourceGroupName $ResourceGroupName -LabAccountName $LabAccountName) -eq $null ){
Expand Down Expand Up @@ -220,12 +227,14 @@ function New-AzLabMultiple {

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$modulePath = Join-Path $path '..' 'Az.LabServices.psm1'

$modulePath = Join-Path $path '..\Az.LabServices.psm1'
Import-Module $modulePath
# Really?? It got to be the lines below? Doing a ForEach doesn't work ...
$input.movenext() | Out-Null

$obj = $input.current[0]

Write-Verbose "object inside the newazmultiple block $obj"
$obj | New-AzLabSingle
}
Expand Down Expand Up @@ -261,7 +270,15 @@ $labs | ForEach-Object {
if ($_.Emails) {
$_.Emails = ($_.Emails.Split(';')).Trim()
}
$_.LinuxRdp = [System.Convert]::ToBoolean($_.LinuxRdp)

if (Get-Member -InputObject $_ -Name 'GpuDriverEnabled') {
$_.GpuDriverEnabled = [System.Convert]::ToBoolean($_.GpuDriverEnabled)
}

if (Get-Member -InputObject $_ -Name 'LinuxRdp') {
$_.LinuxRdp = [System.Convert]::ToBoolean($_.LinuxRdp)
}

$_.SharedPassword = [System.Convert]::ToBoolean($_.SharedPassword)
if ($_.Schedules) {
Write-Host "Setting schedules for $($_.LabName)"
Expand Down

0 comments on commit d8553f7

Please sign in to comment.