Skip to content

Commit 65c88ce

Browse files
authored
Revert "B #-: Fixes onegate requests adding content-type header (#233)"
This reverts commit fabec86.
1 parent 5e82584 commit 65c88ce

File tree

4 files changed

+85
-44
lines changed

4 files changed

+85
-44
lines changed

appliances/VRouter/vrouter.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ def initialize
1919
@uri = URI.parse(ENV['ONEGATE_ENDPOINT'])
2020
@vmid = ENV['VMID']
2121
@token = ENV['TOKENTXT']
22-
@req_content_type = 'application/json'
2322

2423
@http = Net::HTTP.new(@uri.host, @uri.port)
2524
@http.use_ssl = @uri.scheme == 'https'
@@ -66,7 +65,6 @@ def do_request(req, keep_alive, expect_json: true)
6665

6766
req['X-ONEGATE-VMID'] = @vmid
6867
req['X-ONEGATE-TOKEN'] = @token
69-
req['Content-Type'] = @req_content_type
7068

7169
expect_json ? JSON.parse(@http.request(req).body) : @http.request(req).body
7270
rescue StandardError => e

appliances/scripts/net-99-report-ready

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,28 @@ if [[ -x '/etc/one-appliance/service' ]]; then
2121
fi
2222
fi
2323

24-
if ! command -v onegate ; then
25-
echo "ERROR: No way to signal READY=YES (onegate binary not found)" >&2
26-
exit 1
27-
fi > /dev/null # this will not drop the error message which goes to stderr
24+
###
2825

29-
if onegate vm update --data READY=YES; then
30-
echo "Reported READY"
31-
exit
26+
if which onegate >/dev/null 2>&1; then
27+
if onegate vm update --data READY=YES; then
28+
exit
29+
fi
30+
fi
31+
32+
if which curl >/dev/null 2>&1; then
33+
if curl -X PUT "$ONEGATE_ENDPOINT/vm" \
34+
--header "X-ONEGATE-TOKEN: $TOKENTXT" \
35+
--header "X-ONEGATE-VMID: $VMID" \
36+
-d READY=YES; then
37+
exit
38+
fi
3239
fi
3340

34-
echo "ERROR: Failed to report READY" >&2
35-
exit 1
41+
if which wget >/dev/null 2>&1; then
42+
if wget --method PUT "$ONEGATE_ENDPOINT/vm" \
43+
--header "X-ONEGATE-TOKEN: $TOKENTXT" \
44+
--header "X-ONEGATE-VMID: $VMID" \
45+
--body-data READY=YES; then
46+
exit
47+
fi
48+
fi

context-linux/src/etc/one-context.d/net-99-report-ready

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,43 @@ fi
3232

3333
###
3434

35-
if ! command -v onegate ; then
36-
echo "ERROR: No way to signal READY=YES (onegate binary not found)" >&2
35+
if command -v curl ; then
36+
_command=curl
37+
elif command -v wget && ! wget --help 2>&1 | grep -q BusyBox; then
38+
_command=wget
39+
elif command -v onegate ; then
40+
_command=onegate
41+
else
42+
echo "ERROR: No way to signal READY=YES (no usable binary)" >&2
3743
exit 1
3844
fi > /dev/null # this will not drop the error message which goes to stderr
3945

4046
report_ready() {
41-
onegate vm update --data "READY=YES"
47+
case "$_command" in
48+
curl)
49+
curl -X "PUT" "${ONEGATE_ENDPOINT}/vm" \
50+
--header "X-ONEGATE-TOKEN: $TOKENTXT" \
51+
--header "X-ONEGATE-VMID: $VMID" \
52+
--max-time 10 \
53+
--insecure \
54+
-d "READY=YES"
55+
;;
56+
wget)
57+
wget --method=PUT "${ONEGATE_ENDPOINT}/vm" \
58+
--body-data="READY=YES" \
59+
--header "X-ONEGATE-TOKEN: $TOKENTXT" \
60+
--header "X-ONEGATE-VMID: $VMID" \
61+
--timeout=10 \
62+
--no-check-certificate
63+
;;
64+
onegate)
65+
if command -v timeout >/dev/null; then
66+
timeout 10 onegate vm update --data "READY=YES"
67+
else
68+
onegate vm update --data "READY=YES"
69+
fi
70+
;;
71+
esac
4272
}
4373

4474
is_base64() {

context-linux/src/usr/bin/onegate.rb

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env ruby
22

33
# -------------------------------------------------------------------------- #
4-
# Copyright 2002-2025, OpenNebula Project, OpenNebula Systems #
4+
# Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
55
# #
66
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
77
# not use this file except in compliance with the License. You may obtain #
@@ -29,7 +29,7 @@
2929
module CloudClient
3030

3131
# OpenNebula version
32-
VERSION = '6.10.0'
32+
VERSION = '6.6.1'
3333

3434
# #########################################################################
3535
# Default location for the authentication file
@@ -359,8 +359,7 @@ module Service
359359
'DEPLOYING_NETS' => 11,
360360
'UNDEPLOYING_NETS' => 12,
361361
'FAILED_DEPLOYING_NETS' => 13,
362-
'FAILED_UNDEPLOYING_NETS' => 14,
363-
'HOLD' => 15
362+
'FAILED_UNDEPLOYING_NETS' => 14
364363
}
365364

366365
STATE_STR = [
@@ -378,8 +377,7 @@ module Service
378377
'DEPLOYING_NETS',
379378
'UNDEPLOYING_NETS',
380379
'FAILED_DEPLOYING_NETS',
381-
'FAILED_UNDEPLOYING_NETS',
382-
'HOLD'
380+
'FAILED_UNDEPLOYING_NETS'
383381
]
384382

385383
# Returns the string representation of the service state
@@ -450,8 +448,6 @@ def initialize(opts={})
450448
@user_agent = "OpenNebula #{CloudClient::VERSION} " <<
451449
"(#{opts[:user_agent]||"Ruby"})"
452450

453-
@req_content_type = opts[:req_content_type] || "application/json"
454-
455451
@host = nil
456452
@port = nil
457453

@@ -509,7 +505,6 @@ def do_request(req)
509505
req['User-Agent'] = @user_agent
510506
req['X-ONEGATE-TOKEN'] = @token
511507
req['X-ONEGATE-VMID'] = @vmid
512-
req['Content-Type'] = @req_content_type
513508

514509
res = CloudClient::http_start(@uri, @timeout) do |http|
515510
http.request(req)
@@ -563,26 +558,32 @@ def self.print_key_value(key, value)
563558

564559
def self.help_str
565560
return <<-EOT
566-
## COMMANDS
567-
568-
* onegate vm show [VMID] [--json]
569-
* onegate vm update [VMID] --data KEY=VALUE\\nKEY2=VALUE2
570-
* onegate vm update [VMID] --erase KEY
571-
* onegate vm ACTION VMID
572-
* onegate resume [VMID]
573-
* onegate stop [VMID]
574-
* onegate suspend [VMID]
575-
* onegate terminate [VMID] [--hard]
576-
* onegate reboot [VMID] [--hard]
577-
* onegate poweroff [VMID] [--hard]
578-
* onegate resched [VMID]
579-
* onegate unresched [VMID]
580-
* onegate hold [VMID]
581-
* onegate release [VMID]
582-
* onegate service show [--json][--extended]
583-
* onegate service scale --role ROLE --cardinality CARDINALITY
584-
* onegate vrouter show [--json]
585-
* onegate vnet show VNETID [--json][--extended]
561+
Available commands
562+
$ onegate vm show [VMID] [--json]
563+
564+
$ onegate vm update [VMID] --data KEY=VALUE\\nKEY2=VALUE2
565+
566+
$ onegate vm update [VMID] --erase KEY
567+
568+
$ onegate vm ACTION VMID
569+
$ onegate resume [VMID]
570+
$ onegate stop [VMID]
571+
$ onegate suspend [VMID]
572+
$ onegate terminate [VMID] [--hard]
573+
$ onegate reboot [VMID] [--hard]
574+
$ onegate poweroff [VMID] [--hard]
575+
$ onegate resched [VMID]
576+
$ onegate unresched [VMID]
577+
$ onegate hold [VMID]
578+
$ onegate release [VMID]
579+
580+
$ onegate service show [--json][--extended]
581+
582+
$ onegate service scale --role ROLE --cardinality CARDINALITY
583+
584+
$ onegate vrouter show [--json]
585+
586+
$ onegate vnet show VNETID [--json][--extended]
586587
EOT
587588
end
588589
end
@@ -814,4 +815,3 @@ def self.help_str
814815
STDERR.puts OneGate.help_str
815816
exit -1
816817
end
817-

0 commit comments

Comments
 (0)