From 0df21b6ea89697e8700ad51158327533aa573c91 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Thu, 9 Feb 2017 10:56:01 -0500 Subject: support nova-lxd by reading platform from environment of pid 1. Nova lxd will now put the environment variable 'platform' into pid 1's environment to the value 'OpenStack Nova', which is the same as you would find in kvm guests. LP: #1661797 --- tools/ds-identify | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/tools/ds-identify b/tools/ds-identify index f07866a2..88094af7 100755 --- a/tools/ds-identify +++ b/tools/ds-identify @@ -62,6 +62,7 @@ PATH_VAR_LIB_CLOUD="${PATH_VAR_LIB_CLOUD:-${PATH_ROOT}/var/lib/cloud}" PATH_DI_CONFIG="${PATH_DI_CONFIG:-${PATH_ROOT}/etc/cloud/ds-identify.cfg}" PATH_PROC_CMDLINE="${PATH_PROC_CMDLINE:-${PATH_ROOT}/proc/cmdline}" PATH_PROC_1_CMDLINE="${PATH_PROC_1_CMDLINE:-${PATH_ROOT}/proc/1/cmdline}" +PATH_PROC_1_ENVIRON="${PATH_PROC_1_ENVIRON:-${PATH_ROOT}/proc/1/environ}" PATH_CLOUD_CONFD="${PATH_CLOUD_CONFD:-${PATH_ROOT}/etc/cloud}" PATH_RUN_CI="${PATH_RUN_CI:-${PATH_RUN}/cloud-init}" PATH_RUN_CI_CFG=${PATH_RUN_CI_CFG:-${PATH_RUN_CI}/cloud.cfg} @@ -81,6 +82,7 @@ DI_DMI_PRODUCT_UUID="" DI_FS_LABELS="" DI_KERNEL_CMDLINE="" DI_VIRT="" +DI_PID_1_PLATFORM="" DI_UNAME_KERNEL_NAME="" DI_UNAME_KERNEL_RELEASE="" @@ -350,6 +352,21 @@ read_datasource_list() { return 0 } +read_pid1_platform() { + local oifs="$IFS" out="" tok="" key="" val="" platform="${UNAVAILABLE}" + cached "${DI_PID_1_PLATFORM}" && return + [ -r "${PATH_PROC_1_ENVIRON}" ] || return + out=$(tr '\0' '\n' <"${PATH_PROC_1_ENVIRON}") + IFS="$CR"; set -- $out; IFS="$oifs" + for tok in "$@"; do + key=${tok%%=*} + [ "$key" != "$tok" ] || continue + val=${tok#*=} + [ "$key" = "platform" ] && platform="$val" && break + done + DI_PID_1_PLATFORM="$platform" +} + dmi_product_name_matches() { is_container && return 1 case "${DI_DMI_PRODUCT_NAME}" in @@ -625,13 +642,9 @@ dscheck_OpenStack() { if dmi_product_name_is "OpenStack Nova"; then return ${DS_FOUND} fi - case "${DI_VIRT}" in - lxc|lxc-libvirt) - # FIXME: This could be container on openstack (nova-lxd) - # or nova-libvirt-lxc - return ${DS_NOT_FOUND} - ;; - esac + if [ "${DI_PID_1_PLATFORM}" = "OpenStack Nova" ]; then + return ${DS_FOUND} + fi return ${DS_NOT_FOUND} } @@ -697,6 +710,7 @@ dscheck_None() { collect_info() { read_virt + read_pid1_platform read_kernel_cmdline read_uname_info read_config @@ -716,7 +730,7 @@ print_info() { _print_info() { local n="" v="" vars="" vars="DMI_PRODUCT_NAME DMI_SYS_VENDOR DMI_PRODUCT_SERIAL" - vars="$vars DMI_PRODUCT_UUID" + vars="$vars DMI_PRODUCT_UUID PID_1_PLATFORM" vars="$vars FS_LABELS KERNEL_CMDLINE VIRT" vars="$vars UNAME_KERNEL_NAME UNAME_KERNEL_RELEASE UNAME_KERNEL_VERSION" vars="$vars UNAME_MACHINE UNAME_NODENAME UNAME_OPERATING_SYSTEM" -- cgit v1.2.3