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.
- checksums.yaml +5 -5
- data/bin/oneacct +5 -14
- data/bin/oneacl +4 -15
- data/bin/onecluster +6 -17
- data/bin/onedatastore +6 -17
- data/bin/oneflow +81 -23
- data/bin/oneflow-template +51 -27
- data/bin/onegroup +6 -17
- data/bin/onehook +6 -17
- data/bin/onehost +4 -15
- data/bin/oneimage +95 -18
- data/bin/onemarket +6 -17
- data/bin/onemarketapp +113 -20
- data/bin/onesecgroup +9 -17
- data/bin/oneshowback +14 -20
- data/bin/onetemplate +8 -18
- data/bin/oneuser +26 -17
- data/bin/onevcenter +6 -28
- data/bin/onevdc +6 -17
- data/bin/onevm +142 -21
- data/bin/onevmgroup +9 -17
- data/bin/onevnet +4 -15
- data/bin/onevntemplate +7 -17
- data/bin/onevrouter +6 -17
- data/bin/onezone +6 -17
- data/lib/cli_helper.rb +7 -10
- data/lib/command_parser.rb +1 -1
- data/lib/one_helper/oneacct_helper.rb +9 -22
- 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 +11 -1
- data/lib/one_helper/oneflow_helper.rb +20 -5
- data/lib/one_helper/oneflowtemplate_helper.rb +28 -2
- data/lib/one_helper/onegroup_helper.rb +1 -1
- data/lib/one_helper/onehook_helper.rb +1 -1
- data/lib/one_helper/onehost_helper.rb +1 -5
- data/lib/one_helper/oneimage_helper.rb +7 -7
- data/lib/one_helper/onemarket_helper.rb +1 -1
- data/lib/one_helper/onemarketapp_helper.rb +494 -96
- 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 +12 -1
- data/lib/one_helper/oneuser_helper.rb +11 -3
- data/lib/one_helper/onevcenter_helper.rb +176 -146
- data/lib/one_helper/onevdc_helper.rb +1 -1
- data/lib/one_helper/onevm_helper.rb +9 -9
- data/lib/one_helper/onevmgroup_helper.rb +1 -1
- data/lib/one_helper/onevnet_helper.rb +1 -1
- data/lib/one_helper/onevntemplate_helper.rb +1 -1
- data/lib/one_helper/onevrouter_helper.rb +1 -20
- data/lib/one_helper/onezone_helper.rb +12 -1
- data/lib/one_helper.rb +398 -37
- data/share/schemas/xsd/acct.xsd +179 -0
- data/share/schemas/xsd/acl_pool.xsd +22 -0
- data/share/schemas/xsd/api_info.xsd +43 -0
- data/share/schemas/xsd/cluster.xsd +34 -0
- data/share/schemas/xsd/cluster_pool.xsd +12 -0
- data/share/schemas/xsd/datastore.xsd +67 -0
- data/share/schemas/xsd/datastore_pool.xsd +12 -0
- data/share/schemas/xsd/document.xsd +42 -0
- data/share/schemas/xsd/document_pool.xsd +12 -0
- data/share/schemas/xsd/group.xsd +179 -0
- data/share/schemas/xsd/group_pool.xsd +194 -0
- data/share/schemas/xsd/hook.xsd +59 -0
- data/share/schemas/xsd/hook_message_api.xsd +14 -0
- data/share/schemas/xsd/hook_message_retry.xsd +12 -0
- data/share/schemas/xsd/hook_message_state.xsd +25 -0
- data/share/schemas/xsd/hook_pool.xsd +12 -0
- data/share/schemas/xsd/host.xsd +164 -0
- data/share/schemas/xsd/host_pool.xsd +12 -0
- data/share/schemas/xsd/image.xsd +123 -0
- data/share/schemas/xsd/image_pool.xsd +12 -0
- data/share/schemas/xsd/index.xsd +49 -0
- data/share/schemas/xsd/marketplace.xsd +44 -0
- data/share/schemas/xsd/marketplace_pool.xsd +12 -0
- data/share/schemas/xsd/marketplaceapp.xsd +56 -0
- data/share/schemas/xsd/marketplaceapp_pool.xsd +12 -0
- data/share/schemas/xsd/opennebula_configuration.xsd +412 -0
- data/share/schemas/xsd/raftstatus.xsd +18 -0
- data/share/schemas/xsd/security_group.xsd +74 -0
- data/share/schemas/xsd/security_group_pool.xsd +12 -0
- data/share/schemas/xsd/showback.xsd +29 -0
- data/share/schemas/xsd/user.xsd +186 -0
- data/share/schemas/xsd/user_pool.xsd +201 -0
- data/share/schemas/xsd/vdc.xsd +76 -0
- data/share/schemas/xsd/vdc_pool.xsd +12 -0
- data/share/schemas/xsd/vm.xsd +251 -0
- data/share/schemas/xsd/vm_group.xsd +59 -0
- data/share/schemas/xsd/vm_group_pool.xsd +12 -0
- data/share/schemas/xsd/vm_pool.xsd +114 -0
- data/share/schemas/xsd/vmtemplate.xsd +52 -0
- data/share/schemas/xsd/vmtemplate_pool.xsd +12 -0
- data/share/schemas/xsd/vnet.xsd +137 -0
- data/share/schemas/xsd/vnet_pool.xsd +85 -0
- data/share/schemas/xsd/vntemplate.xsd +50 -0
- data/share/schemas/xsd/vntemplate_pool.xsd +12 -0
- data/share/schemas/xsd/vrouter.xsd +49 -0
- data/share/schemas/xsd/vrouter_pool.xsd +12 -0
- data/share/schemas/xsd/zone.xsd +40 -0
- data/share/schemas/xsd/zone_pool.xsd +36 -0
- metadata +92 -30
- data/lib/one_helper/oneprovision_helper.rb +0 -362
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2021, 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 #
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2021, 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 #
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2021, 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 #
|
@@ -87,6 +87,17 @@ EOT
|
|
87
87
|
|
88
88
|
if options[:xml]
|
89
89
|
return 0, resource.to_xml(true)
|
90
|
+
elsif options[:json]
|
91
|
+
# If body is set, the resource contains a JSON inside
|
92
|
+
if options[:body]
|
93
|
+
return 0, check_resource_xsd(resource)
|
94
|
+
else
|
95
|
+
return 0, ::JSON.pretty_generate(
|
96
|
+
check_resource_xsd(resource)
|
97
|
+
)
|
98
|
+
end
|
99
|
+
elsif options[:yaml]
|
100
|
+
return 0, check_resource_xsd(resource).to_yaml(:indent => 4)
|
90
101
|
else
|
91
102
|
format_resource(resource, options)
|
92
103
|
return 0
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2021, 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 #
|
@@ -284,6 +284,14 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
|
|
284
284
|
d["NAME"]
|
285
285
|
end
|
286
286
|
|
287
|
+
column :ENABLED, "User is enabled", :left, :size=>4 do |d|
|
288
|
+
if d["ENABLED"] == "1"
|
289
|
+
"yes"
|
290
|
+
else
|
291
|
+
"no"
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
287
295
|
column :GROUP, "Group of the User", :left, :size=>10 do |d|
|
288
296
|
helper.group_name(d, options)
|
289
297
|
end
|
@@ -434,7 +442,7 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
|
|
434
442
|
d['PASSWORD']
|
435
443
|
end
|
436
444
|
|
437
|
-
default :ID, :NAME, :GROUP, :AUTH, :VMS, :MEMORY, :CPU
|
445
|
+
default :ID, :NAME, :ENABLED, :GROUP, :AUTH, :VMS, :MEMORY, :CPU
|
438
446
|
end
|
439
447
|
|
440
448
|
table
|
@@ -556,7 +564,7 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
|
|
556
564
|
CLIHelper::ShowTable.new(nil, self) do
|
557
565
|
column :ID, "", :size=>7 do |d|
|
558
566
|
d["TOKEN"]
|
559
|
-
|
567
|
+
end
|
560
568
|
|
561
569
|
column :EGID, "", :left, :size=>5 do |d|
|
562
570
|
d["EGID"].to_i == -1 ? "*" + gid : d["EGID"]
|
@@ -1,6 +1,5 @@
|
|
1
|
-
|
2
1
|
# -------------------------------------------------------------------------- #
|
3
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
|
4
3
|
# #
|
5
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
6
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -17,16 +16,21 @@
|
|
17
16
|
|
18
17
|
require 'one_helper'
|
19
18
|
|
19
|
+
##############################################################################
|
20
|
+
# Module OneVcenterHelper
|
21
|
+
##############################################################################
|
20
22
|
class OneVcenterHelper < OpenNebulaHelper::OneHelper
|
21
23
|
|
22
24
|
#
|
23
25
|
# vCenter importer will divide rvmomi resources
|
24
26
|
# in this group, makes parsing easier.
|
25
27
|
module VOBJECT
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
|
29
|
+
DATASTORE = 1
|
30
|
+
TEMPLATE = 2
|
31
|
+
NETWORK = 3
|
32
|
+
IMAGE = 4
|
33
|
+
|
30
34
|
end
|
31
35
|
|
32
36
|
#
|
@@ -37,45 +41,53 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
|
|
37
41
|
# struct: [Array] LIST FORMAT for opennebula cli
|
38
42
|
# related methods: * cli_format
|
39
43
|
#
|
40
|
-
# columns: [Hash(column => Integer)] Will be used in the list command,
|
44
|
+
# columns: [Hash(column => Integer)] Will be used in the list command,
|
45
|
+
# Integer represent nbytes
|
41
46
|
# related methods: * format_list
|
42
47
|
#
|
43
|
-
# cli: [Array] with mandatory args, for example image
|
48
|
+
# cli: [Array] with mandatory args, for example image
|
49
|
+
# listing needs a datastore
|
44
50
|
# related methods: * parse_opts
|
45
51
|
#
|
46
|
-
# dialogue: [Lambda] Used only for Vobject that require a previous
|
52
|
+
# dialogue: [Lambda] Used only for Vobject that require a previous
|
53
|
+
# dialogue with the user, will be triggered
|
47
54
|
# on importation process
|
48
55
|
# related methods: * network_dialogue
|
49
56
|
# * template_dialogue
|
50
57
|
#
|
51
58
|
TABLE = {
|
52
59
|
VOBJECT::DATASTORE => {
|
53
|
-
:struct => [
|
54
|
-
:columns =>
|
60
|
+
:struct => %w[DATASTORE_LIST DATASTORE],
|
61
|
+
:columns =>
|
62
|
+
{ :IMID => 5, :REF => 15, :NAME => 50, :CLUSTERS => 10 },
|
55
63
|
:cli => [:host],
|
56
|
-
:dialogue => ->(arg){}
|
64
|
+
:dialogue => ->(arg) {}
|
57
65
|
},
|
58
66
|
VOBJECT::TEMPLATE => {
|
59
|
-
:struct => [
|
60
|
-
:columns => {:IMID => 5, :REF => 10, :NAME => 50},
|
67
|
+
:struct => %w[TEMPLATE_LIST TEMPLATE],
|
68
|
+
:columns => { :IMID => 5, :REF => 10, :NAME => 50 },
|
61
69
|
:cli => [:host],
|
62
|
-
:dialogue => ->(arg){ OneVcenterHelper.template_dialogue(arg) }
|
70
|
+
:dialogue => ->(arg) { OneVcenterHelper.template_dialogue(arg) }
|
63
71
|
},
|
64
72
|
VOBJECT::NETWORK => {
|
65
|
-
:struct => [
|
66
|
-
:columns => {
|
73
|
+
:struct => %w[NETWORK_LIST NETWORK],
|
74
|
+
:columns => {
|
75
|
+
:IMID => 5,
|
76
|
+
:REF => 15,
|
77
|
+
:NAME => 30,
|
78
|
+
:CLUSTERS => 20
|
79
|
+
},
|
67
80
|
:cli => [:host],
|
68
|
-
:dialogue => ->(arg){ OneVcenterHelper.network_dialogue(arg) }
|
81
|
+
:dialogue => ->(arg) { OneVcenterHelper.network_dialogue(arg) }
|
69
82
|
},
|
70
83
|
VOBJECT::IMAGE => {
|
71
|
-
:struct => [
|
72
|
-
:columns => {:IMID => 5
|
84
|
+
:struct => %w[IMAGE_LIST IMAGE],
|
85
|
+
:columns => { :IMID => 5, :REF => 35, :PATH => 60 },
|
73
86
|
:cli => [:host, :datastore],
|
74
|
-
:dialogue => ->(arg){}
|
87
|
+
:dialogue => ->(arg) {}
|
75
88
|
}
|
76
89
|
}
|
77
90
|
|
78
|
-
|
79
91
|
################################################################
|
80
92
|
# CLI ARGS
|
81
93
|
################################################################
|
@@ -83,28 +95,27 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
|
|
83
95
|
# these methods will be used by table :cli property
|
84
96
|
# the purpose is to inject code when -d option in this case is used
|
85
97
|
#
|
86
|
-
|
98
|
+
# @param arg [String] The parameter passed to the option:w
|
87
99
|
#
|
88
100
|
|
89
101
|
def datastore(arg)
|
90
102
|
ds = VCenterDriver::VIHelper.one_item(OpenNebula::Datastore, arg)
|
91
103
|
|
92
104
|
{
|
93
|
-
ds_ref
|
94
|
-
one_item
|
105
|
+
:ds_ref => ds['TEMPLATE/VCENTER_DS_REF'],
|
106
|
+
:one_item => ds
|
95
107
|
}
|
96
108
|
end
|
97
109
|
|
98
110
|
def host(arg)
|
99
|
-
|
111
|
+
arg
|
100
112
|
end
|
101
113
|
|
102
114
|
########################
|
103
115
|
|
104
|
-
|
105
116
|
# In list command you can use this method to print a header
|
106
117
|
#
|
107
|
-
|
118
|
+
# @param vcenter_host [String] this text will be displayed
|
108
119
|
#
|
109
120
|
def show_header(vcenter_host)
|
110
121
|
CLIHelper.scr_bold
|
@@ -112,33 +123,33 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
|
|
112
123
|
puts "# vCenter: #{vcenter_host}".ljust(50)
|
113
124
|
CLIHelper.scr_restore
|
114
125
|
puts
|
115
|
-
|
116
126
|
end
|
117
127
|
|
118
128
|
# Using for parse a String into a VOBJECT
|
119
129
|
# We will use VOBJECT instances for handle any operatiion
|
120
130
|
#
|
121
|
-
|
131
|
+
# @param type [String] String representing the vCenter resource
|
122
132
|
#
|
123
|
-
def
|
124
|
-
raise
|
133
|
+
def object_update(type)
|
134
|
+
raise 'you need to use -o option!' unless type
|
125
135
|
|
126
136
|
type = type.downcase
|
127
|
-
|
137
|
+
case type
|
138
|
+
when 'datastores'
|
128
139
|
@vobject = VOBJECT::DATASTORE
|
129
|
-
|
140
|
+
when 'templates'
|
130
141
|
@vobject = VOBJECT::TEMPLATE
|
131
|
-
|
142
|
+
when 'networks'
|
132
143
|
@vobject = VOBJECT::NETWORK
|
133
|
-
|
144
|
+
when 'images'
|
134
145
|
@vobject = VOBJECT::IMAGE
|
135
146
|
else
|
136
147
|
puts "unknown #{type} type option"
|
137
|
-
puts
|
138
|
-
puts
|
139
|
-
puts
|
140
|
-
puts
|
141
|
-
puts
|
148
|
+
puts ' -o options:'
|
149
|
+
puts ' datastores'
|
150
|
+
puts ' templates'
|
151
|
+
puts ' networks'
|
152
|
+
puts ' images'
|
142
153
|
|
143
154
|
exit 0
|
144
155
|
end
|
@@ -146,11 +157,11 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
|
|
146
157
|
|
147
158
|
# Handles connection to vCenter.
|
148
159
|
#
|
149
|
-
|
160
|
+
# @param options [Hash] options for the connection
|
150
161
|
#
|
151
162
|
def connection_options(object_name, options)
|
152
163
|
if options[:vuser].nil? || options[:vcenter].nil?
|
153
|
-
raise
|
164
|
+
raise 'vCenter connection parameters are mandatory to import'\
|
154
165
|
" #{object_name}:\n"\
|
155
166
|
"\t --vcenter vCenter hostname\n"\
|
156
167
|
"\t --vuser username to login in vcenter"
|
@@ -158,23 +169,29 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
|
|
158
169
|
|
159
170
|
password = options[:vpass] || OpenNebulaHelper::OneHelper.get_password
|
160
171
|
{
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
172
|
+
:user => options[:vuser],
|
173
|
+
:password => password,
|
174
|
+
:host => options[:vcenter],
|
175
|
+
:port => options[:port]
|
165
176
|
}
|
166
177
|
end
|
167
178
|
|
168
|
-
def cli_format(
|
169
|
-
{
|
179
|
+
def cli_format(hash)
|
180
|
+
{
|
181
|
+
TABLE[@vobject][:struct].first =>
|
182
|
+
{
|
183
|
+
TABLE[@vobject][:struct].last =>
|
184
|
+
hash.values
|
185
|
+
}
|
186
|
+
}
|
170
187
|
end
|
171
188
|
|
172
189
|
# This method will print a list for a vcenter_resource.
|
173
190
|
#
|
174
|
-
def list_object(
|
191
|
+
def list_object(_options, list)
|
175
192
|
vcenter_host = list.keys[0]
|
176
193
|
list = cli_format(list.values.first)
|
177
|
-
table = format_list
|
194
|
+
table = format_list
|
178
195
|
|
179
196
|
show_header(vcenter_host)
|
180
197
|
|
@@ -184,11 +201,12 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
|
|
184
201
|
# handles :cli section of TABLE
|
185
202
|
# used for executing the dialogue in some VOBJECTS
|
186
203
|
#
|
187
|
-
# @param object_info [Hash] This is the object
|
204
|
+
# @param object_info [Hash] This is the object
|
205
|
+
# with all the info related to the object
|
188
206
|
# that will be imported
|
189
207
|
#
|
190
208
|
def cli_dialogue(object_info)
|
191
|
-
|
209
|
+
TABLE[@vobject][:dialogue].call(object_info)
|
192
210
|
end
|
193
211
|
|
194
212
|
# This method iterates over the possible options for certain resources
|
@@ -197,17 +215,18 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
|
|
197
215
|
# @param opts [Hash] options object passed to the onecenter tool
|
198
216
|
#
|
199
217
|
def parse_opts(opts)
|
200
|
-
|
218
|
+
object_update(opts[:object])
|
201
219
|
|
202
220
|
res = {}
|
203
221
|
TABLE[@vobject][:cli].each do |arg|
|
204
222
|
raise "#{arg} it's mandadory for this op" if opts[arg].nil?
|
205
|
-
|
223
|
+
|
224
|
+
res[arg] = method(arg).call(opts[arg])
|
206
225
|
end
|
207
226
|
|
208
227
|
res[:config] = parse_file(opts[:configuration]) if opts[:configuration]
|
209
228
|
|
210
|
-
|
229
|
+
res
|
211
230
|
end
|
212
231
|
|
213
232
|
# This method will parse a yaml
|
@@ -218,8 +237,8 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
|
|
218
237
|
#
|
219
238
|
def parse_file(path)
|
220
239
|
begin
|
221
|
-
|
222
|
-
rescue
|
240
|
+
_config = YAML.safe_load(File.read(path))
|
241
|
+
rescue StandardError => _e
|
223
242
|
str_error="Unable to read '#{path}'. Invalid YAML syntax:\n"
|
224
243
|
|
225
244
|
raise str_error
|
@@ -230,42 +249,44 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
|
|
230
249
|
# with the purpose of build a complete CLI list
|
231
250
|
# OpenNebula way
|
232
251
|
#
|
233
|
-
def format_list
|
252
|
+
def format_list
|
234
253
|
config = TABLE[@vobject][:columns]
|
235
|
-
|
236
|
-
column :IMID,
|
254
|
+
CLIHelper::ShowTable.new do
|
255
|
+
column :IMID, 'identifier for ...', :size=>config[:IMID] || 4 do |d|
|
237
256
|
d[:import_id]
|
238
257
|
end
|
239
258
|
|
240
|
-
column :REF,
|
259
|
+
column :REF, 'ref', :left, :adjust, :size=>config[:REF] || 15 do |d|
|
241
260
|
d[:ref]
|
242
261
|
end
|
243
262
|
|
244
|
-
column :NAME,
|
263
|
+
column :NAME, 'Name', :left, :expand,
|
264
|
+
:size=>config[:NAME] || 20 do |d|
|
245
265
|
d[:name] || d[:simple_name]
|
246
266
|
end
|
247
267
|
|
248
|
-
column :CLUSTERS,
|
268
|
+
column :CLUSTERS, 'CLUSTERS', :left,
|
269
|
+
:size=>config[:CLUSTERS] || 10 do |d|
|
249
270
|
d = d[:clusters] if d[:clusters]
|
250
271
|
d[:one_ids] || d[:cluster].to_s
|
251
272
|
end
|
252
273
|
|
253
|
-
column :PATH,
|
274
|
+
column :PATH, 'PATH', :left, :expand,
|
275
|
+
:size=>config[:PATH] || 10 do |d|
|
254
276
|
d[:path]
|
255
277
|
end
|
256
278
|
|
257
279
|
default(*config.keys)
|
258
280
|
end
|
259
|
-
|
260
|
-
table
|
261
281
|
end
|
262
282
|
|
263
283
|
################################################################
|
264
284
|
# CLI DIALOGUES
|
265
285
|
################################################################
|
266
286
|
def self.template_dialogue(t)
|
267
|
-
rps_list =
|
268
|
-
return
|
287
|
+
rps_list = lambda {
|
288
|
+
return '' if t[:rp_list].empty?
|
289
|
+
|
269
290
|
puts
|
270
291
|
t[:rp_list].each do |rp|
|
271
292
|
puts " #{rp[:name]}"
|
@@ -277,91 +298,96 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
|
|
277
298
|
|
278
299
|
# default opts
|
279
300
|
opts = {
|
280
|
-
linked_clone
|
281
|
-
copy
|
282
|
-
name
|
283
|
-
folder
|
284
|
-
resourcepool
|
285
|
-
type
|
301
|
+
:linked_clone => '0',
|
302
|
+
:copy => '0',
|
303
|
+
:name => '',
|
304
|
+
:folder => '',
|
305
|
+
:resourcepool => [],
|
306
|
+
:type => ''
|
286
307
|
}
|
287
308
|
|
288
309
|
STDOUT.print "\n- Template: \e[92m#{t[:template_name]}\e[39m\n\n"\
|
289
310
|
|
290
311
|
# LINKED CLONE OPTION
|
291
312
|
STDOUT.print "\n For faster deployment operations"\
|
292
|
-
|
293
|
-
|
294
|
-
"\n Would you like to use Linked Clones
|
313
|
+
' and lower disk usage, OpenNebula'\
|
314
|
+
' can create new VMs as linked clones.'\
|
315
|
+
"\n Would you like to use Linked Clones"\
|
316
|
+
' with VMs based on this template (y/[n])? '
|
295
317
|
|
296
318
|
if STDIN.gets.strip.downcase == 'y'
|
297
319
|
opts[:linked_clone] = '1'
|
298
320
|
|
299
|
-
|
300
321
|
# CREATE COPY OPTION
|
301
322
|
STDOUT.print "\n Linked clones requires that delta"\
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
"
|
323
|
+
' disks must be created for '\
|
324
|
+
'each disk in the template.'\
|
325
|
+
' This operation may change the template contents.'\
|
326
|
+
" \n Do you want OpenNebula to "\
|
327
|
+
'create a copy of the template,'\
|
328
|
+
' so the original template remains untouched ([y]/n)? '
|
306
329
|
|
307
330
|
if STDIN.gets.strip.downcase != 'n'
|
308
331
|
opts[:copy] = '1'
|
309
332
|
|
310
333
|
# NAME OPTION
|
311
334
|
STDOUT.print "\n The new template will be named"\
|
312
|
-
|
335
|
+
' adding a one- prefix to the name'\
|
313
336
|
" of the original template. \n"\
|
314
|
-
|
315
|
-
|
316
|
-
|
337
|
+
' If you prefer a different name'\
|
338
|
+
' please specify or press Enter'\
|
339
|
+
' to use defaults: '
|
317
340
|
|
318
341
|
template_name = STDIN.gets.strip.downcase
|
319
342
|
opts[:name] = template_name
|
320
343
|
|
321
|
-
STDOUT.print "\n WARNING!!! The cloning
|
344
|
+
STDOUT.print "\n WARNING!!! The cloning "\
|
345
|
+
'operation can take some time'\
|
322
346
|
" depending on the size of disks.\n"
|
323
347
|
end
|
324
348
|
end
|
325
349
|
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
350
|
+
sdtout_print = "\n\n Do you want to specify a folder where"\
|
351
|
+
' the deployed VMs based on this template will appear'\
|
352
|
+
" in vSphere's VM and Templates section?"\
|
353
|
+
"\n If no path is set, VMs will be placed in the same"\
|
354
|
+
' location where the template lives.'\
|
355
|
+
"\n Please specify a path using slashes to separate folders"\
|
356
|
+
' e.g /Management/VMs or press Enter to use defaults: '\
|
357
|
+
|
358
|
+
STDOUT.print sdtout_print
|
333
359
|
|
334
360
|
vcenter_vm_folder = STDIN.gets.strip
|
335
361
|
opts[:folder] = vcenter_vm_folder
|
336
362
|
|
337
363
|
STDOUT.print "\n\n This template is currently set to "\
|
338
|
-
|
364
|
+
'launch VMs in the default resource pool.'\
|
339
365
|
"\n Press y to keep this behaviour, n to select"\
|
340
|
-
|
341
|
-
|
366
|
+
' a new resource pool or d to delegate the choice'\
|
367
|
+
' to the user ([y]/n/d)? '
|
342
368
|
|
343
|
-
answer =
|
369
|
+
answer = STDIN.gets.strip.downcase
|
344
370
|
|
345
371
|
case answer.downcase
|
346
372
|
when 'd' || 'delegate'
|
347
373
|
opts[:type]='list'
|
348
374
|
puts "separate with commas ',' the list that you want to deleate:"
|
349
375
|
|
350
|
-
opts[:resourcepool] = rps_list.call.gsub(/\s+/,
|
376
|
+
opts[:resourcepool] = rps_list.call.gsub(/\s+/, '').split(',')
|
351
377
|
|
352
378
|
when 'n' || 'no'
|
353
379
|
opts[:type]='fixed'
|
354
|
-
puts
|
380
|
+
puts 'choose the proper name'
|
355
381
|
opts[:resourcepool] = rps_list.call
|
356
382
|
else
|
357
383
|
opts[:type]='default'
|
358
384
|
end
|
359
385
|
|
360
|
-
|
386
|
+
opts
|
361
387
|
end
|
362
388
|
|
363
389
|
def self.network_dialogue(n)
|
364
|
-
ask =
|
390
|
+
ask = lambda {|question, default = ''|
|
365
391
|
STDOUT.print question
|
366
392
|
answer = STDIN.gets.strip
|
367
393
|
|
@@ -372,59 +398,63 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
|
|
372
398
|
|
373
399
|
STDOUT.print "\n- Network: \e[92m#{n[:name]}\e[39m\n\n"\
|
374
400
|
|
375
|
-
opts = { size
|
401
|
+
opts = { :size => '255', :type => 'ether' }
|
376
402
|
|
377
|
-
|
378
|
-
|
379
|
-
opts[:size] = ask.call(question,
|
403
|
+
question = ' How many VMs are you planning'\
|
404
|
+
' to fit into this network [255]? '
|
405
|
+
opts[:size] = ask.call(question, '255')
|
380
406
|
|
381
|
-
|
382
|
-
|
383
|
-
type_answer = ask.call(question,
|
407
|
+
question = ' What type of Virtual Network'\
|
408
|
+
' do you want to create (IPv[4],IPv[6], [E]thernet)? '
|
409
|
+
type_answer = ask.call(question, 'ether')
|
384
410
|
|
385
|
-
supported_types = [
|
411
|
+
supported_types = %w[4 6 ether e ip4 ip6]
|
386
412
|
if !supported_types.include?(type_answer)
|
387
|
-
type_answer =
|
388
|
-
|
389
|
-
|
413
|
+
type_answer = 'e'
|
414
|
+
STDOUT.puts " Type [#{type_answer}] not supported,"\
|
415
|
+
' defaulting to Ethernet.'
|
390
416
|
end
|
391
|
-
question_ip
|
392
|
-
|
417
|
+
question_ip =
|
418
|
+
' Please input the first IP in the range: '
|
419
|
+
question_mac =
|
420
|
+
' Please input the first MAC in the range [Enter for default]: '
|
393
421
|
|
394
422
|
case type_answer.downcase
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
opts[:type] =
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
423
|
+
when '4', 'ip4'
|
424
|
+
opts[:ip] = ask.call(question_ip)
|
425
|
+
opts[:mac] = ask.call(question_mac)
|
426
|
+
opts[:type] = 'ip'
|
427
|
+
when '6', 'ip6'
|
428
|
+
opts[:mac] = ask.call(question_mac)
|
429
|
+
|
430
|
+
question = ' Do you want to use SLAAC '\
|
431
|
+
'Stateless Address Autoconfiguration? ([y]/n): '
|
404
432
|
slaac_answer = ask.call(question, 'y').downcase
|
405
433
|
|
406
|
-
|
407
|
-
|
408
|
-
|
434
|
+
if slaac_answer == 'n'
|
435
|
+
question =
|
436
|
+
' Please input the IPv6 address (cannot be empty): '
|
437
|
+
opts[:ip6] = ask.call(question)
|
409
438
|
|
410
|
-
|
411
|
-
|
439
|
+
question =
|
440
|
+
' Please input the Prefix length (cannot be empty): '
|
441
|
+
opts[:prefix_length] = ask.call(question)
|
412
442
|
opts[:type] = 'ip6_static'
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
opts[:type]
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
443
|
+
else
|
444
|
+
question = ' Please input the GLOBAL PREFIX '\
|
445
|
+
'[Enter for default]: '
|
446
|
+
opts[:global_prefix] = ask.call(question)
|
447
|
+
|
448
|
+
question= ' Please input the ULA PREFIX '\
|
449
|
+
'[Enter for default]: '
|
450
|
+
opts[:ula_prefix] = ask.call(question)
|
451
|
+
opts[:type] = 'ip6'
|
452
|
+
end
|
453
|
+
when 'e', 'ether'
|
454
|
+
opts[:mac] = ask.call(question_mac)
|
455
|
+
end
|
456
|
+
|
457
|
+
opts
|
428
458
|
end
|
429
459
|
|
430
460
|
def clear_tags(vmid)
|
@@ -469,7 +499,7 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
|
|
469
499
|
end
|
470
500
|
end
|
471
501
|
|
472
|
-
|
502
|
+
[vm, keys_to_remove]
|
473
503
|
end
|
474
504
|
|
475
505
|
def remove_keys(vm, keys_to_remove)
|