diff --git a/appliances/VRouter/vrouter.rb b/appliances/VRouter/vrouter.rb index 2fac7e6c..6550a1c7 100644 --- a/appliances/VRouter/vrouter.rb +++ b/appliances/VRouter/vrouter.rb @@ -19,7 +19,6 @@ def initialize @uri = URI.parse(ENV['ONEGATE_ENDPOINT']) @vmid = ENV['VMID'] @token = ENV['TOKENTXT'] - @req_content_type = 'application/json' @http = Net::HTTP.new(@uri.host, @uri.port) @http.use_ssl = @uri.scheme == 'https' @@ -66,7 +65,6 @@ def do_request(req, keep_alive, expect_json: true) req['X-ONEGATE-VMID'] = @vmid req['X-ONEGATE-TOKEN'] = @token - req['Content-Type'] = @req_content_type expect_json ? JSON.parse(@http.request(req).body) : @http.request(req).body rescue StandardError => e diff --git a/appliances/scripts/net-99-report-ready b/appliances/scripts/net-99-report-ready index 1e29daca..b60ad38f 100644 --- a/appliances/scripts/net-99-report-ready +++ b/appliances/scripts/net-99-report-ready @@ -21,15 +21,28 @@ if [[ -x '/etc/one-appliance/service' ]]; then fi fi -if ! command -v onegate ; then - echo "ERROR: No way to signal READY=YES (onegate binary not found)" >&2 - exit 1 -fi > /dev/null # this will not drop the error message which goes to stderr +### -if onegate vm update --data READY=YES; then - echo "Reported READY" - exit +if which onegate >/dev/null 2>&1; then + if onegate vm update --data READY=YES; then + exit + fi +fi + +if which curl >/dev/null 2>&1; then + if curl -X PUT "$ONEGATE_ENDPOINT/vm" \ + --header "X-ONEGATE-TOKEN: $TOKENTXT" \ + --header "X-ONEGATE-VMID: $VMID" \ + -d READY=YES; then + exit + fi fi -echo "ERROR: Failed to report READY" >&2 -exit 1 +if which wget >/dev/null 2>&1; then + if wget --method PUT "$ONEGATE_ENDPOINT/vm" \ + --header "X-ONEGATE-TOKEN: $TOKENTXT" \ + --header "X-ONEGATE-VMID: $VMID" \ + --body-data READY=YES; then + exit + fi +fi diff --git a/context-linux/src/etc/one-context.d/net-99-report-ready b/context-linux/src/etc/one-context.d/net-99-report-ready index 389ffc56..2e75af0b 100755 --- a/context-linux/src/etc/one-context.d/net-99-report-ready +++ b/context-linux/src/etc/one-context.d/net-99-report-ready @@ -32,13 +32,43 @@ fi ### -if ! command -v onegate ; then - echo "ERROR: No way to signal READY=YES (onegate binary not found)" >&2 +if command -v curl ; then + _command=curl +elif command -v wget && ! wget --help 2>&1 | grep -q BusyBox; then + _command=wget +elif command -v onegate ; then + _command=onegate +else + echo "ERROR: No way to signal READY=YES (no usable binary)" >&2 exit 1 fi > /dev/null # this will not drop the error message which goes to stderr report_ready() { - onegate vm update --data "READY=YES" + case "$_command" in + curl) + curl -X "PUT" "${ONEGATE_ENDPOINT}/vm" \ + --header "X-ONEGATE-TOKEN: $TOKENTXT" \ + --header "X-ONEGATE-VMID: $VMID" \ + --max-time 10 \ + --insecure \ + -d "READY=YES" + ;; + wget) + wget --method=PUT "${ONEGATE_ENDPOINT}/vm" \ + --body-data="READY=YES" \ + --header "X-ONEGATE-TOKEN: $TOKENTXT" \ + --header "X-ONEGATE-VMID: $VMID" \ + --timeout=10 \ + --no-check-certificate + ;; + onegate) + if command -v timeout >/dev/null; then + timeout 10 onegate vm update --data "READY=YES" + else + onegate vm update --data "READY=YES" + fi + ;; + esac } is_base64() { diff --git a/context-linux/src/usr/bin/onegate.rb b/context-linux/src/usr/bin/onegate.rb index 12723d86..019aef69 100755 --- a/context-linux/src/usr/bin/onegate.rb +++ b/context-linux/src/usr/bin/onegate.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -------------------------------------------------------------------------- # -# Copyright 2002-2025, OpenNebula Project, OpenNebula Systems # +# Copyright 2002-2022, OpenNebula Project, OpenNebula Systems # # # # Licensed under the Apache License, Version 2.0 (the "License"); you may # # not use this file except in compliance with the License. You may obtain # @@ -29,7 +29,7 @@ module CloudClient # OpenNebula version - VERSION = '6.10.0' + VERSION = '6.6.1' # ######################################################################### # Default location for the authentication file @@ -359,8 +359,7 @@ module Service 'DEPLOYING_NETS' => 11, 'UNDEPLOYING_NETS' => 12, 'FAILED_DEPLOYING_NETS' => 13, - 'FAILED_UNDEPLOYING_NETS' => 14, - 'HOLD' => 15 + 'FAILED_UNDEPLOYING_NETS' => 14 } STATE_STR = [ @@ -378,8 +377,7 @@ module Service 'DEPLOYING_NETS', 'UNDEPLOYING_NETS', 'FAILED_DEPLOYING_NETS', - 'FAILED_UNDEPLOYING_NETS', - 'HOLD' + 'FAILED_UNDEPLOYING_NETS' ] # Returns the string representation of the service state @@ -450,8 +448,6 @@ def initialize(opts={}) @user_agent = "OpenNebula #{CloudClient::VERSION} " << "(#{opts[:user_agent]||"Ruby"})" - @req_content_type = opts[:req_content_type] || "application/json" - @host = nil @port = nil @@ -509,7 +505,6 @@ def do_request(req) req['User-Agent'] = @user_agent req['X-ONEGATE-TOKEN'] = @token req['X-ONEGATE-VMID'] = @vmid - req['Content-Type'] = @req_content_type res = CloudClient::http_start(@uri, @timeout) do |http| http.request(req) @@ -563,26 +558,32 @@ def self.print_key_value(key, value) def self.help_str return <<-EOT -## COMMANDS - - * onegate vm show [VMID] [--json] - * onegate vm update [VMID] --data KEY=VALUE\\nKEY2=VALUE2 - * onegate vm update [VMID] --erase KEY - * onegate vm ACTION VMID - * onegate resume [VMID] - * onegate stop [VMID] - * onegate suspend [VMID] - * onegate terminate [VMID] [--hard] - * onegate reboot [VMID] [--hard] - * onegate poweroff [VMID] [--hard] - * onegate resched [VMID] - * onegate unresched [VMID] - * onegate hold [VMID] - * onegate release [VMID] - * onegate service show [--json][--extended] - * onegate service scale --role ROLE --cardinality CARDINALITY - * onegate vrouter show [--json] - * onegate vnet show VNETID [--json][--extended] +Available commands + $ onegate vm show [VMID] [--json] + + $ onegate vm update [VMID] --data KEY=VALUE\\nKEY2=VALUE2 + + $ onegate vm update [VMID] --erase KEY + + $ onegate vm ACTION VMID + $ onegate resume [VMID] + $ onegate stop [VMID] + $ onegate suspend [VMID] + $ onegate terminate [VMID] [--hard] + $ onegate reboot [VMID] [--hard] + $ onegate poweroff [VMID] [--hard] + $ onegate resched [VMID] + $ onegate unresched [VMID] + $ onegate hold [VMID] + $ onegate release [VMID] + + $ onegate service show [--json][--extended] + + $ onegate service scale --role ROLE --cardinality CARDINALITY + + $ onegate vrouter show [--json] + + $ onegate vnet show VNETID [--json][--extended] EOT end end @@ -814,4 +815,3 @@ def self.help_str STDERR.puts OneGate.help_str exit -1 end -