opennebula 7.0.2 → 7.1.80.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/cloud/CloudClient.rb +1 -1
- data/lib/opennebula/acl.rb +11 -13
- data/lib/opennebula/cluster_pool.rb +2 -0
- data/lib/opennebula/datastore_pool.rb +2 -0
- data/lib/opennebula/document.rb +1 -1
- data/lib/opennebula/document_json.rb +1 -0
- data/lib/opennebula/document_pool_json.rb +2 -0
- data/lib/opennebula/error.rb +8 -2
- data/lib/opennebula/flow/service_pool.rb +2 -0
- data/lib/opennebula/flow/service_template.rb +1 -0
- data/lib/opennebula/group.rb +3 -0
- data/lib/opennebula/group_pool.rb +2 -0
- data/lib/opennebula/grpc/acl_pb.rb +21 -0
- data/lib/opennebula/grpc/acl_services_pb.rb +56 -0
- data/lib/opennebula/grpc/backupjob_pb.rb +35 -0
- data/lib/opennebula/grpc/backupjob_services_pb.rb +70 -0
- data/lib/opennebula/grpc/cluster_pb.rb +33 -0
- data/lib/opennebula/grpc/cluster_services_pb.rb +38 -0
- data/lib/opennebula/grpc/datastore_pb.rb +27 -0
- data/lib/opennebula/grpc/datastore_services_pb.rb +62 -0
- data/lib/opennebula/grpc/document_pb.rb +29 -0
- data/lib/opennebula/grpc/document_services_pb.rb +64 -0
- data/lib/opennebula/grpc/group_pb.rb +27 -0
- data/lib/opennebula/grpc/group_services_pb.rb +63 -0
- data/lib/opennebula/grpc/hook_pb.rb +28 -0
- data/lib/opennebula/grpc/hook_services_pb.rb +63 -0
- data/lib/opennebula/grpc/host_pb.rb +27 -0
- data/lib/opennebula/grpc/host_services_pb.rb +62 -0
- data/lib/opennebula/grpc/image_pb.rb +36 -0
- data/lib/opennebula/grpc/image_services_pb.rb +71 -0
- data/lib/opennebula/grpc/marketplace_pb.rb +29 -0
- data/lib/opennebula/grpc/marketplace_services_pb.rb +64 -0
- data/lib/opennebula/grpc/marketplaceapp_pb.rb +32 -0
- data/lib/opennebula/grpc/marketplaceapp_services_pb.rb +67 -0
- data/lib/opennebula/grpc/secgroup_pb.rb +28 -0
- data/lib/opennebula/grpc/secgroup_services_pb.rb +63 -0
- data/lib/opennebula/grpc/shared_pb.rb +16 -0
- data/lib/opennebula/grpc/system_pb.rb +22 -0
- data/lib/opennebula/grpc/system_services_pb.rb +57 -0
- data/lib/opennebula/grpc/template_pb.rb +30 -0
- data/lib/opennebula/grpc/template_services_pb.rb +65 -0
- data/lib/opennebula/grpc/user_pb.rb +32 -0
- data/lib/opennebula/grpc/user_services_pb.rb +68 -0
- data/lib/opennebula/grpc/vdc_pb.rb +34 -0
- data/lib/opennebula/grpc/vdc_services_pb.rb +69 -0
- data/lib/opennebula/grpc/vm_pb.rb +66 -0
- data/lib/opennebula/grpc/vm_services_pb.rb +102 -0
- data/lib/opennebula/grpc/vmgroup_pb.rb +31 -0
- data/lib/opennebula/grpc/vmgroup_services_pb.rb +66 -0
- data/lib/opennebula/grpc/vn_pb.rb +36 -0
- data/lib/opennebula/grpc/vn_services_pb.rb +71 -0
- data/lib/opennebula/grpc/vntemplate_pb.rb +30 -0
- data/lib/opennebula/grpc/vntemplate_services_pb.rb +65 -0
- data/lib/opennebula/grpc/vrouter_pb.rb +31 -0
- data/lib/opennebula/grpc/vrouter_services_pb.rb +66 -0
- data/lib/opennebula/grpc/zone_pb.rb +36 -0
- data/lib/opennebula/grpc/zone_services_pb.rb +68 -0
- data/lib/opennebula/host.rb +2 -0
- data/lib/opennebula/host_pool.rb +2 -0
- data/lib/opennebula/ldap_auth.rb +1 -1
- data/lib/opennebula/lockable_ext.rb +12 -23
- data/lib/opennebula/marketplaceapp_ext.rb +3 -0
- data/lib/opennebula/oneform_client.rb +320 -0
- data/lib/opennebula/pool.rb +2 -1
- data/lib/opennebula/pool_element.rb +8 -8
- data/lib/opennebula/saml_auth.rb +1 -1
- data/lib/opennebula/user_pool.rb +1 -0
- data/lib/opennebula/version.rb +22 -0
- data/lib/opennebula/virtual_machine.rb +34 -2
- data/lib/opennebula/virtual_machine_ext.rb +2 -0
- data/lib/opennebula/virtual_network_pool.rb +2 -0
- data/lib/opennebula/wait_ext.rb +1 -0
- data/lib/opennebula/xml_element.rb +1 -0
- data/lib/opennebula/xml_utils.rb +2 -2
- data/lib/opennebula/zone.rb +4 -3
- data/lib/opennebula.rb +2 -13
- metadata +51 -5
- data/lib/opennebula/client.rb +0 -228
|
@@ -64,7 +64,10 @@ module OpenNebula
|
|
|
64
64
|
:backupcancel => 'vm.backupcancel',
|
|
65
65
|
:attachpci => 'vm.attachpci',
|
|
66
66
|
:detachpci => 'vm.detachpci',
|
|
67
|
-
:restore => 'vm.restore'
|
|
67
|
+
:restore => 'vm.restore',
|
|
68
|
+
:exec => 'vm.exec',
|
|
69
|
+
:retryexec => 'vm.retryexec',
|
|
70
|
+
:cancelexec => 'vm.cancelexec'
|
|
68
71
|
}
|
|
69
72
|
|
|
70
73
|
VM_STATE=['INIT', 'PENDING', 'HOLD', 'ACTIVE', 'STOPPED', 'SUSPENDED', 'DONE', 'FAILED',
|
|
@@ -294,7 +297,10 @@ module OpenNebula
|
|
|
294
297
|
'sg-detach',
|
|
295
298
|
'pci-attach',
|
|
296
299
|
'pci-detach',
|
|
297
|
-
'restore'
|
|
300
|
+
'restore',
|
|
301
|
+
'exec',
|
|
302
|
+
'exec-retry',
|
|
303
|
+
'exec-cancel'
|
|
298
304
|
]
|
|
299
305
|
|
|
300
306
|
# VirtualMachineDriver constants
|
|
@@ -894,6 +900,32 @@ module OpenNebula
|
|
|
894
900
|
@client.call(VM_METHODS[:restore], @pe_id, img_id, inc_id, disk_id)
|
|
895
901
|
end
|
|
896
902
|
|
|
903
|
+
# Execute a command in the VM
|
|
904
|
+
#
|
|
905
|
+
# @param cmd [String] Command to be executed
|
|
906
|
+
# @param cmd_stdin [String] Stdin data for the command
|
|
907
|
+
# @return [nil, OpenNebula::Error] nil in case of sucess, Error
|
|
908
|
+
# otherwise.
|
|
909
|
+
def exec(cmd, cmd_stdin)
|
|
910
|
+
@client.call(VM_METHODS[:exec], @pe_id, cmd, cmd_stdin)
|
|
911
|
+
end
|
|
912
|
+
|
|
913
|
+
# Retry the last command executed in the VM
|
|
914
|
+
#
|
|
915
|
+
# @return [nil, OpenNebula::Error] nil in case of sucess, Error
|
|
916
|
+
# otherwise.
|
|
917
|
+
def exec_retry
|
|
918
|
+
@client.call(VM_METHODS[:retryexec], @pe_id)
|
|
919
|
+
end
|
|
920
|
+
|
|
921
|
+
# Cancel the command being executed in the VM
|
|
922
|
+
#
|
|
923
|
+
# @return [nil, OpenNebula::Error] nil in case of sucess, Error
|
|
924
|
+
# otherwise.
|
|
925
|
+
def exec_cancel
|
|
926
|
+
@client.call(VM_METHODS[:cancelexec], @pe_id)
|
|
927
|
+
end
|
|
928
|
+
|
|
897
929
|
########################################################################
|
|
898
930
|
# Helpers to get VirtualMachine information
|
|
899
931
|
########################################################################
|
data/lib/opennebula/wait_ext.rb
CHANGED
data/lib/opennebula/xml_utils.rb
CHANGED
|
@@ -46,7 +46,7 @@ module OpenNebula
|
|
|
46
46
|
module ParsePoolBase
|
|
47
47
|
attr_accessor :pool
|
|
48
48
|
|
|
49
|
-
def initialize
|
|
49
|
+
def initialize(pool_name, elem_name)
|
|
50
50
|
clear
|
|
51
51
|
|
|
52
52
|
@pool_name = pool_name
|
|
@@ -91,7 +91,7 @@ module OpenNebula
|
|
|
91
91
|
@current = 0
|
|
92
92
|
@levels[0] = Hash.new
|
|
93
93
|
else
|
|
94
|
-
@current = @current -1
|
|
94
|
+
@current = @current - 1
|
|
95
95
|
end
|
|
96
96
|
end
|
|
97
97
|
end
|
data/lib/opennebula/zone.rb
CHANGED
|
@@ -84,10 +84,11 @@ module OpenNebula
|
|
|
84
84
|
return rc if OpenNebula.is_error?(rc)
|
|
85
85
|
|
|
86
86
|
@xml.xpath("SERVER_POOL/SERVER").each do |server|
|
|
87
|
-
endpoint = server.xpath("
|
|
88
|
-
endpoint =
|
|
87
|
+
endpoint = server.xpath("ENDPOINT_GRPC")&.text
|
|
88
|
+
endpoint = server.xpath("ENDPOINT")&.text if endpoint.nil? || endpoint.empty?
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
#puts "endpoint:#{endpoint}:#{server.xpath("ENDPOINT_GRPC").text}:#{server.xpath("ENDPOINT").text}"
|
|
91
|
+
next if endpoint.nil? || endpoint.empty?
|
|
91
92
|
|
|
92
93
|
client = OpenNebula::Client.new(nil, endpoint, {:timeout => 5})
|
|
93
94
|
|
data/lib/opennebula.rb
CHANGED
|
@@ -14,18 +14,12 @@
|
|
|
14
14
|
# limitations under the License. #
|
|
15
15
|
#--------------------------------------------------------------------------- #
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
begin # require 'rubygems'
|
|
19
|
-
require 'rubygems'
|
|
20
|
-
rescue Exception
|
|
21
|
-
end
|
|
22
|
-
|
|
23
17
|
require 'digest/sha1'
|
|
24
18
|
require 'rexml/document'
|
|
25
19
|
require 'pp'
|
|
26
20
|
|
|
27
21
|
require 'opennebula/xml_utils'
|
|
28
|
-
require 'opennebula/client'
|
|
22
|
+
require 'opennebula/lib/client'
|
|
29
23
|
require 'opennebula/error'
|
|
30
24
|
require 'opennebula/utils'
|
|
31
25
|
require 'opennebula/virtual_machine'
|
|
@@ -75,9 +69,4 @@ require 'opennebula/hook_log'
|
|
|
75
69
|
require 'opennebula/flow'
|
|
76
70
|
require 'opennebula/backupjob'
|
|
77
71
|
require 'opennebula/backupjob_pool'
|
|
78
|
-
|
|
79
|
-
module OpenNebula
|
|
80
|
-
|
|
81
|
-
# OpenNebula version
|
|
82
|
-
VERSION = '7.0.2'
|
|
83
|
-
end
|
|
72
|
+
require 'opennebula/version'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: opennebula
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 7.
|
|
4
|
+
version: 7.1.80.pre
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- OpenNebula
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-02-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: nokogiri
|
|
@@ -113,7 +113,6 @@ files:
|
|
|
113
113
|
- lib/opennebula/acl_pool.rb
|
|
114
114
|
- lib/opennebula/backupjob.rb
|
|
115
115
|
- lib/opennebula/backupjob_pool.rb
|
|
116
|
-
- lib/opennebula/client.rb
|
|
117
116
|
- lib/opennebula/cluster.rb
|
|
118
117
|
- lib/opennebula/cluster_pool.rb
|
|
119
118
|
- lib/opennebula/datastore.rb
|
|
@@ -132,6 +131,51 @@ files:
|
|
|
132
131
|
- lib/opennebula/flow/validator.rb
|
|
133
132
|
- lib/opennebula/group.rb
|
|
134
133
|
- lib/opennebula/group_pool.rb
|
|
134
|
+
- lib/opennebula/grpc/acl_pb.rb
|
|
135
|
+
- lib/opennebula/grpc/acl_services_pb.rb
|
|
136
|
+
- lib/opennebula/grpc/backupjob_pb.rb
|
|
137
|
+
- lib/opennebula/grpc/backupjob_services_pb.rb
|
|
138
|
+
- lib/opennebula/grpc/cluster_pb.rb
|
|
139
|
+
- lib/opennebula/grpc/cluster_services_pb.rb
|
|
140
|
+
- lib/opennebula/grpc/datastore_pb.rb
|
|
141
|
+
- lib/opennebula/grpc/datastore_services_pb.rb
|
|
142
|
+
- lib/opennebula/grpc/document_pb.rb
|
|
143
|
+
- lib/opennebula/grpc/document_services_pb.rb
|
|
144
|
+
- lib/opennebula/grpc/group_pb.rb
|
|
145
|
+
- lib/opennebula/grpc/group_services_pb.rb
|
|
146
|
+
- lib/opennebula/grpc/hook_pb.rb
|
|
147
|
+
- lib/opennebula/grpc/hook_services_pb.rb
|
|
148
|
+
- lib/opennebula/grpc/host_pb.rb
|
|
149
|
+
- lib/opennebula/grpc/host_services_pb.rb
|
|
150
|
+
- lib/opennebula/grpc/image_pb.rb
|
|
151
|
+
- lib/opennebula/grpc/image_services_pb.rb
|
|
152
|
+
- lib/opennebula/grpc/marketplace_pb.rb
|
|
153
|
+
- lib/opennebula/grpc/marketplace_services_pb.rb
|
|
154
|
+
- lib/opennebula/grpc/marketplaceapp_pb.rb
|
|
155
|
+
- lib/opennebula/grpc/marketplaceapp_services_pb.rb
|
|
156
|
+
- lib/opennebula/grpc/secgroup_pb.rb
|
|
157
|
+
- lib/opennebula/grpc/secgroup_services_pb.rb
|
|
158
|
+
- lib/opennebula/grpc/shared_pb.rb
|
|
159
|
+
- lib/opennebula/grpc/system_pb.rb
|
|
160
|
+
- lib/opennebula/grpc/system_services_pb.rb
|
|
161
|
+
- lib/opennebula/grpc/template_pb.rb
|
|
162
|
+
- lib/opennebula/grpc/template_services_pb.rb
|
|
163
|
+
- lib/opennebula/grpc/user_pb.rb
|
|
164
|
+
- lib/opennebula/grpc/user_services_pb.rb
|
|
165
|
+
- lib/opennebula/grpc/vdc_pb.rb
|
|
166
|
+
- lib/opennebula/grpc/vdc_services_pb.rb
|
|
167
|
+
- lib/opennebula/grpc/vm_pb.rb
|
|
168
|
+
- lib/opennebula/grpc/vm_services_pb.rb
|
|
169
|
+
- lib/opennebula/grpc/vmgroup_pb.rb
|
|
170
|
+
- lib/opennebula/grpc/vmgroup_services_pb.rb
|
|
171
|
+
- lib/opennebula/grpc/vn_pb.rb
|
|
172
|
+
- lib/opennebula/grpc/vn_services_pb.rb
|
|
173
|
+
- lib/opennebula/grpc/vntemplate_pb.rb
|
|
174
|
+
- lib/opennebula/grpc/vntemplate_services_pb.rb
|
|
175
|
+
- lib/opennebula/grpc/vrouter_pb.rb
|
|
176
|
+
- lib/opennebula/grpc/vrouter_services_pb.rb
|
|
177
|
+
- lib/opennebula/grpc/zone_pb.rb
|
|
178
|
+
- lib/opennebula/grpc/zone_services_pb.rb
|
|
135
179
|
- lib/opennebula/hook.rb
|
|
136
180
|
- lib/opennebula/hook_log.rb
|
|
137
181
|
- lib/opennebula/hook_pool.rb
|
|
@@ -148,6 +192,7 @@ files:
|
|
|
148
192
|
- lib/opennebula/marketplaceapp_ext.rb
|
|
149
193
|
- lib/opennebula/marketplaceapp_pool.rb
|
|
150
194
|
- lib/opennebula/oneflow_client.rb
|
|
195
|
+
- lib/opennebula/oneform_client.rb
|
|
151
196
|
- lib/opennebula/pool.rb
|
|
152
197
|
- lib/opennebula/pool_element.rb
|
|
153
198
|
- lib/opennebula/saml_auth.rb
|
|
@@ -165,6 +210,7 @@ files:
|
|
|
165
210
|
- lib/opennebula/utils.rb
|
|
166
211
|
- lib/opennebula/vdc.rb
|
|
167
212
|
- lib/opennebula/vdc_pool.rb
|
|
213
|
+
- lib/opennebula/version.rb
|
|
168
214
|
- lib/opennebula/virtual_machine.rb
|
|
169
215
|
- lib/opennebula/virtual_machine_ext.rb
|
|
170
216
|
- lib/opennebula/virtual_machine_pool.rb
|
|
@@ -198,9 +244,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
198
244
|
version: '0'
|
|
199
245
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
200
246
|
requirements:
|
|
201
|
-
- - "
|
|
247
|
+
- - ">"
|
|
202
248
|
- !ruby/object:Gem::Version
|
|
203
|
-
version:
|
|
249
|
+
version: 1.3.1
|
|
204
250
|
requirements: []
|
|
205
251
|
rubygems_version: 3.3.5
|
|
206
252
|
signing_key:
|
data/lib/opennebula/client.rb
DELETED
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-2025, OpenNebula Project, OpenNebula Systems #
|
|
3
|
-
# #
|
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
|
-
# not use this file except in compliance with the License. You may obtain #
|
|
6
|
-
# a copy of the License at #
|
|
7
|
-
# #
|
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0 #
|
|
9
|
-
# #
|
|
10
|
-
# Unless required by applicable law or agreed to in writing, software #
|
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS, #
|
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
|
13
|
-
# See the License for the specific language governing permissions and #
|
|
14
|
-
# limitations under the License. #
|
|
15
|
-
#--------------------------------------------------------------------------- #
|
|
16
|
-
|
|
17
|
-
require 'xmlrpc/client'
|
|
18
|
-
require 'bigdecimal'
|
|
19
|
-
require 'stringio'
|
|
20
|
-
require 'openssl'
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
module OpenNebula
|
|
24
|
-
def self.pool_page_size
|
|
25
|
-
@@pool_page_size
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
if OpenNebula::OX
|
|
29
|
-
class OxStreamParser < XMLRPC::XMLParser::AbstractStreamParser
|
|
30
|
-
def initialize
|
|
31
|
-
@parser_class = OxParser
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
class OxParser < Ox::Sax
|
|
35
|
-
include XMLRPC::XMLParser::StreamParserMixin
|
|
36
|
-
|
|
37
|
-
alias :text :character
|
|
38
|
-
alias :end_element :endElement
|
|
39
|
-
alias :start_element :startElement
|
|
40
|
-
|
|
41
|
-
def parse(str)
|
|
42
|
-
|
|
43
|
-
Ox.sax_parse(self, StringIO.new(str),
|
|
44
|
-
:symbolize => false,
|
|
45
|
-
:convert_special => true,
|
|
46
|
-
:skip => :skip_none)
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
elsif OpenNebula::NOKOGIRI
|
|
51
|
-
class NokogiriStreamParser < XMLRPC::XMLParser::AbstractStreamParser
|
|
52
|
-
def initialize
|
|
53
|
-
@parser_class = NokogiriParser
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
class NokogiriParser < Nokogiri::XML::SAX::Document
|
|
57
|
-
include XMLRPC::XMLParser::StreamParserMixin
|
|
58
|
-
|
|
59
|
-
alias :cdata_block :character
|
|
60
|
-
alias :characters :character
|
|
61
|
-
alias :end_element :endElement
|
|
62
|
-
alias :start_element :startElement
|
|
63
|
-
|
|
64
|
-
def parse(str)
|
|
65
|
-
parser = Nokogiri::XML::SAX::Parser.new(self)
|
|
66
|
-
parser.parse(str)
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
DEFAULT_POOL_PAGE_SIZE = 200
|
|
73
|
-
|
|
74
|
-
if size=ENV['ONE_POOL_PAGE_SIZE']
|
|
75
|
-
if size.strip.match(/^\d+$/) && size.to_i >= 2
|
|
76
|
-
@@pool_page_size = size.to_i
|
|
77
|
-
else
|
|
78
|
-
@@pool_page_size = nil
|
|
79
|
-
end
|
|
80
|
-
else
|
|
81
|
-
@@pool_page_size = DEFAULT_POOL_PAGE_SIZE
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
# The client class, represents the connection with the core and handles the
|
|
86
|
-
# xml-rpc calls.
|
|
87
|
-
class Client
|
|
88
|
-
NO_ONE_AUTH_ERROR = "ONE_AUTH file not present"
|
|
89
|
-
|
|
90
|
-
attr_accessor :one_auth
|
|
91
|
-
attr_reader :one_endpoint, :one_zmq
|
|
92
|
-
|
|
93
|
-
begin
|
|
94
|
-
require 'xmlparser'
|
|
95
|
-
XMLPARSER=true
|
|
96
|
-
rescue LoadError
|
|
97
|
-
XMLPARSER=false
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
# Creates a new client object that will be used to call OpenNebula
|
|
101
|
-
# functions.
|
|
102
|
-
#
|
|
103
|
-
# @param [String, nil] secret user credentials ("user:password") or
|
|
104
|
-
# nil to get the credentials from user auth file
|
|
105
|
-
# @param [String, nil] endpoint OpenNebula server endpoint
|
|
106
|
-
# (http://host:2633/RPC2) or nil to get it form the environment
|
|
107
|
-
# variable ONE_XMLRPC or use the default endpoint
|
|
108
|
-
# @param [Hash] options
|
|
109
|
-
# @option params [Integer] :timeout connection timeout in seconds,
|
|
110
|
-
# defaults to 30
|
|
111
|
-
# @option params [String] :http_proxy HTTP proxy string used for
|
|
112
|
-
# connecting to the endpoint; defaults to no proxy
|
|
113
|
-
# @option params [Boolean] :sync Use only one http connection for
|
|
114
|
-
# all calls. It should not be used for multithreaded programs.
|
|
115
|
-
# It's the only mode that can be used with :cert_dir and
|
|
116
|
-
# :disable_ssl_verify
|
|
117
|
-
# @option params [String] :cert_dir Extra directory where to import
|
|
118
|
-
# trusted issuer certificates. Use with :sync = true
|
|
119
|
-
# @option params [String] :disable_ssl_verify Disable SSL certificate
|
|
120
|
-
# verification. Use only for testing and with :sync = true
|
|
121
|
-
#
|
|
122
|
-
# @return [OpenNebula::Client]
|
|
123
|
-
def initialize(secret=nil, endpoint=nil, options={})
|
|
124
|
-
if secret
|
|
125
|
-
@one_auth = secret
|
|
126
|
-
elsif ENV["ONE_AUTH"] and !ENV["ONE_AUTH"].empty? and
|
|
127
|
-
File.file?(ENV["ONE_AUTH"])
|
|
128
|
-
@one_auth = File.read(ENV["ONE_AUTH"])
|
|
129
|
-
elsif ENV["HOME"] and File.file?(ENV["HOME"]+"/.one/one_auth")
|
|
130
|
-
@one_auth = File.read(ENV["HOME"]+"/.one/one_auth")
|
|
131
|
-
elsif File.file?("/var/lib/one/.one/one_auth")
|
|
132
|
-
@one_auth = File.read("/var/lib/one/.one/one_auth")
|
|
133
|
-
else
|
|
134
|
-
raise NO_ONE_AUTH_ERROR
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
@one_auth = @one_auth.rstrip
|
|
138
|
-
|
|
139
|
-
if endpoint
|
|
140
|
-
@one_endpoint = endpoint
|
|
141
|
-
elsif ENV["ONE_XMLRPC"]
|
|
142
|
-
@one_endpoint = ENV["ONE_XMLRPC"]
|
|
143
|
-
elsif ENV['HOME'] and File.exist?(ENV['HOME']+"/.one/one_endpoint")
|
|
144
|
-
@one_endpoint = File.read(ENV['HOME']+"/.one/one_endpoint")
|
|
145
|
-
elsif File.exist?("/var/lib/one/.one/one_endpoint")
|
|
146
|
-
@one_endpoint = File.read("/var/lib/one/.one/one_endpoint")
|
|
147
|
-
else
|
|
148
|
-
@one_endpoint = "http://localhost:2633/RPC2"
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
@one_endpoint= @one_endpoint.rstrip
|
|
152
|
-
|
|
153
|
-
@async = !options[:sync]
|
|
154
|
-
|
|
155
|
-
if options[:subscriber_endpoint]
|
|
156
|
-
@one_zmq = options[:subscriber_endpoint]
|
|
157
|
-
elsif ENV["ONE_ZMQ"]
|
|
158
|
-
@one_zmq = ENV["ONE_ZMQ"]
|
|
159
|
-
else
|
|
160
|
-
@one_zmq = 'tcp://localhost:2101'
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
timeout=nil
|
|
164
|
-
if options[:timeout]
|
|
165
|
-
timeout = options[:timeout]
|
|
166
|
-
elsif ENV['ONE_XMLRPC_TIMEOUT']
|
|
167
|
-
timeout = ENV['ONE_XMLRPC_TIMEOUT'].to_i
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
http_proxy=nil
|
|
171
|
-
http_proxy=options[:http_proxy] if options[:http_proxy]
|
|
172
|
-
|
|
173
|
-
@server = XMLRPC::Client.new2(@one_endpoint, http_proxy, timeout)
|
|
174
|
-
@server.http_header_extra = {'accept-encoding' => 'identity'}
|
|
175
|
-
|
|
176
|
-
http = @server.instance_variable_get("@http")
|
|
177
|
-
|
|
178
|
-
if options[:cert_dir] || ENV['ONE_CERT_DIR']
|
|
179
|
-
raise "SSL options don't work in async mode" if @async
|
|
180
|
-
|
|
181
|
-
cert_dir = options[:cert_dir] || ENV['ONE_CERT_DIR']
|
|
182
|
-
cert_files = Dir["#{cert_dir}/*"]
|
|
183
|
-
|
|
184
|
-
cert_store = OpenSSL::X509::Store.new
|
|
185
|
-
cert_store.set_default_paths
|
|
186
|
-
cert_files.each {|cert| cert_store.add_file(cert) }
|
|
187
|
-
|
|
188
|
-
http.cert_store = cert_store
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
if options[:disable_ssl_verify] || ENV['ONE_DISABLE_SSL_VERIFY']
|
|
192
|
-
raise "SSL options don't work in async mode" if @async
|
|
193
|
-
|
|
194
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
if defined?(OxStreamParser)
|
|
198
|
-
@server.set_parser(OxStreamParser.new)
|
|
199
|
-
elsif OpenNebula::NOKOGIRI
|
|
200
|
-
@server.set_parser(NokogiriStreamParser.new)
|
|
201
|
-
elsif XMLPARSER
|
|
202
|
-
@server.set_parser(XMLRPC::XMLParser::XMLStreamParser.new)
|
|
203
|
-
end
|
|
204
|
-
end
|
|
205
|
-
|
|
206
|
-
def call(action, *args)
|
|
207
|
-
begin
|
|
208
|
-
if @async
|
|
209
|
-
response = @server.call_async("one."+action, @one_auth, *args)
|
|
210
|
-
else
|
|
211
|
-
response = @server.call("one."+action, @one_auth, *args)
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
if response[0] == false
|
|
215
|
-
Error.new(response[1], response[2])
|
|
216
|
-
else
|
|
217
|
-
response[1] #response[1..-1]
|
|
218
|
-
end
|
|
219
|
-
rescue Exception => e
|
|
220
|
-
Error.new(e.message, Error::EXML_RPC_CALL)
|
|
221
|
-
end
|
|
222
|
-
end
|
|
223
|
-
|
|
224
|
-
def get_version()
|
|
225
|
-
call("system.version")
|
|
226
|
-
end
|
|
227
|
-
end
|
|
228
|
-
end
|