Skip to content

Commit 0838779

Browse files
committed
Moved ps1 files into new powercli directory
1 parent 29d9e49 commit 0838779

File tree

3 files changed

+10
-85
lines changed

3 files changed

+10
-85
lines changed
File renamed without changes.

upi/vsphere/upi-functions.ps1 renamed to upi/vsphere/powercli/upi-functions.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ function New-OpenshiftVMs {
219219
}
220220

221221
$jobs += Start-ThreadJob -n "create-vm-$($metadata.infraID)-$($key)" -ScriptBlock {
222-
param($key,$node,$vm_template,$metadata,$tag)
222+
param($key,$node,$vm_template,$metadata,$tag,$scriptdir)
223223
. .\variables.ps1
224-
. .\upi-functions.ps1
224+
. ${scriptdir}\upi-functions.ps1
225225
Connect-VIServer -Server $vcenter -Credential (Import-Clixml $vcentercredpath)
226226

227227
$name = "$($metadata.infraID)-$($key)"
@@ -280,7 +280,7 @@ function New-OpenshiftVMs {
280280
else {
281281
$vm | Start-VM
282282
}
283-
} -ArgumentList @($key,$node,$vm_template,$metadata,$tag)
283+
} -ArgumentList @($key,$node,$vm_template,$metadata,$tag,$SCRIPTDIR)
284284
Write-Progress -id 222 -Activity "Creating virtual machines" -PercentComplete ($vmStep * $vmCount)
285285
$vmCount++
286286
}

upi/vsphere/upi.ps1 renamed to upi/vsphere/powercli/upi.ps1

Lines changed: 7 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/usr/bin/pwsh
22

3+
$MYINV = $MyInvocation
4+
$SCRIPTDIR = split-path $MYINV.MyCommand.Path
5+
36
. .\variables.ps1
4-
. .\upi-functions.ps1
7+
. ${SCRIPTDIR}\upi-functions.ps1
58

69
$ErrorActionPreference = "Stop"
710

@@ -183,9 +186,9 @@ foreach ($fd in $fds)
183186
$ovfConfig.NetworkMapping.VM_Network.Value = $fd.network
184187
Write-Output "OVF: $($ovfConfig)"
185188
$jobs += Start-ThreadJob -n "upload-template-$($fd.cluster)" -ScriptBlock {
186-
param($Version,$vm_template,$ovfConfig,$vmhost,$datastoreInfo,$folder,$tag)
189+
param($Version,$vm_template,$ovfConfig,$vmhost,$datastoreInfo,$folder,$tag,$scriptdir)
187190
. .\variables.ps1
188-
. .\upi-functions.ps1
191+
. ${scriptdir}\upi-functions.ps1
189192
Write-Output "Version: $($Version)"
190193
Write-Output "VM Template: $($vm_template)"
191194
Write-Output "OVF Config: $($ovfConfig)"
@@ -209,7 +212,7 @@ foreach ($fd in $fds)
209212
New-AdvancedSetting -Entity $template -name "disk.EnableUUID" -value 'TRUE' -confirm:$false -Force > $null
210213
New-AdvancedSetting -Entity $template -name "guestinfo.ignition.config.data.encoding" -value "base64" -confirm:$false -Force > $null
211214
#$snapshot = New-Snapshot -VM $template -Name "linked-clone" -Description "linked-clone" -Memory -Quiesce
212-
} -ArgumentList @($Version,$vm_template,$ovfConfig,$vmhost,$datastoreInfo,$folder,$tag)
215+
} -ArgumentList @($Version,$vm_template,$ovfConfig,$vmhost,$datastoreInfo,$folder,$tag,$SCRIPTDIR)
213216
}
214217
}
215218

@@ -248,84 +251,6 @@ Write-Progress -id 222 -Activity "Creating virtual machines" -PercentComplete 0
248251
New-OpenshiftVMs "bootstrap"
249252
New-OpenshiftVMs "master"
250253
New-OpenshiftVMs "worker"
251-
<#
252-
$jobs = @()
253-
$vmStep = (100 / $vmHash.virtualmachines.Count)
254-
$vmCount = 1
255-
foreach ($key in $vmHash.virtualmachines.Keys) {
256-
$node = $vmHash.virtualmachines[$key]
257-
258-
$jobs += Start-ThreadJob -n "create-vm-$($metadata.infraID)-$($key)" -ScriptBlock {
259-
param($key,$node,$vm_template,$metadata,$tag)
260-
. .\variables.ps1
261-
. .\upi-functions.ps1
262-
Connect-VIServer -Server $vcenter -Credential (Import-Clixml $vcentercredpath)
263-
264-
$name = "$($metadata.infraID)-$($key)"
265-
Write-Output "Creating $($name)"
266-
267-
$rp = Get-ResourcePool -Name $($metadata.infraID) -Location $(Get-Cluster -Name $($node.cluster)) -Server $vcenter
268-
##$datastore = Get-Datastore -Name $node.datastore -Server $node.server
269-
$datastoreInfo = Get-Datastore -Name $node.datastore -Location $node.datacenter
270-
271-
# Pull network config for each node
272-
if ($node.type -eq "master") {
273-
$numCPU = $control_plane_num_cpus
274-
$memory = $control_plane_memory
275-
} elseif ($node.type -eq "worker") {
276-
$numCPU = $compute_num_cpus
277-
$memory = $compute_memory
278-
} else {
279-
# should only be bootstrap
280-
$numCPU = $control_plane_num_cpus
281-
$memory = $control_plane_memory
282-
}
283-
$ip = $node.ip
284-
$network = New-VMNetworkConfig -Hostname $name -IPAddress $ip -Netmask $netmask -Gateway $gateway -DNS $dns
285-
286-
# Get the content of the ignition file per machine type (bootstrap, master, worker)
287-
$bytes = Get-Content -Path "./$($node.type).ign" -AsByteStream
288-
$ignition = [Convert]::ToBase64String($bytes)
289-
290-
# Get correct template / folder
291-
$folder = Get-Folder -Name $metadata.infraID -Location $node.datacenter
292-
$template = Get-VM -Name $vm_template -Location $($node.datacenter)
293-
294-
# Clone the virtual machine from the imported template
295-
#$vm = New-OpenShiftVM -Template $template -Name $name -ResourcePool $rp -Datastore $datastoreInfo -Location $folder -LinkedClone -ReferenceSnapshot $snapshot -IgnitionData $ignition -Tag $tag -Networking $network -NumCPU $numCPU -MemoryMB $memory
296-
$vm = New-OpenShiftVM -Template $template -Name $name -ResourcePool $rp -Datastore $datastoreInfo -Location $folder -IgnitionData $ignition -Tag $tag -Networking $network -Network $node.network -NumCPU $numCPU -MemoryMB $memory
297-
298-
# Assign tag so we can later clean up
299-
# New-TagAssignment -Entity $vm -Tag $tag
300-
# New-AdvancedSetting -Entity $vm -name "guestinfo.ignition.config.data" -value $ignition -confirm:$false -Force > $null
301-
# New-AdvancedSetting -Entity $vm -name "guestinfo.hostname" -value $name -Confirm:$false -Force > $null
302-
303-
if ($node.type -eq "master" -And $delayVMStart) {
304-
# To give bootstrap some time to start, lets wait 2 minutes
305-
Start-ThreadJob -ThrottleLimit 5 -InputObject $vm {
306-
Start-Sleep -Seconds 90
307-
$input | Start-VM
308-
}
309-
} elseif ($node.type -eq "worker" -And $delayVMStart) {
310-
# Workers are not needed right away, gotta wait till masters
311-
# have started machine-server. wait 7 minutes to start.
312-
Start-ThreadJob -ThrottleLimit 5 -InputObject $vm {
313-
Start-Sleep -Seconds 600
314-
$input | Start-VM
315-
}
316-
}
317-
else {
318-
$vm | Start-VM
319-
}
320-
} -ArgumentList @($key,$node,$vm_template,$metadata,$tag)
321-
Write-Progress -id 222 -Activity "Creating virtual machines" -PercentComplete ($vmStep * $vmCount)
322-
$vmCount++
323-
}
324-
Wait-Job -Job $jobs
325-
foreach ($job in $jobs) {
326-
Receive-Job -Job $job
327-
}
328-
#>
329254
Write-Progress -id 222 -Activity "Completed virtual machines" -PercentComplete 100 -Completed
330255

331256
## This is nice to have to clear screen when doing things manually. Maybe i'll

0 commit comments

Comments
 (0)