Add lxc storage volume mounting work.

This commit is contained in:
Derek Smith 2023-04-02 09:22:38 -04:00
parent b5c1c22db0
commit 3aaf137707
Signed by: farscapian
GPG Key ID: B443E530A14E1C90
2 changed files with 41 additions and 3 deletions

View File

@ -30,7 +30,20 @@ if ! lxc list --format csv | grep -q "$LXD_VM_NAME"; then
exit 1 exit 1
fi fi
bash -c "./stub_lxc_profile.sh --vm=$VIRTUAL_MACHINE --lxd-hostname=$LXD_VM_NAME" # create the docker volume
VM_ID=w
if [ "$VIRTUAL_MACHINE" = btcpayserver ]; then
VM_ID="b"
fi
DOCKER_VOLUME_NAME="$PRIMARY_DOMAIN_IDENTIFIER-$VM_ID""d"
export DOCKER_VOLUME_NAME="$DOCKER_VOLUME_NAME"
if ! lxc storage volume list ss-base | grep -q "$DOCKER_VOLUME_NAME"; then
lxc storage volume create ss-base "$DOCKER_VOLUME_NAME" --type=filesystem
lxc storage volume set ss-base "$DOCKER_VOLUME_NAME" size="${ROOT_DISK_SIZE_GB}GB"
fi
bash -c "./stub_lxc_profile.sh --vm=$VIRTUAL_MACHINE --lxd-hostname=$LXD_VM_NAME --docker-volume-name=$DOCKER_VOLUME_NAME"
# now let's create a new VM to work with. # now let's create a new VM to work with.
#lxc init --profile="$LXD_VM_NAME" "$BASE_IMAGE_VM_NAME" "$LXD_VM_NAME" --vm #lxc init --profile="$LXD_VM_NAME" "$BASE_IMAGE_VM_NAME" "$LXD_VM_NAME" --vm
@ -39,8 +52,18 @@ if ! lxc list --format csv | grep -q "$LXD_VM_NAME"; then
# let's PIN the HW address for now so we don't exhaust IP # let's PIN the HW address for now so we don't exhaust IP
# and so we can set DNS internally. # and so we can set DNS internally.
lxc config set "$LXD_VM_NAME" "volatile.enp5s0.hwaddr=$MAC_ADDRESS_TO_PROVISION" lxc config set "$LXD_VM_NAME" "volatile.enp5s0.hwaddr=$MAC_ADDRESS_TO_PROVISION"
lxc config device override "$LXD_VM_NAME" root size="${ROOT_DISK_SIZE_GB}GB" #lxc config device override "$LXD_VM_NAME" root size="${ROOT_DISK_SIZE_GB}GB"
#lxc storage volume attach ss-base "$DOCKER_VOLUME_NAME" "$LXD_VM_NAME"
# HOME_VOLUME_NAME="$PRIMARY_DOMAIN_IDENTIFIER-$VM_ID""h"
# if ! lxc storage volume list ss-base | grep -q "$HOME_VOLUME_NAME"; then
# lxc storage volume create ss-base "$HOME_VOLUME_NAME" --type=block
# lxc storage volume set ss-base "$HOME_VOLUME_NAME" size="${ROOT_DISK_SIZE_GB}GB"
# fi
#lxc storage volume attach ss-base "$HOME_VOLUME_NAME" "$LXD_VM_NAME"
# if [ "$VIRTUAL_MACHINE" = btcpayserver ]; then # if [ "$VIRTUAL_MACHINE" = btcpayserver ]; then
# # attach any volumes # # attach any volumes
# for CHAIN in testnet mainnet; do # for CHAIN in testnet mainnet; do

View File

@ -5,6 +5,7 @@ cd "$(dirname "$0")"
VIRTUAL_MACHINE=base VIRTUAL_MACHINE=base
LXD_HOSTNAME= LXD_HOSTNAME=
DOCKER_VOLUME_NAME=
# grab any modifications from the command line. # grab any modifications from the command line.
for i in "$@"; do for i in "$@"; do
@ -17,6 +18,10 @@ for i in "$@"; do
VIRTUAL_MACHINE="${i#*=}" VIRTUAL_MACHINE="${i#*=}"
shift shift
;; ;;
--docker-volume-name=*)
DOCKER_VOLUME_NAME="${i#*=}"
shift
;;
*) *)
echo "Unexpected option: $1" echo "Unexpected option: $1"
exit 1 exit 1
@ -222,6 +227,16 @@ devices:
type: disk type: disk
EOF EOF
if [ "$VIRTUAL_MACHINE" != base ]; then
cat >> "$YAML_PATH" <<EOF
ss-data:
path: ${REMOTE_DATA_PATH}
pool: ss-base
source: ${DOCKER_VOLUME_NAME}
type: disk
EOF
fi
# Stub out the network piece for the base image. # Stub out the network piece for the base image.
if [ "$VIRTUAL_MACHINE" = base ]; then if [ "$VIRTUAL_MACHINE" = base ]; then
cat >> "$YAML_PATH" <<EOF cat >> "$YAML_PATH" <<EOF