1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

F #5890: Initial support of not up-to-date hosts

* Adjust :ip[6]tables commands to work with legacy versions. Prior to
  version 1.6.1 -W option is not supported (e.g. ubuntu 16.04)
* Check sudo access for vgpu commands. Added in 6.4.0 release

co-authoted-by: Christian González <cgonzalez@opennebula.io>
This commit is contained in:
Ruben S. Montero 2022-07-03 11:55:49 +02:00
parent a7c27a2bc0
commit c1be05cfb9
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87
4 changed files with 16 additions and 5 deletions

View File

@ -32,8 +32,8 @@ function destroy_and_monitor
virsh --connect $LIBVIRT_URI destroy $deploy_id
# Destroy vGPU
sudo /var/tmp/one/vgpu "DELETE" "$DATASTORE/vm.xml"
# Destroy vGPU (only if suported by node)
(sudo -l | grep -q vgpu) && sudo /var/tmp/one/vgpu "DELETE" "$DATASTORE/vm.xml"
virsh --connect $LIBVIRT_URI --readonly dominfo $deploy_id > /dev/null 2>&1
[ "x$?" != "x0" ]

View File

@ -37,7 +37,8 @@ if [ -n "${nvram}" ]; then
fi
# Create vGPU following NVIDIA official guide: https://docs.nvidia.com/grid/latest/pdf/grid-vgpu-user-guide.pdf
sudo /var/tmp/one/vgpu "CREATE" "$DEP_FILE_LOCATION/vm.xml"
# Only if supported by node
(sudo -l | grep -q vgpu) && sudo /var/tmp/one/vgpu "CREATE" "$DEP_FILE_LOCATION/vm.xml"
DATA=`virsh --connect $LIBVIRT_URI create $DEP_FILE`

View File

@ -73,8 +73,8 @@ retry $TIMEOUT monitor
force_shutdown "$deploy_id" \
"virsh --connect $LIBVIRT_URI destroy $deploy_id"
# Destroy vGPU
sudo /var/tmp/one/vgpu "DELETE" "$DATASTORE/vm.xml"
# Destroy vGPU. Only if supported by node
(sudo -l | grep -q vgpu) && sudo /var/tmp/one/vgpu "DELETE" "$DATASTORE/vm.xml"
# Compact memory
if [ "x$CLEANUP_MEMORY_ON_STOP" = "xyes" ]; then

View File

@ -37,6 +37,16 @@ module VNMMAD
:ipset => 'sudo -n ipset'
}
# Adjust :ip[6]tables commands to work with legacy version
stdout = Open3.capture3('iptables --version')[0]
regex = /.*v(?<version>\d+.\d+.\d+)/
iptables_version = Gem::Version.new(stdout.match(regex)[:version])
if Gem::Version.new('1.6.1') > iptables_version
COMMANDS[:iptables] = 'sudo -n iptables -w 3'
COMMANDS[:ip6tables] = 'sudo -n ip6tables -w 3'
end
# Represents an Array of commands to be executed by the networking
# drivers # The commands
class Commands < Array