Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions appliances/VRouter/vrouter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down
31 changes: 22 additions & 9 deletions appliances/scripts/net-99-report-ready
Original file line number Diff line number Diff line change
Expand Up @@ -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
36 changes: 33 additions & 3 deletions context-linux/src/etc/one-context.d/net-99-report-ready
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
60 changes: 30 additions & 30 deletions context-linux/src/usr/bin/onegate.rb
Original file line number Diff line number Diff line change
@@ -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 #
Expand Down Expand Up @@ -29,7 +29,7 @@
module CloudClient

# OpenNebula version
VERSION = '6.10.0'
VERSION = '6.6.1'

# #########################################################################
# Default location for the authentication file
Expand Down Expand Up @@ -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 = [
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -814,4 +815,3 @@ def self.help_str
STDERR.puts OneGate.help_str
exit -1
end