Allow computes without virtualization enabled to be unlocked

The goenabled script in mtce-compute checks if hardware
virtualization is enabled, before allowing the node to
become enabled.  (hardware only)

This check is only needed if the compute is being used as an
openstack compute node, and so the check has been updated
to look for the appropriate label.

Puppet stores the labels in the hieradata file in /tmp.

That file is recreated when the host is rebooted or unlocked,
and labels cannot be changed unless a host is locked.

Change-Id: I6862a1b7824c759f0c3caea37c3ae6e4e9ab43b7
Closes-Bug: 1843616
Signed-off-by: Al Bailey <Al.Bailey@windriver.com>
This commit is contained in:
Al Bailey 2019-09-13 12:27:48 -05:00
parent 67d4ba105f
commit b1df966e02
1 changed files with 11 additions and 5 deletions

View File

@ -35,6 +35,8 @@ OPTS+="nested_virt:${nested_virt}, "
hardware_virt_supported=$(virt-host-validate qemu 2>/dev/null | grep -q -w -e FAIL && echo "false" || echo "true")
OPTS+="hardware_virt_supported:${hardware_virt_supported}"
REASONS=$(virt-host-validate qemu 2>/dev/null | grep -w -e FAIL)
openstack_label=$(grep -w -q openstack-compute-node /tmp/puppet/hieradata/host.yaml && echo "true" || echo "false")
# Check that virtualization is supported on hardware. It is sufficient just to
# check the output of virt-host-validate. Additional facts are gathered for
@ -47,11 +49,15 @@ REASONS=$(virt-host-validate qemu 2>/dev/null | grep -w -e FAIL)
# - on emulated systems such as VirtualBox or QEMU, vmx is not required
# - if vmx is enabled on QEMU, it can also support nested virtualization
if [ "${host_type}" == "physical" ] && [ "${hardware_virt_supported}" == "false" ]; then
LOG "Virtualization is not supported: ${OPTS}. Failing goenabled check."
LOG "Failure reasons:"$'\n'"${REASONS}"
exit 1
# Virtualization check is only required if openstack-compute-node label is detected.
if [ "${openstack_label}" == "true" ]; then
LOG "Openstack Label detected"
if [ "${host_type}" == "physical" ] && [ "${hardware_virt_supported}" == "false" ]; then
LOG "Virtualization is not supported: ${OPTS}. Failing goenabled check."
LOG "Failure reasons:"$'\n'"${REASONS}"
exit 1
fi
LOG "Virtualization is supported: ${OPTS}."
fi
LOG "Virtualization is supported: ${OPTS}."
exit 0