Compare commits

...

5 Commits

Author SHA1 Message Date
Vlastimil Holer 5a7b1f53e7
B #216: More specific detach NIC workarounds
4 years ago
Vlastimil Holer 9b98a6ada8
M #-: Bump version to 5.12.0.2
4 years ago
Vlastimil Holer bdc853e74b
F OpenNebula/one#5112: Update OneGate client to 5.12.6 (EE)
4 years ago
Vlastimil Holer 38633f11f5
M #-: Bump version to 5.12.0.1
4 years ago
Petr Ospalý 20a9c97343
B #212: Fix chown command on FreeBSD
4 years ago

@ -39,7 +39,7 @@ fi
### ###
VERSION=${VERSION:-5.12.0} VERSION=${VERSION:-5.12.0.2}
RELEASE=${RELEASE:-0} RELEASE=${RELEASE:-0}
MAINTAINER=${MAINTAINER:-OpenNebula Systems <support@opennebula.systems>} MAINTAINER=${MAINTAINER:-OpenNebula Systems <support@opennebula.systems>}
LICENSE=${LICENSE:-Apache 2.0} LICENSE=${LICENSE:-Apache 2.0}

@ -17,33 +17,36 @@
#--------------------------------------------------------------------------- # #--------------------------------------------------------------------------- #
ENV_FILE=/var/run/one-context/one_env ENV_FILE=/var/run/one-context/one_env
MOUNT_DIR=${MOUNT_DIR:-/mnt} MOUNT_DIR="${MOUNT_DIR:-/mnt}"
TOKENTXT=$(cat "${MOUNT_DIR}/token.txt") TOKEN_FILE="${MOUNT_DIR}/token.txt"
if [ -n "$ONEGATE_TOKEN" ]; then if [ -n "$ONEGATE_TOKEN" ]; then
TOKENTXT="$ONEGATE_TOKEN" TOKENTXT="$ONEGATE_TOKEN"
elif [ -f "$TOKEN_FILE" ]; then
TOKENTXT=$(cat "$TOKEN_FILE")
fi fi
umask 0377 umask 0377
echo "export TOKENTXT=\"$TOKENTXT\"" > $ENV_FILE echo "export TOKENTXT=\"$TOKENTXT\"" > "$ENV_FILE"
echo "export VMID=\"$VMID\"" >> $ENV_FILE echo "export VMID=\"$VMID\"" >> "$ENV_FILE"
echo "export ONEGATE_ENDPOINT=\"$ONEGATE_ENDPOINT\"" >> $ENV_FILE echo "export ONEGATE_ENDPOINT=\"$ONEGATE_ENDPOINT\"" >> "$ENV_FILE"
function export_rc_vars function export_rc_vars
{ {
if [ -f $1 ] ; then if [ -n "$1" ] && [ -f "$1" ] ; then
ONE_VARS=$(cat $1 | egrep -e '^[a-zA-Z\-\_0-9]*=' | sed 's/=.*$//') ONE_VARS=$(grep -E -e '^[a-zA-Z\-\_0-9]*=' "$1" | sed 's/=.*$//')
. $1 # shellcheck disable=SC1090
. "$1"
for v in $ONE_VARS; do for v in $ONE_VARS; do
echo "export $v=\"${!v}\"" >> $ENV_FILE echo "export $v=\"${!v}\"" >> "$ENV_FILE"
done done
fi fi
} }
export_rc_vars ${CONTEXT_FILE} export_rc_vars "${CONTEXT_FILE}"
chown root:root $ENV_FILE chown "root:$(id -gn root)" "$ENV_FILE"
chmod 0400 $ENV_FILE chmod 0400 "$ENV_FILE"

@ -2,6 +2,7 @@
# https://github.com/OpenNebula/one/issues/4130 # https://github.com/OpenNebula/one/issues/4130
# https://github.com/OpenNebula/one/issues/4194 # https://github.com/OpenNebula/one/issues/4194
SUBSYSTEM=="net", ACTION=="remove", \ SUBSYSTEM=="net", ACTION=="remove", \
ENV{ID_BUS}=="?*", \
RUN+="/bin/sh -c 'test -f /var/run/one-context/context.sh.local && echo >> /var/run/one-context/context.sh.local; test -f /var/run/one-context/context.sh.network && echo >> /var/run/one-context/context.sh.network'" RUN+="/bin/sh -c 'test -f /var/run/one-context/context.sh.local && echo >> /var/run/one-context/context.sh.local; test -f /var/run/one-context/context.sh.network && echo >> /var/run/one-context/context.sh.network'"
# On NIC hotplug the delayed reconfiguration is triggered. # On NIC hotplug the delayed reconfiguration is triggered.

@ -2,6 +2,7 @@
# https://github.com/OpenNebula/one/issues/4130 # https://github.com/OpenNebula/one/issues/4130
# https://github.com/OpenNebula/one/issues/4194 # https://github.com/OpenNebula/one/issues/4194
SUBSYSTEM=="net", ACTION=="remove", \ SUBSYSTEM=="net", ACTION=="remove", \
ENV{ID_BUS}=="?*", \
RUN+="/bin/sh -c 'test -f /var/run/one-context/context.sh.local && echo >> /var/run/one-context/context.sh.local; test -f /var/run/one-context/context.sh.network && echo >> /var/run/one-context/context.sh.network'" RUN+="/bin/sh -c 'test -f /var/run/one-context/context.sh.local && echo >> /var/run/one-context/context.sh.local; test -f /var/run/one-context/context.sh.network && echo >> /var/run/one-context/context.sh.network'"
# On NIC hotplug the delayed reconfiguration is triggered. # On NIC hotplug the delayed reconfiguration is triggered.

@ -2,6 +2,7 @@
# https://github.com/OpenNebula/one/issues/4130 # https://github.com/OpenNebula/one/issues/4130
# https://github.com/OpenNebula/one/issues/4194 # https://github.com/OpenNebula/one/issues/4194
SUBSYSTEM=="net", ACTION=="remove", \ SUBSYSTEM=="net", ACTION=="remove", \
ENV{ID_BUS}=="?*", \
RUN+="/bin/sh -c 'test -f /var/run/one-context/context.sh.local && echo >> /var/run/one-context/context.sh.local; test -f /var/run/one-context/context.sh.network && echo >> /var/run/one-context/context.sh.network'" RUN+="/bin/sh -c 'test -f /var/run/one-context/context.sh.local && echo >> /var/run/one-context/context.sh.local; test -f /var/run/one-context/context.sh.network && echo >> /var/run/one-context/context.sh.network'"
# On NIC hotplug the delayed reconfiguration is triggered. # On NIC hotplug the delayed reconfiguration is triggered.

@ -2,6 +2,7 @@
# https://github.com/OpenNebula/one/issues/4130 # https://github.com/OpenNebula/one/issues/4130
# https://github.com/OpenNebula/one/issues/4194 # https://github.com/OpenNebula/one/issues/4194
SUBSYSTEM=="net", ACTION=="remove", \ SUBSYSTEM=="net", ACTION=="remove", \
ENV{INTERFACE}=="eth*", \
RUN+="/bin/sh -c 'test -f /var/run/one-context/context.sh.local && echo >> /var/run/one-context/context.sh.local; test -f /var/run/one-context/context.sh.network && echo >> /var/run/one-context/context.sh.network'" RUN+="/bin/sh -c 'test -f /var/run/one-context/context.sh.local && echo >> /var/run/one-context/context.sh.local; test -f /var/run/one-context/context.sh.network && echo >> /var/run/one-context/context.sh.network'"
# On NIC hotplug the delayed reconfiguration is triggered. # On NIC hotplug the delayed reconfiguration is triggered.

@ -29,7 +29,7 @@ require 'pp'
module CloudClient module CloudClient
# OpenNebula version # OpenNebula version
VERSION = '5.11.80' VERSION = '5.12.6'
# ######################################################################### # #########################################################################
# Default location for the authentication file # Default location for the authentication file
@ -220,6 +220,7 @@ module OneGate
DISK_RESIZE DISK_RESIZE
DISK_RESIZE_POWEROFF DISK_RESIZE_POWEROFF
DISK_RESIZE_UNDEPLOYED DISK_RESIZE_UNDEPLOYED
HOTPLUG_NIC_POWEROFF
} }
SHORT_VM_STATES={ SHORT_VM_STATES={
@ -300,7 +301,8 @@ module OneGate
"PROLOG_MIGRATE_UNKNOWN_FAILURE" => "fail", "PROLOG_MIGRATE_UNKNOWN_FAILURE" => "fail",
"DISK_RESIZE" => "drsz", "DISK_RESIZE" => "drsz",
"DISK_RESIZE_POWEROFF" => "drsz", "DISK_RESIZE_POWEROFF" => "drsz",
"DISK_RESIZE_UNDEPLOYED" => "drsz" "DISK_RESIZE_UNDEPLOYED" => "drsz",
"HOTPLUG_NIC_POWEROFF" => "hotp"
} }
def self.state_to_str(id, lcm_id) def self.state_to_str(id, lcm_id)
@ -392,6 +394,35 @@ module OneGate
end end
end end
# Virtual Router module
module VirtualRouter
def self.print(json_hash, _extended = false)
OneGate.print_header('VROUTER ' + json_hash['VROUTER']['ID'])
OneGate.print_key_value('NAME', json_hash['VROUTER']['NAME'])
vms_ids = Array(json_hash['VROUTER']['VMS']['ID'])
vms = vms_ids.join(',')
OneGate.print_key_value('VMS', vms)
puts
end
end
# Virtual Network module
module VirtualNetwork
def self.print(json_hash, _extended = false)
OneGate.print_header('VNET')
OneGate.print_key_value('ID', json_hash['VNET']['ID'])
puts
end
end
class Client class Client
def initialize(opts={}) def initialize(opts={})
@vmid = ENV["VMID"] @vmid = ENV["VMID"]
@ -471,8 +502,8 @@ module OneGate
def self.parse_json(response) def self.parse_json(response)
if CloudClient::is_error?(response) if CloudClient::is_error?(response)
puts "ERROR: " STDERR.puts 'ERROR: '
puts response.message STDERR.puts response.message
exit -1 exit -1
else else
return JSON.parse(response.body) return JSON.parse(response.body)
@ -535,6 +566,10 @@ Available commands
$ onegate service show [--json][--extended] $ onegate service show [--json][--extended]
$ onegate service scale --role ROLE --cardinality CARDINALITY $ onegate service scale --role ROLE --cardinality CARDINALITY
$ onegate vrouter show [--json]
$ onegate vnet show VNETID [--json][--extended]
EOT EOT
end end
end end
@ -574,7 +609,7 @@ OptionParser.new do |opts|
end end
opts.on("-h", "--help", "Show this message") do opts.on("-h", "--help", "Show this message") do
puts OneGate.help_str STDERR.puts OneGate.help_str
exit exit
end end
end.parse! end.parse!
@ -599,7 +634,7 @@ when "vm"
end end
when "update" when "update"
if !options[:data] && !options[:erase] if !options[:data] && !options[:erase]
puts "You have to provide the data as a param (--data, --erase)" STDERR.puts 'You have to provide the data as a param (--data, --erase)'
exit -1 exit -1
end end
@ -616,8 +651,8 @@ when "vm"
end end
if CloudClient::is_error?(response) if CloudClient::is_error?(response)
puts "ERROR: " STDERR.puts 'ERROR: '
puts response.message STDERR.puts response.message
exit -1 exit -1
end end
when "resume", when "resume",
@ -647,18 +682,18 @@ when "vm"
response = client.post("/vms/"+ARGV[2]+"/action", action_hash.to_json) response = client.post("/vms/"+ARGV[2]+"/action", action_hash.to_json)
if CloudClient::is_error?(response) if CloudClient::is_error?(response)
puts "ERROR: " STDERR.puts 'ERROR: '
puts response.message STDERR.puts response.message
exit -1 exit -1
end end
else else
puts "You have to provide a VM ID" STDERR.puts 'You have to provide a VM ID'
exit -1 exit -1
end end
else else
puts OneGate.help_str STDERR.puts OneGate.help_str
puts STDERR.puts
puts "Action #{ARGV[1]} not supported" STDERR.puts "Action #{ARGV[1]} not supported"
exit -1 exit -1
end end
when "service" when "service"
@ -691,18 +726,79 @@ when "service"
}.to_json) }.to_json)
if CloudClient::is_error?(response) if CloudClient::is_error?(response)
puts "ERROR: " STDERR.puts 'ERROR: '
puts response.message STDERR.puts response.message
exit -1 exit -1
end end
else else
puts OneGate.help_str STDERR.puts OneGate.help_str
puts STDERR.puts
puts "Action #{ARGV[1]} not supported" STDERR.puts "Action #{ARGV[1]} not supported"
exit -1
end
when 'vrouter'
case ARGV[1]
when 'show'
if options[:extended]
extra = {}
extra['extended'] = true
extra = URI.encode_www_form(extra)
end
response = client.get('/vrouter', extra)
json_hash = OneGate.parse_json(response)
if options[:json]
puts JSON.pretty_generate(json_hash)
else
if options[:extended]
OneGate::VirtualRouter.print(json_hash, true)
else
OneGate::VirtualRouter.print(json_hash)
end
end
else
STDERR.puts OneGate.help_str
STDERR.puts
STDERR.puts "Action #{ARGV[1]} not supported"
exit(-1)
end
when 'vnet'
case ARGV[1]
when 'show'
if ARGV[2]
if options[:extended]
extra = {}
extra['extended'] = true
extra = URI.encode_www_form(extra)
end
response = client.get('/vnet/'+ARGV[2], extra)
json_hash = OneGate.parse_json(response)
if options[:json]
puts JSON.pretty_generate(json_hash)
else
if options[:extended]
OneGate::VirtualNetwork.print(json_hash, true)
else
OneGate::VirtualNetwork.print(json_hash)
end
end
else
STDERR.puts 'You have to provide a VNET ID'
exit -1 exit -1
end end
else else
puts OneGate.help_str STDERR.puts OneGate.help_str
STDERR.puts
STDERR.puts "Action #{ARGV[1]} not supported"
exit(-1)
end
else
STDERR.puts OneGate.help_str
exit -1 exit -1
end end

Loading…
Cancel
Save