LXD drivers contextualization (#126)

* F #1684: LXD drivers contextualization
pull/129/head
Daniel Clavijo Coca 6 years ago committed by Alejandro Huertas Herrero
parent fc8535e4d8
commit 9fc1df3b11

@ -163,7 +163,7 @@ EOT
get_interface_mac()
{
ip link show | awk '/^[0-9]+: [A-Za-z0-9]+:/ { device=$2; gsub(/:/, "",device)} /link\/ether/ { print device " " $2 }'
ip link show | awk '/^[0-9]+: [A-Za-z0-9@]+:/ { device=$2; gsub(/:/, "",device); split(device,dev,"@")} /link\/ether/ { print dev[1] " " $2 }'
}
get_context_interfaces()

@ -198,7 +198,7 @@ EOT
get_interface_mac()
{
ip link show | awk '/^[0-9]+: [[:alnum:]]+:/ { device=$2; gsub(/:/, "",device)} /link\/ether/ { print device " " $2 }'
ip link show | awk '/^[0-9]+: [A-Za-z0-9@]+:/ { device=$2; gsub(/:/, "",device); split(device,dev,"@")} /link\/ether/ { print dev[1] " " $2 }'
}
get_context_interfaces()

@ -190,7 +190,7 @@ EOT
get_interface_mac()
{
ip link show | awk '/^[0-9]+: [A-Za-z0-9]+:/ { device=$2; gsub(/:/, "",device)} /link\/ether/ { print device " " $2 }'
ip link show | awk '/^[0-9]+: [A-Za-z0-9@]+:/ { device=$2; gsub(/:/, "",device); split(device,dev,"@")} /link\/ether/ { print dev[1] " " $2 }'
}
get_context_interfaces()

@ -156,7 +156,7 @@ EOT
get_interface_mac()
{
ip link show | awk '/^[0-9]+: [[:alnum:]]+:/ { device=$2; gsub(/:/, "",device)} /link\/ether/ { print device " " $2 }'
ip link show | awk '/^[0-9]+: [A-Za-z0-9@]+:/ { device=$2; gsub(/:/, "",device); split(device,dev,"@")} /link\/ether/ { print dev[1] " " $2 }'
}
get_context_interfaces()

@ -147,7 +147,7 @@ function vmware_context {
function get_new_context {
local dev_context=$(blkid -l -t LABEL="CONTEXT" -o device)
if [ -e "${dev_context}" ]; then
MOUNT_DIR=$(mktemp -d "${RUNTIME_DIR}/mount.XXXXXX" 2>/dev/null)
mount_dir
if ! [ -d "${MOUNT_DIR}" ]; then
log err 'Error: Failed to create mountpoint' 2
exit 1
@ -160,11 +160,14 @@ function get_new_context {
exit 1
fi
local fn_mnt_context="${MOUNT_DIR}/context.sh"
if [ -f "${fn_mnt_context}" ]; then
log debug "Found context ${fn_mnt_context}"
cp "${fn_mnt_context}" "${CONTEXT_NEW}"
fi
context_sh $MOUNT_DIR
elif find '/context' -mindepth 1 -print -quit 2>/dev/null | grep -q .; then
mount_dir
cp '/context/*' "${MOUNT_DIR}"
context_sh "${MOUNT_DIR}"
elif vmware_context ; then
log debug "Reading context via vmtoolsd"
@ -185,6 +188,19 @@ function get_new_context {
chmod 0400 "${CONTEXT_NEW}"
}
function mount_dir
{
MOUNT_DIR=$(mktemp -d "${RUNTIME_DIR}/mount.XXXXXX" 2>/dev/null)
}
function context_sh {
local fn_mnt_context="${1}/context.sh"
if [ -f "${fn_mnt_context}" ]; then
log debug "Found context ${fn_mnt_context}"
cp "${fn_mnt_context}" "${CONTEXT_NEW}"
fi
}
function check_context {
local _f_new=$1
local _f_old=$2
@ -244,7 +260,7 @@ function cleanup {
if [ -d "${MOUNT_DIR}" ]; then
log debug "Unmounting ${MOUNT_DIR}"
umount -l "${MOUNT_DIR}"
rmdir "${MOUNT_DIR}"
rm -r "${MOUNT_DIR}"
fi
# remove remporary files

Loading…
Cancel
Save