generated from a7d-corp/homelab-instance-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a single master for testing (#10)
* add a single master for testing * completely rework repo
- Loading branch information
1 parent
a458f0e
commit 1395470
Showing
5 changed files
with
125 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
pve_token_id="$${1}" | ||
pve_token="$${2}" | ||
host="$${3}" | ||
vmid="$${4}" | ||
role="$${5}" | ||
serial="$${6}" | ||
uuid="$${7}" | ||
|
||
if [[ "$${role}" == "master" ]]; then | ||
sku=${master_sku} | ||
else | ||
sku=${worker_sku} | ||
fi | ||
|
||
curl --silent --insecure -H \ | ||
"Authorization: PVEAPIToken=$${pve_token_id}=$${pve_token}" \ | ||
-X POST \ | ||
${pm_api_url}/nodes/$${host}/qemu/$${vmid}/status/stop | ||
_ret=$? | ||
|
||
if [ $_ret != 0 ]; then | ||
echo "stopping VM $${vmid} failed" | ||
exit 1 | ||
fi | ||
|
||
while ! curl --silent --insecure -H \ | ||
"Authorization: PVEAPIToken=$${pve_token_id}=$${pve_token}" \ | ||
${pm_api_url}/nodes/$${host}/qemu/$${vmid}/status/current \ | ||
| jq -r .data.status | grep -q "stopped"; \ | ||
do sleep 5 ; | ||
done | ||
|
||
curl --silent --insecure -H \ | ||
"Authorization: PVEAPIToken=$${pve_token_id}=$${pve_token}" \ | ||
-X POST --data-urlencode \ | ||
smbios1="serial=$${serial},family=${family},sku=$${sku},uuid=$${uuid}" \ | ||
${pm_api_url}/nodes/$${host}/qemu/$${vmid}/config | ||
_ret=$? | ||
|
||
if [ $_ret != 0 ]; then | ||
echo "updating smbios values for VM $${vmid} failed" | ||
exit 1 | ||
fi | ||
|
||
sleep 5 | ||
|
||
curl --silent --insecure -H \ | ||
"Authorization: PVEAPIToken=$${pve_token_id}=$${pve_token}" \ | ||
-X POST \ | ||
${pm_api_url}/nodes/$${host}/qemu/$${vmid}/status/start | ||
_ret=$? | ||
|
||
if [ $_ret != 0 ]; then | ||
echo "starting VM $${vmid} failed" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters