opennebula-cli 4.0.1 → 4.1.80.beta

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.
data/bin/oneimage CHANGED
@@ -212,10 +212,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do
212
212
  be launched to modify the current content.
213
213
  EOT
214
214
 
215
- command :update, update_desc, :imageid, [:file, nil] do
216
- helper.perform_action(args[0],options,"modified") do |image|
217
- str = OpenNebulaHelper.update_template(args[0], image, args[1])
218
- image.update(str)
215
+ command :update, update_desc, :imageid, [:file, nil],
216
+ :options=>OpenNebulaHelper::APPEND do
217
+ helper.perform_action(args[0],options,"modified") do |obj|
218
+ if options[:append]
219
+ str = OpenNebulaHelper.append_template(args[0], obj, args[1])
220
+ else
221
+ str = OpenNebulaHelper.update_template(args[0], obj, args[1])
222
+ end
223
+
224
+ obj.update(str, options[:append])
219
225
  end
220
226
  end
221
227
 
data/bin/onetemplate CHANGED
@@ -259,10 +259,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do
259
259
  be launched to modify the current content.
260
260
  EOT
261
261
 
262
- command :update, update_desc, :templateid, [:file, nil] do
263
- helper.perform_action(args[0],options,"modified") do |template|
264
- str = OpenNebulaHelper.update_template(args[0], template, args[1])
265
- template.update(str)
262
+ command :update, update_desc, :templateid, [:file, nil],
263
+ :options=>OpenNebulaHelper::APPEND do
264
+ helper.perform_action(args[0],options,"modified") do |obj|
265
+ if options[:append]
266
+ str = OpenNebulaHelper.append_template(args[0], obj, args[1])
267
+ else
268
+ str = OpenNebulaHelper.update_template(args[0], obj, args[1])
269
+ end
270
+
271
+ obj.update(str, options[:append])
266
272
  end
267
273
  end
268
274
 
data/bin/oneuser CHANGED
@@ -192,10 +192,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do
192
192
  be launched to modify the current content.
193
193
  EOT
194
194
 
195
- command :update, update_desc, :userid, [:file, nil] do
196
- helper.perform_action(args[0],options,"modified") do |user|
197
- str = OpenNebulaHelper.update_template(args[0], user, args[1])
198
- user.update(str)
195
+ command :update, update_desc, :userid, [:file, nil],
196
+ :options=>OpenNebulaHelper::APPEND do
197
+ helper.perform_action(args[0],options,"modified") do |obj|
198
+ if options[:append]
199
+ str = OpenNebulaHelper.append_template(args[0], obj, args[1])
200
+ else
201
+ str = OpenNebulaHelper.update_template(args[0], obj, args[1])
202
+ end
203
+
204
+ obj.update(str, options[:append])
199
205
  end
200
206
  end
201
207
 
data/bin/onevm CHANGED
@@ -208,11 +208,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do
208
208
  editor will be launched to modify the current content.
209
209
  EOT
210
210
 
211
- command :update, update_desc, :vmid, [:file, nil] do
212
- helper.perform_action(args[0],options,"modified") do |vm|
213
- str = OpenNebulaHelper.update_template(args[0], vm, args[1],
214
- 'USER_TEMPLATE')
215
- vm.update(str)
211
+ command :update, update_desc, :vmid, [:file, nil],
212
+ :options=>OpenNebulaHelper::APPEND do
213
+ helper.perform_action(args[0],options,"modified") do |obj|
214
+ if options[:append]
215
+ str = OpenNebulaHelper.append_template(args[0], obj, args[1], 'USER_TEMPLATE')
216
+ else
217
+ str = OpenNebulaHelper.update_template(args[0], obj, args[1], 'USER_TEMPLATE')
218
+ end
219
+
220
+ obj.update(str, options[:append])
216
221
  end
217
222
  end
218
223
 
data/bin/onevnet CHANGED
@@ -199,10 +199,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do
199
199
  be launched to modify the current content.
200
200
  EOT
201
201
 
202
- command :update, update_desc, :vnetid, [:file, nil] do
203
- helper.perform_action(args[0],options,"modified") do |vnet|
204
- str = OpenNebulaHelper.update_template(args[0], vnet, args[1])
205
- vnet.update(str)
202
+ command :update, update_desc, :vnetid, [:file, nil],
203
+ :options=>OpenNebulaHelper::APPEND do
204
+ helper.perform_action(args[0],options,"modified") do |obj|
205
+ if options[:append]
206
+ str = OpenNebulaHelper.append_template(args[0], obj, args[1])
207
+ else
208
+ str = OpenNebulaHelper.update_template(args[0], obj, args[1])
209
+ end
210
+
211
+ obj.update(str, options[:append])
206
212
  end
207
213
  end
208
214
 
data/lib/one_helper.rb CHANGED
@@ -67,6 +67,13 @@ EOT
67
67
  :description => "Describe list columns"
68
68
  }
69
69
 
70
+ APPEND = {
71
+ :name => "append",
72
+ :short => "-a",
73
+ :large => "--append",
74
+ :description => "Append new attributes to the current template"
75
+ }
76
+
70
77
  # Command line VM template options
71
78
  TEMPLATE_NAME_VM={
72
79
  :name => 'name',
@@ -655,21 +662,31 @@ EOT
655
662
  end
656
663
 
657
664
  def OpenNebulaHelper.update_template(id, resource, path=nil, xpath='TEMPLATE')
665
+ return update_template_helper(false, id, resource, path, xpath)
666
+ end
667
+
668
+ def OpenNebulaHelper.append_template(id, resource, path=nil, xpath='TEMPLATE')
669
+ return update_template_helper(true, id, resource, path, xpath)
670
+ end
671
+
672
+ def OpenNebulaHelper.update_template_helper(append, id, resource, path, xpath)
658
673
  unless path
659
674
  require 'tempfile'
660
675
 
661
676
  tmp = Tempfile.new(id.to_s)
662
677
  path = tmp.path
663
678
 
664
- rc = resource.info
679
+ if !append
680
+ rc = resource.info
665
681
 
666
- if OpenNebula.is_error?(rc)
667
- puts rc.message
668
- exit -1
669
- end
682
+ if OpenNebula.is_error?(rc)
683
+ puts rc.message
684
+ exit -1
685
+ end
670
686
 
671
- tmp << resource.template_like_str(xpath)
672
- tmp.flush
687
+ tmp << resource.template_like_str(xpath)
688
+ tmp.flush
689
+ end
673
690
 
674
691
  editor_path = ENV["EDITOR"] ? ENV["EDITOR"] : EDITOR_PATH
675
692
  system("#{editor_path} #{path}")
@@ -743,26 +760,8 @@ EOT
743
760
  end
744
761
  end
745
762
 
746
- if options[:net_context] && options[:nic]
747
- nets=options[:nic].map {|n| parse_user_object(n).last }
748
-
749
- if nets!=nets.uniq
750
- STDERR.puts "Network context generation from command "<<
751
- "line is not supported for VMs with\n"<<
752
- "more than one network with the same name."
753
- exit(-1)
754
- end
755
-
756
- nets.each_with_index do |name, index|
757
- lines<<"ETH#{index}_IP = \"$NIC[IP, NETWORK=\\\"#{name}\\\"]\""
758
- lines<<"ETH#{index}_NETWORK = \"$NETWORK[NETWORK_ADDRESS, NETWORK=\\\"#{name}\\\"]\""
759
- lines<<"ETH#{index}_MASK = \"$NETWORK[NETWORK_MASK, NETWORK=\\\"#{name}\\\"]\""
760
- lines<<"ETH#{index}_GATEWAY = \"$NETWORK[GATEWAY, NETWORK=\\\"#{name}\\\"]\""
761
- lines<<"ETH#{index}_DNS = \"$NETWORK[DNS, NETWORK=\\\"#{name}\\\"]\""
762
- lines<<"ETH#{index}_IPV6 = \"$NIC[IP6_GLOBAL, NETWORK=\\\"#{name}\\\"]\""
763
- lines<<"ETH#{index}_GATEWAY6 = \"$NETWORK[GATEWAY6, NETWORK=\\\"#{name}\\\"]\""
764
- lines<<"ETH#{index}_CONTEXT_FORCE_IPV4 = \"$NETWORK[CONTEXT_FORCE_IPV4, NETWORK=\\\"#{name}\\\"]\""
765
- end
763
+ if options[:net_context]
764
+ lines << "NETWORK = \"YES\""
766
765
  end
767
766
 
768
767
  lines+=options[:context] if options[:context]
@@ -44,11 +44,27 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
44
44
  d["ID"]
45
45
  end
46
46
 
47
- column :NAME, "Name of the Datastore", :left, :size=>25 do |d|
47
+ column :NAME, "Name of the Datastore", :left, :size=>13 do |d|
48
48
  d["NAME"]
49
49
  end
50
50
 
51
- column :CLUSTER, "Name of the Cluster", :left, :size=>15 do |d|
51
+ column :SIZE, "Datastore total size", :size =>10 do |d|
52
+ if d['TEMPLATE']['TYPE'] == 'SYSTEM_DS'
53
+ "-"
54
+ else
55
+ OpenNebulaHelper.unit_to_str(d['TOTAL_MB'].to_i, {}, 'M')
56
+ end
57
+ end
58
+
59
+ column :AVAIL, "Datastore free size", :left, :size =>5 do |d|
60
+ if d['TOTAL_MB'].to_i == 0
61
+ "-"
62
+ else
63
+ "#{((d['FREE_MB'].to_f/d['TOTAL_MB'].to_f) * 100).round()}%"
64
+ end
65
+ end
66
+
67
+ column :CLUSTER, "Name of the Cluster", :left, :size=>12 do |d|
52
68
  OpenNebulaHelper.cluster_str(d["CLUSTER"])
53
69
  end
54
70
 
@@ -73,7 +89,7 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
73
89
  d["TM_MAD"]
74
90
  end
75
91
 
76
- default :ID, :NAME, :CLUSTER, :IMAGES, :TYPE, :DS, :TM
92
+ default :ID, :NAME, :SIZE, :AVAIL, :CLUSTER, :IMAGES, :TYPE, :DS, :TM
77
93
  end
78
94
 
79
95
  table
@@ -99,6 +115,8 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
99
115
  str="%-15s: %-20s"
100
116
  str_h1="%-80s"
101
117
 
118
+ system = datastore.type == 1
119
+
102
120
  CLIHelper.print_header(str_h1 % "DATASTORE #{datastore['ID']} INFORMATION")
103
121
  puts str % ["ID", datastore.id.to_s]
104
122
  puts str % ["NAME", datastore.name]
@@ -113,6 +131,12 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
113
131
  puts str % ["DISK_TYPE",Image::DISK_TYPES[datastore['DISK_TYPE'].to_i]]
114
132
  puts
115
133
 
134
+ CLIHelper.print_header(str_h1 % "DATASTORE CAPACITY", false)
135
+ puts str % ["TOTAL:", system ? '-' : OpenNebulaHelper.unit_to_str(datastore['TOTAL_MB'].to_i, {},'M')]
136
+ puts str % ["USED: ", system ? '-' : OpenNebulaHelper.unit_to_str(datastore['USED_MB'].to_i, {},'M')]
137
+ puts str % ["FREE:", system ? '-' : OpenNebulaHelper.unit_to_str(datastore['FREE_MB'].to_i, {},'M')]
138
+ puts
139
+
116
140
  CLIHelper.print_header(str_h1 % "PERMISSIONS",false)
117
141
 
118
142
  ["OWNER", "GROUP", "OTHER"].each { |e|
metadata CHANGED
@@ -1,45 +1,41 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: opennebula-cli
3
- version: !ruby/object:Gem::Version
4
- hash: 61
5
- prerelease:
6
- segments:
7
- - 4
8
- - 0
9
- - 1
10
- version: 4.0.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 4.1.80.beta
5
+ prerelease: 7
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - OpenNebula
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2013-05-20 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2013-07-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: opennebula
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - "="
27
- - !ruby/object:Gem::Version
28
- hash: 61
29
- segments:
30
- - 4
31
- - 0
32
- - 1
33
- version: 4.0.1
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 4.1.80.beta
34
22
  type: :runtime
35
- version_requirements: *id001
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 4.1.80.beta
36
30
  description: Commands used to talk to OpenNebula
37
31
  email: contact@opennebula.org
38
- executables:
32
+ executables:
39
33
  - oneacct
40
34
  - oneacl
41
35
  - onecluster
42
36
  - onedatastore
37
+ - oneflow
38
+ - oneflow-template
43
39
  - onegroup
44
40
  - onehost
45
41
  - oneimage
@@ -48,14 +44,14 @@ executables:
48
44
  - onevm
49
45
  - onevnet
50
46
  extensions: []
51
-
52
47
  extra_rdoc_files: []
53
-
54
- files:
48
+ files:
55
49
  - bin/oneacct
56
50
  - bin/oneacl
57
51
  - bin/onecluster
58
52
  - bin/onedatastore
53
+ - bin/oneflow
54
+ - bin/oneflow-template
59
55
  - bin/onegroup
60
56
  - bin/onehost
61
57
  - bin/oneimage
@@ -82,36 +78,27 @@ files:
82
78
  - LICENSE
83
79
  homepage: http://opennebula.org
84
80
  licenses: []
85
-
86
81
  post_install_message:
87
82
  rdoc_options: []
88
-
89
- require_paths:
83
+ require_paths:
90
84
  - lib
91
- required_ruby_version: !ruby/object:Gem::Requirement
85
+ required_ruby_version: !ruby/object:Gem::Requirement
92
86
  none: false
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- hash: 3
97
- segments:
98
- - 0
99
- version: "0"
100
- required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
92
  none: false
102
- requirements:
103
- - - ">="
104
- - !ruby/object:Gem::Version
105
- hash: 3
106
- segments:
107
- - 0
108
- version: "0"
93
+ requirements:
94
+ - - ! '>'
95
+ - !ruby/object:Gem::Version
96
+ version: 1.3.1
109
97
  requirements: []
110
-
111
98
  rubyforge_project:
112
99
  rubygems_version: 1.8.25
113
100
  signing_key:
114
101
  specification_version: 3
115
102
  summary: OpenNebula Command Line Interface
116
103
  test_files: []
117
-
104
+ has_rdoc: