opennebula-cli 4.14.2 → 4.90.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/NOTICE +1 -1
  3. data/bin/oneacct +1 -1
  4. data/bin/oneacl +1 -1
  5. data/bin/onecluster +4 -1
  6. data/bin/onedatastore +4 -1
  7. data/bin/oneflow +26 -1
  8. data/bin/oneflow-template +57 -1
  9. data/bin/onegroup +4 -1
  10. data/bin/onehost +24 -15
  11. data/bin/oneimage +5 -3
  12. data/bin/onemarket +178 -0
  13. data/bin/onemarketapp +282 -0
  14. data/bin/onesecgroup +18 -1
  15. data/bin/oneshowback +1 -1
  16. data/bin/onetemplate +30 -21
  17. data/bin/oneuser +12 -6
  18. data/bin/oneuser.backup +522 -0
  19. data/bin/onevcenter +287 -1
  20. data/bin/onevdc +4 -1
  21. data/bin/onevm +78 -56
  22. data/bin/onevnet +10 -4
  23. data/bin/onevrouter +305 -0
  24. data/bin/onezone +4 -1
  25. data/lib/cli_helper.rb +1 -1
  26. data/lib/command_parser.rb +1 -1
  27. data/lib/one_helper/oneacct_helper.rb +1 -1
  28. data/lib/one_helper/oneacl_helper.rb +11 -5
  29. data/lib/one_helper/onecluster_helper.rb +1 -1
  30. data/lib/one_helper/onedatastore_helper.rb +17 -7
  31. data/lib/one_helper/onegroup_helper.rb +1 -1
  32. data/lib/one_helper/onehost_helper.rb +2 -5
  33. data/lib/one_helper/oneimage_helper.rb +1 -15
  34. data/lib/one_helper/onemarket_helper.rb +152 -0
  35. data/lib/one_helper/onemarketapp_helper.rb +223 -0
  36. data/lib/one_helper/onequota_helper.rb +1 -1
  37. data/lib/one_helper/onesecgroup_helper.rb +46 -3
  38. data/lib/one_helper/onetemplate_helper.rb +146 -11
  39. data/lib/one_helper/oneuser_helper.rb +1 -1
  40. data/lib/one_helper/onevdc_helper.rb +1 -1
  41. data/lib/one_helper/onevm_helper.rb +37 -53
  42. data/lib/one_helper/onevnet_helper.rb +23 -11
  43. data/lib/one_helper/onevrouter_helper.rb +221 -0
  44. data/lib/one_helper/onezone_helper.rb +1 -1
  45. data/lib/one_helper.rb +193 -25
  46. metadata +21 -10
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2015, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2016, OpenNebula Project, OpenNebula Systems #
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 #
@@ -84,6 +84,14 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
84
84
  }
85
85
  }
86
86
 
87
+ IP={
88
+ :name => "ip",
89
+ :short => "-i ip",
90
+ :large => "--ip ip",
91
+ :format => String,
92
+ :description => "IP address for the new NIC"
93
+ }
94
+
87
95
  FILE = {
88
96
  :name => "file",
89
97
  :short => "-f file",
@@ -131,12 +139,6 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
131
139
  :description=> "Does not communicate with the guest OS"
132
140
  }
133
141
 
134
- RECREATE = {
135
- :name => "recreate",
136
- :large => "--recreate",
137
- :description=> "Resubmits a fresh VM"
138
- }
139
-
140
142
  def self.rname
141
143
  "VM"
142
144
  end
@@ -170,16 +172,11 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
170
172
  end
171
173
 
172
174
  vm_nics.each do |nic|
173
- if nic.has_key?("IP")
174
- ips.push(nic["IP"])
175
- end
176
-
177
- if nic.has_key?("IP6_GLOBAL")
178
- ips.push(nic["IP6_GLOBAL"])
179
- end
180
-
181
- if nic.has_key?("IP6_ULA")
182
- ips.push(nic["IP6_ULA"])
175
+ ["IP", "IP6_GLOBAL", "IP6_ULA",
176
+ "VROUTER_IP", "VROUTER_IP6_GLOBAL", "VROUTER_IP6_ULA"].each do |attr|
177
+ if nic.has_key?(attr)
178
+ ips.push(nic[attr])
179
+ end
183
180
  end
184
181
  end
185
182
 
@@ -333,6 +330,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
333
330
  :PROLOG_MIGRATE_FAILURE => :migrate,
334
331
  :PROLOG_MIGRATE_POWEROFF_FAILURE => :migrate,
335
332
  :PROLOG_MIGRATE_SUSPEND_FAILURE => :migrate,
333
+ :PROLOG_MIGRATE_UNKNOWN_FAILURE => :migrate,
336
334
  :PROLOG_FAILURE => :prolog,
337
335
  :PROLOG_RESUME_FAILURE => :resume,
338
336
  :PROLOG_UNDEPLOY_FAILURE => :resume,
@@ -517,6 +515,8 @@ in the frontend machine.
517
515
  OpenNebulaHelper.time_to_str(vm['/VM/ETIME'])]
518
516
  value=vm['DEPLOY_ID']
519
517
  puts str % ["DEPLOY ID", value=="" ? "-" : value]
518
+ value=vm['TEMPLATE/VROUTER_ID']
519
+ puts str % ["VIRTUAL ROUTER ID", value] if value
520
520
 
521
521
  puts
522
522
 
@@ -724,7 +724,6 @@ in the frontend machine.
724
724
  nic_default = {"NETWORK" => "-",
725
725
  "IP" => "-",
726
726
  "MAC"=> "-",
727
- "VLAN"=>"no",
728
727
  "BRIDGE"=>"-"}
729
728
 
730
729
  shown_ips = []
@@ -735,37 +734,31 @@ in the frontend machine.
735
734
 
736
735
  next if nic.has_key?("CLI_DONE")
737
736
 
738
- if nic.has_key?("IP6_LINK")
739
- shown_ips << nic["IP6_LINK"]
740
-
741
- ip6_link = {"IP" => nic.delete("IP6_LINK"),
742
- "CLI_DONE" => true,
743
- "DOUBLE_ENTRY" => true}
744
- vm_nics.insert(array_id+1,ip6_link)
737
+ ["IP6_LINK", "IP6_ULA", "IP6_GLOBAL"].each do |attr|
738
+ if nic.has_key?(attr)
739
+ shown_ips << nic[attr]
745
740
 
746
- array_id += 1
747
- end
748
-
749
- if nic.has_key?("IP6_ULA")
750
- shown_ips << nic["IP6_ULA"]
751
-
752
- ip6_link = {"IP" => nic.delete("IP6_ULA"),
753
- "CLI_DONE" => true,
754
- "DOUBLE_ENTRY" => true}
755
- vm_nics.insert(array_id+1,ip6_link)
741
+ ipstr = {"IP" => nic.delete(attr),
742
+ "CLI_DONE" => true,
743
+ "DOUBLE_ENTRY" => true}
744
+ vm_nics.insert(array_id+1,ipstr)
756
745
 
757
- array_id += 1
746
+ array_id += 1
747
+ end
758
748
  end
759
749
 
760
- if nic.has_key?("IP6_GLOBAL")
761
- shown_ips << nic["IP6_GLOBAL"]
750
+ ["VROUTER_IP", "VROUTER_IP6_LINK",
751
+ "VROUTER_IP6_ULA", "VROUTER_IP6_GLOBAL"].each do |attr|
752
+ if nic.has_key?(attr)
753
+ shown_ips << nic[attr]
762
754
 
763
- ip6_link = {"IP" => nic.delete("IP6_GLOBAL"),
764
- "CLI_DONE" => true,
765
- "DOUBLE_ENTRY" => true}
766
- vm_nics.insert(array_id+1,ip6_link)
755
+ ipstr = {"IP" => nic.delete(attr) + " (VRouter)",
756
+ "CLI_DONE" => true,
757
+ "DOUBLE_ENTRY" => true}
758
+ vm_nics.insert(array_id+1,ipstr)
767
759
 
768
- array_id += 1
760
+ array_id += 1
761
+ end
769
762
  end
770
763
 
771
764
  shown_ips << nic["IP"] if nic.has_key?("IP")
@@ -782,8 +775,7 @@ in the frontend machine.
782
775
  "NIC_ID" => "-",
783
776
  "IP" => ip,
784
777
  "NETWORK" => "Additional IP",
785
- "BRIDGE" => "-",
786
- "VLAN" => "-"
778
+ "BRIDGE" => "-"
787
779
  }
788
780
  end
789
781
 
@@ -804,14 +796,6 @@ in the frontend machine.
804
796
  end
805
797
  end
806
798
 
807
- column :VLAN, "", :size=>4 do |d|
808
- if d["DOUBLE_ENTRY"]
809
- ""
810
- else
811
- d["VLAN"].downcase
812
- end
813
- end
814
-
815
799
  column :BRIDGE, "", :left, :size=>12 do |d|
816
800
  if d["DOUBLE_ENTRY"]
817
801
  ""
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2015, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2016, OpenNebula Project, OpenNebula Systems #
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 #
@@ -102,10 +102,11 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
102
102
  :description=> "Netmask in dot notation"
103
103
  ]
104
104
 
105
- VLAN = [
106
- :name => "vlan",
107
- :large => "--vlan",
108
- :description=> "Use network isolation"
105
+ VN_MAD = [
106
+ :name => "vn_mad",
107
+ :large => "--vn_mad mad",
108
+ :format => String,
109
+ :description=> "Use this driver for the network"
109
110
  ]
110
111
 
111
112
  VLAN_ID = [
@@ -116,7 +117,7 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
116
117
  ]
117
118
 
118
119
  ADDAR_OPTIONS = [
119
- SIZE, MAC, IP, IP6_GLOBAL, IP6_ULA, GATEWAY, NETMASK, VLAN, VLAN_ID ]
120
+ SIZE, MAC, IP, IP6_GLOBAL, IP6_ULA, GATEWAY, NETMASK, VN_MAD, VLAN_ID ]
120
121
 
121
122
  def self.rname
122
123
  "VNET"
@@ -149,8 +150,8 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
149
150
  d["NAME"]
150
151
  end
151
152
 
152
- column :CLUSTER, "Name of the Cluster", :left, :size=>10 do |d|
153
- OpenNebulaHelper.cluster_str(d["CLUSTER"])
153
+ column :CLUSTERS, "Cluster IDs", :left, :size=>10 do |d|
154
+ OpenNebulaHelper.clusters_str(d["CLUSTERS"]["ID"])
154
155
  end
155
156
 
156
157
  column :BRIDGE, "Bridge associated to the Virtual Network", :left,
@@ -163,7 +164,7 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
163
164
  d["USED_LEASES"]
164
165
  end
165
166
 
166
- default :ID, :USER, :GROUP, :NAME, :CLUSTER, :BRIDGE, :LEASES
167
+ default :ID, :USER, :GROUP, :NAME, :CLUSTERS, :BRIDGE, :LEASES
167
168
  end
168
169
 
169
170
  table
@@ -209,9 +210,10 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
209
210
  puts str % ["NAME", vn['NAME']]
210
211
  puts str % ["USER", vn['UNAME']]
211
212
  puts str % ["GROUP", vn['GNAME']]
212
- puts str % ["CLUSTER", OpenNebulaHelper.cluster_str(vn['CLUSTER'])]
213
+ puts str % ["CLUSTERS",
214
+ OpenNebulaHelper.clusters_str(vn.retrieve_elements("CLUSTERS/ID"))]
213
215
  puts str % ["BRIDGE", vn["BRIDGE"]]
214
- puts str % ["VLAN", OpenNebulaHelper.boolean_to_str(vn['VLAN'])]
216
+ puts str % ["VN_MAD", vn['VN_MAD']] if !vn['VN_MAD'].empty?
215
217
  puts str % ["PHYSICAL DEVICE", vn["PHYDEV"]] if !vn["PHYDEV"].empty?
216
218
  puts str % ["VLAN ID", vn["VLAN_ID"]] if !vn["VLAN_ID"].empty?
217
219
  puts str % ["USED LEASES", vn['USED_LEASES']]
@@ -251,6 +253,7 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
251
253
  str="%-15s: %-20s"
252
254
  puts str % ["SIZE", ar["SIZE"]]
253
255
  puts str % ["LEASES", ar["USED_LEASES"]]
256
+ puts str % ["VN_MAD", ar["VN_MAD"]] if ar["VN_MAD"]
254
257
  puts
255
258
 
256
259
  format = "%-10s %34s %34s"
@@ -308,6 +311,8 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
308
311
  "V:#{d['VM']}"
309
312
  elsif d['VNET']
310
313
  "N:#{d['VNET']}"
314
+ elsif d['VROUTER']
315
+ "R:#{d['VROUTER']}"
311
316
  end
312
317
  end
313
318
 
@@ -324,6 +329,13 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
324
329
  end
325
330
  end.show(leases, {})
326
331
 
332
+ puts
333
+
334
+ CLIHelper.print_header("%-15s" % "VIRTUAL ROUTERS")
335
+ vn.vrouter_ids.each do |id|
336
+ puts "%-15s" % [id]
337
+ end
338
+
327
339
  if options[:show_ar]
328
340
  ar_list.each do |ar_id|
329
341
  puts
@@ -0,0 +1,221 @@
1
+ # -------------------------------------------------------------------------- #
2
+ # Copyright 2002-2016, OpenNebula Project, OpenNebula Systems #
3
+ # #
4
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
+ # not use this file except in compliance with the License. You may obtain #
6
+ # a copy of the License at #
7
+ # #
8
+ # http://www.apache.org/licenses/LICENSE-2.0 #
9
+ # #
10
+ # Unless required by applicable law or agreed to in writing, software #
11
+ # distributed under the License is distributed on an "AS IS" BASIS, #
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
13
+ # See the License for the specific language governing permissions and #
14
+ # limitations under the License. #
15
+ #--------------------------------------------------------------------------- #
16
+
17
+ require 'one_helper'
18
+
19
+ class OneVirtualRouterHelper < OpenNebulaHelper::OneHelper
20
+
21
+ ALL_TEMPLATE = {
22
+ :name => "all",
23
+ :large => "--all",
24
+ :description => "Show all template data"
25
+ }
26
+
27
+ def self.rname
28
+ "VROUTER"
29
+ end
30
+
31
+ def self.conf_file
32
+ "onevrouter.yaml"
33
+ end
34
+
35
+ def show_resource(id, options)
36
+ resource = retrieve_resource(id)
37
+
38
+ if !options[:extended].nil?
39
+ rc = resource.info(options[:extended])
40
+ else
41
+ rc = resource.info
42
+ end
43
+
44
+ return -1, rc.message if OpenNebula.is_error?(rc)
45
+
46
+ if options[:xml]
47
+ return 0, resource.to_xml(true)
48
+ else
49
+ format_resource(resource, options)
50
+ return 0
51
+ end
52
+ end
53
+
54
+ def format_pool(options)
55
+ config_file = self.class.table_conf
56
+
57
+ table = CLIHelper::ShowTable.new(config_file, self) do
58
+ column :ID, "ONE identifier for the Virtual Router", :size=>4 do |d|
59
+ d["ID"]
60
+ end
61
+
62
+ column :NAME, "Name of the Virtual Router", :left, :size=>27 do |d|
63
+ d["NAME"]
64
+ end
65
+
66
+ column :USER, "Username of the Virtual Router owner", :left,
67
+ :size=>15 do |d|
68
+ helper.user_name(d, options)
69
+ end
70
+
71
+ column :GROUP, "Group of the Virtual Router", :left, :size=>15 do |d|
72
+ helper.group_name(d, options)
73
+ end
74
+
75
+ default :ID, :USER, :GROUP, :NAME
76
+ end
77
+
78
+ table
79
+ end
80
+
81
+ private
82
+
83
+ def factory(id=nil)
84
+ if id
85
+ OpenNebula::VirtualRouter.new_with_id(id, @client)
86
+ else
87
+ xml=OpenNebula::VirtualRouter.build_xml
88
+ OpenNebula::VirtualRouter.new(xml, @client)
89
+ end
90
+ end
91
+
92
+ def factory_pool(user_flag=-2)
93
+ OpenNebula::VirtualRouterPool.new(@client, user_flag)
94
+ end
95
+
96
+ def format_resource(obj, options = {})
97
+ str="%-15s: %-20s"
98
+ str_h1="%-80s"
99
+
100
+ CLIHelper.print_header(
101
+ str_h1 % "VIRTUAL ROUTER #{obj['ID']} INFORMATION")
102
+ puts str % ["ID", obj.id.to_s]
103
+ puts str % ["NAME", obj.name]
104
+ puts str % ["USER", obj['UNAME']]
105
+ puts str % ["GROUP", obj['GNAME']]
106
+ puts
107
+
108
+ CLIHelper.print_header(str_h1 % "PERMISSIONS",false)
109
+
110
+ ["OWNER", "GROUP", "OTHER"].each { |e|
111
+ mask = "---"
112
+ mask[0] = "u" if obj["PERMISSIONS/#{e}_U"] == "1"
113
+ mask[1] = "m" if obj["PERMISSIONS/#{e}_M"] == "1"
114
+ mask[2] = "a" if obj["PERMISSIONS/#{e}_A"] == "1"
115
+
116
+ puts str % [e, mask]
117
+ }
118
+
119
+ if obj.has_elements?("/VROUTER/TEMPLATE/NIC")
120
+ puts
121
+ CLIHelper.print_header(str_h1 % "VIRTUAL ROUTER NICS",false)
122
+
123
+ nic_default = {"NETWORK" => "-",
124
+ "IP" => "-"}
125
+
126
+ array_id = 0
127
+ vm_nics = [obj.to_hash['VROUTER']['TEMPLATE']['NIC']].flatten.compact
128
+ vm_nics.each {|nic|
129
+
130
+ next if nic.has_key?("CLI_DONE")
131
+
132
+ floating = (nic.has_key?("FLOATING_IP") && nic["FLOATING_IP"].upcase() == "YES" )
133
+
134
+ if floating
135
+ if nic.has_key?("IP6_LINK")
136
+ ip6_link = {"IP" => nic.delete("IP6_LINK"),
137
+ "CLI_DONE" => true,
138
+ "DOUBLE_ENTRY" => true}
139
+ vm_nics.insert(array_id+1,ip6_link)
140
+
141
+ array_id += 1
142
+ end
143
+
144
+ if nic.has_key?("IP6_ULA")
145
+ ip6_link = {"IP" => nic.delete("IP6_ULA"),
146
+ "CLI_DONE" => true,
147
+ "DOUBLE_ENTRY" => true}
148
+ vm_nics.insert(array_id+1,ip6_link)
149
+
150
+ array_id += 1
151
+ end
152
+
153
+ if nic.has_key?("IP6_GLOBAL")
154
+ ip6_link = {"IP" => nic.delete("IP6_GLOBAL"),
155
+ "CLI_DONE" => true,
156
+ "DOUBLE_ENTRY" => true}
157
+ vm_nics.insert(array_id+1,ip6_link)
158
+
159
+ array_id += 1
160
+ end
161
+ else
162
+ nic.delete("IP")
163
+ end
164
+
165
+ nic.merge!(nic_default) {|k,v1,v2| v1}
166
+ array_id += 1
167
+ }
168
+
169
+ CLIHelper::ShowTable.new(nil, self) do
170
+ column :ID, "", :size=>3 do |d|
171
+ if d["DOUBLE_ENTRY"]
172
+ ""
173
+ else
174
+ d["NIC_ID"]
175
+ end
176
+ end
177
+
178
+ column :NETWORK, "", :left, :size=>20 do |d|
179
+ if d["DOUBLE_ENTRY"]
180
+ ""
181
+ else
182
+ d["NETWORK"]
183
+ end
184
+ end
185
+
186
+ column :MANAGEMENT, "", :left, :size=>10 do |d|
187
+ if d["DOUBLE_ENTRY"]
188
+ ""
189
+ else
190
+ if !d["VROUTER_MANAGEMENT"].nil?
191
+ d["VROUTER_MANAGEMENT"]
192
+ else
193
+ "NO"
194
+ end
195
+ end
196
+ end
197
+
198
+
199
+ column :IP, "",:left, :donottruncate, :size=>15 do |d|
200
+ d["IP"]
201
+ end
202
+ end.show(vm_nics,{})
203
+ end
204
+
205
+ while obj.has_elements?("/VROUTER/TEMPLATE/NIC")
206
+ obj.delete_element("/VROUTER/TEMPLATE/NIC")
207
+ end if !options[:all]
208
+
209
+ puts
210
+
211
+ CLIHelper.print_header(str_h1 % "TEMPLATE CONTENTS",false)
212
+ puts obj.template_str
213
+
214
+ puts
215
+
216
+ CLIHelper.print_header("%-15s" % "VIRTUAL MACHINES")
217
+ obj.vm_ids.each do |id|
218
+ puts "%-15s" % [id]
219
+ end
220
+ end
221
+ end
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2015, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2016, OpenNebula Project, OpenNebula Systems #
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 #