Skip to content

Commit

Permalink
Merge pull request #459 from microsoft/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
jaromirk authored Sep 27, 2021
2 parents 7694bf4 + 64b3253 commit 4847a33
Show file tree
Hide file tree
Showing 19 changed files with 543 additions and 465 deletions.
264 changes: 196 additions & 68 deletions Scenarios/AzSHCI Deployment/Scenario.ps1

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions Scenarios/AzSHCI and MDT/LabConfig.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
$LabConfig=@{ DomainAdminName='LabAdmin'; AdminPassword='LS1setup!' ; <#Prefix = 'WSLab-'#> ; DCEdition='4'; Internet=$true ; TelemetryLevel='Full' ; TelemetryNickname='' ; AdditionalNetworksConfig=@(); VMs=@()}
$LabConfig=@{<#SwitchNics="NIC1","NIC2";#> DomainAdminName='LabAdmin'; AdminPassword='LS1setup!' <#;Prefix = 'WSLab-'#> ; DCEdition='4'; Internet=$true ; TelemetryLevel='Full' ; TelemetryNickname='' ; AdditionalNetworksConfig=@(); VMs=@()}

#MDT machine (GUI is needed as Core does not have WDSUtil)
$LabConfig.VMs += @{ VMName = 'MDT' ; Configuration = 'S2D' ; ParentVHD = 'Win2022_G2.vhdx' ; SSDNumber = 1; SSDSize=1TB ; MGMTNICs=1 }

#Management machine
$LabConfig.VMs += @{ VMName = 'Management' ; ParentVHD = 'Win2022_G2.vhdx' ; MGMTNICs=1 }

#optional Windows 11 machine for management
$LabConfig.VMs += @{ VMName = 'Win11' ; ParentVHD = 'Win1121H2_G2.vhdx' ; MGMTNICs=1}
#$LabConfig.VMs += @{ VMName = 'Win11' ; ParentVHD = 'Win1121H2_G2.vhdx' ; MGMTNICs=1}

133 changes: 104 additions & 29 deletions Scenarios/AzSHCI and MDT/Scenario.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,11 @@
New-Item -Path $using:DeploymentShareLocation -ItemType Directory -ErrorAction Ignore
New-SmbShare -Name "DeploymentShare$" -Path "$using:DeploymentShareLocation" -FullAccess Administrators
}
Start-Sleep 5
#map MDT deployment share as PSDrive
New-PSDrive -Name "DS001" -PSProvider "MDTProvider" -Root "\\$MDTServer\DeploymentShare$" -Description "MDT Deployment Share" -NetworkPath "\\$MDTServer\DeploymentShare$" -Verbose | add-MDTPersistentDrive -Verbose

#sometimes happens that script to complains: The process cannot access the file '\\MDT\DeploymentShare$\Control\Settings.xml' because it is being used by another process.
do{
New-PSDrive -Name "DS001" -PSProvider "MDTProvider" -Root "\\$MDTServer\DeploymentShare$" -Description "MDT Deployment Share" -NetworkPath "\\$MDTServer\DeploymentShare$" -Verbose | add-MDTPersistentDrive -Verbose
}until (get-psdrive -Name DS001)
#Configure SQL Services

Invoke-Command -ComputerName $MDTServer -scriptblock {
Expand Down Expand Up @@ -888,8 +889,8 @@ foreach ($idrac_ip in $idrac_ips){
#in real world scenairos you can have hash table like this:
<#
$HVHosts = @()
$HVHosts+=@{ComputerName="AxNode1" ;IPAddress="10.0.0.120" ; MACAddress="0C:42:A1:DD:57:DD" ; GUID="4C4C4544-004D-5410-8031-B4C04F373733"}
$HVHosts+=@{ComputerName="AxNode2" ;IPAddress="10.0.0.121" ; MACAddress="0C:42:A1:DD:57:C9" ; GUID="4C4C4544-004D-5410-8033-B4C04F373733"}
$HVHosts+=@{ComputerName="AxNode1" ;IPAddress="10.0.0.120" ; MACAddress="0C:42:A1:DD:57:DC" ; GUID="4C4C4544-004D-5410-8031-B4C04F373733"}
$HVHosts+=@{ComputerName="AxNode2" ;IPAddress="10.0.0.121" ; MACAddress="0C:42:A1:DD:57:C8" ; GUID="4C4C4544-004D-5410-8033-B4C04F373733"}
#>

#grab machines that attempted to boot in last 5 minutes and create hash table.
Expand Down Expand Up @@ -1047,32 +1048,106 @@ $TextToSearch

#region update task sequence with drivers

#Dell driver catalog https://downloads.dell.com/catalog/ASHCI-Catalog.xml.gz
#Download catalog
Start-BitsTransfer -Source "https://downloads.dell.com/catalog/ASHCI-Catalog.xml.gz" -Destination "$env:UserProfile\Downloads\ASHCI-Catalog.xml.gz"
#unzip gzip https://scatteredcode.net/download-and-extract-gzip-tar-with-powershell/
Function Expand-GZipArchive{
Param(
$infile,
$outfile = ($infile -replace '\.gz$','')
)
$input = New-Object System.IO.FileStream $inFile, ([IO.FileMode]::Open), ([IO.FileAccess]::Read), ([IO.FileShare]::Read)
$output = New-Object System.IO.FileStream $outFile, ([IO.FileMode]::Create), ([IO.FileAccess]::Write), ([IO.FileShare]::None)
$gzipStream = New-Object System.IO.Compression.GzipStream $input, ([IO.Compression.CompressionMode]::Decompress)
$buffer = New-Object byte[](1024)
while($true){
$read = $gzipstream.Read($buffer, 0, 1024)
if ($read -le 0){break}
$output.Write($buffer, 0, $read)
#Download DSU
#https://github.com/DellProSupportGse/Tools/blob/main/DART.ps1

#grab DSU links from Dell website
$URL="https://dl.dell.com/omimswac/dsu/"
$Results=Invoke-WebRequest $URL -UseDefaultCredentials
$Links=$results.Links.href | Select-Object -Skip 1
#create PSObject from results
$DSUs=@()
foreach ($Link in $Links){
$DSUs+=[PSCustomObject]@{
Link = "https://dl.dell.com$Link"
Version = $link -split "_" | Select-Object -Last 2 | Select-Object -First 1
}
$gzipStream.Close()
$output.Close()
$input.Close()
}
Expand-GZipArchive "$env:UserProfile\Downloads\ASHCI-Catalog.xml.gz" "$env:UserProfile\Downloads\ASHCI-Catalog.xml"
#load xml
[xml]$xml=Get-Content "$env:UserProfile\Downloads\ASHCI-Catalog.xml"
}
#download latest to separate folder
$LatestDSU=$DSUs | Sort-Object Version | Select-Object -Last 1
$Folder="$env:USERPROFILE\Downloads\DSU"
if (-not (Test-Path $Folder)){New-Item -Path $Folder -ItemType Directory}
Start-BitsTransfer -Source $LatestDSU.Link -Destination $Folder\DSU.exe

#add DSU as application to MDT
Import-Module "C:\Program Files\Microsoft Deployment Toolkit\bin\MicrosoftDeploymentToolkit.psd1"
if (-not(Get-PSDrive -Name ds001 -ErrorAction Ignore)){
New-PSDrive -Name "DS001" -PSProvider "MDTProvider" -Root "\\$MDTServer\DeploymentShare$" -Description "MDT Deployment Share" -NetworkPath "\\$MDTServer\DeploymentShare$" -Verbose | add-MDTPersistentDrive -Verbose
}
$AppName="Dell DSU $($LatestDSU.Version)"
Import-MDTApplication -path "DS001:\Applications" -enable "True" -Name $AppName -ShortName "DSU" -Version $LatestDSU.Version -Publisher "Dell" -Language "" -CommandLine "DSU.exe /silent" -WorkingDirectory ".\Applications\$AppName" -ApplicationSourcePath $Folder -DestinationFolder $AppName -Verbose
#grap package ID for role config
$DSUID=(Get-ChildItem -Path DS001:\Applications | Where-Object Name -eq $AppName).GUID

#download catalog and create answer file to run DSU
#Dell Azure Stack HCI driver catalog https://downloads.dell.com/catalog/ASHCI-Catalog.xml.gz
#Download catalog
Start-BitsTransfer -Source "https://downloads.dell.com/catalog/ASHCI-Catalog.xml.gz" -Destination "$env:UserProfile\Downloads\ASHCI-Catalog.xml.gz"
#unzip gzip to a folder https://scatteredcode.net/download-and-extract-gzip-tar-with-powershell/
$Folder="$env:USERPROFILE\Downloads\DSUPackage"
if (-not (Test-Path $Folder)){New-Item -Path $Folder -ItemType Directory}
Function Expand-GZipArchive{
Param(
$infile,
$outfile = ($infile -replace '\.gz$','')
)
$input = New-Object System.IO.FileStream $inFile, ([IO.FileMode]::Open), ([IO.FileAccess]::Read), ([IO.FileShare]::Read)
$output = New-Object System.IO.FileStream $outFile, ([IO.FileMode]::Create), ([IO.FileAccess]::Write), ([IO.FileShare]::None)
$gzipStream = New-Object System.IO.Compression.GzipStream $input, ([IO.Compression.CompressionMode]::Decompress)
$buffer = New-Object byte[](1024)
while($true){
$read = $gzipstream.Read($buffer, 0, 1024)
if ($read -le 0){break}
$output.Write($buffer, 0, $read)
}
$gzipStream.Close()
$output.Close()
$input.Close()
}
Expand-GZipArchive "$env:UserProfile\Downloads\ASHCI-Catalog.xml.gz" "$folder\ASHCI-Catalog.xml"
#create answerfile for DU
$content='@
a
c
@'
Set-Content -Path "$folder\answer.txt" -Value $content -NoNewline
$content='"C:\Program Files\Dell\DELL EMC System Update\DSU.exe" --catalog-location=ASHCI-Catalog.xml --apply-upgrades <answer.txt'
Set-Content -Path "$folder\install.cmd" -Value $content -NoNewline

#add package to MDT
[xml]$xml=Get-Content "$folder\ASHCI-Catalog.xml"
$version=$xml.Manifest.version
$AppName="Dell DSU AzSHCI Package $Version"
$Commandline="install.cmd"
Import-MDTApplication -path "DS001:\Applications" -enable "True" -Name $AppName -ShortName "DSUAzSHCIPackage" -Version $Version -Publisher "Dell" -Language "" -CommandLine $Commandline -WorkingDirectory ".\Applications\$AppName" -ApplicationSourcePath $Folder -DestinationFolder $AppName -Verbose
#configure app to reboot after run
Set-ItemProperty -Path DS001:\Applications\$AppName -Name Reboot -Value "True"
#configure dependency on DSU
$guids=@()
$guids+=$DSUID
Set-ItemProperty -Path DS001:\Applications\$AppName -Name Dependency -Value $guids
#grap package ID for role config
$DSUPackageID=(Get-ChildItem -Path DS001:\Applications | Where-Object Name -eq $AppName).GUID

#Create Role
$RoleName="AXNodeDrivers"
if (-not (Get-MDTRole -name $RoleName)){
New-MDTRole -name $RoleName -settings @{
OSInstall ='YES'
}
}
#Add apps to role
$ID=(get-mdtrole -name $RoleName).ID
Set-MDTRoleApplication -id $ID -applications $DSUID,$DSUPackageID

#add role that will install drivers to AX computers
foreach ($HVHost in $HVHosts){
$MDTComputer=Get-MDTComputer -macAddress $HVHost.MACAddress
$Roles=($MDTComputer | Get-MDTComputerRole).Role
$Roles+=$RoleName
#Get-MDTComputer -macAddress $HVHost.MACAddress | Set-MDTComputerRole -roles JoinDomain,AZSHCI
$MDTComputer | Set-MDTComputerRole -roles $Roles
}
#download catalog drivers <TBD>
<#
#Create output folder
Expand Down
102 changes: 102 additions & 0 deletions Scenarios/AzSHCI and VMFleet/Scenario.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#Run from DC or Management machine

#region Variables and prerequisites
$ClusterName="AzSHCI-Cluster"
$Nodes=(Get-ClusterNode -Cluster $ClusterName).Name
$VolumeSize=1TB

Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Install-Module -Name VMFleet -Force
Install-Module -Name PrivateCloud.DiagnosticInfo -Force

#Make sure Hyper-V is installed (to be able to work with VHD)
$Result=Install-WindowsFeature -Name "Hyper-V" -ErrorAction SilentlyContinue
if ($result.ExitCode -eq "failed"){
Enable-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V -Online -NoRestart
}
#endregion

#region Configure VMFleet prereqs
#Create Volumes
Foreach ($Node in $Nodes){
if (-not (Get-Virtualdisk -CimSession $ClusterName -FriendlyName $Node)){
New-Volume -CimSession $Node -StoragePoolFriendlyName "S2D on $ClusterName" -FileSystem CSVFS_ReFS -FriendlyName $Node -Size $VolumeSize
}
}

if (-not (Get-Virtualdisk -CimSession $ClusterName -FriendlyName Collect)){
New-Volume -CimSession $CLusterName -StoragePoolFriendlyName "S2D on $ClusterName" -FileSystem CSVFS_ReFS -FriendlyName Collect -Size 100GB
}

#Ask for VHD
Write-Output "Please select VHD created using CreateVMFleetImage"
[reflection.assembly]::loadwithpartialname("System.Windows.Forms")
$openFile = New-Object System.Windows.Forms.OpenFileDialog -Property @{
Title="Please select VHD created by convert-windowsimage. Click cancel if you want to create it"
}
$openFile.Filter = "vhdx files (*.vhdx)|*.vhdx|All files (*.*)|*.*"
If($openFile.ShowDialog() -eq "OK"){
Write-Output "File $($openfile.FileName) selected"
}
$VHDPath=$openfile.FileName

#Copy VHD to collect folder
Copy-Item -Path $VHDPath -Destination \\$ClusterName\ClusterStorage$\Collect\
#Copy VMFleet to cluster nodes
$Sessions=New-PSSession -ComputerName $Nodes
Foreach ($Session in $Sessions){
Copy-Item -Recurse -Path "C:\Program Files\WindowsPowerShell\Modules\VMFleet" -Destination "C:\Program Files\WindowsPowerShell\Modules\" -ToSession $Session -Force
}
#endregion

#region install and create VMFleet
$VHDName=$VHDPath | Split-Path -Leaf
#Grab nubmer of Logical Processors per node divided by 2
$NumberOfVMs=(Get-CimInstance -CimSession $ClusterName -ClassName Win32_ComputerSystem).NumberOfLogicalProcessors/2

#Enable CredSSP
# Temporarily enable CredSSP delegation to avoid double-hop issue
foreach ($Node in $Nodes){
Enable-WSManCredSSP -Role "Client" -DelegateComputer $Node -Force
}
Invoke-Command -ComputerName $Nodes -ScriptBlock { Enable-WSManCredSSP Server -Force }

$password = ConvertTo-SecureString "LS1setup!" -AsPlainText -Force
$Credentials = New-Object System.Management.Automation.PSCredential ("CORP\LabAdmin", $password)

Invoke-Command -ComputerName $Nodes[0] -Credential $Credentials -Authentication Credssp -ScriptBlock {
Install-Fleet #as vmfleet has issues with Install-Fleet -ClusterName https://github.com/microsoft/diskspd/issues/157
#It's probably more convenient to run this command on cluster as all VHD copying will happen on cluster itself.
New-Fleet -BaseVHD "c:\ClusterStorage\Collect\$using:VHDName" -VMs $using:NumberOfVMs -AdminPass P@ssw0rd -Admin Administrator -ConnectUser corp\LabAdmin -ConnectPass LS1setup!
}

# Disable CredSSP
Disable-WSManCredSSP -Role Client
Invoke-Command -ComputerName $nodes -ScriptBlock { Disable-WSManCredSSP Server }
#endregion

#region Measure Performance
#make sure PrivateCloud.DiagnosticInfo is present
$Nodes=(Get-ClusterNode -Cluster $ClusterName).Name
$Sessions=New-PSSession $Nodes
foreach ($Session in $Sessions){
Copy-Item -Path 'C:\Program Files\WindowsPowerShell\Modules\PrivateCloud.DiagnosticInfo' -Destination 'C:\Program Files\WindowsPowerShell\Modules\' -ToSession $Session -Recurse -Force
}

# Temporarily enable CredSSP delegation to avoid double-hop issue
foreach ($Node in $Nodes){
Enable-WSManCredSSP -Role "Client" -DelegateComputer $Node -Force
}
Invoke-Command -ComputerName $Nodes -ScriptBlock { Enable-WSManCredSSP Server -Force }

$password = ConvertTo-SecureString "LS1setup!" -AsPlainText -Force
$Credentials = New-Object System.Management.Automation.PSCredential ("CORP\LabAdmin", $password)

Invoke-Command -ComputerName $Nodes[0] -Credential $Credentials -Authentication Credssp -ScriptBlock {
Measure-FleetCoreWorkload
}

# Disable CredSSP
Disable-WSManCredSSP -Role Client
Invoke-Command -ComputerName $nodes -ScriptBlock { Disable-WSManCredSSP Server }
#endregion
Empty file.
Binary file removed Scenarios/VMFleet/Screenshots/Error_wrongVHD.png
Binary file not shown.
Binary file removed Scenarios/VMFleet/Screenshots/Error_wrongVHD1.png
Binary file not shown.
Binary file removed Scenarios/VMFleet/Screenshots/ToolsVHD.png
Binary file not shown.
Binary file removed Scenarios/VMFleet/Screenshots/VMFleet_Step1.png
Binary file not shown.
Binary file removed Scenarios/VMFleet/Screenshots/VMFleet_Step2.png
Binary file not shown.
Binary file removed Scenarios/VMFleet/Screenshots/VMFleet_Step3.png
Binary file not shown.
Binary file removed Scenarios/VMFleet/Screenshots/VMFleet_Step4.png
Binary file not shown.
Binary file removed Scenarios/VMFleet/Screenshots/VMFleet_Step5.png
Binary file not shown.
Binary file removed Scenarios/VMFleet/Screenshots/VMfleetInAction.png
Binary file not shown.
Binary file removed Scenarios/VMFleet/Screenshots/scenario.png
Binary file not shown.
68 changes: 0 additions & 68 deletions Scenarios/VMFleet/readme.md

This file was deleted.

Loading

0 comments on commit 4847a33

Please sign in to comment.