opennebula-cli 5.12.13 → 5.13.80.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +5 -5
  2. data/bin/oneacct +5 -14
  3. data/bin/oneacl +4 -15
  4. data/bin/onecluster +6 -17
  5. data/bin/onedatastore +6 -17
  6. data/bin/oneflow +81 -23
  7. data/bin/oneflow-template +51 -27
  8. data/bin/onegroup +6 -17
  9. data/bin/onehook +6 -17
  10. data/bin/onehost +4 -15
  11. data/bin/oneimage +95 -18
  12. data/bin/onemarket +6 -17
  13. data/bin/onemarketapp +113 -20
  14. data/bin/onesecgroup +9 -17
  15. data/bin/oneshowback +14 -20
  16. data/bin/onetemplate +8 -18
  17. data/bin/oneuser +26 -17
  18. data/bin/onevcenter +6 -28
  19. data/bin/onevdc +6 -17
  20. data/bin/onevm +142 -21
  21. data/bin/onevmgroup +9 -17
  22. data/bin/onevnet +4 -15
  23. data/bin/onevntemplate +7 -17
  24. data/bin/onevrouter +6 -17
  25. data/bin/onezone +6 -17
  26. data/lib/cli_helper.rb +7 -10
  27. data/lib/command_parser.rb +1 -1
  28. data/lib/one_helper/oneacct_helper.rb +9 -22
  29. data/lib/one_helper/oneacl_helper.rb +1 -1
  30. data/lib/one_helper/onecluster_helper.rb +1 -1
  31. data/lib/one_helper/onedatastore_helper.rb +11 -1
  32. data/lib/one_helper/oneflow_helper.rb +20 -5
  33. data/lib/one_helper/oneflowtemplate_helper.rb +28 -2
  34. data/lib/one_helper/onegroup_helper.rb +1 -1
  35. data/lib/one_helper/onehook_helper.rb +1 -1
  36. data/lib/one_helper/onehost_helper.rb +1 -5
  37. data/lib/one_helper/oneimage_helper.rb +7 -7
  38. data/lib/one_helper/onemarket_helper.rb +1 -1
  39. data/lib/one_helper/onemarketapp_helper.rb +494 -96
  40. data/lib/one_helper/onequota_helper.rb +1 -1
  41. data/lib/one_helper/onesecgroup_helper.rb +1 -1
  42. data/lib/one_helper/onetemplate_helper.rb +12 -1
  43. data/lib/one_helper/oneuser_helper.rb +11 -3
  44. data/lib/one_helper/onevcenter_helper.rb +176 -146
  45. data/lib/one_helper/onevdc_helper.rb +1 -1
  46. data/lib/one_helper/onevm_helper.rb +9 -9
  47. data/lib/one_helper/onevmgroup_helper.rb +1 -1
  48. data/lib/one_helper/onevnet_helper.rb +1 -1
  49. data/lib/one_helper/onevntemplate_helper.rb +1 -1
  50. data/lib/one_helper/onevrouter_helper.rb +1 -20
  51. data/lib/one_helper/onezone_helper.rb +12 -1
  52. data/lib/one_helper.rb +398 -37
  53. data/share/schemas/xsd/acct.xsd +179 -0
  54. data/share/schemas/xsd/acl_pool.xsd +22 -0
  55. data/share/schemas/xsd/api_info.xsd +43 -0
  56. data/share/schemas/xsd/cluster.xsd +34 -0
  57. data/share/schemas/xsd/cluster_pool.xsd +12 -0
  58. data/share/schemas/xsd/datastore.xsd +67 -0
  59. data/share/schemas/xsd/datastore_pool.xsd +12 -0
  60. data/share/schemas/xsd/document.xsd +42 -0
  61. data/share/schemas/xsd/document_pool.xsd +12 -0
  62. data/share/schemas/xsd/group.xsd +179 -0
  63. data/share/schemas/xsd/group_pool.xsd +194 -0
  64. data/share/schemas/xsd/hook.xsd +59 -0
  65. data/share/schemas/xsd/hook_message_api.xsd +14 -0
  66. data/share/schemas/xsd/hook_message_retry.xsd +12 -0
  67. data/share/schemas/xsd/hook_message_state.xsd +25 -0
  68. data/share/schemas/xsd/hook_pool.xsd +12 -0
  69. data/share/schemas/xsd/host.xsd +164 -0
  70. data/share/schemas/xsd/host_pool.xsd +12 -0
  71. data/share/schemas/xsd/image.xsd +123 -0
  72. data/share/schemas/xsd/image_pool.xsd +12 -0
  73. data/share/schemas/xsd/index.xsd +49 -0
  74. data/share/schemas/xsd/marketplace.xsd +44 -0
  75. data/share/schemas/xsd/marketplace_pool.xsd +12 -0
  76. data/share/schemas/xsd/marketplaceapp.xsd +56 -0
  77. data/share/schemas/xsd/marketplaceapp_pool.xsd +12 -0
  78. data/share/schemas/xsd/opennebula_configuration.xsd +412 -0
  79. data/share/schemas/xsd/raftstatus.xsd +18 -0
  80. data/share/schemas/xsd/security_group.xsd +74 -0
  81. data/share/schemas/xsd/security_group_pool.xsd +12 -0
  82. data/share/schemas/xsd/showback.xsd +29 -0
  83. data/share/schemas/xsd/user.xsd +186 -0
  84. data/share/schemas/xsd/user_pool.xsd +201 -0
  85. data/share/schemas/xsd/vdc.xsd +76 -0
  86. data/share/schemas/xsd/vdc_pool.xsd +12 -0
  87. data/share/schemas/xsd/vm.xsd +251 -0
  88. data/share/schemas/xsd/vm_group.xsd +59 -0
  89. data/share/schemas/xsd/vm_group_pool.xsd +12 -0
  90. data/share/schemas/xsd/vm_pool.xsd +114 -0
  91. data/share/schemas/xsd/vmtemplate.xsd +52 -0
  92. data/share/schemas/xsd/vmtemplate_pool.xsd +12 -0
  93. data/share/schemas/xsd/vnet.xsd +137 -0
  94. data/share/schemas/xsd/vnet_pool.xsd +85 -0
  95. data/share/schemas/xsd/vntemplate.xsd +50 -0
  96. data/share/schemas/xsd/vntemplate_pool.xsd +12 -0
  97. data/share/schemas/xsd/vrouter.xsd +49 -0
  98. data/share/schemas/xsd/vrouter_pool.xsd +12 -0
  99. data/share/schemas/xsd/zone.xsd +40 -0
  100. data/share/schemas/xsd/zone_pool.xsd +36 -0
  101. metadata +92 -30
  102. data/lib/one_helper/oneprovision_helper.rb +0 -362
@@ -1,362 +0,0 @@
1
- # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, 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 'nokogiri'
18
- require 'securerandom'
19
-
20
- # OneProvision Helper
21
- class OneProvisionHelper < OpenNebulaHelper::OneHelper
22
-
23
- RESOURCES = %w[
24
- CLUSTERS
25
- DATASTORES
26
- HOSTS
27
- NETWORKS
28
- IMAGES
29
- TEMPLATES
30
- VNTEMPLATES
31
- FLOWTEMPLATES
32
- ]
33
-
34
- def self.rname
35
- 'PROVISION'
36
- end
37
-
38
- def self.conf_file
39
- 'oneprovision.yaml'
40
- end
41
-
42
- def parse_options(options)
43
- OneProvision::OneProvisionLogger.get_logger(options)
44
- OneProvision::Mode.get_run_mode(options)
45
- OneProvision::Options.get_run_options(options)
46
- OneProvision::ObjectOptions.get_obj_options(options)
47
- end
48
-
49
- def format_pool
50
- config_file = self.class.table_conf
51
-
52
- CLIHelper::ShowTable.new(config_file, self) do
53
- column :ID, 'Identifier for the Provision', :size => 36 do |p|
54
- p['ID']
55
- end
56
-
57
- column :NAME, 'Name of the Provision', :left, :size => 25 do |p|
58
- p['NAME']
59
- end
60
-
61
- column :CLUSTERS, 'Number of Clusters', :size => 8 do |p|
62
- p['CLUSTERS']['ID'].size rescue 0
63
- end
64
-
65
- column :HOSTS, 'Number of Hosts', :size => 5 do |p|
66
- p['HOSTS']['ID'].size rescue 0
67
- end
68
-
69
- column :NETWORKS, 'Number of Networks', :size => 5 do |p|
70
- p['NETWORKS']['ID'].size rescue 0
71
- end
72
-
73
- column :DATASTORES, 'Number of Datastores', :size => 10 do |p|
74
- p['DATASTORES']['ID'].size rescue 0
75
- end
76
-
77
- column :STAT, 'Status of the Provision', :left, :size => 15 do |p|
78
- p['STATUS'] rescue '-'
79
- end
80
-
81
- default :ID, :NAME, :CLUSTERS, :HOSTS, :NETWORKS, :DATASTORES, :STAT
82
- end
83
- end
84
-
85
- #######################################################################
86
- # Helper provision functions
87
- #######################################################################
88
-
89
- def create(config, cleanup, timeout, virtual)
90
- msg = 'OpenNebula is not running'
91
-
92
- OneProvision::Utils.fail(msg) if OneProvision::Utils.one_running?
93
-
94
- provision = OneProvision::Provision.new(SecureRandom.uuid)
95
-
96
- provision.create(config, cleanup, timeout, virtual)
97
- end
98
-
99
- def configure(provision_id, force)
100
- provision = OneProvision::Provision.new(provision_id)
101
-
102
- provision.refresh
103
-
104
- provision.configure(force)
105
- end
106
-
107
- def delete(provision_id, cleanup, timeout)
108
- provision = OneProvision::Provision.new(provision_id)
109
-
110
- provision.refresh
111
-
112
- provision.delete(cleanup, timeout)
113
- end
114
-
115
- #######################################################################
116
- # Helper host functions
117
- #######################################################################
118
-
119
- def host_operation(id, operation, options, args)
120
- host = OneProvision::Host.new
121
- host.info(id)
122
-
123
- case operation[:operation]
124
- when 'resume'
125
- host.resume
126
- when 'poweroff'
127
- host.poweroff
128
- when 'reboot'
129
- host.reboot((options.key? :hard))
130
- when 'delete'
131
- host.delete
132
- when 'configure'
133
- host.configure((options.key? :force))
134
- when 'ssh'
135
- host.ssh(args)
136
- end
137
- end
138
-
139
- #######################################################################
140
- # Helper datastore functions
141
- #######################################################################
142
-
143
- def datastore_operation(datastore, operation)
144
- case operation[:operation]
145
- when 'delete'
146
- msg = "Deleting datastore #{datastore['ID']}"
147
-
148
- OneProvision::OneProvisionLogger.info(msg)
149
-
150
- datastore.delete
151
- end
152
- end
153
-
154
- #######################################################################
155
- # Helper network functions
156
- #######################################################################
157
-
158
- def network_operation(network, operation)
159
- case operation[:operation]
160
- when 'delete'
161
- msg = "Deleting network #{network['ID']}"
162
-
163
- OneProvision::OneProvisionLogger.info(msg)
164
-
165
- network.delete
166
- end
167
- end
168
-
169
- #######################################################################
170
- # Helper resource functions
171
- #######################################################################
172
-
173
- def resources_operation(args, operation, options, type)
174
- parse_options(options)
175
-
176
- helper = nil
177
-
178
- case type
179
- when 'HOST' then helper = OneHostHelper.new
180
- when 'DATASTORE' then helper = OneDatastoreHelper.new
181
- when 'NETWORK' then helper = OneVNetHelper.new
182
- end
183
-
184
- objects = names_to_ids(args[0], type)
185
-
186
- helper.set_client(options)
187
- helper.perform_actions(objects,
188
- options,
189
- operation[:message]) do |obj|
190
- case type
191
- when 'HOST'
192
- host_operation(obj['ID'], operation, options, args[1])
193
- when 'DATASTORE'
194
- datastore_operation(obj, operation)
195
- when 'NETWORK'
196
- network_operation(obj, operation)
197
- end
198
- end
199
- end
200
-
201
- #######################################################################
202
- # Utils functions
203
- #######################################################################
204
-
205
- def provision_ids
206
- clusters = OneProvision::Cluster.new.pool
207
- rc = clusters.info
208
-
209
- if OpenNebula.is_error?(rc)
210
- OneProvision::Utils.fail(rc.message)
211
- end
212
-
213
- clusters = clusters.reject do |x|
214
- x['TEMPLATE/PROVISION/PROVISION_ID'].nil?
215
- end
216
-
217
- clusters = clusters.uniq do |x|
218
- x['TEMPLATE/PROVISION/PROVISION_ID']
219
- end
220
-
221
- ids = []
222
-
223
- clusters.each {|c| ids << c['TEMPLATE/PROVISION/PROVISION_ID'] }
224
-
225
- ids
226
- end
227
-
228
- def names_to_ids(objects, type)
229
- [objects].flatten.map do |obj|
230
- OpenNebulaHelper.rname_to_id(obj.to_s, type)[1]
231
- end
232
- end
233
-
234
- def get_list(provision_list)
235
- ret = []
236
- ids = provision_ids
237
-
238
- ids.each do |i|
239
- provision = OneProvision::Provision.new(i)
240
- provision.refresh
241
-
242
- element = {}
243
-
244
- element['ID'] = i if provision_list
245
- element['ID'] = provision.clusters[0]['ID'] unless provision_list
246
-
247
- element['NAME'] = provision.name
248
- element['STATUS'] = provision.status
249
-
250
- RESOURCES.each do |c|
251
- obj = OneProvision::Resource.object(c)
252
- obj_ids = obj.get(i).map do |o|
253
- o['ID']
254
- end
255
-
256
- next if obj_ids.empty?
257
-
258
- element[c.to_s.upcase] = { 'ID' => [] }
259
- element[c.to_s.upcase]['ID'] = obj_ids
260
- end
261
-
262
- ret << element
263
- end
264
-
265
- ret
266
- end
267
-
268
- def list(options)
269
- list = get_list(true)
270
-
271
- if options.key? :xml
272
- list.map {|e| to_xml(e) }
273
- else
274
- format_pool.show(list, options)
275
- end
276
-
277
- 0
278
- end
279
-
280
- def show(provision_id, xml)
281
- provision = OneProvision::Provision.new(provision_id)
282
-
283
- provision.refresh
284
-
285
- OneProvision::Utils.fail('Provision not found.') unless provision.exists
286
-
287
- ret = {}
288
- ret['ID'] = provision_id
289
- ret['NAME'] = provision.name
290
- ret['STATUS'] = provision.status
291
-
292
- RESOURCES.each do |r|
293
- obj = OneProvision::Resource.object(r)
294
-
295
- next unless obj
296
-
297
- obj_ids = obj.get(provision_id).map {|o| o['ID'] }
298
-
299
- next if obj_ids.empty?
300
-
301
- ret[r] = obj_ids
302
- end
303
-
304
- if xml
305
- to_xml(ret)
306
- else
307
- format_resource(ret)
308
- end
309
-
310
- 0
311
- end
312
-
313
- def format_resource(provision)
314
- str_h1 = '%-80s'
315
- status = provision['STATUS']
316
- id = provision['ID']
317
-
318
- CLIHelper.print_header(str_h1 % "PROVISION #{id} INFORMATION")
319
- puts format('ID : %<s>s', :s => id)
320
- puts format('NAME : %<s>s', :s => provision['NAME'])
321
- puts format('STATUS : %<s>s', :s => CLIHelper.color_state(status))
322
-
323
- RESOURCES.each do |r|
324
- next unless provision[r]
325
-
326
- puts
327
- CLIHelper.print_header(format('%<s>s', :s => r.upcase))
328
- provision[r].each do |i|
329
- puts format('%<s>s', :s => i)
330
- end
331
- end
332
- end
333
-
334
- private
335
-
336
- def to_xml(provision)
337
- xml = "<PROVISION>
338
- <ID>#{provision['ID']}</ID>
339
- <NAME>#{provision['NAME']}</NAME>
340
- <STATUS>#{provision['STATUS']}</STATUS>
341
- #{
342
- RESOURCES.map do |r|
343
- next unless provision[r]
344
-
345
- provision[r] = provision[r]['ID'] if provision[r].is_a? Hash
346
-
347
- ids = provision[r].map do |id|
348
- "<ID>#{id}</ID>"
349
- end.join("\n")
350
-
351
- "<#{r.upcase}>
352
- #{ids}
353
- </#{r.upcase}"
354
- end.join("\n")
355
- }
356
- </PROVISION>"
357
-
358
- doc = Nokogiri.XML(xml) {|config| config.default_xml.noblanks }
359
- puts doc.root.to_xml(:indent => 2)
360
- end
361
-
362
- end