opennebula 5.12.12 → 5.13.80.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/DriverExecHelper.rb +43 -27
- data/lib/OpenNebulaDriver.rb +7 -3
- data/lib/VirtualMachineDriver.rb +8 -1
- data/lib/cloud/CloudClient.rb +1 -1
- data/lib/datacenter.rb +1258 -0
- data/lib/datastore.rb +1025 -0
- data/lib/distributed_firewall.rb +280 -0
- data/lib/file_helper.rb +370 -0
- data/lib/host.rb +1517 -0
- data/lib/logical_port.rb +50 -0
- data/lib/logical_switch.rb +77 -0
- data/lib/memoize.rb +74 -0
- data/lib/models/role.rb +1126 -0
- data/lib/models/service.rb +709 -0
- data/lib/models.rb +32 -0
- data/lib/network.rb +635 -0
- data/lib/nsx_client.rb +144 -0
- data/lib/nsx_component.rb +28 -0
- data/lib/nsx_constants.rb +149 -0
- data/lib/nsx_driver.rb +78 -0
- data/lib/nsx_error.rb +77 -0
- data/lib/nsx_rule.rb +193 -0
- data/lib/nsxt_client.rb +176 -0
- data/lib/nsxt_dfw.rb +196 -0
- data/lib/nsxt_logical_port.rb +94 -0
- data/lib/nsxt_rule.rb +188 -0
- data/lib/nsxt_tz.rb +38 -0
- data/lib/nsxv_client.rb +176 -0
- data/lib/nsxv_dfw.rb +202 -0
- data/lib/nsxv_logical_port.rb +107 -0
- data/lib/nsxv_rule.rb +172 -0
- data/lib/nsxv_tz.rb +41 -0
- data/lib/opaque_network.rb +134 -0
- data/lib/opennebula/document.rb +7 -28
- data/lib/opennebula/document_json.rb +41 -11
- data/lib/opennebula/error.rb +3 -0
- data/lib/opennebula/flow/grammar.rb +1195 -0
- data/lib/opennebula/flow/service_pool.rb +190 -0
- data/lib/opennebula/flow/service_template.rb +572 -0
- data/lib/opennebula/flow/service_template_ext.rb +84 -0
- data/lib/opennebula/flow/service_template_pool.rb +32 -0
- data/lib/opennebula/flow/validator.rb +499 -0
- data/lib/opennebula/flow.rb +23 -0
- data/lib/opennebula/hook.rb +4 -11
- data/lib/opennebula/image.rb +16 -13
- data/lib/opennebula/lockable_ext.rb +163 -0
- data/lib/opennebula/marketplaceapp.rb +8 -118
- data/lib/opennebula/marketplaceapp_ext.rb +522 -0
- data/lib/opennebula/oneflow_client.rb +3 -2
- data/lib/opennebula/pool.rb +3 -2
- data/lib/opennebula/template.rb +3 -12
- data/lib/opennebula/template_ext.rb +325 -0
- data/lib/opennebula/user.rb +25 -1
- data/lib/opennebula/virtual_machine.rb +24 -206
- data/lib/opennebula/virtual_machine_ext.rb +469 -0
- data/lib/opennebula/virtual_machine_pool.rb +0 -4
- data/lib/opennebula/virtual_network.rb +3 -9
- data/lib/opennebula/virtual_router.rb +3 -11
- data/lib/opennebula/vm_group.rb +3 -10
- data/lib/opennebula/vntemplate.rb +3 -12
- data/lib/opennebula/wait_ext.rb +222 -0
- data/lib/opennebula.rb +4 -1
- data/lib/rest_client.rb +201 -0
- data/lib/scripts_common.rb +180 -0
- data/lib/transport_zone.rb +43 -0
- data/lib/vcenter_driver.rb +8 -21
- data/lib/vcenter_importer.rb +616 -0
- data/lib/vi_client.rb +281 -0
- data/lib/vi_helper.rb +312 -0
- data/lib/virtual_machine.rb +3477 -0
- data/lib/virtual_wire.rb +158 -0
- data/lib/vm_device.rb +80 -0
- data/lib/vm_disk.rb +202 -0
- data/lib/vm_folder.rb +69 -0
- data/lib/vm_helper.rb +30 -0
- data/lib/vm_monitor.rb +303 -0
- data/lib/vm_nic.rb +70 -0
- data/lib/vm_template.rb +1961 -0
- data/lib/vmm_importer.rb +121 -0
- metadata +140 -26
@@ -0,0 +1,190 @@
|
|
1
|
+
# -------------------------------------------------------------------------- #
|
2
|
+
# Copyright 2002-2021, 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
|
+
module OpenNebula
|
18
|
+
|
19
|
+
# ServicePool class
|
20
|
+
class OpenNebulaServicePool < DocumentPoolJSON
|
21
|
+
|
22
|
+
DOCUMENT_TYPE = 100
|
23
|
+
|
24
|
+
def initialize(client, user_id = -2)
|
25
|
+
super(client, user_id)
|
26
|
+
end
|
27
|
+
|
28
|
+
def factory(element_xml)
|
29
|
+
service = OpenNebula::Service.new(element_xml, @client)
|
30
|
+
service.load_body
|
31
|
+
service
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
# ServicePool class
|
37
|
+
class ServicePool < Pool
|
38
|
+
|
39
|
+
# rubocop:disable Style/ClassVars
|
40
|
+
@@mutex = Mutex.new
|
41
|
+
@@mutex_hash = {}
|
42
|
+
# rubocop:enable Style/ClassVars
|
43
|
+
|
44
|
+
# Class constructor
|
45
|
+
#
|
46
|
+
# @param [OpenNebula::Client] client the xml-rpc client
|
47
|
+
# @param [Integer] user_id the filter flag, see
|
48
|
+
# http://docs.opennebula.io/stable/integration/system_interfaces/api.html
|
49
|
+
#
|
50
|
+
# @return [DocumentPool] the new object
|
51
|
+
def initialize(cloud_auth, client)
|
52
|
+
# TODO, what if cloud_auth is nil?
|
53
|
+
@cloud_auth = cloud_auth
|
54
|
+
@client = client
|
55
|
+
@one_pool = nil
|
56
|
+
|
57
|
+
if @client
|
58
|
+
info = Nokogiri::XML(@client.call('user.info', -1))
|
59
|
+
@user_id = Integer(info.xpath('/USER/ID').text)
|
60
|
+
end
|
61
|
+
|
62
|
+
super('DOCUMENT_POOL', 'DOCUMENT', @client)
|
63
|
+
end
|
64
|
+
|
65
|
+
def client
|
66
|
+
# If there's a client defined use it
|
67
|
+
return @client unless @client.nil?
|
68
|
+
|
69
|
+
# If not, get one via cloud_auth
|
70
|
+
@cloud_auth.client
|
71
|
+
end
|
72
|
+
|
73
|
+
def info
|
74
|
+
osp = OpenNebulaServicePool.new(client)
|
75
|
+
rc = osp.info
|
76
|
+
|
77
|
+
@one_pool = osp
|
78
|
+
|
79
|
+
rc
|
80
|
+
end
|
81
|
+
|
82
|
+
def info_all
|
83
|
+
osp = OpenNebulaServicePool.new(client)
|
84
|
+
rc = osp.info_all
|
85
|
+
|
86
|
+
@one_pool = osp
|
87
|
+
|
88
|
+
rc
|
89
|
+
end
|
90
|
+
|
91
|
+
# rubocop:disable Lint/ToJSON
|
92
|
+
def to_json
|
93
|
+
# rubocop:enable Lint/ToJSON
|
94
|
+
@one_pool.to_json
|
95
|
+
end
|
96
|
+
|
97
|
+
def each(&block)
|
98
|
+
return if @one_pool.nil?
|
99
|
+
|
100
|
+
@one_pool.each(&block)
|
101
|
+
end
|
102
|
+
|
103
|
+
# Iterates over pool pages
|
104
|
+
# size:: nil => default page size
|
105
|
+
# > 0 => page size
|
106
|
+
# state state of objects
|
107
|
+
def each_page(size)
|
108
|
+
loop_page(size, Service::DOCUMENT_TYPE, false) do |element, page|
|
109
|
+
page.each("//#{element}") do |obj|
|
110
|
+
service = Service.new_with_id(obj['ID'], @client)
|
111
|
+
service.info
|
112
|
+
|
113
|
+
yield(service)
|
114
|
+
end
|
115
|
+
|
116
|
+
size
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
# Retrieves a Service element from OpenNebula. The Service::info()
|
121
|
+
# method is called
|
122
|
+
#
|
123
|
+
# @param [Integer] service_id Numerical Id of the service to retrieve
|
124
|
+
# @yieldparam [Service] this block will have the service's mutex locked.
|
125
|
+
# The mutex will be unlocked after the block execution.
|
126
|
+
#
|
127
|
+
# @return [Service, OpenNebula::Error] The Service in case of success
|
128
|
+
def get(service_id, external_client = nil, &block)
|
129
|
+
service_id = service_id.to_i if service_id
|
130
|
+
aux_client = nil
|
131
|
+
|
132
|
+
if external_client.nil?
|
133
|
+
aux_client = client
|
134
|
+
else
|
135
|
+
aux_client = external_client
|
136
|
+
end
|
137
|
+
|
138
|
+
service = Service.new_with_id(service_id, aux_client)
|
139
|
+
|
140
|
+
if block_given?
|
141
|
+
obj_mutex = nil
|
142
|
+
entry = nil
|
143
|
+
|
144
|
+
@@mutex.synchronize do
|
145
|
+
# entry is an array of [Mutex, waiting]
|
146
|
+
# waiting is the number of threads waiting on this mutex
|
147
|
+
entry = @@mutex_hash[service_id]
|
148
|
+
|
149
|
+
if entry.nil?
|
150
|
+
entry = [Mutex.new, 0]
|
151
|
+
@@mutex_hash[service_id] = entry
|
152
|
+
end
|
153
|
+
|
154
|
+
obj_mutex = entry[0]
|
155
|
+
entry[1] = entry[1] + 1
|
156
|
+
|
157
|
+
if @@mutex_hash.size > 10000
|
158
|
+
@@mutex_hash.delete_if do |_s_id, entry_loop|
|
159
|
+
entry_loop[1] == 0
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
rc = obj_mutex.synchronize do
|
165
|
+
rc = service.info
|
166
|
+
|
167
|
+
if OpenNebula.is_error?(rc)
|
168
|
+
return rc
|
169
|
+
end
|
170
|
+
|
171
|
+
block.call(service)
|
172
|
+
end
|
173
|
+
|
174
|
+
@@mutex.synchronize do
|
175
|
+
entry[1] = entry[1] - 1
|
176
|
+
end
|
177
|
+
|
178
|
+
if OpenNebula.is_error?(rc)
|
179
|
+
return rc
|
180
|
+
end
|
181
|
+
else
|
182
|
+
service.info
|
183
|
+
end
|
184
|
+
|
185
|
+
service
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|