mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-09-11 01:44:38 +00:00
[API] Add API to vms (#2021)
* add API to debian-vm.sh * [API] Add API calls to VMs * [API] Add API calls to VMs * [API] Add API calls to VMs * [API] Add API calls to VMs * [API] Add API calls to VMs * debian-vm.sh Co-authored-by: bvdberg01 <74251551+bvdberg01@users.noreply.github.com> * updates --------- Co-authored-by: bvdberg01 <74251551+bvdberg01@users.noreply.github.com> Co-authored-by: Rögl-Brunner Michel <Michel.Roegl-brunner@htl-braunau.int>
This commit is contained in:
parent
b9094e306e
commit
a481e89cad
13 changed files with 215 additions and 17 deletions
|
@ -4,6 +4,9 @@
|
|||
# Author: MickLesk (CanbiZ)
|
||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||
|
||||
source /dev/stdin <<< $(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func)
|
||||
|
||||
|
||||
function header_info {
|
||||
clear
|
||||
cat <<"EOF"
|
||||
|
@ -17,6 +20,12 @@ EOF
|
|||
}
|
||||
header_info
|
||||
echo -e "\n Loading..."
|
||||
#API VARIABLES
|
||||
RANDOM_UUID="$(cat /proc/sys/kernel/random/uuid)"
|
||||
METHOD=""
|
||||
NSAPP="arch-linux-vm"
|
||||
var_os="arch-linux"
|
||||
var_version=" "
|
||||
GEN_MAC=02:$(openssl rand -hex 5 | awk '{print toupper($0)}' | sed 's/\(..\)/\1:/g; s/.$//')
|
||||
NEXTID=$(pvesh get /cluster/nextid)
|
||||
|
||||
|
@ -56,10 +65,13 @@ THIN="discard=on,ssd=1,"
|
|||
set -e
|
||||
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
|
||||
trap cleanup EXIT
|
||||
trap 'post_update_to_api "failed" "INTERRUPTED"' SIGINT
|
||||
trap 'post_update_to_api "failed" "TERMINATED"' SIGTERM
|
||||
function error_handler() {
|
||||
local exit_code="$?"
|
||||
local line_number="$1"
|
||||
local command="$2"
|
||||
post_update_to_api "failed" "${commad}"
|
||||
local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}"
|
||||
echo -e "\n$error_message\n"
|
||||
cleanup_vmid
|
||||
|
@ -111,7 +123,7 @@ function check_root() {
|
|||
}
|
||||
|
||||
function pve_check() {
|
||||
if ! pveversion | grep -Eq "pve-manager/8\.[1-3](\.[0-9]+)*"; then
|
||||
if ! pveversion | grep -Eq "pve-manager/8\.[1-3](\.[0-9]+)*"; then
|
||||
msg_error "${CROSS}${RD}This version of Proxmox Virtual Environment is not supported"
|
||||
echo -e "Requires Proxmox Virtual Environment Version 8.1 or later."
|
||||
echo -e "Exiting..."
|
||||
|
@ -164,6 +176,7 @@ function default_settings() {
|
|||
VLAN=""
|
||||
MTU=""
|
||||
START_VM="yes"
|
||||
METHOD="default"
|
||||
echo -e "${CONTAINERID}${BOLD}${DGN}Virtual Machine ID: ${BGN}${VMID}${CL}"
|
||||
echo -e "${CONTAINERTYPE}${BOLD}${DGN}Machine Type: ${BGN}i440fx${CL}"
|
||||
echo -e "${DISKSIZE}${BOLD}${DGN}Disk Size: ${BGN}${DISK_SIZE}${CL}"
|
||||
|
@ -181,6 +194,7 @@ function default_settings() {
|
|||
}
|
||||
|
||||
function advanced_settings() {
|
||||
METHOD="advanced"
|
||||
while true; do
|
||||
if VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||
if [ -z "$VMID" ]; then
|
||||
|
@ -377,6 +391,7 @@ arch_check
|
|||
pve_check
|
||||
ssh_check
|
||||
start_script
|
||||
post_to_api_vm
|
||||
|
||||
msg_info "Validating Storage"
|
||||
while read -r line; do
|
||||
|
@ -493,5 +508,6 @@ if [ "$START_VM" == "yes" ]; then
|
|||
qm start $VMID
|
||||
msg_ok "Started Arch Linux VM"
|
||||
fi
|
||||
post_update_to_api "done" "none"
|
||||
|
||||
msg_ok "Completed Successfully!\n"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue