chore: adding code
This commit is contained in:
parent
1378861295
commit
0a2d1bd711
16 changed files with 2603 additions and 0 deletions
4
bin/get_hosts_pub_ips.sh
Executable file
4
bin/get_hosts_pub_ips.sh
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
[ -z "$1" ] && echo "source-cloud-home-name not found" && exit 1
|
||||
. ./.env
|
||||
../klouds/bin/hosts_list.sh $1 -src ../klouds/home -filter pub
|
||||
23
bin/make_kenv.sh
Executable file
23
bin/make_kenv.sh
Executable file
|
|
@ -0,0 +1,23 @@
|
|||
#!/bin/bash
|
||||
# tecoder --fencrypt _datacfg.yaml > kdata.yaml
|
||||
#
|
||||
ENCODER="/usr/local/bin/tecoder"
|
||||
ARGSENCODER="-e"
|
||||
|
||||
SOURCE_ENV=".env"
|
||||
TARGET_ENV=".envk"
|
||||
|
||||
[ ! -r "$SOURCE_ENV" ] && echo "File $SOURCE_ENV not found" && exit 1
|
||||
|
||||
USER=$(grep "USER" $SOURCE_ENV | cut -f2 -d"=")
|
||||
[ -z "$USER" ] && echo "User is empty" && exit 1
|
||||
|
||||
PASSWRD=$(grep "PASSWORD" $SOURCE_ENV | cut -f2 -d"=")
|
||||
[ -z "$PASSWRD" ] && echo "Password is empty" && exit 1
|
||||
|
||||
kuser=$($ENCODER $ARGSENCODER $USER)
|
||||
[ -z "$kuser" ] && echo "Unable to encode User" && exit 1
|
||||
kpasswdr=$($ENCODER $ARGSENCODER $PASSWRD)
|
||||
[ -z "$kpasswdr" ] && echo "Unable to encode Password" && exit 1
|
||||
|
||||
echo "export KUPCLAPI=\"$kuser $kpasswdr\"" > $TARGET_ENV
|
||||
22
bin/on_cloud.sh
Executable file
22
bin/on_cloud.sh
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
UPCLAPI_CMD="./build/upclapi"
|
||||
USAGE="on_cloud.sh home-cloud-dir-name tsksrvc [ args ]
|
||||
example: on_cloud.sh wuji/dvara info
|
||||
"
|
||||
[ -z "$1" ] || [ "$1" == "-h" ] && echo "$USAGE" && $UPCLAPI_CMD -h && exit
|
||||
. ./env
|
||||
CLOUD_CONFIG_PATH="$KLDS_HOME/$1/$KLDS_CONFIG"
|
||||
[ ! -r "$CLOUD_CONFIG_PATH" ] && echo "$CLOUD_CONFIG_PATH not found" && exit
|
||||
[ -z "$2" ] && echo "No tsksrvc defined" && echo "$USAGE" && exit 1
|
||||
case "$2" in
|
||||
c|create|createserver) TSKSRVC="createserver" ;;
|
||||
d|delete|deleteserver) TSKSRVC="deleteserver" ;;
|
||||
i|info) TSKSRVC="infoserver" ;;
|
||||
*) TSKSRVC="$2"
|
||||
esac
|
||||
|
||||
if $UPCLAPI_CMD -c "$TSKSRVC" -f "$CLOUD_CONFIG_PATH" ; then
|
||||
[ "$TSKSRVC" == "createserver" ] && "$ROOT_KLDS"/bin/hosts_list.sh "$1" -src "$KLDS_HOME" -filter pub
|
||||
fi
|
||||
|
||||
|
||||
54
bin/update_storage.sh
Executable file
54
bin/update_storage.sh
Executable file
|
|
@ -0,0 +1,54 @@
|
|||
#!/bin/bash
|
||||
USAGE="update_storage.sh [-d] server-name new-size"
|
||||
[ "$1" == "-h" ] && echo "$USAGE" && exit
|
||||
[ "$1" == "-d" ] && DEBUG=$1 && shift
|
||||
[ -z "$1" ] && echo "No server found" && echo "$USAGE" && exit 1
|
||||
SERVER_ID=$1
|
||||
[ -z "$2" ] && echo "No new size found" && echo "$USAGE" && exit 1
|
||||
NEW_SIZE=$2
|
||||
STOPPED="stopped"
|
||||
STARTED="started"
|
||||
MAX_TRIES=5
|
||||
SLEEP_TIME=10
|
||||
|
||||
_server_state() {
|
||||
[ -z "$1" ] && return
|
||||
upctl server show "$1" | grep State | awk '{print $2}'
|
||||
}
|
||||
_is_server_started() {
|
||||
[ -z "$1" ] && return
|
||||
_server_state "$1" | grep started
|
||||
}
|
||||
_stop_server() {
|
||||
[ -z "$1" ] && return
|
||||
[[ "$(_server_state "$1")" =~ $STOPPED ]] && return
|
||||
#[[ ! "$(_server_state "$1")" =~ $STOPPED ]] &&
|
||||
upctl server stop "$1" 2>/dev/null
|
||||
local n=0
|
||||
echo -n "Stopping $1 "
|
||||
while [[ ! "$(_server_state "$1")" =~ $STOPPED ]]
|
||||
do
|
||||
n=$((n+1))
|
||||
echo -n ". "
|
||||
sleep $SLEEP_TIME
|
||||
[ "$n" -gt $MAX_TRIES ] && echo "Server $1 not $STOPPED" && exit 2
|
||||
done
|
||||
echo " $(_server_state "$1")"
|
||||
}
|
||||
|
||||
STORE_UUID=$(upctl server show "$SERVER_ID" -o json | jq -r '.storage[].uuid ' | sed 's/"//')
|
||||
[ -z "$STORE_UUID" ] && echo "No store found for $SERVER_ID" && exit 1
|
||||
STORE_SIZE=$(upctl server show "$SERVER_ID" -o json | jq '.storage[].size ')
|
||||
|
||||
echo "$SERVER_ID: store $STORE_UUID from $STORE_SIZE to $NEW_SIZE"
|
||||
[ "$STORE_SIZE" -gt "$NEW_SIZE" ] && echo "$NEW_SIZE is less then current $STORE_SIZE" && exit 1
|
||||
|
||||
_stop_server "$SERVER_ID"
|
||||
[ -n "$DEBUG" ] && _server_state "$SERVER_ID"
|
||||
|
||||
if upctl storage modify "$STORE_UUID" --size "$NEW_SIZE" ; then
|
||||
[ -n "$DEBUG" ] && _server_state "$SERVER_ID"
|
||||
[[ ! "$(_server_state "$1")" =~ $STARTED ]] && upctl server start "$SERVER_ID"
|
||||
else
|
||||
echo "errors in modify $SERVER_ID $STORE_UUID"
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue