in frontend/src/old-pages/Configure/util.tsx [22:133]
function loadTemplateLazy(config: any, callback?: () => void) {
const loadingPath = ['app', 'wizard', 'source', 'loading']
const subnets = getState(['aws', 'subnets']) || []
const keypairs = getState(['aws', 'keypairs']) || []
const keypairNames = new Set(keypairs.map((kp: any) => kp.KeyName))
const keypairPath = ['HeadNode', 'Ssh', 'KeyName']
const version = getState(['app', 'version', 'full'])
const defaultRegion = getState(['aws', 'region'])
if (getIn(config, ['Image', 'CustomAmi']))
setState(['app', 'wizard', 'customAMI', 'enabled'], true)
if (!getIn(config, ['Image', 'Os']) && !getIn(config, ['Image', 'CustomAmi']))
config = setIn(config, ['Image', 'Os'], 'alinux2')
if (!getIn(config, ['Scheduling', 'Scheduler']))
config = setIn(config, ['Scheduling', 'Scheduler'], 'slurm')
if (!getIn(config, ['HeadNode', 'InstanceType']))
config = setIn(config, ['HeadNode', 'InstanceType'], 't2.micro')
const subnetIndex = subnets.reduce((acc: any, subnet: any) => {
acc[subnet.SubnetId] = subnet.VpcId
return acc
}, {})
if (getIn(config, ['HeadNode', 'Networking', 'SubnetId'])) {
const vpc = getIn(subnetIndex, [
getIn(config, ['HeadNode', 'Networking', 'SubnetId']),
])
if (vpc) setState(['app', 'wizard', 'vpc'], vpc)
}
if (getIn(config, ['DirectoryService']))
setState(['app', 'wizard', 'multiUser'], true)
else clearState(['app', 'wizard', 'multiUser'])
const storages = (getIn(config, ['SharedStorage']) as Storages) || []
const uiSettings = mapStorageToUiSettings(storages)
setState(['app', 'wizard', 'storage', 'ui'], uiSettings)
if (getIn(config, ['Scheduling', 'SlurmQueues'])) {
let queues = getIn(config, ['Scheduling', 'SlurmQueues'])
for (let i = 0; i < queues.length; i++) {
let computeResources = getIn(config, [
'Scheduling',
'SlurmQueues',
i,
'ComputeResources',
])
computeResources = mapComputeResources(
version,
defaultRegion,
computeResources,
)
config = setIn(
config,
['Scheduling', 'SlurmQueues', i, 'ComputeResources'],
computeResources,
)
for (let j = 0; j < computeResources.length; j++) {
if (
getIn(config, [
'Scheduling',
'SlurmQueues',
i,
'ComputeResources',
j,
'Efa',
'Enabled',
])
) {
let gdr = getIn(config, [
'Scheduling',
'SlurmQueues',
i,
'ComputeResources',
j,
'Efa',
'GdrSupport',
])
if (gdr !== true && gdr !== false)
config = setIn(
config,
[
'Scheduling',
'SlurmQueues',
i,
'ComputeResources',
j,
'Efa',
'GdrSupport',
],
true,
)
}
}
}
}
// Don't override defaults
setState(['app', 'wizard', 'loaded'], true)
setState(['app', 'wizard', 'config'], config)
if (keypairs.length > 0 && !keypairNames.has(getIn(config, keypairPath)))
setState(['app', 'wizard', 'config', ...keypairPath], keypairs[0].KeyName)
setState(['app', 'wizard', 'page'], 'cluster')
console.log('config: ', getState(['app', 'wizard', 'config']))
setState(loadingPath, false)
callback && callback()
}