opennebula-cli 5.4.15 → 5.5.80.pre
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 +4 -4
- data/NOTICE +1 -1
- data/bin/oneacct +3 -3
- data/bin/oneacl +2 -2
- data/bin/onecluster +1 -1
- data/bin/onedatastore +1 -1
- data/bin/oneflow +1 -1
- data/bin/oneflow-template +1 -1
- data/bin/onegroup +1 -1
- data/bin/onehost +1 -1
- data/bin/oneimage +64 -1
- data/bin/onemarket +1 -1
- data/bin/onemarketapp +65 -2
- data/bin/onesecgroup +1 -1
- data/bin/oneshowback +2 -2
- data/bin/onetemplate +66 -3
- data/bin/oneuser +3 -3
- data/bin/onevcenter +95 -86
- data/bin/onevdc +1 -1
- data/bin/onevm +75 -11
- data/bin/onevmgroup +64 -1
- data/bin/onevnet +64 -1
- data/bin/onevrouter +64 -1
- data/bin/onezone +1 -1
- data/lib/cli_helper.rb +1 -1
- data/lib/command_parser.rb +9 -1
- data/lib/one_helper/oneacct_helper.rb +22 -18
- data/lib/one_helper/oneacl_helper.rb +1 -1
- data/lib/one_helper/onecluster_helper.rb +1 -1
- data/lib/one_helper/onedatastore_helper.rb +1 -1
- data/lib/one_helper/onegroup_helper.rb +1 -1
- data/lib/one_helper/onehost_helper.rb +32 -6
- data/lib/one_helper/oneimage_helper.rb +2 -1
- data/lib/one_helper/onemarket_helper.rb +1 -1
- data/lib/one_helper/onemarketapp_helper.rb +2 -1
- data/lib/one_helper/onequota_helper.rb +1 -1
- data/lib/one_helper/onesecgroup_helper.rb +1 -1
- data/lib/one_helper/onetemplate_helper.rb +2 -1
- data/lib/one_helper/oneuser_helper.rb +13 -1
- data/lib/one_helper/onevcenter_helper.rb +425 -0
- data/lib/one_helper/onevdc_helper.rb +5 -5
- data/lib/one_helper/onevm_helper.rb +100 -2
- data/lib/one_helper/onevmgroup_helper.rb +14 -9
- data/lib/one_helper/onevnet_helper.rb +7 -3
- data/lib/one_helper/onevrouter_helper.rb +2 -1
- data/lib/one_helper/onezone_helper.rb +22 -39
- data/lib/one_helper.rb +64 -8
- metadata +7 -6
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
|
|
2
|
+
# -------------------------------------------------------------------------- #
|
|
3
|
+
# Copyright 2002-2018, OpenNebula Project, OpenNebula Systems #
|
|
4
|
+
# #
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
6
|
+
# not use this file except in compliance with the License. You may obtain #
|
|
7
|
+
# a copy of the License at #
|
|
8
|
+
# #
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0 #
|
|
10
|
+
# #
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software #
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS, #
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
|
14
|
+
# See the License for the specific language governing permissions and #
|
|
15
|
+
# limitations under the License. #
|
|
16
|
+
#--------------------------------------------------------------------------- #
|
|
17
|
+
|
|
18
|
+
require 'one_helper'
|
|
19
|
+
|
|
20
|
+
class OneVcenterHelper < OpenNebulaHelper::OneHelper
|
|
21
|
+
|
|
22
|
+
#
|
|
23
|
+
# vCenter importer will divide rvmomi resources
|
|
24
|
+
# in this group, makes parsing easier.
|
|
25
|
+
module VOBJECT
|
|
26
|
+
DATASTORE = 1
|
|
27
|
+
TEMPLATE = 2
|
|
28
|
+
NETWORK = 3
|
|
29
|
+
IMAGE = 4
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
#
|
|
33
|
+
# onevcenter helper main constant
|
|
34
|
+
# This will control everything displayed on STDOUT
|
|
35
|
+
# Resources (above) uses this table
|
|
36
|
+
#
|
|
37
|
+
# struct: [Array] LIST FORMAT for opennebula cli
|
|
38
|
+
# related methods: * cli_format
|
|
39
|
+
#
|
|
40
|
+
# columns: [Hash(column => Integer)] Will be used in the list command, Integer represent nbytes
|
|
41
|
+
# related methods: * format_list
|
|
42
|
+
#
|
|
43
|
+
# cli: [Array] with mandatory args, for example image listing needs a datastore
|
|
44
|
+
# related methods: * parse_opts
|
|
45
|
+
#
|
|
46
|
+
# dialogue: [Lambda] Used only for Vobject that require a previous dialogue with the user, will be triggered
|
|
47
|
+
# on importation process
|
|
48
|
+
# related methods: * network_dialogue
|
|
49
|
+
# * template_dialogue
|
|
50
|
+
#
|
|
51
|
+
TABLE = {
|
|
52
|
+
VOBJECT::DATASTORE => {
|
|
53
|
+
:struct => ["DATASTORE_LIST", "DATASTORE"],
|
|
54
|
+
:columns => {:IMID => 5, :REF => 15, :NAME => 50, :CLUSTERS => 10},
|
|
55
|
+
:cli => [:host],
|
|
56
|
+
:dialogue => ->(arg){}
|
|
57
|
+
},
|
|
58
|
+
VOBJECT::TEMPLATE => {
|
|
59
|
+
:struct => ["TEMPLATE_LIST", "TEMPLATE"],
|
|
60
|
+
:columns => {:IMID => 5, :REF => 10, :NAME => 50},
|
|
61
|
+
:cli => [:host],
|
|
62
|
+
:dialogue => ->(arg){ OneVcenterHelper.template_dialogue(arg) }
|
|
63
|
+
},
|
|
64
|
+
VOBJECT::NETWORK => {
|
|
65
|
+
:struct => ["NETWORK_LIST", "NETWORK"],
|
|
66
|
+
:columns => {:IMID => 5, :REF => 15, :NAME => 30, :CLUSTERS => 20},
|
|
67
|
+
:cli => [:host],
|
|
68
|
+
:dialogue => ->(arg){ OneVcenterHelper.network_dialogue(arg) }
|
|
69
|
+
},
|
|
70
|
+
VOBJECT::IMAGE => {
|
|
71
|
+
:struct => ["IMAGE_LIST", "IMAGE"],
|
|
72
|
+
:columns => {:IMID => 5,:REF => 35, :PATH => 60},
|
|
73
|
+
:cli => [:host, :datastore],
|
|
74
|
+
:dialogue => ->(arg){}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
################################################################
|
|
80
|
+
# CLI ARGS
|
|
81
|
+
################################################################
|
|
82
|
+
|
|
83
|
+
# these methods will be used by table :cli property
|
|
84
|
+
# the purpose is to inject code when -d option in this case is used
|
|
85
|
+
#
|
|
86
|
+
# @param arg [String] The parameter passed to the option:w
|
|
87
|
+
#
|
|
88
|
+
|
|
89
|
+
def datastore(arg)
|
|
90
|
+
ds = VCenterDriver::VIHelper.one_item(OpenNebula::Datastore, arg)
|
|
91
|
+
|
|
92
|
+
{
|
|
93
|
+
ds_ref: ds['TEMPLATE/VCENTER_DS_REF'],
|
|
94
|
+
one_item: ds
|
|
95
|
+
}
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def host(arg)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
########################
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
# In list command you can use this method to print a header
|
|
105
|
+
#
|
|
106
|
+
# @param vcenter_host [String] this text will be displayed
|
|
107
|
+
#
|
|
108
|
+
def show_header(vcenter_host)
|
|
109
|
+
CLIHelper.scr_bold
|
|
110
|
+
CLIHelper.scr_underline
|
|
111
|
+
puts "# vCenter: #{vcenter_host}".ljust(50)
|
|
112
|
+
CLIHelper.scr_restore
|
|
113
|
+
puts
|
|
114
|
+
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Using for parse a String into a VOBJECT
|
|
118
|
+
# We will use VOBJECT instances for handle any operatiion
|
|
119
|
+
#
|
|
120
|
+
# @param type [String] String representing the vCenter resource
|
|
121
|
+
#
|
|
122
|
+
def set_object(type)
|
|
123
|
+
type = type.downcase
|
|
124
|
+
if (type == "datastores")
|
|
125
|
+
@vobject = VOBJECT::DATASTORE
|
|
126
|
+
elsif (type == "templates")
|
|
127
|
+
@vobject = VOBJECT::TEMPLATE
|
|
128
|
+
elsif (type =="networks")
|
|
129
|
+
@vobject = VOBJECT::NETWORK
|
|
130
|
+
elsif (type == "images")
|
|
131
|
+
@vobject = VOBJECT::IMAGE
|
|
132
|
+
else
|
|
133
|
+
puts "unknown #{type} type option"
|
|
134
|
+
puts " -o options:"
|
|
135
|
+
puts " datastores"
|
|
136
|
+
puts " templates"
|
|
137
|
+
puts " networks"
|
|
138
|
+
puts " images"
|
|
139
|
+
|
|
140
|
+
exit 0
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Handles connection to vCenter.
|
|
145
|
+
#
|
|
146
|
+
# @param options [Hash] options for the connection
|
|
147
|
+
#
|
|
148
|
+
def connection_options(object_name, options)
|
|
149
|
+
if options[:vuser].nil? || options[:vcenter].nil?
|
|
150
|
+
raise "vCenter connection parameters are mandatory to import"\
|
|
151
|
+
" #{object_name}:\n"\
|
|
152
|
+
"\t --vcenter vCenter hostname\n"\
|
|
153
|
+
"\t --vuser username to login in vcenter"
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
password = options[:vpass] || OpenNebulaHelper::OneHelper.get_password
|
|
157
|
+
{
|
|
158
|
+
:user => options[:vuser],
|
|
159
|
+
:password => password,
|
|
160
|
+
:host => options[:vcenter]
|
|
161
|
+
}
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def cli_format( hash)
|
|
165
|
+
{TABLE[@vobject][:struct].first => {TABLE[@vobject][:struct].last => hash.values}}
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# This method will print a list for a vcenter_resource.
|
|
169
|
+
#
|
|
170
|
+
def list_object(options, list)
|
|
171
|
+
vcenter_host = list.keys[0]
|
|
172
|
+
list = cli_format(list.values.first)
|
|
173
|
+
table = format_list()
|
|
174
|
+
|
|
175
|
+
show_header(vcenter_host)
|
|
176
|
+
|
|
177
|
+
table.show(list)
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
# handles :cli section of TABLE
|
|
181
|
+
# used for executing the dialogue in some VOBJECTS
|
|
182
|
+
#
|
|
183
|
+
# @param object_info [Hash] This is the object with all the info related to the object
|
|
184
|
+
# that will be imported
|
|
185
|
+
#
|
|
186
|
+
def cli_dialogue(object_info)
|
|
187
|
+
return TABLE[@vobject][:dialogue].(object_info)
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# This method iterates over the possible options for certain resources
|
|
191
|
+
# and will raise an error in case of missing mandatory param
|
|
192
|
+
#
|
|
193
|
+
# @param opts [Hash] options object passed to the onecenter tool
|
|
194
|
+
#
|
|
195
|
+
def parse_opts(opts)
|
|
196
|
+
set_object(opts[:object])
|
|
197
|
+
|
|
198
|
+
res = {}
|
|
199
|
+
TABLE[@vobject][:cli].each do |arg|
|
|
200
|
+
raise "#{arg} it's mandadory for this op" if opts[arg].nil?
|
|
201
|
+
res[arg] = self.method(arg).call(opts[arg])
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
res[:config] = parse_file(opts[:configuration]) if opts[:configuration]
|
|
205
|
+
|
|
206
|
+
return res
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# This method will parse a yaml
|
|
210
|
+
# Only used for a feature that adds the posibility
|
|
211
|
+
# of import resources with custom params (bulk)
|
|
212
|
+
#
|
|
213
|
+
# @param path [String] Path of the file
|
|
214
|
+
#
|
|
215
|
+
def parse_file(path)
|
|
216
|
+
begin
|
|
217
|
+
config = YAML::load(File.read(path))
|
|
218
|
+
rescue Exception => e
|
|
219
|
+
str_error="Unable to read '#{path}'. Invalid YAML syntax:\n"
|
|
220
|
+
|
|
221
|
+
raise str_error
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
# Use the attributes provided by TABLE
|
|
226
|
+
# with the purpose of build a complete CLI list
|
|
227
|
+
# OpenNebula way
|
|
228
|
+
#
|
|
229
|
+
def format_list()
|
|
230
|
+
config = TABLE[@vobject][:columns]
|
|
231
|
+
table = CLIHelper::ShowTable.new() do
|
|
232
|
+
column :IMID, "identifier for ...", :size=>config[:IMID] || 4 do |d|
|
|
233
|
+
d[:import_id]
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
column :REF, "ref", :left, :size=>config[:REF] || 15 do |d|
|
|
237
|
+
d[:ref]
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
column :NAME, "Name", :left, :size=>config[:NAME] || 20 do |d|
|
|
241
|
+
d[:name] || d[:simple_name]
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
column :CLUSTERS, "CLUSTERS", :left, :size=>config[:CLUSTERS] || 10 do |d|
|
|
245
|
+
d = d[:clusters] if d[:clusters]
|
|
246
|
+
d[:one_ids] || d[:cluster].to_s
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
column :PATH, "PATH", :left, :size=>config[:PATH] || 10 do |d|
|
|
250
|
+
d[:path]
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
default(*config.keys)
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
table
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
################################################################
|
|
260
|
+
# CLI DIALOGUES
|
|
261
|
+
################################################################
|
|
262
|
+
def self.template_dialogue(t)
|
|
263
|
+
rps_list = -> {
|
|
264
|
+
return "" if t[:rp_list].empty?
|
|
265
|
+
puts
|
|
266
|
+
t[:rp_list].each do |rp|
|
|
267
|
+
puts " #{rp[:name]}"
|
|
268
|
+
end
|
|
269
|
+
puts
|
|
270
|
+
|
|
271
|
+
return STDIN.gets.strip.downcase
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
# default opts
|
|
275
|
+
opts = {
|
|
276
|
+
linked_clone: '0',
|
|
277
|
+
copy: '0',
|
|
278
|
+
name: '',
|
|
279
|
+
folder: '',
|
|
280
|
+
resourcepool: [],
|
|
281
|
+
type: ''
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
STDOUT.print "\n- Template: \e[92m#{t[:template_name]}\e[39m\n\n"\
|
|
285
|
+
|
|
286
|
+
# LINKED CLONE OPTION
|
|
287
|
+
STDOUT.print "\n For faster deployment operations"\
|
|
288
|
+
" and lower disk usage, OpenNebula"\
|
|
289
|
+
" can create new VMs as linked clones."\
|
|
290
|
+
"\n Would you like to use Linked Clones with VMs based on this template (y/[n])? "
|
|
291
|
+
|
|
292
|
+
if STDIN.gets.strip.downcase == 'y'
|
|
293
|
+
opts[:linked_clone] = '1'
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
# CREATE COPY OPTION
|
|
297
|
+
STDOUT.print "\n Linked clones requires that delta"\
|
|
298
|
+
" disks must be created for each disk in the template."\
|
|
299
|
+
" This operation may change the template contents."\
|
|
300
|
+
" \n Do you want OpenNebula to create a copy of the template,"\
|
|
301
|
+
" so the original template remains untouched ([y]/n)? "
|
|
302
|
+
|
|
303
|
+
if STDIN.gets.strip.downcase != 'n'
|
|
304
|
+
opts[:copy] = '1'
|
|
305
|
+
|
|
306
|
+
# NAME OPTION
|
|
307
|
+
STDOUT.print "\n The new template will be named"\
|
|
308
|
+
" adding a one- prefix to the name"\
|
|
309
|
+
" of the original template. \n"\
|
|
310
|
+
" If you prefer a different name"\
|
|
311
|
+
" please specify or press Enter"\
|
|
312
|
+
" to use defaults: "
|
|
313
|
+
|
|
314
|
+
template_name = STDIN.gets.strip.downcase
|
|
315
|
+
opts[:name] = template_name
|
|
316
|
+
|
|
317
|
+
STDOUT.print "\n WARNING!!! The cloning operation can take some time"\
|
|
318
|
+
" depending on the size of disks.\n"
|
|
319
|
+
end
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
STDOUT.print "\n\n Do you want to specify a folder where"\
|
|
323
|
+
" the deployed VMs based on this template will appear"\
|
|
324
|
+
" in vSphere's VM and Templates section?"\
|
|
325
|
+
"\n If no path is set, VMs will be placed in the same"\
|
|
326
|
+
" location where the template lives."\
|
|
327
|
+
"\n Please specify a path using slashes to separate folders"\
|
|
328
|
+
" e.g /Management/VMs or press Enter to use defaults: "\
|
|
329
|
+
|
|
330
|
+
vcenter_vm_folder = STDIN.gets.strip
|
|
331
|
+
opts[:folder] = vcenter_vm_folder
|
|
332
|
+
|
|
333
|
+
STDOUT.print "\n\n This template is currently set to "\
|
|
334
|
+
"launch VMs in the default resource pool."\
|
|
335
|
+
"\n Press y to keep this behaviour, n to select"\
|
|
336
|
+
" a new resource pool or d to delegate the choice"\
|
|
337
|
+
" to the user ([y]/n/d)? "
|
|
338
|
+
|
|
339
|
+
answer = STDIN.gets.strip.downcase
|
|
340
|
+
|
|
341
|
+
case answer.downcase
|
|
342
|
+
when 'd' || 'delegate'
|
|
343
|
+
opts[:type]='list'
|
|
344
|
+
puts "separate with commas ',' the list that you want to deleate:"
|
|
345
|
+
|
|
346
|
+
opts[:resourcepool] = rps_list.call.gsub(/\s+/, "").split(",")
|
|
347
|
+
|
|
348
|
+
when 'n' || 'no'
|
|
349
|
+
opts[:type]='fixed'
|
|
350
|
+
puts "choose the proper name"
|
|
351
|
+
opts[:resourcepool] = rps_list.call
|
|
352
|
+
else
|
|
353
|
+
opts[:type]='default'
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
return opts
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
def self.network_dialogue(n)
|
|
360
|
+
ask = -> (question, default = ""){
|
|
361
|
+
STDOUT.print question
|
|
362
|
+
answer = STDIN.gets.strip
|
|
363
|
+
|
|
364
|
+
answer = default if answer.empty?
|
|
365
|
+
|
|
366
|
+
return answer
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
STDOUT.print "\n- Network: \e[92m#{n[:name]}\e[39m\n\n"\
|
|
370
|
+
|
|
371
|
+
opts = { size: "255", type: "ether" }
|
|
372
|
+
|
|
373
|
+
question = " How many VMs are you planning"\
|
|
374
|
+
" to fit into this network [255]? "
|
|
375
|
+
opts[:size] = ask.call(question, "255")
|
|
376
|
+
|
|
377
|
+
question = " What type of Virtual Network"\
|
|
378
|
+
" do you want to create (IPv[4],IPv[6], [E]thernet)? "
|
|
379
|
+
type_answer = ask.call(question, "ether")
|
|
380
|
+
|
|
381
|
+
supported_types = ["4","6","ether", "e", "ip4", "ip6" ]
|
|
382
|
+
if !supported_types.include?(type_answer)
|
|
383
|
+
type_answer = 'e'
|
|
384
|
+
STDOUT.puts " Type [#{type_answer}] not supported,"\
|
|
385
|
+
" defaulting to Ethernet."
|
|
386
|
+
end
|
|
387
|
+
question_ip = " Please input the first IP in the range: "
|
|
388
|
+
question_mac = " Please input the first MAC in the range [Enter for default]: "
|
|
389
|
+
|
|
390
|
+
case type_answer.downcase
|
|
391
|
+
when "4", "ip4"
|
|
392
|
+
opts[:ip] = ask.call(question_ip)
|
|
393
|
+
opts[:mac] = ask.call(question_mac)
|
|
394
|
+
opts[:type] = "ip"
|
|
395
|
+
when "6", "ip6"
|
|
396
|
+
opts[:mac] = ask.call(question_mac)
|
|
397
|
+
|
|
398
|
+
question = " Do you want to use SLAAC "\
|
|
399
|
+
"Stateless Address Autoconfiguration? ([y]/n): "
|
|
400
|
+
slaac_answer = ask.call(question, 'y').downcase
|
|
401
|
+
|
|
402
|
+
if slaac_answer == 'n'
|
|
403
|
+
question = " Please input the IPv6 address (cannot be empty): "
|
|
404
|
+
opts[:ip6] = ask.call(question)
|
|
405
|
+
|
|
406
|
+
question = " Please input the Prefix length (cannot be empty): "
|
|
407
|
+
opts[:prefix_length] = ask.call(question)
|
|
408
|
+
opts[:type] = 'ip6_static'
|
|
409
|
+
else
|
|
410
|
+
question = " Please input the GLOBAL PREFIX "\
|
|
411
|
+
"[Enter for default]: "
|
|
412
|
+
opts[:global_prefix] = ask.call(question)
|
|
413
|
+
|
|
414
|
+
question= " Please input the ULA PREFIX "\
|
|
415
|
+
"[Enter for default]: "
|
|
416
|
+
opts[:ula_prefix] = ask.call(question)
|
|
417
|
+
opts[:type] = 'ip6'
|
|
418
|
+
end
|
|
419
|
+
when "e", "ether"
|
|
420
|
+
opts[:mac] = ask.call(question_mac)
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
return opts
|
|
424
|
+
end
|
|
425
|
+
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2018, 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 #
|
|
@@ -62,19 +62,19 @@ class OneVdcHelper < OpenNebulaHelper::OneHelper
|
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
column :CLUSTERS, "Number of Clusters", :size=>8 do |d|
|
|
65
|
-
@ext.id_list_size(d["CLUSTERS"]["CLUSTER"], "CLUSTER")
|
|
65
|
+
@ext.id_list_size(d["CLUSTERS"]["CLUSTER"], "CLUSTER") rescue "-"
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
column :HOSTS, "Number of Hosts", :size=>5 do |d|
|
|
69
|
-
@ext.id_list_size(d["HOSTS"]["HOST"], "HOST")
|
|
69
|
+
@ext.id_list_size(d["HOSTS"]["HOST"], "HOST") rescue "-"
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
column :VNETS, "Number of Networks", :size=>5 do |d|
|
|
73
|
-
@ext.id_list_size(d["VNETS"]["VNET"], "VNET")
|
|
73
|
+
@ext.id_list_size(d["VNETS"]["VNET"], "VNET") rescue "-"
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
column :DATASTORES, "Number of Datastores", :size=>10 do |d|
|
|
77
|
-
@ext.id_list_size(d["DATASTORES"]["DATASTORE"], "DATASTORE")
|
|
77
|
+
@ext.id_list_size(d["DATASTORES"]["DATASTORE"], "DATASTORE") rescue "-"
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
default :ID, :NAME, :GROUPS, :CLUSTERS, :HOSTS, :VNETS, :DATASTORES
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2018, 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 #
|
|
@@ -114,6 +114,45 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
|
114
114
|
:format => Time
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
WEEKLY = {
|
|
118
|
+
:name => "weekly",
|
|
119
|
+
:large => "--weekly days",
|
|
120
|
+
:description => "Schedules this action to be executed after" \
|
|
121
|
+
"the given time. For example: onevm resume 0 --schedule \"09/23 14:15\"",
|
|
122
|
+
:format => String
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
MONTHLY = {
|
|
126
|
+
:name => "monthly",
|
|
127
|
+
:large => "--monthly days",
|
|
128
|
+
:description => "Schedules this action to be executed after" \
|
|
129
|
+
"the given time. For example: onevm resume 0 --schedule \"09/23 14:15\"",
|
|
130
|
+
:format => String
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
YEARLY = {
|
|
134
|
+
:name => "yearly",
|
|
135
|
+
:large => "--yearly days",
|
|
136
|
+
:description => "Schedules this action to be executed after" \
|
|
137
|
+
"the given time. For example: onevm resume 0 --schedule \"09/23 14:15\"",
|
|
138
|
+
:format => String
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
HOURLY = {
|
|
142
|
+
:name => "hourly",
|
|
143
|
+
:large => "--hourly hour",
|
|
144
|
+
:description => "Schedules this action to be executed after" \
|
|
145
|
+
"the given time. For example: onevm resume 0 --schedule \"09/23 14:15\"",
|
|
146
|
+
:format => Numeric
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
END_TIME = {
|
|
150
|
+
:name => "end",
|
|
151
|
+
:large => "--end number|TIME",
|
|
152
|
+
:description => "----",
|
|
153
|
+
:format => String
|
|
154
|
+
}
|
|
155
|
+
|
|
117
156
|
ALL_TEMPLATE = {
|
|
118
157
|
:name => "all",
|
|
119
158
|
:large => "--all",
|
|
@@ -314,6 +353,31 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
|
314
353
|
ids, options,
|
|
315
354
|
"#{action} scheduled at #{options[:schedule]}") do |vm|
|
|
316
355
|
|
|
356
|
+
str_periodic = ""
|
|
357
|
+
|
|
358
|
+
if options.key?(:weekly)
|
|
359
|
+
str_periodic << ", REPEAT = 0, DAYS = \"#{options[:weekly]}\""
|
|
360
|
+
elsif options.key?(:monthly)
|
|
361
|
+
str_periodic << ", REPEAT = 1, DAYS = \"#{options[:monthly]}\""
|
|
362
|
+
elsif options.key?(:yearly)
|
|
363
|
+
str_periodic << ", REPEAT = 2, DAYS = \"#{options[:yearly]}\""
|
|
364
|
+
elsif options.key?(:hourly)
|
|
365
|
+
str_periodic << ", REPEAT = 3, DAYS = \"#{options[:hourly].to_s}\""
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
if options.key?(:end)
|
|
369
|
+
begin
|
|
370
|
+
end_date = Date.parse(options[:end])
|
|
371
|
+
str_periodic << ", END_TYPE = 2, END_VALUE = #{end_date.to_time.to_i}"
|
|
372
|
+
rescue ArgumentError
|
|
373
|
+
if options[:end].to_i > 0
|
|
374
|
+
str_periodic << ", END_TYPE = 1, END_VALUE = #{options[:end].to_i}"
|
|
375
|
+
end
|
|
376
|
+
end
|
|
377
|
+
elsif str_periodic != ""
|
|
378
|
+
str_periodic << ", END_TYPE = 0"
|
|
379
|
+
end
|
|
380
|
+
|
|
317
381
|
rc = vm.info
|
|
318
382
|
|
|
319
383
|
if OpenNebula.is_error?(rc)
|
|
@@ -331,7 +395,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
|
331
395
|
|
|
332
396
|
tmp_str = vm.user_template_str
|
|
333
397
|
|
|
334
|
-
tmp_str << "\nSCHED_ACTION = [ID = #{id}, ACTION = #{action}, TIME = #{options[:schedule].to_i}]"
|
|
398
|
+
tmp_str << "\nSCHED_ACTION = [ID = #{id}, ACTION = #{action}, TIME = #{options[:schedule].to_i}" << str_periodic << "]"
|
|
335
399
|
|
|
336
400
|
vm.update(tmp_str)
|
|
337
401
|
end
|
|
@@ -516,6 +580,7 @@ in the frontend machine.
|
|
|
516
580
|
puts str % ["GROUP", vm['GNAME']]
|
|
517
581
|
puts str % ["STATE", vm.state_str]
|
|
518
582
|
puts str % ["LCM_STATE", vm.lcm_state_str]
|
|
583
|
+
puts str % ["LOCK", OpenNebulaHelper.level_lock_to_str(vm['LOCK/LOCKED'])]
|
|
519
584
|
puts str % ["RESCHED", OpenNebulaHelper.boolean_to_str(vm['RESCHED'])]
|
|
520
585
|
puts str % ["HOST",
|
|
521
586
|
vm['/VM/HISTORY_RECORDS/HISTORY[last()]/HOSTNAME']] if
|
|
@@ -997,6 +1062,39 @@ in the frontend machine.
|
|
|
997
1062
|
OpenNebulaHelper.time_to_str(d["TIME"], false) if !d.nil?
|
|
998
1063
|
end
|
|
999
1064
|
|
|
1065
|
+
column :"REPEAT", "", :size=>20 do |d|
|
|
1066
|
+
str_rep = ""
|
|
1067
|
+
if !d.nil? && d.key?("REPEAT")
|
|
1068
|
+
if d["REPEAT"] == "0"
|
|
1069
|
+
str_rep << "Weekly "
|
|
1070
|
+
elsif d["REPEAT"] == "1"
|
|
1071
|
+
str_rep << "Monthly "
|
|
1072
|
+
elsif d["REPEAT"] == "2"
|
|
1073
|
+
str_rep << "Yearly "
|
|
1074
|
+
elsif d["REPEAT"] == "3"
|
|
1075
|
+
str_rep << "Each " << d['DAYS'] << " hours"
|
|
1076
|
+
end
|
|
1077
|
+
if d["REPEAT"] != "3"
|
|
1078
|
+
str_rep << d["DAYS"]
|
|
1079
|
+
end
|
|
1080
|
+
end
|
|
1081
|
+
str_rep if !d.nil?
|
|
1082
|
+
end
|
|
1083
|
+
|
|
1084
|
+
column :"END", "", :size=>20 do |d|
|
|
1085
|
+
str_end = ""
|
|
1086
|
+
if !d.nil? && d.key?("END_TYPE")
|
|
1087
|
+
if d["END_TYPE"] == "0"
|
|
1088
|
+
str_end << "None"
|
|
1089
|
+
elsif d["END_TYPE"] == "1"
|
|
1090
|
+
str_end << "After " << d["END_VALUE"] << " times"
|
|
1091
|
+
elsif d["END_TYPE"] == "2"
|
|
1092
|
+
str_end << "On " << OpenNebulaHelper.time_to_str(d["END_VALUE"], false, false, true)
|
|
1093
|
+
end
|
|
1094
|
+
end
|
|
1095
|
+
str_end if !d.nil?
|
|
1096
|
+
end
|
|
1097
|
+
|
|
1000
1098
|
column :"DONE", "", :size=>12 do |d|
|
|
1001
1099
|
OpenNebulaHelper.time_to_str(d["DONE"], false) if !d.nil?
|
|
1002
1100
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2018, 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 #
|
|
@@ -60,15 +60,19 @@ class OneVMGroupHelper < OpenNebulaHelper::OneHelper
|
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
column :ROLES, "Roles in the VM Group", :left, :size=>36 do |d|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
begin
|
|
64
|
+
roles = [d["ROLES"]["ROLE"]].flatten
|
|
65
|
+
roles_names = ""
|
|
66
|
+
|
|
67
|
+
if !roles.nil?
|
|
68
|
+
rnames = roles.collect { |i| i["NAME"] }
|
|
69
|
+
roles_names = rnames.join(", ") if !rnames.empty?
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
roles_names
|
|
73
|
+
rescue
|
|
74
|
+
"-"
|
|
69
75
|
end
|
|
70
|
-
|
|
71
|
-
roles_names
|
|
72
76
|
end
|
|
73
77
|
|
|
74
78
|
default :ID, :USER, :GROUP, :NAME, :VMS, :ROLES
|
|
@@ -102,6 +106,7 @@ class OneVMGroupHelper < OpenNebulaHelper::OneHelper
|
|
|
102
106
|
puts str % ["NAME", vmgroup.name]
|
|
103
107
|
puts str % ["USER", vmgroup['UNAME']]
|
|
104
108
|
puts str % ["GROUP", vmgroup['GNAME']]
|
|
109
|
+
puts str % ["LOCK", OpenNebulaHelper.level_lock_to_str(vmgroup['LOCK/LOCKED'])]
|
|
105
110
|
|
|
106
111
|
CLIHelper.print_header(str_h1 % "PERMISSIONS",false)
|
|
107
112
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
|
2
|
-
# Copyright 2002-
|
|
2
|
+
# Copyright 2002-2018, 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 #
|
|
@@ -160,7 +160,7 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
|
|
160
160
|
end
|
|
161
161
|
|
|
162
162
|
column :CLUSTERS, "Cluster IDs", :left, :size=>10 do |d|
|
|
163
|
-
OpenNebulaHelper.clusters_str(d["CLUSTERS"]["ID"])
|
|
163
|
+
OpenNebulaHelper.clusters_str(d["CLUSTERS"]["ID"]) rescue "-"
|
|
164
164
|
end
|
|
165
165
|
|
|
166
166
|
column :BRIDGE, "Bridge associated to the Virtual Network", :left,
|
|
@@ -214,17 +214,21 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
|
|
214
214
|
CLIHelper.print_header(str_h1 %
|
|
215
215
|
["VIRTUAL NETWORK #{vn.id.to_s} INFORMATION"])
|
|
216
216
|
|
|
217
|
-
str="%-
|
|
217
|
+
str="%-25s: %-20s"
|
|
218
218
|
puts str % ["ID", vn.id.to_s]
|
|
219
219
|
puts str % ["NAME", vn['NAME']]
|
|
220
220
|
puts str % ["USER", vn['UNAME']]
|
|
221
221
|
puts str % ["GROUP", vn['GNAME']]
|
|
222
|
+
puts str % ["LOCK", OpenNebulaHelper.level_lock_to_str(vn['LOCK/LOCKED'])]
|
|
222
223
|
puts str % ["CLUSTERS",
|
|
223
224
|
OpenNebulaHelper.clusters_str(vn.retrieve_elements("CLUSTERS/ID"))]
|
|
224
225
|
puts str % ["BRIDGE", vn["BRIDGE"]]
|
|
225
226
|
puts str % ["VN_MAD", vn['VN_MAD']] if !vn['VN_MAD'].empty?
|
|
226
227
|
puts str % ["PHYSICAL DEVICE", vn["PHYDEV"]] if !vn["PHYDEV"].empty?
|
|
227
228
|
puts str % ["VLAN ID", vn["VLAN_ID"]] if !vn["VLAN_ID"].empty?
|
|
229
|
+
puts str % ["AUTOMATIC VLAN ID", vn["VLAN_ID_AUTOMATIC"]=="1" ? "YES" : "NO"]
|
|
230
|
+
puts str % ["OUTER VLAN ID", vn["OUTER_VLAN_ID"]] if !vn["OUTER_VLAN_ID"]
|
|
231
|
+
puts str % ["AUTOMATIC OUTER VLAN ID", vn["OUTER_VLAN_ID_AUTOMATIC"]=="1" ? "YES" : "NO"]
|
|
228
232
|
puts str % ["USED LEASES", vn['USED_LEASES']]
|
|
229
233
|
puts
|
|
230
234
|
|