opennebula 7.0.2 → 7.2.0

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.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cloud/CloudClient.rb +3 -3
  3. data/lib/models/role.rb +1 -1
  4. data/lib/models/service.rb +1 -1
  5. data/lib/models/vmrole.rb +1 -1
  6. data/lib/models/vrrole.rb +1 -1
  7. data/lib/models.rb +1 -1
  8. data/lib/opennebula/acl.rb +12 -14
  9. data/lib/opennebula/acl_pool.rb +1 -1
  10. data/lib/opennebula/backupjob.rb +1 -1
  11. data/lib/opennebula/backupjob_pool.rb +1 -1
  12. data/lib/opennebula/cluster.rb +1 -1
  13. data/lib/opennebula/cluster_pool.rb +3 -1
  14. data/lib/opennebula/datastore.rb +1 -1
  15. data/lib/opennebula/datastore_pool.rb +3 -1
  16. data/lib/opennebula/document.rb +2 -2
  17. data/lib/opennebula/document_json.rb +2 -1
  18. data/lib/opennebula/document_pool.rb +1 -1
  19. data/lib/opennebula/document_pool_json.rb +3 -1
  20. data/lib/opennebula/error.rb +9 -3
  21. data/lib/opennebula/flow/grammar.rb +1 -1
  22. data/lib/opennebula/flow/service_pool.rb +3 -1
  23. data/lib/opennebula/flow/service_template.rb +2 -1
  24. data/lib/opennebula/flow/service_template_ext.rb +1 -1
  25. data/lib/opennebula/flow/service_template_pool.rb +1 -1
  26. data/lib/opennebula/flow/validator.rb +1 -1
  27. data/lib/opennebula/flow.rb +1 -1
  28. data/lib/opennebula/group.rb +4 -1
  29. data/lib/opennebula/group_pool.rb +3 -1
  30. data/lib/opennebula/grpc/acl_pb.rb +21 -0
  31. data/lib/opennebula/grpc/acl_services_pb.rb +56 -0
  32. data/lib/opennebula/grpc/backupjob_pb.rb +35 -0
  33. data/lib/opennebula/grpc/backupjob_services_pb.rb +70 -0
  34. data/lib/opennebula/grpc/cluster_pb.rb +33 -0
  35. data/lib/opennebula/grpc/cluster_services_pb.rb +38 -0
  36. data/lib/opennebula/grpc/datastore_pb.rb +27 -0
  37. data/lib/opennebula/grpc/datastore_services_pb.rb +62 -0
  38. data/lib/opennebula/grpc/document_pb.rb +29 -0
  39. data/lib/opennebula/grpc/document_services_pb.rb +64 -0
  40. data/lib/opennebula/grpc/group_pb.rb +27 -0
  41. data/lib/opennebula/grpc/group_services_pb.rb +63 -0
  42. data/lib/opennebula/grpc/hook_pb.rb +28 -0
  43. data/lib/opennebula/grpc/hook_services_pb.rb +63 -0
  44. data/lib/opennebula/grpc/host_pb.rb +27 -0
  45. data/lib/opennebula/grpc/host_services_pb.rb +62 -0
  46. data/lib/opennebula/grpc/image_pb.rb +36 -0
  47. data/lib/opennebula/grpc/image_services_pb.rb +71 -0
  48. data/lib/opennebula/grpc/marketplace_pb.rb +29 -0
  49. data/lib/opennebula/grpc/marketplace_services_pb.rb +64 -0
  50. data/lib/opennebula/grpc/marketplaceapp_pb.rb +32 -0
  51. data/lib/opennebula/grpc/marketplaceapp_services_pb.rb +67 -0
  52. data/lib/opennebula/grpc/secgroup_pb.rb +28 -0
  53. data/lib/opennebula/grpc/secgroup_services_pb.rb +63 -0
  54. data/lib/opennebula/grpc/shared_pb.rb +16 -0
  55. data/lib/opennebula/grpc/system_pb.rb +22 -0
  56. data/lib/opennebula/grpc/system_services_pb.rb +57 -0
  57. data/lib/opennebula/grpc/template_pb.rb +30 -0
  58. data/lib/opennebula/grpc/template_services_pb.rb +65 -0
  59. data/lib/opennebula/grpc/user_pb.rb +32 -0
  60. data/lib/opennebula/grpc/user_services_pb.rb +68 -0
  61. data/lib/opennebula/grpc/vdc_pb.rb +34 -0
  62. data/lib/opennebula/grpc/vdc_services_pb.rb +69 -0
  63. data/lib/opennebula/grpc/vm_pb.rb +66 -0
  64. data/lib/opennebula/grpc/vm_services_pb.rb +102 -0
  65. data/lib/opennebula/grpc/vmgroup_pb.rb +31 -0
  66. data/lib/opennebula/grpc/vmgroup_services_pb.rb +66 -0
  67. data/lib/opennebula/grpc/vn_pb.rb +36 -0
  68. data/lib/opennebula/grpc/vn_services_pb.rb +71 -0
  69. data/lib/opennebula/grpc/vntemplate_pb.rb +30 -0
  70. data/lib/opennebula/grpc/vntemplate_services_pb.rb +65 -0
  71. data/lib/opennebula/grpc/vrouter_pb.rb +31 -0
  72. data/lib/opennebula/grpc/vrouter_services_pb.rb +66 -0
  73. data/lib/opennebula/grpc/zone_pb.rb +36 -0
  74. data/lib/opennebula/grpc/zone_services_pb.rb +68 -0
  75. data/lib/opennebula/hook.rb +1 -1
  76. data/lib/opennebula/hook_log.rb +1 -1
  77. data/lib/opennebula/hook_pool.rb +1 -1
  78. data/lib/opennebula/host.rb +3 -1
  79. data/lib/opennebula/host_pool.rb +3 -1
  80. data/lib/opennebula/image.rb +11 -10
  81. data/lib/opennebula/image_pool.rb +1 -1
  82. data/lib/opennebula/ldap_auth.rb +2 -2
  83. data/lib/opennebula/ldap_auth_spec.rb +1 -1
  84. data/lib/opennebula/lockable_ext.rb +13 -24
  85. data/lib/opennebula/marketplace.rb +1 -1
  86. data/lib/opennebula/marketplace_pool.rb +1 -1
  87. data/lib/opennebula/marketplaceapp.rb +1 -1
  88. data/lib/opennebula/marketplaceapp_ext.rb +4 -1
  89. data/lib/opennebula/marketplaceapp_pool.rb +1 -1
  90. data/lib/opennebula/oneflow_client.rb +1 -1
  91. data/lib/opennebula/oneform_client.rb +320 -0
  92. data/lib/opennebula/pool.rb +3 -2
  93. data/lib/opennebula/pool_element.rb +9 -9
  94. data/lib/opennebula/saml_auth.rb +2 -2
  95. data/lib/opennebula/security_group.rb +1 -1
  96. data/lib/opennebula/security_group_pool.rb +1 -1
  97. data/lib/opennebula/server_cipher_auth.rb +1 -1
  98. data/lib/opennebula/server_x509_auth.rb +1 -1
  99. data/lib/opennebula/ssh_auth.rb +1 -1
  100. data/lib/opennebula/system.rb +1 -1
  101. data/lib/opennebula/template.rb +1 -1
  102. data/lib/opennebula/template_ext.rb +1 -1
  103. data/lib/opennebula/template_pool.rb +1 -1
  104. data/lib/opennebula/user.rb +1 -1
  105. data/lib/opennebula/user_pool.rb +2 -1
  106. data/lib/opennebula/utils.rb +1 -1
  107. data/lib/opennebula/vdc.rb +1 -1
  108. data/lib/opennebula/vdc_pool.rb +1 -1
  109. data/lib/opennebula/version.rb +22 -0
  110. data/lib/opennebula/virtual_machine.rb +35 -3
  111. data/lib/opennebula/virtual_machine_ext.rb +3 -1
  112. data/lib/opennebula/virtual_machine_pool.rb +1 -1
  113. data/lib/opennebula/virtual_network.rb +1 -1
  114. data/lib/opennebula/virtual_network_pool.rb +3 -1
  115. data/lib/opennebula/virtual_router.rb +1 -1
  116. data/lib/opennebula/virtual_router_pool.rb +1 -1
  117. data/lib/opennebula/vm_group.rb +1 -1
  118. data/lib/opennebula/vm_group_pool.rb +1 -1
  119. data/lib/opennebula/vntemplate.rb +1 -1
  120. data/lib/opennebula/vntemplate_pool.rb +1 -1
  121. data/lib/opennebula/wait_ext.rb +2 -1
  122. data/lib/opennebula/x509_auth.rb +1 -1
  123. data/lib/opennebula/xml_element.rb +2 -1
  124. data/lib/opennebula/xml_pool.rb +1 -1
  125. data/lib/opennebula/xml_utils.rb +3 -3
  126. data/lib/opennebula/zone.rb +5 -4
  127. data/lib/opennebula/zone_pool.rb +1 -1
  128. data/lib/opennebula.rb +3 -14
  129. metadata +49 -3
  130. data/lib/opennebula/client.rb +0 -228
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2025, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2026, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -42,6 +42,8 @@ module OpenNebula
42
42
 
43
43
  # Default Factory Method for the Pools
44
44
  def factory(element_xml)
45
+ require 'opennebula/virtual_network'
46
+
45
47
  OpenNebula::VirtualNetwork.new(element_xml,@client)
46
48
  end
47
49
 
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2025, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2026, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2025, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2026, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2025, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2026, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2025, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2026, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2025, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2026, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2025, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2026, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2025, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2026, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -17,6 +17,7 @@
17
17
  require 'opennebula/host'
18
18
  require 'opennebula/image'
19
19
  require 'opennebula/virtual_machine'
20
+ require 'opennebula/virtual_network'
20
21
 
21
22
  module OpenNebula
22
23
 
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2025, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2026, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2025, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2026, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -14,6 +14,7 @@
14
14
  # limitations under the License. #
15
15
  #--------------------------------------------------------------------------- #
16
16
 
17
+ require 'rexml/document'
17
18
 
18
19
  module OpenNebula
19
20
  # The XMLElement class provides an abstraction of the underlying
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2025, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2026, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2025, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2026, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -46,7 +46,7 @@ module OpenNebula
46
46
  module ParsePoolBase
47
47
  attr_accessor :pool
48
48
 
49
- def initialize (pool_name, elem_name)
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
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2025, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2026, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -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("ENDPOINT")
88
- endpoint = endpoint.text if endpoint
87
+ endpoint = server.xpath("ENDPOINT_GRPC")&.text
88
+ endpoint = server.xpath("ENDPOINT")&.text if endpoint.nil? || endpoint.empty?
89
89
 
90
- next if endpoint.nil?
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
 
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2025, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2026, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
data/lib/opennebula.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2025, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2026, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -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.0.2
4
+ version: 7.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenNebula
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-12-09 00:00:00.000000000 Z
11
+ date: 2026-03-30 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
@@ -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