opennebula-cli 4.10.1 → 4.10.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4dccabe5f373b31c2629fe27f64edef81d2169a5
4
- data.tar.gz: 8b52bea0dacb43cae5fd9c93a914f6405e9f9af5
3
+ metadata.gz: 2b27f616d275440e4bfb83d9ec0b519361ed4abf
4
+ data.tar.gz: c104259923ec8765e0e1cefcdf504204ec743ea4
5
5
  SHA512:
6
- metadata.gz: 9a203047edd0f7453663ee8dbcc3eb79a56eb7ef51ab2728696855bb42da08491ecf1aacdf6ef3aac6ee36a8e5ebc0aef3520f95653fbf655ce88b171191ef68
7
- data.tar.gz: 1cb04d2679abf318b21c60ee253b3bc5006a80a8a5a7c2d966b91c59569f8a98fecb42b506861be686c2b86d44d4d54d0d04687a1d803f6531d4e38e3ae1e1aa
6
+ metadata.gz: 1ea168960417e9bf0efd193f4f9cc89a9faa88ffe7a459ae438051ba5944828ae2407f4002ac032be8ad713ac2c1be6a9e1274fd4bbc6454cfe67b8fd4c479ff
7
+ data.tar.gz: 598dc916b8552ada376587ac6940fccb443efe8401bb912d1aa7074e7461bcc2ad2f2edadc7fe9d1c1403d737618f986f1546ab7aa0bc4f13bb18a02655c1297
data/bin/oneacct CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
4
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
data/bin/oneacl CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
4
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
data/bin/onecluster CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
4
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
data/bin/onedatastore CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
4
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
data/bin/oneflow CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2010-2014, C12G Labs S.L. #
4
+ # Copyright 2010-2015, C12G Labs S.L. #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
data/bin/oneflow-template CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2010-2014, C12G Labs S.L. #
4
+ # Copyright 2010-2015, C12G Labs S.L. #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
data/bin/onegroup CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
4
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
data/bin/onehost CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
4
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
data/bin/oneimage CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
4
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
data/bin/onetemplate CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
4
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
data/bin/oneuser CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
4
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
data/bin/onevcenter CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
4
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
@@ -182,7 +182,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
182
182
  next if STDIN.gets.strip.downcase != 'y'
183
183
 
184
184
  if tmps.empty?
185
- STDOUT.print " No VM Templates found in #{dc}...\n\n"
185
+ STDOUT.print " No new VM Templates found in #{dc}...\n\n"
186
186
  next
187
187
  end
188
188
 
@@ -214,4 +214,146 @@ cmd=CommandParser::CmdParser.new(ARGV) do
214
214
 
215
215
  exit 0
216
216
  end
217
+
218
+ network_desc = <<-EOT.unindent
219
+ Import vCenter networks into OpenNebula
220
+ EOT
221
+
222
+ command :networks, network_desc, :options=>[ VCENTER, USER, PASS ] do
223
+ if options[:vuser].nil? ||
224
+ options[:vpass].nil? ||
225
+ options[:vcenter].nil?
226
+ STDERR.puts "vCenter connection parameters are mandatory to import"\
227
+ " vCenter networks:\n"\
228
+ "\t --vcenter vCenter hostname\n"\
229
+ "\t --vuser username to login in vcenter\n"\
230
+ "\t --vpass password for the user"
231
+ exit -1
232
+ end
233
+
234
+ begin
235
+ STDOUT.print "\nConnecting to vCenter: #{options[:vcenter]}..."
236
+
237
+ vc = VCenterDriver::VIClient.new_connection(
238
+ :user => options[:vuser],
239
+ :password => options[:vpass],
240
+ :host => options[:vcenter])
241
+
242
+ STDOUT.print "done!\n\n"
243
+
244
+ STDOUT.print "Looking for vCenter networks..."
245
+
246
+ rs = vc.vcenter_networks
247
+
248
+ STDOUT.print "done!\n"
249
+
250
+ rs.each {|dc, tmps|
251
+ STDOUT.print "\nDo you want to process datacenter #{dc} [y/n]? "
252
+
253
+ next if STDIN.gets.strip.downcase != 'y'
254
+
255
+ if tmps.empty?
256
+ STDOUT.print " No new Networks found in #{dc}...\n\n"
257
+ next
258
+ end
259
+
260
+ tmps.each{ |n|
261
+ print_str = "\n * Network found:\n"\
262
+ " - Name : #{n[:name]}\n"\
263
+ " - Type : #{n[:type]}\n"
264
+ print_str += " - VLAN ID : #{n[:vlan]}\n" if n[:vlan]
265
+ print_str += " Import this Network [y/n]? "
266
+
267
+ STDOUT.print print_str
268
+
269
+ next if STDIN.gets.strip.downcase != 'y'
270
+
271
+ # Size
272
+
273
+ STDOUT.print " How many VMs are you planning"\
274
+ " to fit into this network [255]? "
275
+
276
+ size = STDIN.gets.strip
277
+
278
+ size = "255" if size.to_i.to_s != size
279
+
280
+ # Type
281
+
282
+ STDOUT.print " What type of Virtual Network"\
283
+ " do you want to create (IPv[4],IPv[6]"\
284
+ ",[E]thernet) ?"
285
+
286
+ type = STDIN.gets.strip
287
+
288
+ ar_str = "\nAR=[TYPE=\""
289
+
290
+ case type.downcase
291
+ when "4"
292
+ ar_str += "IP4\""
293
+ STDOUT.print " Please input the first IP "\
294
+ "in the range: "
295
+ ip = STDIN.gets.strip
296
+ ar_str += ",IP=" + ip
297
+
298
+ STDOUT.print " Please input the first MAC "\
299
+ "in the range [Enter for default]: "
300
+ mac = STDIN.gets.strip
301
+ ar_str += ",MAC=" + mac if !mac.empty?
302
+ when "6"
303
+ ar_str += "IP6\""
304
+ STDOUT.print " Please input the first MAC "\
305
+ "in the range [Enter for default]: "
306
+ mac = STDIN.gets.strip
307
+ ar_str += ",MAC=" + mac if !mac.empty?
308
+
309
+ STDOUT.print " Please input the GLOBAL PREFIX "\
310
+ "[Enter for default]: "
311
+ gp = STDIN.gets.strip
312
+ ar_str += ",GLOBAL_PREFIX=" + gp if !gp.empty?
313
+
314
+ STDOUT.print " Please input the ULA PREFIX "\
315
+ "[Enter for default]: "
316
+ up = STDIN.gets.strip
317
+ ar_str += ",ULA_PREFIX=" + up if !up.empty?
318
+ when "e"
319
+ ar_str += "ETHER\""
320
+ STDOUT.print " Please input the first MAC "\
321
+ "in the range [Enter for default]: "
322
+ mac = STDIN.gets.strip
323
+ ar_str += ",MAC=" + mac if !mac.empty?
324
+ else
325
+ STDOUT.puts " Type [#{type}] not supported,"\
326
+ " defaulting to Ethernet."
327
+ ar_str += "ETHER\""
328
+ STDOUT.print " Please input the first MAC "\
329
+ "in the range [Enter for default]: "
330
+ mac = STDIN.gets.strip
331
+ ar_str += ",MAC=" + mac if !mac.empty?
332
+ end
333
+
334
+ ar_str += ",SIZE = \"#{size}\"]"
335
+
336
+ one_vn = ::OpenNebula::VirtualNetwork.new(
337
+ ::OpenNebula::Template.build_xml, vc.one)
338
+
339
+ vnet_template = n[:one] + ar_str
340
+
341
+ rc = one_vn.allocate(vnet_template)
342
+
343
+ if ::OpenNebula.is_error?(rc)
344
+ STDOUT.puts " Error creating virtual network: " +
345
+ " #{rc.message}\n"
346
+ else
347
+ STDOUT.puts " OpenNebula virtual network " +
348
+ "#{one_vn.id} created with size #{size}!\n"
349
+ end
350
+ }
351
+ }
352
+ rescue Exception => e
353
+ STDOUT.puts "error: #{e.message}"
354
+ exit -1
355
+ end
356
+
357
+ exit 0
358
+ end
217
359
  end
data/bin/onevm CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
4
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
data/bin/onevnet CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
4
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
data/bin/onezone CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
4
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
data/lib/cli_helper.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
2
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
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-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
2
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
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/one_helper.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
2
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
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 #
@@ -28,7 +28,7 @@ include OpenNebula
28
28
  module OpenNebulaHelper
29
29
  ONE_VERSION=<<-EOT
30
30
  OpenNebula #{OpenNebula::VERSION}
31
- Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs
31
+ Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs
32
32
 
33
33
  Licensed under the Apache License, Version 2.0 (the "License"); you may
34
34
  not use this file except in compliance with the License. You may obtain
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
2
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
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-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
2
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
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-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
2
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
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-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
2
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
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-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
2
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
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 #
@@ -108,6 +108,22 @@ class OneGroupHelper < OpenNebulaHelper::OneHelper
108
108
  column :VMS , "Number of VMS", :size=>9 do |d|
109
109
  begin
110
110
  q = quotas[d['ID']]
111
+
112
+ if q['VM_QUOTA']['VM'].nil? && d["ID"].to_i != 0
113
+ q['VM_QUOTA']['VM'] = {
114
+ "VMS" => OneQuotaHelper::LIMIT_DEFAULT,
115
+ "VMS_USED" => "0",
116
+ "CPU" => OneQuotaHelper::LIMIT_DEFAULT,
117
+ "CPU_USED" => "0",
118
+ "MEMORY" => OneQuotaHelper::LIMIT_DEFAULT,
119
+ "MEMORY_USED" => "0",
120
+ "VOLATILE_SIZE" => OneQuotaHelper::LIMIT_DEFAULT,
121
+ "VOLATILE_SIZE_USED" => "0"
122
+ }
123
+
124
+ quotas[d['ID']] = q
125
+ end
126
+
111
127
  limit = q['VM_QUOTA']['VM']["VMS"]
112
128
 
113
129
  if limit == OneQuotaHelper::LIMIT_DEFAULT
@@ -129,6 +145,22 @@ class OneGroupHelper < OpenNebulaHelper::OneHelper
129
145
  column :MEMORY, "Total memory allocated to user VMs", :size=>17 do |d|
130
146
  begin
131
147
  q = quotas[d['ID']]
148
+
149
+ if q['VM_QUOTA']['VM'].nil? && d["ID"].to_i != 0
150
+ q['VM_QUOTA']['VM'] = {
151
+ "VMS" => OneQuotaHelper::LIMIT_DEFAULT,
152
+ "VMS_USED" => "0",
153
+ "CPU" => OneQuotaHelper::LIMIT_DEFAULT,
154
+ "CPU_USED" => "0",
155
+ "MEMORY" => OneQuotaHelper::LIMIT_DEFAULT,
156
+ "MEMORY_USED" => "0",
157
+ "VOLATILE_SIZE" => OneQuotaHelper::LIMIT_DEFAULT,
158
+ "VOLATILE_SIZE_USED" => "0"
159
+ }
160
+
161
+ quotas[d['ID']] = q
162
+ end
163
+
132
164
  limit = q['VM_QUOTA']['VM']["MEMORY"]
133
165
 
134
166
  if limit == OneQuotaHelper::LIMIT_DEFAULT
@@ -153,6 +185,22 @@ class OneGroupHelper < OpenNebulaHelper::OneHelper
153
185
  column :CPU, "Total CPU allocated to user VMs", :size=>11 do |d|
154
186
  begin
155
187
  q = quotas[d['ID']]
188
+
189
+ if q['VM_QUOTA']['VM'].nil? && d["ID"].to_i != 0
190
+ q['VM_QUOTA']['VM'] = {
191
+ "VMS" => OneQuotaHelper::LIMIT_DEFAULT,
192
+ "VMS_USED" => "0",
193
+ "CPU" => OneQuotaHelper::LIMIT_DEFAULT,
194
+ "CPU_USED" => "0",
195
+ "MEMORY" => OneQuotaHelper::LIMIT_DEFAULT,
196
+ "MEMORY_USED" => "0",
197
+ "VOLATILE_SIZE" => OneQuotaHelper::LIMIT_DEFAULT,
198
+ "VOLATILE_SIZE_USED" => "0"
199
+ }
200
+
201
+ quotas[d['ID']] = q
202
+ end
203
+
156
204
  limit = q['VM_QUOTA']['VM']["CPU"]
157
205
 
158
206
  if limit == OneQuotaHelper::LIMIT_DEFAULT
@@ -269,6 +317,6 @@ class OneGroupHelper < OpenNebulaHelper::OneHelper
269
317
  }
270
318
 
271
319
  helper = OneQuotaHelper.new
272
- helper.format_quota(group_hash['GROUP'], default_quotas)
320
+ helper.format_quota(group_hash['GROUP'], default_quotas, group.id)
273
321
  end
274
322
  end
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
2
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
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-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
2
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
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-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
2
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
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 #
@@ -189,8 +189,9 @@ class OneQuotaHelper
189
189
  # Outputs formated quota information to stdout
190
190
  # @param qh [Hash] with the quotas for a given resource
191
191
  # @param default_quotas_hash [XMLElement] with the default quota limits
192
+ # @param resource_id [Integer] user/group ID
192
193
  #
193
- def format_quota(qh, default_quotas)
194
+ def format_quota(qh, default_quotas, resource_id)
194
195
  str_h1="%-80s"
195
196
 
196
197
  puts
@@ -203,6 +204,23 @@ class OneQuotaHelper
203
204
 
204
205
  vm_quotas = [qh['VM_QUOTA']['VM']].flatten
205
206
 
207
+ # This initializes the VM quotas for users/groups that don't have any
208
+ # resource usage yet. It not applied to oneamdin
209
+ if vm_quotas[0].nil? && resource_id.to_i != 0
210
+ limit = LIMIT_DEFAULT
211
+
212
+ vm_quotas = [{
213
+ "VMS" => limit,
214
+ "VMS_USED" => "0",
215
+ "CPU" => limit,
216
+ "CPU_USED" => "0",
217
+ "MEMORY" => limit,
218
+ "MEMORY_USED" => "0",
219
+ "VOLATILE_SIZE" => limit,
220
+ "VOLATILE_SIZE_USED" => "0"
221
+ }]
222
+ end
223
+
206
224
  if !vm_quotas[0].nil?
207
225
  CLIHelper::ShowTable.new(nil, self) do
208
226
  column :"NUMBER OF VMS", "", :right, :size=>17 do |d|
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
2
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
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-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
2
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
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 #
@@ -251,6 +251,22 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
251
251
  column :VMS , "Number of VMS", :size=>9 do |d|
252
252
  begin
253
253
  q = quotas[d['ID']]
254
+
255
+ if q['VM_QUOTA']['VM'].nil? && d["ID"].to_i != 0
256
+ q['VM_QUOTA']['VM'] = {
257
+ "VMS" => OneQuotaHelper::LIMIT_DEFAULT,
258
+ "VMS_USED" => "0",
259
+ "CPU" => OneQuotaHelper::LIMIT_DEFAULT,
260
+ "CPU_USED" => "0",
261
+ "MEMORY" => OneQuotaHelper::LIMIT_DEFAULT,
262
+ "MEMORY_USED" => "0",
263
+ "VOLATILE_SIZE" => OneQuotaHelper::LIMIT_DEFAULT,
264
+ "VOLATILE_SIZE_USED" => "0"
265
+ }
266
+
267
+ quotas[d['ID']] = q
268
+ end
269
+
254
270
  limit = q['VM_QUOTA']['VM']["VMS"]
255
271
 
256
272
  if limit == OneQuotaHelper::LIMIT_DEFAULT
@@ -274,6 +290,22 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
274
290
  column :MEMORY, "Total memory allocated to user VMs", :size=>17 do |d|
275
291
  begin
276
292
  q = quotas[d['ID']]
293
+
294
+ if q['VM_QUOTA']['VM'].nil? && d["ID"].to_i != 0
295
+ q['VM_QUOTA']['VM'] = {
296
+ "VMS" => OneQuotaHelper::LIMIT_DEFAULT,
297
+ "VMS_USED" => "0",
298
+ "CPU" => OneQuotaHelper::LIMIT_DEFAULT,
299
+ "CPU_USED" => "0",
300
+ "MEMORY" => OneQuotaHelper::LIMIT_DEFAULT,
301
+ "MEMORY_USED" => "0",
302
+ "VOLATILE_SIZE" => OneQuotaHelper::LIMIT_DEFAULT,
303
+ "VOLATILE_SIZE_USED" => "0"
304
+ }
305
+
306
+ quotas[d['ID']] = q
307
+ end
308
+
277
309
  limit = q['VM_QUOTA']['VM']["MEMORY"]
278
310
 
279
311
  if limit == OneQuotaHelper::LIMIT_DEFAULT
@@ -300,6 +332,22 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
300
332
  column :CPU, "Total CPU allocated to user VMs", :size=>11 do |d|
301
333
  begin
302
334
  q = quotas[d['ID']]
335
+
336
+ if q['VM_QUOTA']['VM'].nil? && d["ID"].to_i != 0
337
+ q['VM_QUOTA']['VM'] = {
338
+ "VMS" => OneQuotaHelper::LIMIT_DEFAULT,
339
+ "VMS_USED" => "0",
340
+ "CPU" => OneQuotaHelper::LIMIT_DEFAULT,
341
+ "CPU_USED" => "0",
342
+ "MEMORY" => OneQuotaHelper::LIMIT_DEFAULT,
343
+ "MEMORY_USED" => "0",
344
+ "VOLATILE_SIZE" => OneQuotaHelper::LIMIT_DEFAULT,
345
+ "VOLATILE_SIZE_USED" => "0"
346
+ }
347
+
348
+ quotas[d['ID']] = q
349
+ end
350
+
303
351
  limit = q['VM_QUOTA']['VM']["CPU"]
304
352
 
305
353
  if limit == OneQuotaHelper::LIMIT_DEFAULT
@@ -393,6 +441,6 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
393
441
  }
394
442
 
395
443
  helper = OneQuotaHelper.new
396
- helper.format_quota(user_hash['USER'], default_quotas)
444
+ helper.format_quota(user_hash['USER'], default_quotas, user.id)
397
445
  end
398
446
  end
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
2
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
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 #
@@ -438,7 +438,28 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
438
438
  puts
439
439
  CLIHelper.print_header(str_h1 % "VM NICS",false)
440
440
 
441
- vm_nics = [vm.to_hash['VM']['TEMPLATE']['NIC']].flatten if !vm_nics
441
+ # vm_nics is defined for hybridvisors. If there are both IP from
442
+ # the hybridvisor and from OpenNebula nics check if the IP is the
443
+ # same as one of IPs generated by OpenNebula and show standard
444
+ # information. If it's a different IP show all the information.
445
+ #
446
+ # The template can already contain one NIC not controled by
447
+ # OpenNebula and we want to show also that info.
448
+ if vm_nics
449
+ if vm.has_elements?("/VM/TEMPLATE/NIC")
450
+ nics = [vm.to_hash['VM']['TEMPLATE']['NIC']].flatten
451
+ ips = nics.map {|n| n['IP'] }
452
+ ip = vm_nics.first['IP']
453
+
454
+ if ips.include? ip
455
+ vm_nics = nics
456
+ else
457
+ vm_nics += nics
458
+ end
459
+ end
460
+ else
461
+ vm_nics = [vm.to_hash['VM']['TEMPLATE']['NIC']].flatten
462
+ end
442
463
 
443
464
  nic_default = {"NETWORK" => "-",
444
465
  "IP" => "-",
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
2
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
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-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
2
+ # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #
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 #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opennebula-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.10.1
4
+ version: 4.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenNebula
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-20 00:00:00.000000000 Z
11
+ date: 2015-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opennebula
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 4.10.1
19
+ version: 4.10.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 4.10.1
26
+ version: 4.10.2
27
27
  description: Commands used to talk to OpenNebula
28
28
  email: contact@opennebula.org
29
29
  executables:
@@ -38,10 +38,10 @@ executables:
38
38
  - oneimage
39
39
  - onetemplate
40
40
  - oneuser
41
- - onevcenter
42
41
  - onevm
43
42
  - onevnet
44
43
  - onezone
44
+ - onevcenter
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
@@ -98,9 +98,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  version: '0'
99
99
  requirements: []
100
100
  rubyforge_project:
101
- rubygems_version: 2.2.2
101
+ rubygems_version: 2.4.5
102
102
  signing_key:
103
103
  specification_version: 4
104
104
  summary: OpenNebula Command Line Interface
105
105
  test_files: []
106
- has_rdoc: