opennebula-cli 4.3.90.rc1 → 4.4.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.
- checksums.yaml +7 -0
- data/bin/oneflow +1 -1
- data/bin/onehost +18 -3
- data/bin/onetemplate +11 -0
- data/lib/one_helper/onedatastore_helper.rb +3 -1
- data/lib/one_helper/onehost_helper.rb +96 -12
- data/lib/one_helper/oneimage_helper.rb +1 -4
- data/lib/one_helper/onetemplate_helper.rb +7 -0
- metadata +10 -15
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 09217c63aeee7abd11ea62bbce95d89aebf56bbf
|
4
|
+
data.tar.gz: d7f49893d15771de27179a3abbdf5df268b2f395
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9c3429402c0d4d1dddc85d22d31318b6572839b54f87383f42c7e96c6708e90b3d6d689a7ad4e0cf9372fcd44416d8c191387cedd82ad9e1892fcc629e805f72
|
7
|
+
data.tar.gz: 939acfc80e9e32485bcebbec3944f77b059ad1e4344bce722fc79dfa75df8234a84b7747a1ad319174e050fcd4fa4e67d2f00f60f485ef12386545ca2f56d848
|
data/bin/oneflow
CHANGED
@@ -251,7 +251,7 @@ def show_service(client, args, options)
|
|
251
251
|
puts str % ["ROLE STATE", Role.state_str(role['state'])]
|
252
252
|
puts str % ["PARENTS", role['parents'].join(', ')] if role['parents']
|
253
253
|
puts str % ["VM TEMPLATE", role['vm_template']]
|
254
|
-
puts str % ["
|
254
|
+
puts str % ["CARDINALITY", role['cardinality']]
|
255
255
|
puts str % ["MIN VMS", role['min_vms']] if role['min_vms']
|
256
256
|
puts str % ["MAX VMS", role['max_vms']] if role['max_vms']
|
257
257
|
puts str % ["COOLDOWN", "#{role['cooldown']}s"] if role['cooldown']
|
data/bin/onehost
CHANGED
@@ -73,8 +73,22 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
73
73
|
:format => String
|
74
74
|
}
|
75
75
|
|
76
|
+
FORCE = {
|
77
|
+
:name => "force",
|
78
|
+
:large => "--force" ,
|
79
|
+
:description => "Force probe upgrade in onehost sync"
|
80
|
+
}
|
81
|
+
|
82
|
+
RSYNC = {
|
83
|
+
:name => "rsync",
|
84
|
+
:large => "--rsync" ,
|
85
|
+
:description => "Use rsync to synchronize remotes. In case some " <<
|
86
|
+
"probes are no longer in the fronted are deleted in the hosts." <<
|
87
|
+
" rsync command must be installed in the frontend and nodes."
|
88
|
+
}
|
89
|
+
|
76
90
|
CREAT_OPTIONS = [ IM, VMM, VNET, OneClusterHelper::CLUSTER ]
|
77
|
-
SYNC_OPTIONS = [ OneClusterHelper::CLUSTER ]
|
91
|
+
SYNC_OPTIONS = [ OneClusterHelper::CLUSTER, FORCE, RSYNC ]
|
78
92
|
|
79
93
|
########################################################################
|
80
94
|
# Formatters for arguments
|
@@ -173,8 +187,9 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
173
187
|
onehost sync host01,host02,host03
|
174
188
|
EOT
|
175
189
|
|
176
|
-
command :sync, sync_desc, [:range
|
177
|
-
|
190
|
+
command :sync, sync_desc, [:range, :hostid_list, nil],
|
191
|
+
:options=>SYNC_OPTIONS do
|
192
|
+
helper.sync(args[0], options)
|
178
193
|
end
|
179
194
|
|
180
195
|
list_desc = <<-EOT.unindent
|
data/bin/onetemplate
CHANGED
@@ -54,6 +54,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
54
54
|
instantiate_options = [
|
55
55
|
OneTemplateHelper::VM_NAME,
|
56
56
|
OneTemplateHelper::MULTIPLE,
|
57
|
+
OneTemplateHelper::USERDATA,
|
57
58
|
OneVMHelper::HOLD
|
58
59
|
]
|
59
60
|
|
@@ -196,6 +197,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
196
197
|
|
197
198
|
if args[1]
|
198
199
|
extra_template = File.read(args[1])
|
200
|
+
elsif options[:userdata]
|
201
|
+
t.info
|
202
|
+
if t.has_elements?('TEMPLATE/EC2')
|
203
|
+
t.add_element(
|
204
|
+
'TEMPLATE/EC2',
|
205
|
+
'USERDATA' => options[:userdata])
|
206
|
+
|
207
|
+
extra_template = t.template_like_str(
|
208
|
+
'TEMPLATE', false, 'EC2')
|
209
|
+
end
|
199
210
|
else
|
200
211
|
res = OpenNebulaHelper.create_template(options)
|
201
212
|
|
@@ -134,10 +134,12 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
|
|
134
134
|
|
135
135
|
shared = datastore['TEMPLATE/SHARED']
|
136
136
|
local = shared != nil && shared.upcase == 'NO'
|
137
|
+
limit_mb = datastore['TEMPLATE/LIMIT_MB']
|
137
138
|
|
138
139
|
puts str % ["TOTAL:", local ? '-' : OpenNebulaHelper.unit_to_str(datastore['TOTAL_MB'].to_i, {},'M')]
|
139
|
-
puts str % ["USED: ", local ? '-' : OpenNebulaHelper.unit_to_str(datastore['USED_MB'].to_i, {},'M')]
|
140
140
|
puts str % ["FREE:", local ? '-' : OpenNebulaHelper.unit_to_str(datastore['FREE_MB'].to_i, {},'M')]
|
141
|
+
puts str % ["USED: ", local ? '-' : OpenNebulaHelper.unit_to_str(datastore['USED_MB'].to_i, {},'M')]
|
142
|
+
puts str % ["LIMIT:", local || limit_mb.nil? ? '-' : OpenNebulaHelper.unit_to_str(limit_mb.to_i, {},'M')]
|
141
143
|
puts
|
142
144
|
|
143
145
|
CLIHelper.print_header(str_h1 % "PERMISSIONS",false)
|
@@ -18,6 +18,9 @@ require 'one_helper'
|
|
18
18
|
require 'one_helper/onevm_helper'
|
19
19
|
|
20
20
|
class OneHostHelper < OpenNebulaHelper::OneHelper
|
21
|
+
TEMPLATE_XPATH = '//HOST/TEMPLATE'
|
22
|
+
VERSION_XPATH = "#{TEMPLATE_XPATH}/VERSION"
|
23
|
+
|
21
24
|
def self.rname
|
22
25
|
"HOST"
|
23
26
|
end
|
@@ -163,6 +166,18 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
|
|
163
166
|
|
164
167
|
NUM_THREADS = 15
|
165
168
|
def sync(host_ids, options)
|
169
|
+
begin
|
170
|
+
current_version = File.read(REMOTES_LOCATION+'/VERSION').strip
|
171
|
+
rescue
|
172
|
+
STDERR.puts("Could not read #{REMOTES_LOCATION}/VERSION")
|
173
|
+
exit(-1)
|
174
|
+
end
|
175
|
+
|
176
|
+
if current_version.empty?
|
177
|
+
STDERR.puts "Remotes version can not be empty"
|
178
|
+
exit(-1)
|
179
|
+
end
|
180
|
+
|
166
181
|
cluster_id = options[:cluster]
|
167
182
|
|
168
183
|
# Get remote_dir (implies oneadmin group)
|
@@ -192,7 +207,7 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
|
|
192
207
|
|
193
208
|
# Assign hosts to threads
|
194
209
|
i = 0
|
195
|
-
|
210
|
+
queue = Array.new
|
196
211
|
|
197
212
|
pool.each do |host|
|
198
213
|
if host_ids
|
@@ -201,33 +216,69 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
|
|
201
216
|
next if host['CLUSTER_ID'].to_i != cluster_id
|
202
217
|
end
|
203
218
|
|
204
|
-
|
205
|
-
|
206
|
-
|
219
|
+
host_version=host['TEMPLATE/VERSION']
|
220
|
+
|
221
|
+
if !options[:force]
|
222
|
+
next if host_version && host_version >= current_version
|
223
|
+
end
|
224
|
+
|
225
|
+
puts "* Adding #{host['NAME']} to upgrade"
|
226
|
+
|
227
|
+
queue << host
|
207
228
|
end
|
208
229
|
|
209
230
|
# Run the jobs in threads
|
210
231
|
host_errors = Array.new
|
211
|
-
|
232
|
+
queue_lock = Mutex.new
|
233
|
+
error_lock = Mutex.new
|
234
|
+
total = queue.length
|
235
|
+
|
236
|
+
if total==0
|
237
|
+
puts "No hosts are going to be updated."
|
238
|
+
exit(0)
|
239
|
+
end
|
240
|
+
|
241
|
+
ts = (1..NUM_THREADS).map do |t|
|
242
|
+
Thread.new do
|
243
|
+
while true do
|
244
|
+
host = nil
|
245
|
+
size = 0
|
246
|
+
|
247
|
+
queue_lock.synchronize do
|
248
|
+
host=queue.shift
|
249
|
+
size=queue.length
|
250
|
+
end
|
251
|
+
|
252
|
+
break if !host
|
253
|
+
|
254
|
+
print_update_info(total-size, total, host['NAME'])
|
255
|
+
|
256
|
+
if options[:rsync]
|
257
|
+
sync_cmd = "rsync -Laz --delete #{REMOTES_LOCATION}" <<
|
258
|
+
" #{host['NAME']}:#{remote_dir}"
|
259
|
+
else
|
260
|
+
sync_cmd = "scp -rp #{REMOTES_LOCATION}/. " <<
|
261
|
+
"#{host['NAME']}:#{remote_dir} 2> /dev/null"
|
262
|
+
end
|
212
263
|
|
213
|
-
ts = hs_threads.map do |t|
|
214
|
-
Thread.new {
|
215
|
-
t.each do |host|
|
216
|
-
sync_cmd = "scp -rp #{REMOTES_LOCATION}/. #{host}:#{remote_dir} 2> /dev/null"
|
217
264
|
`#{sync_cmd} 2>/dev/null`
|
218
265
|
|
219
266
|
if !$?.success?
|
220
|
-
|
221
|
-
host_errors << host
|
267
|
+
error_lock.synchronize {
|
268
|
+
host_errors << host['NAME']
|
222
269
|
}
|
270
|
+
else
|
271
|
+
update_version(host, current_version)
|
223
272
|
end
|
224
273
|
end
|
225
|
-
|
274
|
+
end
|
226
275
|
end
|
227
276
|
|
228
277
|
# Wait for threads to finish
|
229
278
|
ts.each{|t| t.join}
|
230
279
|
|
280
|
+
puts
|
281
|
+
|
231
282
|
if host_errors.empty?
|
232
283
|
puts "All hosts updated successfully."
|
233
284
|
0
|
@@ -240,6 +291,39 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
|
|
240
291
|
|
241
292
|
private
|
242
293
|
|
294
|
+
def print_update_info(current, total, host)
|
295
|
+
bar_length=40
|
296
|
+
|
297
|
+
percentage=current.to_f/total.to_f
|
298
|
+
done=(percentage*bar_length).floor
|
299
|
+
|
300
|
+
bar="["
|
301
|
+
bar+="="*done
|
302
|
+
bar+="-"*(bar_length-done)
|
303
|
+
bar+="]"
|
304
|
+
|
305
|
+
info="#{current}/#{total}"
|
306
|
+
|
307
|
+
str="#{bar} #{info} "
|
308
|
+
name=host[0..(79-str.length)]
|
309
|
+
str=str+name
|
310
|
+
str=str+" "*(79-str.length)
|
311
|
+
|
312
|
+
print "#{str}\r"
|
313
|
+
STDOUT.flush
|
314
|
+
end
|
315
|
+
|
316
|
+
def update_version(host, version)
|
317
|
+
if host.has_elements?(VERSION_XPATH)
|
318
|
+
host.delete_element(VERSION_XPATH)
|
319
|
+
end
|
320
|
+
|
321
|
+
host.add_element(TEMPLATE_XPATH, 'VERSION' => version)
|
322
|
+
|
323
|
+
template=host.template_str
|
324
|
+
host.update(template)
|
325
|
+
end
|
326
|
+
|
243
327
|
def factory(id=nil)
|
244
328
|
if id
|
245
329
|
OpenNebula::Host.new_with_id(id, @client)
|
@@ -124,12 +124,9 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
|
|
124
124
|
{
|
125
125
|
:name => "size",
|
126
126
|
:large => "--size size",
|
127
|
-
:description => "Size in MB. Used for DATABLOCK type",
|
127
|
+
:description => "Size in MB. Used for DATABLOCK type or SOURCE based images.",
|
128
128
|
:format => String,
|
129
129
|
:proc => lambda do |o, options|
|
130
|
-
if !options[:type] || !(options[:type].upcase=='DATABLOCK')
|
131
|
-
next [-1, "Size is only used for DATABLOCK type images"]
|
132
|
-
end
|
133
130
|
|
134
131
|
m=o.strip.match(/^(\d+(?:\.\d+)?)(m|mb|g|gb)?$/i)
|
135
132
|
|
@@ -36,6 +36,13 @@ EOT
|
|
36
36
|
:description => "Instance multiple VMs"
|
37
37
|
}
|
38
38
|
|
39
|
+
USERDATA={
|
40
|
+
:name => "userdata",
|
41
|
+
:large => "--userdata userdata",
|
42
|
+
:format => String,
|
43
|
+
:description => "Integrate userdata into the EC2 section"
|
44
|
+
}
|
45
|
+
|
39
46
|
def self.rname
|
40
47
|
"VMTEMPLATE"
|
41
48
|
end
|
metadata
CHANGED
@@ -1,32 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opennebula-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
5
|
-
prerelease: 7
|
4
|
+
version: 4.4.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- OpenNebula
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-12-02 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: opennebula
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - '='
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: 4.
|
19
|
+
version: 4.4.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - '='
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: 4.
|
26
|
+
version: 4.4.0
|
30
27
|
description: Commands used to talk to OpenNebula
|
31
28
|
email: contact@opennebula.org
|
32
29
|
executables:
|
@@ -78,27 +75,25 @@ files:
|
|
78
75
|
- LICENSE
|
79
76
|
homepage: http://opennebula.org
|
80
77
|
licenses: []
|
78
|
+
metadata: {}
|
81
79
|
post_install_message:
|
82
80
|
rdoc_options: []
|
83
81
|
require_paths:
|
84
82
|
- lib
|
85
83
|
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
-
none: false
|
87
84
|
requirements:
|
88
|
-
- -
|
85
|
+
- - '>='
|
89
86
|
- !ruby/object:Gem::Version
|
90
87
|
version: '0'
|
91
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
-
none: false
|
93
89
|
requirements:
|
94
|
-
- -
|
90
|
+
- - '>='
|
95
91
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
92
|
+
version: '0'
|
97
93
|
requirements: []
|
98
94
|
rubyforge_project:
|
99
|
-
rubygems_version:
|
95
|
+
rubygems_version: 2.0.3
|
100
96
|
signing_key:
|
101
|
-
specification_version:
|
97
|
+
specification_version: 4
|
102
98
|
summary: OpenNebula Command Line Interface
|
103
99
|
test_files: []
|
104
|
-
has_rdoc:
|