opennebula 5.13.80.pre → 5.13.85.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc16996ef3b6218367420d87066688a52ee86042
4
- data.tar.gz: dae462f84f7ec7bfed459506c56981be1e27974e
3
+ metadata.gz: 8a310ceb9e0f7774f113a0c0ad808a4ffeee42c5
4
+ data.tar.gz: 3024b6d5dbd9fa7c78b2ba1a37dad209a0275945
5
5
  SHA512:
6
- metadata.gz: d6a40c0cbf0a2125a07d18348d0d13471562d81581c06318126a7d671025bdcf34a30c5228af30bd37014af65329714ada099de91fcde70db29198b2731c0fc8
7
- data.tar.gz: 4a53d311862746b7712066d355120306a5b3d4311315dabf24513f5e20dc509acb4254e5d58556090b768f3aa33e89df2311c10127d87c918f7c0befe2b6c8a1
6
+ metadata.gz: f5c51baccf26fda19df4d7a74a70ac8ce9ea0cc93e4b6242294d89c38b2d00c5effcc4ff1d21f7e72527ee2850b087ca57a72e59349dfa4d10d077561927d74d
7
+ data.tar.gz: 59a563064db5aad4e3f95370d283b1212b103e0ae092ac356f473be97843659d26ab56d7b4ac2e40aed91ffe5571a37addfa7dd4f47bc813c50dfc6b55b04c40
@@ -51,7 +51,7 @@ end
51
51
  module CloudClient
52
52
 
53
53
  # OpenNebula version
54
- VERSION = '5.13.80'
54
+ VERSION = '5.13.85'
55
55
 
56
56
  # #########################################################################
57
57
  # Default location for the authentication file
data/lib/datastore.rb CHANGED
@@ -653,8 +653,8 @@ module VCenterDriver
653
653
 
654
654
  wout.close
655
655
  size = rout.readlines.select do |l|
656
- l.start_with?('Content-Length')
657
- end[0].sub('Content-Length: ', '')
656
+ l.downcase.start_with?('content-length')
657
+ end[0].downcase.sub('content-length: ', '')
658
658
  rout.close
659
659
  size.chomp.to_i < 4096 # If <4k, then is a descriptor
660
660
  end
data/lib/opennebula.rb CHANGED
@@ -77,5 +77,5 @@ require 'opennebula/flow'
77
77
  module OpenNebula
78
78
 
79
79
  # OpenNebula version
80
- VERSION = '5.13.80'
80
+ VERSION = '5.13.85'
81
81
  end
@@ -88,7 +88,7 @@ module OpenNebula
88
88
  NO_ONE_AUTH_ERROR = "ONE_AUTH file not present"
89
89
 
90
90
  attr_accessor :one_auth
91
- attr_reader :one_endpoint
91
+ attr_reader :one_endpoint, :one_zmq
92
92
 
93
93
  begin
94
94
  require 'xmlparser'
@@ -152,6 +152,14 @@ module OpenNebula
152
152
 
153
153
  @async = !options[:sync]
154
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
+
155
163
  timeout=nil
156
164
  if options[:timeout]
157
165
  timeout = options[:timeout]
@@ -308,6 +308,8 @@ module OpenNebula
308
308
  end
309
309
 
310
310
  def wait_state(state, timeout=120)
311
+ require 'opennebula/wait_ext'
312
+
311
313
  extend OpenNebula::WaitExt
312
314
 
313
315
  rc = wait(state, timeout)
@@ -322,5 +322,7 @@ module OpenNebula
322
322
  def is_paginated?
323
323
  PAGINATED_POOLS.include?(@pool_name)
324
324
  end
325
+
325
326
  end
327
+
326
328
  end
@@ -75,6 +75,17 @@ module OpenNebula::TemplateExt
75
75
  return [image, ids]
76
76
  end
77
77
 
78
+ i_state = OpenNebula::Image::IMAGE_STATES[
79
+ image['STATE'].to_i
80
+ ]
81
+
82
+ unless %w[LOCKED READY USED].include?(i_state)
83
+ logger.fatal "Wrong image state #{i_state}" if logger
84
+
85
+ rollback(ids)
86
+ return [image, ids]
87
+ end
88
+
78
89
  logger.info "Adding disk with image #{image.id}" if logger
79
90
 
80
91
  tmpl, main = create_app_template(image, idx)
@@ -209,8 +220,14 @@ module OpenNebula::TemplateExt
209
220
  # - content for VM template
210
221
  #-------------------------------------------------------------------
211
222
  def create_app_template(image, idx = 0)
212
- # Wait until the image is READY to safe copy it to the MP
213
- image.wait('READY') if Integer(image['STATE']) != 1
223
+ i_state = OpenNebula::Image::IMAGE_STATES[image['STATE'].to_i]
224
+
225
+ # If the image is used, there is no need to wait until it is
226
+ # ready because the image is already ready to be copied
227
+ if i_state != 'USED' && Integer(image['STATE']) != 1
228
+ # Wait until the image is READY to safe copy it to the MP
229
+ image.wait('READY')
230
+ end
214
231
 
215
232
  # Rename to avoid clashing names
216
233
  app_name = "#{image['NAME']}-#{SecureRandom.hex[0..9]}"
@@ -771,6 +771,8 @@ module OpenNebula
771
771
  end
772
772
 
773
773
  def wait_state(state, timeout=120)
774
+ require 'opennebula/wait_ext'
775
+
774
776
  extend OpenNebula::WaitExt
775
777
 
776
778
  rc = wait2(state, 'LCM_INIT', timeout)
@@ -324,7 +324,7 @@ module OpenNebula::VirtualMachineExt
324
324
  tmp.delete(true)
325
325
 
326
326
  binfo[:apps].each do |id|
327
- log "Deleting applicance #{id}" if logger
327
+ logger.info "Deleting applicance #{id}" if logger
328
328
 
329
329
  papp = OpenNebula::MarketPlaceApp.new_with_id(id, @client)
330
330
 
@@ -14,19 +14,117 @@
14
14
  # limitations under the License. #
15
15
  #--------------------------------------------------------------------------- #
16
16
 
17
- require 'ffi-rzmq'
18
17
 
19
18
  require 'opennebula/host'
20
19
  require 'opennebula/image'
21
20
  require 'opennebula/virtual_machine'
22
21
 
22
+ module OpenNebula::WaitExtEvent
23
+ def wait_event(ctx, event, timeout)
24
+ subscriber = ctx.socket(ZMQ::SUB)
25
+
26
+ # Create subscriber
27
+ key = ''
28
+ content = ''
29
+
30
+ subscriber.setsockopt(ZMQ::RCVTIMEO, timeout * 1000)
31
+ subscriber.setsockopt(ZMQ::SUBSCRIBE, event)
32
+ subscriber.connect(@client.one_zmq)
33
+
34
+ rc = subscriber.recv_string(key)
35
+ rc = subscriber.recv_string(content) if rc != -1
36
+
37
+ return if ZMQ::Util.errno == ZMQ::EAGAIN || rc == -1
38
+
39
+ content
40
+ ensure
41
+ subscriber.setsockopt(ZMQ::UNSUBSCRIBE, event)
42
+ subscriber.close
43
+ end
44
+
45
+ def wait2(sstr1, sstr2, timeout = 60, cycles = -1)
46
+ wfun = OpenNebula::WaitExt::WAIT[self.class]
47
+
48
+ # Start with a timeout of 2 seconds, to wait until the first
49
+ # info.
50
+ #
51
+ # The timeout is increased later, to avoid multiple info calls.
52
+ c_timeout = 2
53
+ recvs = 0
54
+ in_state = false
55
+
56
+ # Subscribe with timeout seconds
57
+ #
58
+ # Subscribe string:
59
+ #
60
+ # EVENT STATE element_name/state_str//self.ID
61
+ #
62
+ # - element_name: is the element name to find in the message
63
+ # - self.ID: returns element ID to find in the message
64
+ ctx = ZMQ::Context.new(1)
65
+
66
+ until in_state || (cycles != -1 && recvs >= cycles)
67
+ content = wait_event(ctx,
68
+ wfun[:event].call(self, sstr1, sstr2),
69
+ c_timeout)
70
+
71
+ if content && !content.empty?
72
+ in_state = wfun[:in_state_e].call(sstr1, sstr2, content)
73
+
74
+ break if in_state
75
+ end
76
+
77
+ c_timeout *= 10
78
+ c_timeout = timeout if c_timeout > timeout
79
+
80
+ rco = info
81
+
82
+ return false if OpenNebula.is_error?(rco)
83
+
84
+ in_state = wfun[:in_state].call(self, sstr1, sstr2)
85
+
86
+ recvs += 1
87
+ end
88
+
89
+ in_state
90
+ end
91
+
92
+ end
93
+
94
+ module OpenNebula::WaitExtPolling
95
+ def wait2(sstr1, sstr2, timeout = 60, cycles = -1)
96
+ wfun = OpenNebula::WaitExt::WAIT[self.class]
97
+
98
+ stime = 5
99
+ recvs = 0
100
+ cycles = timeout / stime
101
+ in_state = false
102
+
103
+ loop do
104
+ rco = info
105
+
106
+ return false if OpenNebula.is_error?(rco)
107
+
108
+ in_state = wfun[:in_state].call(self, sstr1, sstr2)
109
+
110
+ recvs += 1
111
+
112
+ break if in_state || recvs >= cycles
113
+
114
+ sleep stime
115
+ end
116
+
117
+ in_state
118
+ end
119
+
120
+ end
121
+
23
122
  # Module to decorate Wait classes with the following methods:
24
123
  # - Wait
25
124
  #
26
125
  # rubocop:disable Style/ClassAndModuleChildren
27
126
  module OpenNebula::WaitExt
28
-
29
- # Wait classes and the name published in ZMQ
127
+ # Wait classes and the name published in ZMQ/STATE
30
128
  WAIT = {
31
129
  OpenNebula::Host => {
32
130
  :event => lambda {|o, s1, _s2|
@@ -78,7 +176,7 @@ module OpenNebula::WaitExt
78
176
  },
79
177
 
80
178
  :in_state => lambda {|o, s1, s2|
81
- obj_s1 = Integer(o['STATE'])
179
+ obj_s1 = Integer(o['STATE'])
82
180
  inx_s1 = OpenNebula::VirtualMachine::VM_STATE.index(s1)
83
181
 
84
182
  obj_s2 = Integer(o['LCM_STATE'])
@@ -105,93 +203,30 @@ module OpenNebula::WaitExt
105
203
  wait?(obj)
106
204
 
107
205
  class << obj
206
+ begin
207
+ require 'ffi-rzmq'
108
208
 
109
- # Wait until the element reaches some specific state
110
- # It waits until the state can be found in ZMQ event message
111
- #
112
- # @param state_str [String] State name to wait
113
- # @param timeout [Integer] Number of seconds to timeout event recv
114
- # @param cycles [Integer] Number of recv cycles. After each one
115
- # object status is checked in OpenNebula.
116
- # Use -1 (default) to wait forever.
117
- def wait(state_str, timeout = 60, cycles = -1)
118
- wait2(state_str, '', timeout, cycles)
119
- end
120
-
121
- def wait_event(ctx, event, timeout)
122
- subscriber = ctx.socket(ZMQ::SUB)
123
-
124
- # Create subscriber
125
- key = ''
126
- content = ''
127
-
128
- subscriber.setsockopt(ZMQ::RCVTIMEO, timeout * 1000)
129
- subscriber.setsockopt(ZMQ::SUBSCRIBE, event)
130
- subscriber.connect('tcp://localhost:2101')
131
-
132
- rc = subscriber.recv_string(key)
133
- rc = subscriber.recv_string(content) if rc != -1
134
-
135
- return if ZMQ::Util.errno == ZMQ::EAGAIN || rc == -1
136
-
137
- content
138
- ensure
139
- subscriber.setsockopt(ZMQ::UNSUBSCRIBE, event)
140
- subscriber.close
141
- end
142
-
143
- def wait2(sstr1, sstr2, timeout = 60, cycles = -1)
144
- wfun = WAIT[self.class]
145
-
146
- # Start with a timeout of 2 seconds, to wait until the first
147
- # info.
148
- #
149
- # The timeout is increased later, to avoid multiple info calls.
150
- c_timeout = 2
151
- recvs = 0
152
- in_state = false
153
-
154
- # Subscribe with timeout seconds
155
- #
156
- # Subscribe string:
157
- #
158
- # EVENT STATE element_name/state_str//self.ID
159
- #
160
- # - element_name: is the element name to find in the message
161
- # - self.ID: returns element ID to find in the message
162
- ctx = ZMQ::Context.new(1)
163
-
164
- until in_state || (cycles != -1 && recvs >= cycles)
165
- content = wait_event(ctx,
166
- wfun[:event].call(self, sstr1, sstr2),
167
- c_timeout)
168
-
169
- if content && !content.empty?
170
- in_state = wfun[:in_state_e].call(sstr1, sstr2, content)
171
-
172
- break if in_state
173
- end
174
-
175
- c_timeout *= 10
176
- c_timeout = timeout if c_timeout > timeout
177
-
178
- rco = info
179
-
180
- return false if OpenNebula.is_error?(rco)
181
-
182
- in_state = wfun[:in_state].call(self, sstr1, sstr2)
183
-
184
- recvs += 1
185
- end
186
-
187
- in_state
188
- end
189
-
209
+ include OpenNebula::WaitExtEvent
210
+ rescue LoadError
211
+ include OpenNebula::WaitExtPolling
212
+ end
190
213
  end
191
214
 
192
215
  super
193
216
  end
194
217
 
218
+ # Wait until the element reaches some specific state
219
+ # It waits until the state can be found in ZMQ event message
220
+ #
221
+ # @param state_str [String] State name to wait
222
+ # @param timeout [Integer] Number of seconds to timeout event recv
223
+ # @param cycles [Integer] Number of recv cycles. After each one
224
+ # object status is checked in OpenNebula.
225
+ # Use -1 (default) to wait forever.
226
+ def wait(state_str, timeout = 60, cycles = -1)
227
+ wait2(state_str, '', timeout, cycles)
228
+ end
229
+
195
230
  # Check if object has the method wait or not
196
231
  #
197
232
  # @param obj [Object or Class] Object to check class
@@ -1961,7 +1961,7 @@ module VCenterDriver
1961
1961
  end
1962
1962
 
1963
1963
  card_spec = {
1964
- :key => 0,
1964
+ :key => Time.now.utc.strftime('%Y%m%d%M%S%L').to_i,
1965
1965
  :deviceInfo => {
1966
1966
  :label => 'net' + card_num.to_s,
1967
1967
  :summary => pg_name
@@ -2107,7 +2107,7 @@ module VCenterDriver
2107
2107
  end
2108
2108
 
2109
2109
  card_spec = {
2110
- :key => 0,
2110
+ :key => Time.now.utc.strftime('%Y%m%d%M%S%L').to_i,
2111
2111
  :deviceInfo => {
2112
2112
  :label => 'net' + card_num.to_s,
2113
2113
  :summary => pg_name
data/lib/vm_template.rb CHANGED
@@ -602,7 +602,7 @@ module VCenterDriver
602
602
  def nic_alias_from_nic(id, nic, nic_index, network_found, vm_object)
603
603
  nic_tmp = ''
604
604
 
605
- nic_alias_index = 1
605
+ nic_alias_index = 0
606
606
  if nic[:ipv4_additionals]
607
607
  nic[:ipv4_additionals].split(',').each do |ipv4_additional|
608
608
  ipv4, ipv6 =
@@ -1014,7 +1014,7 @@ module VCenterDriver
1014
1014
  # Track allocated networks for rollback
1015
1015
  allocated_networks = []
1016
1016
 
1017
- nic_index = 1
1017
+ nic_index = 0
1018
1018
 
1019
1019
  vc_nics.each do |nic|
1020
1020
  # Check if the network already exists
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: 5.13.80.pre
4
+ version: 5.13.85.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenNebula
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-28 00:00:00.000000000 Z
11
+ date: 2021-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri