opennebula-cli 4.14.2 → 4.90.0.beta1
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 +1 -1
- data/bin/oneacl +1 -1
- data/bin/onecluster +4 -1
- data/bin/onedatastore +4 -1
- data/bin/oneflow +26 -1
- data/bin/oneflow-template +57 -1
- data/bin/onegroup +4 -1
- data/bin/onehost +24 -15
- data/bin/oneimage +5 -3
- data/bin/onemarket +178 -0
- data/bin/onemarketapp +282 -0
- data/bin/onesecgroup +18 -1
- data/bin/oneshowback +1 -1
- data/bin/onetemplate +30 -21
- data/bin/oneuser +12 -6
- data/bin/oneuser.backup +522 -0
- data/bin/onevcenter +287 -1
- data/bin/onevdc +4 -1
- data/bin/onevm +78 -56
- data/bin/onevnet +10 -4
- data/bin/onevrouter +305 -0
- data/bin/onezone +4 -1
- data/lib/cli_helper.rb +1 -1
- data/lib/command_parser.rb +1 -1
- data/lib/one_helper/oneacct_helper.rb +1 -1
- data/lib/one_helper/oneacl_helper.rb +11 -5
- data/lib/one_helper/onecluster_helper.rb +1 -1
- data/lib/one_helper/onedatastore_helper.rb +17 -7
- data/lib/one_helper/onegroup_helper.rb +1 -1
- data/lib/one_helper/onehost_helper.rb +2 -5
- data/lib/one_helper/oneimage_helper.rb +1 -15
- data/lib/one_helper/onemarket_helper.rb +152 -0
- data/lib/one_helper/onemarketapp_helper.rb +223 -0
- data/lib/one_helper/onequota_helper.rb +1 -1
- data/lib/one_helper/onesecgroup_helper.rb +46 -3
- data/lib/one_helper/onetemplate_helper.rb +146 -11
- data/lib/one_helper/oneuser_helper.rb +1 -1
- data/lib/one_helper/onevdc_helper.rb +1 -1
- data/lib/one_helper/onevm_helper.rb +37 -53
- data/lib/one_helper/onevnet_helper.rb +23 -11
- data/lib/one_helper/onevrouter_helper.rb +221 -0
- data/lib/one_helper/onezone_helper.rb +1 -1
- data/lib/one_helper.rb +193 -25
- metadata +21 -10
@@ -0,0 +1,152 @@
|
|
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 OneMarketPlaceHelper < OpenNebulaHelper::OneHelper
|
20
|
+
MARKETPLACE = {
|
21
|
+
:name => "marketplace",
|
22
|
+
:short => "-m id|name",
|
23
|
+
:large => "--marketplace id|name" ,
|
24
|
+
:description => "Selects the marketplace",
|
25
|
+
:format => String,
|
26
|
+
:proc => lambda { |o, options|
|
27
|
+
OpenNebulaHelper.rname_to_id(o, "MARKETPLACE")
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
def self.rname
|
32
|
+
"MARKETPLACE"
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.conf_file
|
36
|
+
"onemarket.yaml"
|
37
|
+
end
|
38
|
+
|
39
|
+
def format_pool(options)
|
40
|
+
config_file = self.class.table_conf
|
41
|
+
|
42
|
+
table = CLIHelper::ShowTable.new(config_file, self) do
|
43
|
+
column :ID, "ONE identifier for the Marketplace", :size=>4 do |d|
|
44
|
+
d["ID"]
|
45
|
+
end
|
46
|
+
|
47
|
+
column :USER, "Username of the Marketplace owner", :left,
|
48
|
+
:size=>10 do |d|
|
49
|
+
helper.user_name(d, options)
|
50
|
+
end
|
51
|
+
|
52
|
+
column :GROUP, "Group of the Marketplace", :left,
|
53
|
+
:size=>10 do |d|
|
54
|
+
helper.group_name(d, options)
|
55
|
+
end
|
56
|
+
|
57
|
+
column :NAME, "Name of the Marketplace", :left, :size=>30 do |d|
|
58
|
+
d["NAME"]
|
59
|
+
end
|
60
|
+
|
61
|
+
column :SIZE, "Marketplace total size", :size =>10 do |d|
|
62
|
+
OpenNebulaHelper.unit_to_str(d['TOTAL_MB'].to_i, {}, 'M')
|
63
|
+
end
|
64
|
+
|
65
|
+
column :AVAIL, "Marketplace free size", :left, :size =>10 do |d|
|
66
|
+
if d['TOTAL_MB'].to_i == 0
|
67
|
+
"-"
|
68
|
+
else
|
69
|
+
"#{((d['FREE_MB'].to_f/d['TOTAL_MB'].to_f) * 100).round()}%"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
column :APPS, "Number of marketplace apps", :size=>6 do |d|
|
74
|
+
if d["MARKETPLACEAPPS"]["ID"].nil?
|
75
|
+
"0"
|
76
|
+
else
|
77
|
+
[d["MARKETPLACEAPPS"]["ID"]].flatten.size
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
column :MAD, "Marketplace driver", :left, :size=>7 do |d|
|
82
|
+
d["MARKET_MAD"]
|
83
|
+
end
|
84
|
+
|
85
|
+
column :ZONE, "Zone ID", :size=>4 do |d|
|
86
|
+
d["ZONE_ID"]
|
87
|
+
end
|
88
|
+
|
89
|
+
default :ID, :NAME, :SIZE, :AVAIL, :APPS, :MAD, :ZONE
|
90
|
+
end
|
91
|
+
|
92
|
+
table
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
|
97
|
+
def factory(id=nil)
|
98
|
+
if id
|
99
|
+
OpenNebula::MarketPlace.new_with_id(id, @client)
|
100
|
+
else
|
101
|
+
xml=OpenNebula::MarketPlace.build_xml
|
102
|
+
OpenNebula::MarketPlace.new(xml, @client)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def factory_pool(user_flag=-2)
|
107
|
+
OpenNebula::MarketPlacePool.new(@client)
|
108
|
+
end
|
109
|
+
|
110
|
+
def format_resource(market, options = {})
|
111
|
+
str="%-15s: %-20s"
|
112
|
+
str_h1="%-80s"
|
113
|
+
|
114
|
+
CLIHelper.print_header(str_h1 % "MARKETPLACE #{market['ID']} INFORMATION")
|
115
|
+
puts str % ["ID", market.id.to_s]
|
116
|
+
puts str % ["NAME", market.name]
|
117
|
+
puts str % ["USER", market['UNAME']]
|
118
|
+
puts str % ["GROUP", market['GNAME']]
|
119
|
+
|
120
|
+
puts str % ["MARKET_MAD", market['MARKET_MAD']]
|
121
|
+
puts
|
122
|
+
|
123
|
+
CLIHelper.print_header(str_h1 % "MARKETPLACE CAPACITY", false)
|
124
|
+
|
125
|
+
puts str % ["TOTAL:", OpenNebulaHelper.unit_to_str(market['TOTAL_MB'].to_i,{},'M')]
|
126
|
+
puts str % ["FREE:", OpenNebulaHelper.unit_to_str(market['FREE_MB'].to_i, {},'M')]
|
127
|
+
puts str % ["USED: ", OpenNebulaHelper.unit_to_str(market['USED_MB'].to_i, {},'M')]
|
128
|
+
puts
|
129
|
+
|
130
|
+
CLIHelper.print_header(str_h1 % "PERMISSIONS",false)
|
131
|
+
|
132
|
+
["OWNER", "GROUP", "OTHER"].each { |e|
|
133
|
+
mask = "---"
|
134
|
+
mask[0] = "u" if market["PERMISSIONS/#{e}_U"] == "1"
|
135
|
+
mask[1] = "m" if market["PERMISSIONS/#{e}_M"] == "1"
|
136
|
+
mask[2] = "a" if market["PERMISSIONS/#{e}_A"] == "1"
|
137
|
+
|
138
|
+
puts str % [e, mask]
|
139
|
+
}
|
140
|
+
puts
|
141
|
+
|
142
|
+
CLIHelper.print_header(str_h1 % "MARKETPLACE TEMPLATE", false)
|
143
|
+
puts market.template_str
|
144
|
+
|
145
|
+
puts
|
146
|
+
|
147
|
+
CLIHelper.print_header("%-15s" % "MARKETAPPS")
|
148
|
+
market.marketapp_ids.each do |id|
|
149
|
+
puts "%-15s" % [id]
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
@@ -0,0 +1,223 @@
|
|
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 OneMarketPlaceAppHelper < OpenNebulaHelper::OneHelper
|
20
|
+
TEMPLATE_OPTIONS=[
|
21
|
+
{
|
22
|
+
:name => "name",
|
23
|
+
:large => "--name name",
|
24
|
+
:format => String,
|
25
|
+
:description => "Name of the new MarketPlaceApp"
|
26
|
+
},
|
27
|
+
{
|
28
|
+
:name => "description",
|
29
|
+
:large => "--description description",
|
30
|
+
:format => String,
|
31
|
+
:description => "Description for the new MarketPlaceApp"
|
32
|
+
},
|
33
|
+
{
|
34
|
+
:name => "image",
|
35
|
+
:large => "--image id|name" ,
|
36
|
+
:description => "Selects the image",
|
37
|
+
:format => String,
|
38
|
+
:template_key => "origin_id",
|
39
|
+
:proc => lambda { |o, options|
|
40
|
+
OpenNebulaHelper.rname_to_id(o, "IMAGE")
|
41
|
+
}
|
42
|
+
},
|
43
|
+
OpenNebulaHelper::DRY
|
44
|
+
]
|
45
|
+
|
46
|
+
VMNAME = {
|
47
|
+
:name => "vmname",
|
48
|
+
:large => "--vmname name" ,
|
49
|
+
:description => "Selects the name for the new VM Template, if the App contains one",
|
50
|
+
:format => String
|
51
|
+
}
|
52
|
+
|
53
|
+
def self.rname
|
54
|
+
"MARKETPLACEAPP"
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.conf_file
|
58
|
+
"onemarketapp.yaml"
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.state_to_str(id)
|
62
|
+
id = id.to_i
|
63
|
+
state_str = MarketPlaceApp::MARKETPLACEAPP_STATES[id]
|
64
|
+
return MarketPlaceApp::SHORT_MARKETPLACEAPP_STATES[state_str]
|
65
|
+
end
|
66
|
+
|
67
|
+
def format_pool(options)
|
68
|
+
config_file = self.class.table_conf
|
69
|
+
|
70
|
+
table = CLIHelper::ShowTable.new(config_file, self) do
|
71
|
+
column :ID, "ONE identifier for the marketplace app", :size=>4 do |d|
|
72
|
+
d["ID"]
|
73
|
+
end
|
74
|
+
|
75
|
+
column :NAME, "Name of the marketplace app", :left, :size=>25 do |d|
|
76
|
+
d["NAME"]
|
77
|
+
end
|
78
|
+
|
79
|
+
column :VERSION, "Version of the app", :size=>10 do |d|
|
80
|
+
d["VERSION"]
|
81
|
+
end
|
82
|
+
|
83
|
+
column :SIZE, "App size", :size =>5 do |d|
|
84
|
+
OpenNebulaHelper.unit_to_str(d['SIZE'].to_i, {}, 'M')
|
85
|
+
end
|
86
|
+
|
87
|
+
column :STAT, "State of the app", :size=>4 do |d|
|
88
|
+
OneMarketPlaceAppHelper.state_to_str(d["STATE"])
|
89
|
+
end
|
90
|
+
|
91
|
+
column :REGTIME, "Registration time of the app", :size=>8 do |d|
|
92
|
+
Time.at(d['REGTIME'].to_i).strftime("%D")
|
93
|
+
end
|
94
|
+
|
95
|
+
column :TYPE, "Marketplace app type", :size=>4 do |d|
|
96
|
+
type = MarketPlaceApp::MARKETPLACEAPP_TYPES[d["TYPE"].to_i]
|
97
|
+
MarketPlaceApp::SHORT_MARKETPLACEAPP_TYPES[type]
|
98
|
+
end
|
99
|
+
|
100
|
+
column :MARKET, "Name of the MarketPlace", :left, :size=>20 do |d|
|
101
|
+
d["MARKETPLACE"]
|
102
|
+
end
|
103
|
+
|
104
|
+
column :ZONE, "Zone ID", :size=>4 do |d|
|
105
|
+
d["ZONE_ID"]
|
106
|
+
end
|
107
|
+
|
108
|
+
default :ID,:NAME,:VERSION,:SIZE,:STAT,:TYPE,:REGTIME,:MARKET,:ZONE
|
109
|
+
end
|
110
|
+
|
111
|
+
table
|
112
|
+
end
|
113
|
+
|
114
|
+
def self.create_template_options_used?(options)
|
115
|
+
# Get the template options names as symbols. options hash
|
116
|
+
# uses symbols
|
117
|
+
template_options=self::TEMPLATE_OPTIONS.map do |o|
|
118
|
+
o[:name].to_sym
|
119
|
+
end
|
120
|
+
|
121
|
+
# Check if one at least one of the template options is
|
122
|
+
# in options hash
|
123
|
+
(template_options-options.keys)!=template_options
|
124
|
+
end
|
125
|
+
|
126
|
+
private
|
127
|
+
|
128
|
+
def factory(id=nil)
|
129
|
+
if id
|
130
|
+
OpenNebula::MarketPlaceApp.new_with_id(id, @client)
|
131
|
+
else
|
132
|
+
xml=OpenNebula::MarketPlaceApp.build_xml
|
133
|
+
OpenNebula::MarketPlaceApp.new(xml, @client)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def factory_pool(user_flag=-2)
|
138
|
+
OpenNebula::MarketPlaceAppPool.new(@client, user_flag)
|
139
|
+
end
|
140
|
+
|
141
|
+
def format_resource(app, options = {})
|
142
|
+
str="%-15s: %-20s"
|
143
|
+
str_h1="%-80s"
|
144
|
+
|
145
|
+
CLIHelper.print_header(str_h1 % "MARKETPLACE APP #{app['ID']} INFORMATION")
|
146
|
+
puts str % ["ID", app.id.to_s]
|
147
|
+
puts str % ["NAME", app.name]
|
148
|
+
puts str % ["TYPE", app.type_str]
|
149
|
+
puts str % ["USER", app['UNAME']]
|
150
|
+
puts str % ["GROUP", app['GNAME']]
|
151
|
+
puts str % ["MARKETPLACE", app['MARKETPLACE']]
|
152
|
+
puts str % ["STATE", OneMarketPlaceAppHelper.state_to_str(app["STATE"])]
|
153
|
+
|
154
|
+
puts
|
155
|
+
|
156
|
+
CLIHelper.print_header(str_h1 % "PERMISSIONS",false)
|
157
|
+
|
158
|
+
["OWNER", "GROUP", "OTHER"].each { |e|
|
159
|
+
mask = "---"
|
160
|
+
mask[0] = "u" if app["PERMISSIONS/#{e}_U"] == "1"
|
161
|
+
mask[1] = "m" if app["PERMISSIONS/#{e}_M"] == "1"
|
162
|
+
mask[2] = "a" if app["PERMISSIONS/#{e}_A"] == "1"
|
163
|
+
|
164
|
+
puts str % [e, mask]
|
165
|
+
}
|
166
|
+
puts
|
167
|
+
|
168
|
+
CLIHelper.print_header(str_h1 % "DETAILS", false)
|
169
|
+
|
170
|
+
puts str % ["SOURCE", app['SOURCE']]
|
171
|
+
puts str % ["MD5", app['MD5']]
|
172
|
+
puts str % ["PUBLISHER", app['PUBLISHER']]
|
173
|
+
puts str % ["REGISTER TIME", Time.at(app['REGTIME'].to_i).strftime("%c") ]
|
174
|
+
puts str % ["VERSION", app['VERSION']]
|
175
|
+
puts str % ["DESCRIPTION", app['DESCRIPTION']]
|
176
|
+
puts str % ["SIZE", OpenNebulaHelper.unit_to_str(app['SIZE'].to_i,{},'M')]
|
177
|
+
puts str % ["ORIGIN_ID", app['ORIGIN_ID']]
|
178
|
+
puts str % ["FORMAT", app['FORMAT']]
|
179
|
+
|
180
|
+
puts
|
181
|
+
|
182
|
+
CLIHelper.print_header(str_h1 % "IMPORT TEMPLATE", false)
|
183
|
+
|
184
|
+
puts Base64.decode64(app['APPTEMPLATE64'])
|
185
|
+
|
186
|
+
puts
|
187
|
+
|
188
|
+
CLIHelper.print_header(str_h1 % "MARKETPLACE APP TEMPLATE", false)
|
189
|
+
puts app.template_str
|
190
|
+
|
191
|
+
puts
|
192
|
+
end
|
193
|
+
|
194
|
+
def self.create_variables(options, name)
|
195
|
+
if Array===name
|
196
|
+
names=name
|
197
|
+
else
|
198
|
+
names=[name]
|
199
|
+
end
|
200
|
+
|
201
|
+
t=''
|
202
|
+
names.each do |n|
|
203
|
+
if options[n]
|
204
|
+
t<<"#{n.to_s.upcase}=\"#{options[n]}\"\n"
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
t
|
209
|
+
end
|
210
|
+
|
211
|
+
def self.create_datastore_template(options)
|
212
|
+
template_options=TEMPLATE_OPTIONS.map do |o|
|
213
|
+
o[:name].to_sym
|
214
|
+
end
|
215
|
+
|
216
|
+
template=create_variables(options, template_options-[:dry,:image])
|
217
|
+
|
218
|
+
template<<"ORIGIN_ID=#{options[:image]}\n" if options[:image]
|
219
|
+
template << "TYPE=image\n"
|
220
|
+
|
221
|
+
[0, template]
|
222
|
+
end
|
223
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
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 #
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
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 #
|
@@ -17,6 +17,15 @@
|
|
17
17
|
require 'one_helper'
|
18
18
|
|
19
19
|
class OneSecurityGroupHelper < OpenNebulaHelper::OneHelper
|
20
|
+
RECOVER = {
|
21
|
+
:name => "recover",
|
22
|
+
:short => "-r",
|
23
|
+
:large => "--recover" ,
|
24
|
+
:description => "If set the commit operation will only operate on "\
|
25
|
+
"outdated and error VMs. This is intended for retrying updates of "\
|
26
|
+
"VMs or reinitialize the updating process if oned stopped or fail.",
|
27
|
+
}
|
28
|
+
|
20
29
|
def self.rname
|
21
30
|
"SECURITY_GROUP"
|
22
31
|
end
|
@@ -33,7 +42,7 @@ class OneSecurityGroupHelper < OpenNebulaHelper::OneHelper
|
|
33
42
|
d["ID"]
|
34
43
|
end
|
35
44
|
|
36
|
-
column :NAME, "Name of the Security Group", :left, :size=>
|
45
|
+
column :NAME, "Name of the Security Group", :left, :size=>20 do |d|
|
37
46
|
d["NAME"]
|
38
47
|
end
|
39
48
|
|
@@ -46,7 +55,31 @@ class OneSecurityGroupHelper < OpenNebulaHelper::OneHelper
|
|
46
55
|
helper.group_name(d, options)
|
47
56
|
end
|
48
57
|
|
49
|
-
|
58
|
+
column :UPDATED, "Number of VMs with updated rules", :size=>8 do |d|
|
59
|
+
if d["UPDATED_VMS"]["ID"].nil?
|
60
|
+
"0"
|
61
|
+
else
|
62
|
+
[d["UPDATED_VMS"]["ID"]].flatten.size
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
column :OUTDATED, "Number of VMs with outdated rules", :size=>8 do |d|
|
67
|
+
if d["OUTDATED_VMS"]["ID"].nil?
|
68
|
+
"0"
|
69
|
+
else
|
70
|
+
[d["OUTDATED_VMS"]["ID"]].flatten.size
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
column :ERROR, "Number of VMs that failed to update rules", :size=>8 do |d|
|
75
|
+
if d["ERROR_VMS"]["ID"].nil?
|
76
|
+
"0"
|
77
|
+
else
|
78
|
+
[d["ERROR_VMS"]["ID"]].flatten.size
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
default :ID, :USER, :GROUP, :NAME, :UPDATED, :OUTDATED, :ERROR
|
50
83
|
end
|
51
84
|
|
52
85
|
table
|
@@ -91,6 +124,16 @@ class OneSecurityGroupHelper < OpenNebulaHelper::OneHelper
|
|
91
124
|
|
92
125
|
puts
|
93
126
|
|
127
|
+
CLIHelper.print_header(str_h1 % "VIRTUAL MACHINES", false)
|
128
|
+
|
129
|
+
updated, outdated, error = secgroup.vm_ids
|
130
|
+
|
131
|
+
puts str % ["UPDATED", updated.join(',') ]
|
132
|
+
puts str % ["OUTDATED", outdated.join(',') ]
|
133
|
+
puts str % ["ERROR", error.join(',') ]
|
134
|
+
|
135
|
+
puts
|
136
|
+
|
94
137
|
CLIHelper.print_header(str_h1 % ["RULES"], false)
|
95
138
|
|
96
139
|
if !secgroup.to_hash['SECURITY_GROUP']['TEMPLATE']['RULE'].nil?
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
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 #
|
@@ -51,6 +51,20 @@ EOT
|
|
51
51
|
"information, such as the SIZE for each DISK"
|
52
52
|
}
|
53
53
|
|
54
|
+
RECURSIVE={
|
55
|
+
:name => "recursive",
|
56
|
+
:large => "--recursive",
|
57
|
+
:description => "Applies the action to the template plus any "+
|
58
|
+
"image defined in DISK"
|
59
|
+
}
|
60
|
+
|
61
|
+
PERSISTENT={
|
62
|
+
:name => "persistent",
|
63
|
+
:large => "--persistent",
|
64
|
+
:description => "Creates a private persistent copy of the template "+
|
65
|
+
"plus any image defined in DISK, and instantiates that copy"
|
66
|
+
}
|
67
|
+
|
54
68
|
def self.rname
|
55
69
|
"VMTEMPLATE"
|
56
70
|
end
|
@@ -111,7 +125,10 @@ EOT
|
|
111
125
|
table
|
112
126
|
end
|
113
127
|
|
114
|
-
|
128
|
+
INT_EXP = /^-?\d+$/
|
129
|
+
FLOAT_EXP = /^-?\d+(\.\d+)?$/
|
130
|
+
|
131
|
+
def self.get_user_inputs(template)
|
115
132
|
user_inputs = template['VMTEMPLATE']['TEMPLATE']['USER_INPUTS']
|
116
133
|
|
117
134
|
return "" if !user_inputs
|
@@ -121,23 +138,41 @@ EOT
|
|
121
138
|
puts "There are some parameters that require user input. Use the string <<EDITOR>> to launch an editor (e.g. for multi-line inputs)"
|
122
139
|
|
123
140
|
user_inputs.each do |key, val|
|
124
|
-
input_cfg = val.split('|')
|
141
|
+
input_cfg = val.split('|', -1)
|
125
142
|
|
126
|
-
if input_cfg.length
|
127
|
-
STDERR.puts "Malformed user input. It should have 3 parts separated by '|':"
|
143
|
+
if input_cfg.length < 3
|
144
|
+
STDERR.puts "Malformed user input. It should have at least 3 parts separated by '|':"
|
128
145
|
STDERR.puts " #{key}: #{val}"
|
129
146
|
exit(-1)
|
130
147
|
end
|
131
148
|
|
132
|
-
|
133
|
-
optional.strip
|
149
|
+
mandatory, type, description, params, initial = input_cfg
|
150
|
+
optional = mandatory.strip == "O"
|
134
151
|
type.strip!
|
135
152
|
description.strip!
|
136
153
|
|
137
|
-
|
154
|
+
if input_cfg.length > 3
|
155
|
+
if input_cfg.length != 5
|
156
|
+
STDERR.puts "Malformed user input. It should have 5 parts separated by '|':"
|
157
|
+
STDERR.puts " #{key}: #{val}"
|
158
|
+
exit(-1)
|
159
|
+
end
|
160
|
+
|
161
|
+
params.strip!
|
162
|
+
initial.strip!
|
163
|
+
end
|
164
|
+
|
165
|
+
puts " * (#{key}) #{description}"
|
166
|
+
|
167
|
+
header = " "
|
168
|
+
if initial != nil && initial != ""
|
169
|
+
header += "Press enter for default (#{initial}). "
|
170
|
+
end
|
138
171
|
|
139
172
|
case type
|
140
173
|
when 'text', 'text64'
|
174
|
+
print header
|
175
|
+
|
141
176
|
answer = STDIN.readline.chop
|
142
177
|
|
143
178
|
if answer == "<<EDITOR>>"
|
@@ -147,15 +182,115 @@ EOT
|
|
147
182
|
if type == 'text64'
|
148
183
|
answer = Base64::encode64(answer).strip.delete("\n")
|
149
184
|
end
|
185
|
+
|
150
186
|
when 'password'
|
187
|
+
print header
|
188
|
+
|
151
189
|
answer = OpenNebulaHelper::OneHelper.get_password
|
190
|
+
|
191
|
+
when 'number', 'number-float'
|
192
|
+
if type == "number"
|
193
|
+
header += "Integer: "
|
194
|
+
exp = INT_EXP
|
195
|
+
else
|
196
|
+
header += "Float: "
|
197
|
+
exp = FLOAT_EXP
|
198
|
+
end
|
199
|
+
|
200
|
+
begin
|
201
|
+
print header
|
202
|
+
answer = STDIN.readline.chop
|
203
|
+
|
204
|
+
answer = initial if (answer == "")
|
205
|
+
|
206
|
+
noanswer = ((answer == "") && optional)
|
207
|
+
end while !noanswer && (answer =~ exp) == nil
|
208
|
+
|
209
|
+
if noanswer
|
210
|
+
next
|
211
|
+
end
|
212
|
+
|
213
|
+
when 'range', 'range-float'
|
214
|
+
min,max = params.split('..')
|
215
|
+
|
216
|
+
if min.nil? || max.nil?
|
217
|
+
STDERR.puts "Malformed user input. Parameters should be 'min..max':"
|
218
|
+
STDERR.puts " #{key}: #{val}"
|
219
|
+
exit(-1)
|
220
|
+
end
|
221
|
+
|
222
|
+
if type == "range"
|
223
|
+
exp = INT_EXP
|
224
|
+
min = min.to_i
|
225
|
+
max = max.to_i
|
226
|
+
|
227
|
+
header += "Integer in the range [#{min}..#{max}]: "
|
228
|
+
else
|
229
|
+
exp = FLOAT_EXP
|
230
|
+
min = min.to_f
|
231
|
+
max = max.to_f
|
232
|
+
|
233
|
+
header += "Float in the range [#{min}..#{max}]: "
|
234
|
+
end
|
235
|
+
|
236
|
+
begin
|
237
|
+
print header
|
238
|
+
answer = STDIN.readline.chop
|
239
|
+
|
240
|
+
answer = initial if (answer == "")
|
241
|
+
|
242
|
+
noanswer = ((answer == "") && optional)
|
243
|
+
end while !noanswer && ((answer =~ exp) == nil || answer.to_f < min || answer.to_f > max)
|
244
|
+
|
245
|
+
if noanswer
|
246
|
+
next
|
247
|
+
end
|
248
|
+
|
249
|
+
when 'list'
|
250
|
+
options = params.split(",")
|
251
|
+
|
252
|
+
options.each_with_index {|opt,i|
|
253
|
+
puts " #{i} #{opt}"
|
254
|
+
}
|
255
|
+
|
256
|
+
puts
|
257
|
+
|
258
|
+
header += "Please type the selection number: "
|
259
|
+
|
260
|
+
begin
|
261
|
+
print header
|
262
|
+
answer = STDIN.readline.chop
|
263
|
+
|
264
|
+
if (answer == "")
|
265
|
+
answer = initial
|
266
|
+
else
|
267
|
+
answer = options[answer.to_i]
|
268
|
+
end
|
269
|
+
|
270
|
+
noanswer = ((answer == "") && optional)
|
271
|
+
|
272
|
+
end while !noanswer && (!options.include?(answer))
|
273
|
+
|
274
|
+
if noanswer
|
275
|
+
next
|
276
|
+
end
|
277
|
+
|
278
|
+
when 'fixed'
|
279
|
+
puts " Fixed value of (#{initial}). Cannot be changed"
|
280
|
+
answer = initial
|
281
|
+
|
152
282
|
else
|
153
|
-
STDERR.puts "
|
283
|
+
STDERR.puts "Wrong type for user input:"
|
154
284
|
STDERR.puts " #{key}: #{val}"
|
155
285
|
exit(-1)
|
156
286
|
end
|
157
|
-
|
158
|
-
|
287
|
+
|
288
|
+
# Do not replace values that are equal to the ones already in the
|
289
|
+
# template. Useful for cpu, mem, vcpu
|
290
|
+
if answer != template['VMTEMPLATE']['TEMPLATE'][key]
|
291
|
+
answers << "#{key} = \""
|
292
|
+
answers << answer.gsub('"', "\\\"") << "\"\n"
|
293
|
+
end
|
159
294
|
end
|
160
295
|
|
161
296
|
answers
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
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 #
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
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 #
|