forked from Fediversity/Fediversity
Make API URL an argument of the provisioning script
This commit is contained in:
parent
5c7ac44387
commit
9e95287715
2 changed files with 14 additions and 10 deletions
|
@ -4,8 +4,6 @@ set -euC
|
||||||
################################################################################
|
################################################################################
|
||||||
## Constants
|
## Constants
|
||||||
|
|
||||||
readonly api_url=https://192.168.51.81:8006/api2/json
|
|
||||||
|
|
||||||
## FIXME: There seems to be a problem with file upload where the task is
|
## FIXME: There seems to be a problem with file upload where the task is
|
||||||
## registered to `node051` no matter what node we are actually uploading to? For
|
## registered to `node051` no matter what node we are actually uploading to? For
|
||||||
## now, let us just use `node051` everywhere.
|
## now, let us just use `node051` everywhere.
|
||||||
|
@ -17,6 +15,7 @@ mkdir $tmpdir
|
||||||
################################################################################
|
################################################################################
|
||||||
## Parse arguments
|
## Parse arguments
|
||||||
|
|
||||||
|
api_url=
|
||||||
username=
|
username=
|
||||||
password=
|
password=
|
||||||
sockets=1
|
sockets=1
|
||||||
|
@ -31,6 +30,7 @@ help () {
|
||||||
Usage: $0 [OPTION...] ID [ID...]
|
Usage: $0 [OPTION...] ID [ID...]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
--api-url STR Base URL of the Proxmox API (required)
|
||||||
--username STR Username, with provider (eg. niols@pve; required)
|
--username STR Username, with provider (eg. niols@pve; required)
|
||||||
--password STR Password (required)
|
--password STR Password (required)
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ Options:
|
||||||
Options can also be provided by adding assignments to a '.proxmox' file in the
|
Options can also be provided by adding assignments to a '.proxmox' file in the
|
||||||
current working directory. For instance, it could contain:
|
current working directory. For instance, it could contain:
|
||||||
|
|
||||||
|
api_url=https://192.168.51.81:8006/api2/json
|
||||||
cores=7
|
cores=7
|
||||||
username=mireille@pve
|
username=mireille@pve
|
||||||
debug=true
|
debug=true
|
||||||
|
@ -55,7 +56,7 @@ EOF
|
||||||
# shellcheck disable=SC2059
|
# shellcheck disable=SC2059
|
||||||
die () { printf '\033[31m'; printf "$@"; printf '\033[0m\n'; exit 2; }
|
die () { printf '\033[31m'; printf "$@"; printf '\033[0m\n'; exit 2; }
|
||||||
# shellcheck disable=SC2059
|
# shellcheck disable=SC2059
|
||||||
die_with_help () { printf '\033[31m'; printf "$@"; printf '\033[0m\n'; help; exit 2; }
|
die_with_help () { printf '\033[31m'; printf "$@"; printf '\033[0m\n\n'; help; exit 2; }
|
||||||
|
|
||||||
# shellcheck disable=SC2059
|
# shellcheck disable=SC2059
|
||||||
debug () { if $debug; then printf >&2 '\033[37m'; printf >&2 "$@"; printf >&2 '\033[0m\n'; fi }
|
debug () { if $debug; then printf >&2 '\033[37m'; printf >&2 "$@"; printf >&2 '\033[0m\n'; fi }
|
||||||
|
@ -68,6 +69,7 @@ while [ $# -gt 0 ]; do
|
||||||
argument=$1
|
argument=$1
|
||||||
shift
|
shift
|
||||||
case $argument in
|
case $argument in
|
||||||
|
--api-url|--api_url) readonly api_url="$1"; shift ;;
|
||||||
--username) readonly username="$1"; shift ;;
|
--username) readonly username="$1"; shift ;;
|
||||||
--password) readonly password="$1"; shift ;;
|
--password) readonly password="$1"; shift ;;
|
||||||
|
|
||||||
|
@ -86,11 +88,11 @@ while [ $# -gt 0 ]; do
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -z "$vm_ids" ]; then
|
if [ -z "$vm_ids" ]; then
|
||||||
die_with_help "Required: at least one VM id.\n"
|
die_with_help "Required: at least one VM id."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$username" ] || [ -z "$password" ]; then
|
if [ -z "$api_url" ] || [ -z "$username" ] || [ -z "$password" ]; then
|
||||||
die_with_help "Required: '--username' and '--password'.\n"
|
die_with_help "Required: '--api-url', '--username' and '--password'."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
readonly sockets
|
readonly sockets
|
||||||
|
|
|
@ -4,8 +4,6 @@ set -euC
|
||||||
################################################################################
|
################################################################################
|
||||||
## Constants
|
## Constants
|
||||||
|
|
||||||
readonly api_url=https://192.168.51.81:8006/api2/json
|
|
||||||
|
|
||||||
## FIXME: There seems to be a problem with file upload where the task is
|
## FIXME: There seems to be a problem with file upload where the task is
|
||||||
## registered to `node051` no matter what node we are actually uploading to? For
|
## registered to `node051` no matter what node we are actually uploading to? For
|
||||||
## now, let us just use `node051` everywhere.
|
## now, let us just use `node051` everywhere.
|
||||||
|
@ -17,6 +15,7 @@ mkdir $tmpdir
|
||||||
################################################################################
|
################################################################################
|
||||||
## Parse arguments
|
## Parse arguments
|
||||||
|
|
||||||
|
api_url=
|
||||||
username=
|
username=
|
||||||
password=
|
password=
|
||||||
vm_ids=
|
vm_ids=
|
||||||
|
@ -26,6 +25,7 @@ help () {
|
||||||
Usage: $0 [OPTION...] ID [ID...]
|
Usage: $0 [OPTION...] ID [ID...]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
--api-url STR Base URL of the Proxmox API (required)
|
||||||
--username STR Username, with provider (eg. niols@pve)
|
--username STR Username, with provider (eg. niols@pve)
|
||||||
--password STR Password
|
--password STR Password
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ Options:
|
||||||
Options can also be provided by adding assignments to a '.proxmox' file in the
|
Options can also be provided by adding assignments to a '.proxmox' file in the
|
||||||
current working directory. For instance, it could contain:
|
current working directory. For instance, it could contain:
|
||||||
|
|
||||||
|
api_url=https://192.168.51.81:8006/api2/json
|
||||||
cores=7
|
cores=7
|
||||||
username=mireille@pve
|
username=mireille@pve
|
||||||
debug=true
|
debug=true
|
||||||
|
@ -55,6 +56,7 @@ while [ $# -gt 0 ]; do
|
||||||
argument=$1
|
argument=$1
|
||||||
shift
|
shift
|
||||||
case $argument in
|
case $argument in
|
||||||
|
--api-url|--api_url) readonly api_url="$1"; shift ;;
|
||||||
--username) readonly username=$1; shift ;;
|
--username) readonly username=$1; shift ;;
|
||||||
--password) readonly password=$1; shift ;;
|
--password) readonly password=$1; shift ;;
|
||||||
|
|
||||||
|
@ -70,8 +72,8 @@ if [ -z "$vm_ids" ]; then
|
||||||
die_with_help "Required: at least one VM id.\n"
|
die_with_help "Required: at least one VM id.\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$username" ] || [ -z "$password" ]; then
|
if [ -z "$api_url" ] || [ -z "$username" ] || [ -z "$password" ]; then
|
||||||
die_with_help "Required: '--username' and '--password'.\n"
|
die_with_help "Required: '--api-url', '--username' and '--password'."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
Loading…
Add table
Reference in a new issue