Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,44 @@ $MainTemplateParameters
#Write-Warning "Skipping Test..."
#break

# Helper function to recursively search for a pattern in nested objects
# Returns the top-level property name and the matching value when found
function Find-OutputProperty {
param(
[Parameter(Mandatory=$true)]
[PSObject]$Object,

[Parameter(Mandatory=$true)]
[string]$Pattern,

[Parameter(Mandatory=$false)]
[string]$TopLevelPropertyName = $null
)

foreach ($prop in $Object.psobject.properties) {
# Track the top-level property name for matching with template parameters
# This is the property name we'll use to look up in MainTemplateParameters
$topLevelName = if ($TopLevelPropertyName) { $TopLevelPropertyName } else { $prop.Name }

if ($prop.Value -is [string] -and $prop.Value -like $Pattern) {
# Found a matching string value - return the top-level property name
return [PSCustomObject]@{
Name = $topLevelName
Value = $prop.Value
}
}
elseif ($prop.Value -is [PSCustomObject] -or $prop.Value -is [System.Collections.Specialized.OrderedDictionary]) {
# Recursively search nested objects, preserving the top-level property name
$result = Find-OutputProperty -Object $prop.Value -Pattern $Pattern -TopLevelPropertyName $topLevelName
if ($result) {
return $result
}
}
}

return $null
}

# First, find all size selectors in CreateUIDefinition.
$sizeSelectors = $CreateUIDefinitionObject |
Find-JsonContent -Key type -Value Microsoft.Compute.SizeSelector
Expand All @@ -42,11 +80,9 @@ foreach ($selector in $sizeSelectors) { # Then walk each selector,
} else {
"*basics(*$($controlName)*"
}
$theOutput = foreach ($out in $CreateUIDefinitionObject.parameters.outputs.psobject.properties) {
if ($out.Value -like $lookingFor) {
$out; break
}
}

# Use the helper function to recursively search for the pattern in outputs
$theOutput = Find-OutputProperty -Object $CreateUIDefinitionObject.parameters.outputs -Pattern $lookingFor

if (-not $theOutput) {
Write-Error "Could not find VM SizeSelector '$($selector.Name)' in outputs" -TargetObject $selector
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"parameters": {
"clusters": {
"type": "object"
}
},
"resources": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
"handler": "Microsoft.Azure.CreateUIDef",
"version": "0.1.2-preview",
"parameters": {
"basics": [],
"steps": [
{
"label": "Scheduler",
"name": "scheduler",
"bladeTitle": "Scheduler",
"bladeSubtitle": "Configure Scheduler",
"elements": [
{
"label": "Scheduler Section",
"name": "schedulerSection",
"type": "Microsoft.Common.Section",
"elements": [
{
"label": "Scheduler VM Size",
"name": "vmsize",
"type": "Microsoft.Compute.SizeSelector",
"osPlatform": "Linux",
"count": 1,
"recommendedSizes": [
"Standard_B1s"
]
}
]
},
{
"label": "Login Nodes Section",
"name": "loginNodesSection",
"type": "Microsoft.Common.Section",
"elements": [
{
"label": "Login Node VM Size",
"name": "vmsize",
"type": "Microsoft.Compute.SizeSelector",
"osPlatform": "Linux",
"count": 1,
"recommendedSizes": [
"Standard_B1ms"
]
}
]
}
]
},
{
"label": "Slurm Settings",
"name": "slurmSettings",
"bladeTitle": "Slurm Settings",
"elements": [
{
"label": "HTC Section",
"name": "HTCSection",
"type": "Microsoft.Common.Section",
"elements": [
{
"label": "HTC VM Size",
"name": "vmsize",
"type": "Microsoft.Compute.SizeSelector",
"osPlatform": "Linux",
"count": 1,
"recommendedSizes": [
"Standard_B2s"
]
}
]
}
]
}
],
"outputs": {
"location": "[location()]",
"clusters": {
"slurm": {
"schedulerNode": {
"sku": "[steps('scheduler').schedulerSection.vmsize]"
},
"loginNodes": {
"sku": "[steps('scheduler').loginNodesSection.vmsize]"
},
"htc": {
"sku": "[steps('slurmSettings').HTCSection.vmsize]"
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"parameters": {
"clusters": {
"type": "object"
}
},
"resources": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
"handler": "Microsoft.Azure.CreateUIDef",
"version": "0.1.2-preview",
"parameters": {
"basics": [],
"steps": [
{
"label": "Scheduler",
"name": "scheduler",
"bladeTitle": "Scheduler",
"bladeSubtitle": "Configure Scheduler",
"subLabel": {
"preValidation": "Configure Scheduler",
"postValidation": "Done"
},
"elements": [
{
"label": "Scheduler Section",
"name": "schedulerSection",
"type": "Microsoft.Common.Section",
"elements": [
{
"label": "VM Size",
"name": "vmsize",
"toolTip": "Scheduler VM size",
"type": "Microsoft.Compute.SizeSelector",
"osPlatform": "Linux",
"count": 1,
"recommendedSizes": [
"Standard_B1s",
"Standard_B1ms"
]
}
]
}
]
}
],
"outputs": {
"location": "[location()]",
"clusters": {
"schedulerNode": {
"sku": "[steps('scheduler').schedulerSection.vmsize]"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"parameters": {
"clusters": {
"type": "object"
}
},
"resources": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
"handler": "Microsoft.Azure.CreateUIDef",
"version": "0.1.2-preview",
"parameters": {
"basics": [],
"steps": [
{
"label": "Scheduler",
"name": "scheduler",
"bladeTitle": "Scheduler",
"bladeSubtitle": "Configure Scheduler",
"subLabel": {
"preValidation": "Configure Scheduler",
"postValidation": "Done"
},
"elements": [
{
"label": "Scheduler Section",
"name": "schedulerSection",
"type": "Microsoft.Common.Section",
"elements": [
{
"label": "VM Size",
"name": "vmsize",
"toolTip": "Scheduler VM size",
"type": "Microsoft.Compute.SizeSelector",
"osPlatform": "Linux",
"count": 1,
"recommendedSizes": [
"Standard_B1s",
"Standard_B1ms"
]
}
]
}
]
}
],
"outputs": {
"location": "[location()]",
"clusters": {
"slurm": {
"schedulerNode": {
"sku": "[steps('scheduler').schedulerSection.vmsize]"
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"parameters": {
"clusters": {
"type": "object"
}
},
"resources": []
}
Loading