opennebula-cli 5.6.0 → 5.6.1

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: d4017d877673760df00dd6e69de62d11219d7cff
4
- data.tar.gz: aa1b5def2ce6dd9f38fae26ecefc3f5f1d352a70
3
+ metadata.gz: 7898ac99cecd152ea743a52a93477038ee82ba80
4
+ data.tar.gz: 51743bf968d7d071faf589feaf5ebab16fef8b39
5
5
  SHA512:
6
- metadata.gz: 67f265fdb49077e5b92f9b973eded9a4def990490884b67fe99a61f7d48690703d8fdb9ff4c3ae3ad415f1b07ebba57622efb2b6238759d5bfddadbba90d34f4
7
- data.tar.gz: 30aa09b27074ee9800bb54c8d2f1f544e83ed4557ca0a9d11ffbcc980fb130ed8ab63556db4beeebf6f7d60c46ddaa47c02978ec2e5640e6f36f444e9fa39bf7
6
+ metadata.gz: 7c7d8725c0fd499f613584bd1b04985049196a6d132bde5257c861f3e3166808849f9be4de8323a5be7f094756373b307691ed1159a787708679070026b442da
7
+ data.tar.gz: 747442104db1ef7dfbfd0c8adf19f9a9deab687fec3f9fe5c09f16f24dbad18a563c74b3199e5f0c7127dbd0025f72bb82e07b05ada3fb3b90d7754a183662b6
data/bin/onevcenter CHANGED
@@ -51,7 +51,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
51
51
  :short => "-o object",
52
52
  :large => "--object object ",
53
53
  :format => String,
54
- :description => "vCenter object"
54
+ :description => "vCenter object: [datastores, templates, networks, datastores, images]"
55
55
  }
56
56
 
57
57
  HOST = {
@@ -128,8 +128,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do
128
128
  ############################################################################
129
129
  list_desc = <<-EOT.unindent
130
130
  Show a list with unimported vCenter objects
131
- EOT
132
131
 
132
+ Examples:
133
+ - listing available templates:
134
+
135
+ onevcenter list -o templates -h <host_id>
136
+
137
+ - listing available images:
138
+
139
+ onevcenter list -o datastores -h <host_id> -d <ds-img_id>
140
+ EOT
133
141
  command :list, list_desc, :options=>[ OBJECT, HOST, DATASTORE, VCENTER, USER, PASS ] do
134
142
  begin
135
143
  args = helper.parse_opts(options)
@@ -148,6 +156,19 @@ cmd=CommandParser::CmdParser.new(ARGV) do
148
156
 
149
157
  import_desc = <<-EOT.unindent
150
158
  Import the the desired vCenter object
159
+
160
+ Examples:
161
+ - importing first datastore
162
+
163
+ onevcenter list -o templates -h <host_id>
164
+
165
+ - importing 2 concrete templates:
166
+
167
+ onevcenter import "vm-1252, vm-553, vm-1248" -o templates -h <host_id>
168
+
169
+ - importing a image range:
170
+
171
+ onevcenter import 0..10 -o images -h <host_id> -d <ds-img_id>
151
172
  EOT
152
173
 
153
174
  command :import, import_desc, [:oid, nil], :options=>[ OBJECT, HOST, DATASTORE ] do
@@ -194,6 +215,11 @@ cmd=CommandParser::CmdParser.new(ARGV) do
194
215
  ############################################################################
195
216
  host_desc = <<-EOT.unindent
196
217
  Import vCenter clusters as OpenNebula hosts
218
+
219
+ Example:
220
+ - Get available clusters:
221
+
222
+ onevcenter hosts --vcenter <vcenter> --vuser <vcenter_user> --vpass <password>
197
223
  EOT
198
224
  command :hosts, host_desc, :options=>[ VCENTER, USER, PASS, USE_DEFAULTS ] do
199
225
  con_ops = helper.connection_options("Hosts", options)
data/bin/onezone CHANGED
@@ -36,6 +36,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do
36
36
 
37
37
  helper = OneZoneHelper.new
38
38
 
39
+ ENDPOINT = {
40
+ :name => "keep",
41
+ :short => "-k",
42
+ :large => "--keep",
43
+ :description => "Don't overwrite endpoint file located in home folder, use it as a temporary zone.",
44
+ :format => String
45
+ }
46
+
39
47
  before_proc do
40
48
  helper.set_client(options)
41
49
  end
@@ -191,7 +199,11 @@ cmd=CommandParser::CmdParser.new(ARGV) do
191
199
  Set shell session access point for the CLI to the given Zone
192
200
  EOT
193
201
 
194
- command :set, set_desc,:zoneid do
195
- helper.set_zone(args[0])
202
+ command :set, set_desc,:zoneid, :options=>ENDPOINT do
203
+ if options.has_key? :keep
204
+ helper.set_zone(args[0], true)
205
+ else
206
+ helper.set_zone(args[0], false)
207
+ end
196
208
  end
197
209
  end
data/lib/cli_helper.rb CHANGED
@@ -132,16 +132,21 @@ module CLIHelper
132
132
  # Print header
133
133
  def CLIHelper.print_header(str, underline=true)
134
134
  if $stdout.tty?
135
- scr_bold
136
- scr_underline if underline
137
- print str
138
- scr_restore
135
+ print_tty_header(str, underline)
139
136
  else
140
137
  print str
141
138
  end
142
139
  puts
143
140
  end
144
141
 
142
+ # Pretty print header
143
+ def CLIHelper.print_tty_header(str, underline=true)
144
+ scr_bold
145
+ scr_underline if underline
146
+ print str
147
+ scr_restore
148
+ end
149
+
145
150
  module HashWithSearch
146
151
  def dsearch(path)
147
152
  stems=path.split('/')
@@ -256,10 +261,18 @@ module CLIHelper
256
261
  end
257
262
  end
258
263
 
264
+ def print_tty_header
265
+ CLIHelper.print_tty_header(header_str)
266
+ puts
267
+ end
268
+
259
269
  private
260
270
 
261
271
  def print_table(data, options)
262
- CLIHelper.print_header(header_str) if !options[:csv]
272
+ if !options[:csv] && !options[:noheader]
273
+ CLIHelper.print_header(header_str)
274
+ end
275
+
263
276
  data ? print_data(data, options) : puts
264
277
  end
265
278
 
@@ -575,8 +575,11 @@ module CommandParser
575
575
  }
576
576
 
577
577
  unless argument
578
- puts error_msg if error_msg
579
- puts "command #{name}: argument #{id} must be one of #{format.join(', ')}"
578
+ if error_msg
579
+ puts error_msg
580
+ else
581
+ puts "command #{name}: argument #{id} must be one of #{format.join(', ')}"
582
+ end
580
583
  exit -1
581
584
  end
582
585
 
data/lib/one_helper.rb CHANGED
@@ -16,6 +16,9 @@
16
16
 
17
17
  require 'cli_helper'
18
18
 
19
+ require 'open3'
20
+ require 'io/console'
21
+
19
22
  begin
20
23
  require 'opennebula'
21
24
  rescue Exception => e
@@ -505,51 +508,255 @@ EOT
505
508
  end
506
509
  end
507
510
 
511
+ #-----------------------------------------------------------------------
512
+ # List pool functions
513
+ #-----------------------------------------------------------------------
514
+ def start_pager
515
+ pager = ENV['ONE_PAGER'] || 'less'
508
516
 
509
- def list_pool(options, top=false, filter_flag=nil)
510
- if options[:describe]
511
- table = format_pool(options)
517
+ # Start pager, defaults to less
518
+ p_r, p_w = IO.pipe
512
519
 
513
- table.describe_columns
514
- return 0
520
+ lpid = fork do
521
+ $stdin.reopen(p_r)
522
+
523
+ p_r.close
524
+ p_w.close
525
+
526
+ Kernel.select [$stdin]
527
+
528
+ exec([pager, pager])
515
529
  end
530
+
531
+ # Send listing to pager pipe
532
+ $stdout.close
533
+ $stdout = p_w.dup
516
534
 
517
- filter_flag ||= OpenNebula::Pool::INFO_ALL
535
+ p_w.close
536
+ p_r.close
537
+
538
+ return lpid
539
+ end
518
540
 
519
- pool = factory_pool(filter_flag)
541
+ def stop_pager(lpid)
542
+ $stdout.close
543
+
544
+ begin
545
+ Process.wait(lpid)
546
+ rescue Errno::ECHILD
547
+ end
548
+ end
549
+
550
+ def print_page(pool, options)
551
+ page = nil
520
552
 
521
553
  if options[:xml]
522
- # TODO: use paginated functions
523
- rc=pool.info
524
- return -1, rc.message if OpenNebula.is_error?(rc)
525
- return 0, pool.to_xml(true)
554
+ elements = 0
555
+ page = ""
556
+
557
+ pool.each {|e|
558
+ elements += 1
559
+ page << e.to_xml(true) << "\n"
560
+ }
526
561
  else
527
- table = format_pool(options)
562
+
563
+ pname = pool.pool_name
564
+ ename = pool.element_name
528
565
 
529
- if top
530
- table.top(options) {
531
- array=pool.get_hash
532
- return -1, array.message if OpenNebula.is_error?(array)
566
+ page = pool.to_hash
567
+ elems = page["#{pname}"]["#{ename}"]
533
568
 
534
- array
535
- }
569
+ if elems.class == Array
570
+ elements = elems.length
536
571
  else
537
- array=pool.get_hash
538
- return -1, array.message if OpenNebula.is_error?(array)
539
-
540
- rname=self.class.rname
541
- elements=array["#{rname}_POOL"][rname]
542
- if options[:ids] && elements
543
- elements.reject! do |element|
544
- !options[:ids].include?(element['ID'].to_i)
545
- end
572
+ elements = 1
573
+ end
574
+ end
575
+
576
+ return elements, page
577
+ end
578
+
579
+ #-----------------------------------------------------------------------
580
+ # List the pool in table form, it uses pagination for interactive
581
+ # output
582
+ #-----------------------------------------------------------------------
583
+ def list_pool_table(table, pool, options, filter_flag)
584
+ if $stdout.isatty
585
+ size = $stdout.winsize[0] - 1
586
+
587
+ # ----------- First page, check if pager is needed -------------
588
+ rc = pool.get_page(size, 0)
589
+ ps = ""
590
+
591
+ return -1, rc.message if OpenNebula.is_error?(rc)
592
+
593
+ elements, hash = print_page(pool, options)
594
+
595
+ ppid = -1
596
+
597
+ if elements >= size
598
+ ppid = start_pager
599
+ end
600
+
601
+ table.show(hash, options)
602
+
603
+ if elements < size
604
+ return 0
605
+ elsif !pool.is_paginated?
606
+ stop_pager(ppid)
607
+ return 0
608
+ end
609
+
610
+ # ------- Rest of the pages in the pool, piped to pager --------
611
+ current = size
612
+
613
+ options[:noheader] = true
614
+
615
+ loop do
616
+ rc = pool.get_page(size, current)
617
+
618
+ return -1, rc.message if OpenNebula.is_error?(rc)
619
+
620
+ current += size
621
+
622
+ begin
623
+ Process.waitpid(ppid, Process::WNOHANG)
624
+ rescue Errno::ECHILD
625
+ break
546
626
  end
547
627
 
548
- table.show(array, options)
628
+ elements, hash = print_page(pool, options)
629
+
630
+ table.show(hash, options)
631
+
632
+ $stdout.flush
633
+
634
+ break if elements < size
635
+ end
636
+
637
+ stop_pager(ppid)
638
+ else
639
+ array = pool.get_hash
640
+ return -1, array.message if OpenNebula.is_error?(array)
641
+
642
+ rname = self.class.rname
643
+ elements = array["#{rname}_POOL"][rname]
644
+
645
+ if options[:ids] && elements
646
+ elements.reject! do |element|
647
+ !options[:ids].include?(element['ID'].to_i)
648
+ end
649
+ end
650
+
651
+ table.show(array, options)
652
+ end
653
+
654
+ return 0
655
+ end
656
+
657
+ #-----------------------------------------------------------------------
658
+ # List pool in XML format, pagination is used in interactive output
659
+ #-----------------------------------------------------------------------
660
+ def list_pool_xml(pool, options, filter_flag)
661
+ if $stdout.isatty
662
+ size = $stdout.winsize[0] - 1
663
+
664
+ # ----------- First page, check if pager is needed -------------
665
+ rc = pool.get_page(size, 0)
666
+ ps = ""
667
+
668
+ return -1, rc.message if OpenNebula.is_error?(rc)
669
+
670
+ pname = pool.pool_name
671
+
672
+ elements, page = print_page(pool, options)
673
+
674
+ ppid = -1
675
+
676
+ if elements >= size
677
+ ppid = start_pager
678
+ end
679
+
680
+ puts "<#{pname}>"
681
+
682
+ puts page
683
+
684
+ if elements < size
685
+ puts "</#{pname}>"
686
+ return 0
549
687
  end
550
688
 
689
+ # ------- Rest of the pages in the pool, piped to pager --------
690
+ current = size
691
+
692
+ loop do
693
+ rc = pool.get_page(size, current)
694
+
695
+ return -1, rc.message if OpenNebula.is_error?(rc)
696
+
697
+ current += size
698
+
699
+ elements, page = print_page(pool, options)
700
+
701
+ puts page
702
+
703
+ $stdout.flush
704
+
705
+ break if elements < size
706
+ end
707
+
708
+ puts "</#{pname}>"
709
+
710
+ stop_pager(ppid)
711
+ else
712
+ rc = pool.info
713
+
714
+ return -1, rc.message if OpenNebula.is_error?(rc)
715
+
716
+ puts pool.to_xml(true)
717
+ end
718
+
719
+ return 0
720
+ end
721
+
722
+ #-----------------------------------------------------------------------
723
+ # List pool table in top-like form
724
+ #-----------------------------------------------------------------------
725
+ def list_pool_top(table, pool, options)
726
+ table.top(options) {
727
+ array = pool.get_hash
728
+
729
+ return -1, array.message if OpenNebula.is_error?(array)
730
+
731
+ array
732
+ }
733
+
734
+ return 0
735
+ end
736
+
737
+
738
+ def list_pool(options, top=false, filter_flag=nil)
739
+ table = format_pool(options)
740
+
741
+ if options[:describe]
742
+ table.describe_columns
743
+
551
744
  return 0
552
745
  end
746
+
747
+ filter_flag ||= OpenNebula::Pool::INFO_ALL
748
+
749
+ pool = factory_pool(filter_flag)
750
+
751
+ if top
752
+ return list_pool_top(table, pool, options)
753
+ elsif options[:xml]
754
+ return list_pool_xml(pool, options, filter_flag)
755
+ else
756
+ return list_pool_table(table, pool, options, filter_flag)
757
+ end
758
+
759
+ return 0
553
760
  end
554
761
 
555
762
  def show_resource(id, options)
@@ -834,8 +1041,11 @@ EOT
834
1041
  end
835
1042
  end
836
1043
 
837
- def OpenNebulaHelper.time_to_str(time, print_seconds=true, print_hours=true, print_years=false)
838
- value=time.to_i
1044
+ def OpenNebulaHelper.time_to_str(time, print_seconds=true,
1045
+ print_hours=true, print_years=false)
1046
+
1047
+ value = time.to_i
1048
+
839
1049
  if value==0
840
1050
  value='-'
841
1051
  else
@@ -111,12 +111,18 @@ class OneGroupHelper < OpenNebulaHelper::OneHelper
111
111
 
112
112
  if q['VM_QUOTA']['VM'].nil? && d["ID"].to_i != 0
113
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",
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
+ "RUNNING_VMS" => OneQuotaHelper::LIMIT_DEFAULT,
121
+ "RUNNING_VMS_USED" => "0",
122
+ "RUNNING_CPU" => OneQuotaHelper::LIMIT_DEFAULT,
123
+ "RUNNING_CPU_USED" => "0",
124
+ "RUNNING_MEMORY" => OneQuotaHelper::LIMIT_DEFAULT,
125
+ "RUNNING_MEMORY_USED" => "0",
120
126
  "SYSTEM_DISK_SIZE" => OneQuotaHelper::LIMIT_DEFAULT,
121
127
  "SYSTEM_DISK_SIZE_USED" => "0"
122
128
  }
@@ -148,12 +154,18 @@ class OneGroupHelper < OpenNebulaHelper::OneHelper
148
154
 
149
155
  if q['VM_QUOTA']['VM'].nil? && d["ID"].to_i != 0
150
156
  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
+ "VMS" => OneQuotaHelper::LIMIT_DEFAULT,
158
+ "VMS_USED" => "0",
159
+ "CPU" => OneQuotaHelper::LIMIT_DEFAULT,
160
+ "CPU_USED" => "0",
161
+ "MEMORY" => OneQuotaHelper::LIMIT_DEFAULT,
162
+ "MEMORY_USED" => "0",
163
+ "RUNNING_VMS" => OneQuotaHelper::LIMIT_DEFAULT,
164
+ "RUNNING_VMS_USED" => "0",
165
+ "RUNNING_CPU" => OneQuotaHelper::LIMIT_DEFAULT,
166
+ "RUNNING_CPU_USED" => "0",
167
+ "RUNNING_MEMORY" => OneQuotaHelper::LIMIT_DEFAULT,
168
+ "RUNNING_MEMORY_USED" => "0",
157
169
  "SYSTEM_DISK_SIZE" => OneQuotaHelper::LIMIT_DEFAULT,
158
170
  "SYSTEM_DISK_SIZE_USED" => "0"
159
171
  }
@@ -188,12 +200,18 @@ class OneGroupHelper < OpenNebulaHelper::OneHelper
188
200
 
189
201
  if q['VM_QUOTA']['VM'].nil? && d["ID"].to_i != 0
190
202
  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",
203
+ "VMS" => OneQuotaHelper::LIMIT_DEFAULT,
204
+ "VMS_USED" => "0",
205
+ "CPU" => OneQuotaHelper::LIMIT_DEFAULT,
206
+ "CPU_USED" => "0",
207
+ "MEMORY" => OneQuotaHelper::LIMIT_DEFAULT,
208
+ "MEMORY_USED" => "0",
209
+ "RUNNING_VMS" => OneQuotaHelper::LIMIT_DEFAULT,
210
+ "RUNNING_VMS_USED" => "0",
211
+ "RUNNING_CPU" => OneQuotaHelper::LIMIT_DEFAULT,
212
+ "RUNNING_CPU_USED" => "0",
213
+ "RUNNING_MEMORY" => OneQuotaHelper::LIMIT_DEFAULT,
214
+ "RUNNING_MEMORY_USED" => "0",
197
215
  "SYSTEM_DISK_SIZE" => OneQuotaHelper::LIMIT_DEFAULT,
198
216
  "SYSTEM_DISK_SIZE_USED" => "0"
199
217
  }
@@ -296,6 +296,9 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
296
296
  # Skip this host from remote syncing if it's OFFLINE
297
297
  next if Host::HOST_STATES[state.to_i] == 'OFFLINE'
298
298
 
299
+ # Skip this host if it is a vCenter cluster
300
+ next if vm_mad == "vcenter"
301
+
299
302
  host_version=host['TEMPLATE/VERSION']
300
303
 
301
304
  begin
@@ -35,8 +35,11 @@ class OneQuotaHelper
35
35
  #
36
36
  # VM = [
37
37
  # VMS = <Max. number of VMs>
38
+ # RUNNING_VMS = <Max. number of running VMs>
38
39
  # MEMORY = <Max. allocated memory (MB)>
40
+ # RUNNING_MEMORY = <Max. running memory (MB)>
39
41
  # CPU = <Max. allocated CPU>
42
+ # RUNNING_CPU = <Max. running CPU>
40
43
  # SYSTEM_DISK_SIZE = <Max. allocated system disk (MB)>
41
44
  # ]
42
45
  #
@@ -196,7 +199,7 @@ class OneQuotaHelper
196
199
 
197
200
  puts
198
201
 
199
- CLIHelper.print_header(str_h1 % "RESOURCE USAGE & QUOTAS",false)
202
+ CLIHelper.print_header(str_h1 % "VMS USAGE & QUOTAS",false)
200
203
 
201
204
  puts
202
205
 
@@ -210,12 +213,18 @@ class OneQuotaHelper
210
213
  limit = LIMIT_DEFAULT
211
214
 
212
215
  vm_quotas = [{
213
- "VMS" => limit,
214
- "VMS_USED" => "0",
215
- "CPU" => limit,
216
- "CPU_USED" => "0",
217
- "MEMORY" => limit,
218
- "MEMORY_USED" => "0",
216
+ "VMS" => limit,
217
+ "VMS_USED" => "0",
218
+ "CPU" => limit,
219
+ "CPU_USED" => "0",
220
+ "MEMORY" => limit,
221
+ "MEMORY_USED" => "0",
222
+ "RUNNING_VMS" => limit,
223
+ "RUNNING_VMS_USED" => "0",
224
+ "RUNNING_CPU" => limit,
225
+ "RUNNING_CPU_USED" => "0",
226
+ "RUNNING_MEMORY" => limit,
227
+ "RUNNING_MEMORY_USED" => "0",
219
228
  "SYSTEM_DISK_SIZE" => limit,
220
229
  "SYSTEM_DISK_SIZE_USED" => "0"
221
230
  }]
@@ -223,7 +232,7 @@ class OneQuotaHelper
223
232
 
224
233
  if !vm_quotas[0].nil?
225
234
  CLIHelper::ShowTable.new(nil, self) do
226
- column :"NUMBER OF VMS", "", :right, :size=>17 do |d|
235
+ column :"VMS", "", :right, :size=>17 do |d|
227
236
  if !d.nil?
228
237
  elem = 'VMS'
229
238
  limit = d[elem]
@@ -297,11 +306,87 @@ class OneQuotaHelper
297
306
  puts
298
307
  end
299
308
 
309
+ CLIHelper.print_header(str_h1 % "VMS USAGE & QUOTAS - RUNNING",false)
310
+
311
+ puts
312
+
313
+ if !vm_quotas[0].nil?
314
+ CLIHelper::ShowTable.new(nil, self) do
315
+ column :"RUNNING VMS", "", :right, :size=>17 do |d|
316
+ if !d.nil?
317
+ elem = 'RUNNING_VMS'
318
+ limit = d[elem] || LIMIT_UNLIMITED
319
+ limit = helper.get_default_limit(
320
+ limit, "VM_QUOTA/VM/#{elem}")
321
+
322
+ if d["RUNNING_VMS_USED"].nil?
323
+ d["RUNNING_VMS_USED"] = 0
324
+ end
325
+
326
+ if limit == LIMIT_UNLIMITED
327
+ "%7d / -" % [d["RUNNING_VMS_USED"]]
328
+ else
329
+ "%7d / %7d" % [d["RUNNING_VMS_USED"], limit]
330
+ end
331
+ end
332
+ end
333
+
334
+ column :"RUNNING MEMORY", "", :right, :size=>20 do |d|
335
+ if !d.nil?
336
+ elem = 'RUNNING_MEMORY'
337
+ limit = d[elem] || LIMIT_UNLIMITED
338
+ limit = helper.get_default_limit(
339
+ limit, "VM_QUOTA/VM/#{elem}")
340
+
341
+ if d["RUNNING_MEMORY_USED"].nil?
342
+ d["RUNNING_MEMORY_USED"] = 0
343
+ end
344
+
345
+ if limit == LIMIT_UNLIMITED
346
+ "%8s / -" % [
347
+ OpenNebulaHelper.unit_to_str(d["RUNNING_MEMORY_USED"].to_i,{},"M")
348
+ ]
349
+ else
350
+ "%8s / %8s" % [
351
+ OpenNebulaHelper.unit_to_str(d["RUNNING_MEMORY_USED"].to_i,{},"M"),
352
+ OpenNebulaHelper.unit_to_str(limit.to_i,{},"M")
353
+ ]
354
+ end
355
+ end
356
+ end
357
+
358
+ column :"RUNNING CPU", "", :right, :size=>20 do |d|
359
+ if !d.nil?
360
+ elem = 'RUNNING_CPU'
361
+ limit = d[elem] || LIMIT_UNLIMITED
362
+ limit = helper.get_default_limit(
363
+ limit, "VM_QUOTA/VM/#{elem}")
364
+
365
+ if d["RUNNING_CPU_USED"].nil?
366
+ d["RUNNING_CPU_USED"] = 0
367
+ end
368
+
369
+ if limit == LIMIT_UNLIMITED
370
+ "%8.2f / -" % [d["RUNNING_CPU_USED"]]
371
+ else
372
+ "%8.2f / %8.2f" % [d["RUNNING_CPU_USED"], limit]
373
+ end
374
+ end
375
+ end
376
+ end.show(vm_quotas, {})
377
+
378
+ puts
379
+ end
380
+
381
+ CLIHelper.print_header(str_h1 % "DATASTORE USAGE & QUOTAS",false)
382
+
383
+ puts
384
+
300
385
  ds_quotas = [qh['DATASTORE_QUOTA']['DATASTORE']].flatten
301
386
 
302
387
  if !ds_quotas[0].nil?
303
388
  CLIHelper::ShowTable.new(nil, self) do
304
- column :"DATASTORE ID", "", :size=>12 do |d|
389
+ column :"ID", "", :size=>12 do |d|
305
390
  d["ID"] if !d.nil?
306
391
  end
307
392
 
@@ -344,11 +429,15 @@ class OneQuotaHelper
344
429
  puts
345
430
  end
346
431
 
432
+ CLIHelper.print_header(str_h1 % "NETWORK USAGE & QUOTAS",false)
433
+
434
+ puts
435
+
347
436
  net_quotas = [qh['NETWORK_QUOTA']['NETWORK']].flatten
348
437
 
349
438
  if !net_quotas[0].nil?
350
439
  CLIHelper::ShowTable.new(nil, self) do
351
- column :"NETWORK ID", "", :size=>12 do |d|
440
+ column :"ID", "", :size=>12 do |d|
352
441
  d["ID"] if !d.nil?
353
442
  end
354
443
 
@@ -371,11 +460,15 @@ class OneQuotaHelper
371
460
  puts
372
461
  end
373
462
 
463
+ CLIHelper.print_header(str_h1 % "IMAGE USAGE & QUOTAS",false)
464
+
465
+ puts
466
+
374
467
  image_quotas = [qh['IMAGE_QUOTA']['IMAGE']].flatten
375
468
 
376
469
  if !image_quotas[0].nil?
377
470
  CLIHelper::ShowTable.new(nil, self) do
378
- column :"IMAGE ID", "", :size=>12 do |d|
471
+ column :"ID", "", :size=>12 do |d|
379
472
  d["ID"] if !d.nil?
380
473
  end
381
474
 
@@ -294,12 +294,18 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
294
294
 
295
295
  if q['VM_QUOTA']['VM'].nil? && d["ID"].to_i != 0
296
296
  q['VM_QUOTA']['VM'] = {
297
- "VMS" => OneQuotaHelper::LIMIT_DEFAULT,
298
- "VMS_USED" => "0",
299
- "CPU" => OneQuotaHelper::LIMIT_DEFAULT,
300
- "CPU_USED" => "0",
301
- "MEMORY" => OneQuotaHelper::LIMIT_DEFAULT,
302
- "MEMORY_USED" => "0",
297
+ "VMS" => OneQuotaHelper::LIMIT_DEFAULT,
298
+ "VMS_USED" => "0",
299
+ "CPU" => OneQuotaHelper::LIMIT_DEFAULT,
300
+ "CPU_USED" => "0",
301
+ "MEMORY" => OneQuotaHelper::LIMIT_DEFAULT,
302
+ "MEMORY_USED" => "0",
303
+ "RUNNING_VMS" => OneQuotaHelper::LIMIT_DEFAULT,
304
+ "RUNNING_VMS_USED" => "0",
305
+ "RUNNING_CPU" => OneQuotaHelper::LIMIT_DEFAULT,
306
+ "RUNNING_CPU_USED" => "0",
307
+ "RUNNING_MEMORY" => OneQuotaHelper::LIMIT_DEFAULT,
308
+ "RUNNING_MEMORY_USED" => "0",
303
309
  "SYSTEM_DISK_SIZE" => OneQuotaHelper::LIMIT_DEFAULT,
304
310
  "SYSTEM_DISK_SIZE_USED" => "0"
305
311
  }
@@ -333,12 +339,18 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
333
339
 
334
340
  if q['VM_QUOTA']['VM'].nil? && d["ID"].to_i != 0
335
341
  q['VM_QUOTA']['VM'] = {
336
- "VMS" => OneQuotaHelper::LIMIT_DEFAULT,
337
- "VMS_USED" => "0",
338
- "CPU" => OneQuotaHelper::LIMIT_DEFAULT,
339
- "CPU_USED" => "0",
340
- "MEMORY" => OneQuotaHelper::LIMIT_DEFAULT,
341
- "MEMORY_USED" => "0",
342
+ "VMS" => OneQuotaHelper::LIMIT_DEFAULT,
343
+ "VMS_USED" => "0",
344
+ "CPU" => OneQuotaHelper::LIMIT_DEFAULT,
345
+ "CPU_USED" => "0",
346
+ "MEMORY" => OneQuotaHelper::LIMIT_DEFAULT,
347
+ "MEMORY_USED" => "0",
348
+ "RUNNING_VMS" => OneQuotaHelper::LIMIT_DEFAULT,
349
+ "RUNNING_VMS_USED" => "0",
350
+ "RUNNING_CPU" => OneQuotaHelper::LIMIT_DEFAULT,
351
+ "RUNNING_CPU_USED" => "0",
352
+ "RUNNING_MEMORY" => OneQuotaHelper::LIMIT_DEFAULT,
353
+ "RUNNING_MEMORY_USED" => "0",
342
354
  "SYSTEM_DISK_SIZE" => OneQuotaHelper::LIMIT_DEFAULT,
343
355
  "SYSTEM_DISK_SIZE_USED" => "0"
344
356
  }
@@ -375,12 +387,18 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
375
387
 
376
388
  if q['VM_QUOTA']['VM'].nil? && d["ID"].to_i != 0
377
389
  q['VM_QUOTA']['VM'] = {
378
- "VMS" => OneQuotaHelper::LIMIT_DEFAULT,
379
- "VMS_USED" => "0",
380
- "CPU" => OneQuotaHelper::LIMIT_DEFAULT,
381
- "CPU_USED" => "0",
382
- "MEMORY" => OneQuotaHelper::LIMIT_DEFAULT,
383
- "MEMORY_USED" => "0",
390
+ "VMS" => OneQuotaHelper::LIMIT_DEFAULT,
391
+ "VMS_USED" => "0",
392
+ "CPU" => OneQuotaHelper::LIMIT_DEFAULT,
393
+ "CPU_USED" => "0",
394
+ "MEMORY" => OneQuotaHelper::LIMIT_DEFAULT,
395
+ "MEMORY_USED" => "0",
396
+ "RUNNING_VMS" => OneQuotaHelper::LIMIT_DEFAULT,
397
+ "RUNNING_VMS_USED" => "0",
398
+ "RUNNING_CPU" => OneQuotaHelper::LIMIT_DEFAULT,
399
+ "RUNNING_CPU_USED" => "0",
400
+ "RUNNING_MEMORY" => OneQuotaHelper::LIMIT_DEFAULT,
401
+ "RUNNING_MEMORY_USED" => "0",
384
402
  "SYSTEM_DISK_SIZE" => OneQuotaHelper::LIMIT_DEFAULT,
385
403
  "SYSTEM_DISK_SIZE_USED" => "0"
386
404
  }
@@ -120,6 +120,8 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
120
120
  # @param type [String] String representing the vCenter resource
121
121
  #
122
122
  def set_object(type)
123
+ raise "you need to use -o option!" unless type
124
+
123
125
  type = type.downcase
124
126
  if (type == "datastores")
125
127
  @vobject = VOBJECT::DATASTORE
@@ -83,25 +83,28 @@ class OneZoneHelper < OpenNebulaHelper::OneHelper
83
83
  table
84
84
  end
85
85
 
86
- def set_zone(zone_id)
87
- zone = factory(zone_id)
88
- rc = zone.info
86
+ def set_zone(zone_id, temporary_zone)
87
+ zone = factory(zone_id)
88
+ rc = zone.info
89
89
 
90
- if OpenNebula.is_error?(rc)
91
- return -1, rc.message
92
- end
93
-
94
- if !zone['TEMPLATE/ENDPOINT']
95
- return -1, "No Endpoint defined for Zone #{zone_id}"
96
- end
90
+ if OpenNebula.is_error?(rc)
91
+ return -1, rc.message
92
+ end
97
93
 
98
- File.open(ENV['HOME']+"/.one/one_endpoint", 'w'){|f|
99
- f.puts zone['TEMPLATE/ENDPOINT']
100
- }
94
+ if !zone['TEMPLATE/ENDPOINT']
95
+ return -1, "No Endpoint defined for Zone #{zone_id}"
96
+ end
101
97
 
102
- puts "Endpoint changed to \"#{zone['TEMPLATE/ENDPOINT']}\" in " <<
103
- "#{ENV['HOME']}/.one/one_endpoint"
104
- return 0
98
+ if temporary_zone
99
+ puts "Type: export ONE_XMLRPC=#{zone['TEMPLATE/ENDPOINT']}"
100
+ else
101
+ File.open(ENV['HOME']+"/.one/one_endpoint", 'w'){|f|
102
+ f.puts zone['TEMPLATE/ENDPOINT']
103
+ }
104
+ puts "Endpoint changed to \"#{zone['TEMPLATE/ENDPOINT']}\" in " <<
105
+ "#{ENV['HOME']}/.one/one_endpoint"
106
+ end
107
+ return 0
105
108
  end
106
109
 
107
110
  private
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: 5.6.0
4
+ version: 5.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenNebula
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-15 00:00:00.000000000 Z
11
+ date: 2018-09-20 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: 5.6.0
19
+ version: 5.6.1
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: 5.6.0
26
+ version: 5.6.1
27
27
  description: Commands used to talk to OpenNebula
28
28
  email: contact@opennebula.org
29
29
  executables: