umbreo_cli 1.0.141
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.env +2 -0
- data/Gemfile +23 -0
- data/Gemfile.lock +106 -0
- data/README.md +1625 -0
- data/Rakefile +44 -0
- data/bin/manifests/init.pp +20 -0
- data/bin/umbreo +1684 -0
- data/bin/umbreo.json +34 -0
- data/lib/umbreo.rb +49 -0
- data/lib/umbreo/helpers/alert_message.rb +58 -0
- data/lib/umbreo/helpers/error_exception.rb +15 -0
- data/lib/umbreo/helpers/file_generator.rb +13 -0
- data/lib/umbreo/helpers/json_base_convert.rb +30 -0
- data/lib/umbreo/helpers/table.rb +45 -0
- data/lib/umbreo/models/amazon_web_service_provider.rb +260 -0
- data/lib/umbreo/models/authentication.rb +99 -0
- data/lib/umbreo/models/blueprint.rb +241 -0
- data/lib/umbreo/models/cloud_provider.rb +143 -0
- data/lib/umbreo/models/configuration.rb +98 -0
- data/lib/umbreo/models/digital_ocean_provider.rb +204 -0
- data/lib/umbreo/models/google_compute_engine_provider.rb +232 -0
- data/lib/umbreo/models/instance.rb +170 -0
- data/lib/umbreo/models/module.rb +61 -0
- data/lib/umbreo/models/openstack_provider.rb +260 -0
- data/lib/umbreo/models/profile.rb +61 -0
- data/lib/umbreo/models/provider.rb +164 -0
- data/lib/umbreo/models/service.rb +244 -0
- data/lib/umbreo/models/service_provider.rb +185 -0
- data/lib/umbreo/models/stack.rb +181 -0
- data/lib/umbreo/models/system.rb +43 -0
- data/lib/umbreo/models/umbreo_stack_template.rb +163 -0
- data/lib/umbreo/models/xenserver_provider.rb +200 -0
- data/lib/umbreo/version.rb +3 -0
- data/manifests/init.pp +20 -0
- data/manifests1/init.pp +9 -0
- data/umbreo.gemspec +28 -0
- metadata +241 -0
data/Rakefile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'rake/clean'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rubygems/package_task'
|
4
|
+
require 'rdoc/task'
|
5
|
+
require 'cucumber'
|
6
|
+
require 'cucumber/rake/task'
|
7
|
+
Rake::RDocTask.new do |rd|
|
8
|
+
rd.main = "README.rdoc"
|
9
|
+
rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
|
10
|
+
rd.title = 'Umbreo Command Line Interface'
|
11
|
+
end
|
12
|
+
|
13
|
+
spec = eval(File.read('umbreo.gemspec'))
|
14
|
+
|
15
|
+
Gem::PackageTask.new(spec) do |pkg|
|
16
|
+
end
|
17
|
+
CUKE_RESULTS = 'results.html'
|
18
|
+
CLEAN << CUKE_RESULTS
|
19
|
+
desc 'Run features'
|
20
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
21
|
+
opts = "features --format html -o #{CUKE_RESULTS} --format progress -x"
|
22
|
+
opts += " --tags #{ENV['TAGS']}" if ENV['TAGS']
|
23
|
+
t.cucumber_opts = opts
|
24
|
+
t.fork = false
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'Run features tagged as work-in-progress (@wip)'
|
28
|
+
Cucumber::Rake::Task.new('features:wip') do |t|
|
29
|
+
tag_opts = ' --tags ~@pending'
|
30
|
+
tag_opts = ' --tags @wip'
|
31
|
+
t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty -x -s#{tag_opts}"
|
32
|
+
t.fork = false
|
33
|
+
end
|
34
|
+
|
35
|
+
task :cucumber => :features
|
36
|
+
task 'cucumber:wip' => 'features:wip'
|
37
|
+
task :wip => 'features:wip'
|
38
|
+
require 'rake/testtask'
|
39
|
+
Rake::TestTask.new do |t|
|
40
|
+
t.libs << "test"
|
41
|
+
t.test_files = FileList['test/*_test.rb']
|
42
|
+
end
|
43
|
+
|
44
|
+
task :default => [:test,:features]
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class apache (
|
2
|
+
$version = 'latest',
|
3
|
+
$service_ensure = "running",
|
4
|
+
$service_enable = true,
|
5
|
+
){
|
6
|
+
package {'apache2':
|
7
|
+
ensure => $version, # Using the class parameter from above
|
8
|
+
before => File['/etc/apache.conf'],
|
9
|
+
}
|
10
|
+
file {'/etc/apache2.conf':
|
11
|
+
ensure => file,
|
12
|
+
owner => 'apache',
|
13
|
+
content => template('apache/apache.conf.erb'), # Template from a module
|
14
|
+
}
|
15
|
+
service {'apache2':
|
16
|
+
ensure => running,
|
17
|
+
enable => true,
|
18
|
+
subscribe => File['/etc/apache.conf'],
|
19
|
+
}
|
20
|
+
}
|
data/bin/umbreo
ADDED
@@ -0,0 +1,1684 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'gli'
|
3
|
+
|
4
|
+
require 'uri'
|
5
|
+
require 'io/console'
|
6
|
+
require 'highline'
|
7
|
+
require 'open3'
|
8
|
+
require 'yaml'
|
9
|
+
require 'umbreo'
|
10
|
+
|
11
|
+
module Umbreo
|
12
|
+
module CLI
|
13
|
+
|
14
|
+
include GLI::App
|
15
|
+
extend self
|
16
|
+
|
17
|
+
version VERSION
|
18
|
+
program_desc 'Umbreo Command Line Interface.'
|
19
|
+
subcommand_option_handling :normal
|
20
|
+
arguments :strict
|
21
|
+
|
22
|
+
#
|
23
|
+
# Intial Actions
|
24
|
+
#
|
25
|
+
pre do |global,command,options,args|
|
26
|
+
$auth = Models::Authentication.new
|
27
|
+
$credential = $auth.retrieve_credentails!
|
28
|
+
end
|
29
|
+
|
30
|
+
post do |global,command,options,args|
|
31
|
+
end
|
32
|
+
|
33
|
+
on_error do |exception|
|
34
|
+
puts exception
|
35
|
+
false
|
36
|
+
end
|
37
|
+
#
|
38
|
+
#
|
39
|
+
#
|
40
|
+
|
41
|
+
desc "Login with your Umbreo credentials"
|
42
|
+
skips_pre
|
43
|
+
command :login do |c|
|
44
|
+
c.flag [:email, :e], desc: "Your Email", type: String
|
45
|
+
c.flag [:password, :p], desc: "Your Password", type: String
|
46
|
+
|
47
|
+
c.action do |global_options, options, args|
|
48
|
+
if options[:email].blank? || options[:password].blank?
|
49
|
+
puts "Enter your #{Rainbow('Umbreo').cyan} credentials."
|
50
|
+
end
|
51
|
+
|
52
|
+
cli = HighLine.new
|
53
|
+
email = options[:email] || cli.ask("Email: ")
|
54
|
+
password = options[:password] || cli.ask("Password (Typing will be hidden): ") {|q| q.echo = false}
|
55
|
+
|
56
|
+
auth = Models::Authentication.new(email, password)
|
57
|
+
|
58
|
+
if auth.valid?
|
59
|
+
auth.sign_in_and_retrieve_token!
|
60
|
+
auth.sign_in_callback
|
61
|
+
else
|
62
|
+
Helpers::AlertMessage.show_error_message(auth.error)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
desc "Logout and clear Umbreo credentials"
|
68
|
+
skips_pre
|
69
|
+
command :logout do |c|
|
70
|
+
c.action do |global_options, options, args|
|
71
|
+
|
72
|
+
auth = Models::Authentication.new
|
73
|
+
auth.sign_out
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
desc "Change endpoint access umbreo server"
|
78
|
+
skips_pre
|
79
|
+
command :endpoint do |c|
|
80
|
+
c.desc "Configure url"
|
81
|
+
c.command :configure do |configure|
|
82
|
+
|
83
|
+
configure.desc "Endpoint URL"
|
84
|
+
configure.flag [:url, :u]
|
85
|
+
|
86
|
+
configure.action do |global_options, options, args|
|
87
|
+
|
88
|
+
cli = HighLine.new
|
89
|
+
endpoint_url = options[:url] || cli.ask("Enter your Endpoint (URL): ")
|
90
|
+
|
91
|
+
if endpoint_url =~ URI::regexp
|
92
|
+
config = Models::Configuration.new
|
93
|
+
data = config.read_file_authentication
|
94
|
+
new_config = { :name=>data[:name], :api_key=>data[:api_key], :email=>data[:email], :authentication_token=>data[:api_key] }
|
95
|
+
config.write_file_authentication(new_config, endpoint_url)
|
96
|
+
|
97
|
+
Helpers::AlertMessage.show_success_message("End point updated, you have to resign in to your app.")
|
98
|
+
else
|
99
|
+
Helpers::AlertMessage.show_error_message("Not valid url")
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
desc "Manage instance or user node"
|
107
|
+
command :instance do |c|
|
108
|
+
|
109
|
+
c.desc "Deploy blueprint"
|
110
|
+
c.command :deploy do |deploy|
|
111
|
+
|
112
|
+
deploy.switch [:custom, :c], desc: "Define custom blueprint", default_value: false
|
113
|
+
deploy.flag [:name, :n], desc: "Instance name"
|
114
|
+
deploy.flag [:desc, :d], desc: "Instance description"
|
115
|
+
deploy.flag [:blueprint, :b], desc: "Directory file of blueprint json"
|
116
|
+
deploy.flag [:service_logging, :l], desc: "Directory file of service logging json"
|
117
|
+
deploy.flag [:service_monitoring, :m], desc: "Directory file of service monitoring json"
|
118
|
+
deploy.flag [:service_backup, :k], desc: "Directory file of service backup json"
|
119
|
+
deploy.flag [:type, :t], desc: "Deployment type, option(test, manual, provider)"
|
120
|
+
deploy.flag [:provider, :p], desc: "Directory file of compute provider json"
|
121
|
+
|
122
|
+
deploy.action do |global_options, options, args|
|
123
|
+
|
124
|
+
cli = HighLine.new
|
125
|
+
|
126
|
+
name = options[:name] || cli.ask("Name of new instance: ")
|
127
|
+
desc = options[:desc] || cli.ask("Description of new instance: ")
|
128
|
+
blueprint_file = options[:blueprint] || cli.ask("Blueprint directory File JSON: ")
|
129
|
+
logging_file = options[:service_logging] || cli.ask("Service logging directory File JSON (optional): ")
|
130
|
+
monitoring_file = options[:service_monitoring] || cli.ask("Service monitoring directory File JSON (optional): ")
|
131
|
+
backup_file = options[:service_backup] || cli.ask("Service backup directory File JSON (optional): ")
|
132
|
+
deploy_type = options[:type] || cli.choose do |menu|
|
133
|
+
menu.prompt = "Please choose deployment type? "
|
134
|
+
menu.choices(:test)
|
135
|
+
menu.choices(:manual)
|
136
|
+
menu.choices(:provider)
|
137
|
+
end
|
138
|
+
|
139
|
+
if deploy_type.present?
|
140
|
+
if deploy_type.to_s == "provider"
|
141
|
+
provider_file = options[:provider] || cli.ask("Compute provider directory File JSON: ")
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
deploy_type = deploy_type == 'manual' ? 'barebone' : deploy_type
|
146
|
+
parameters = {
|
147
|
+
name: name,
|
148
|
+
desc: desc,
|
149
|
+
custom: options[:custom],
|
150
|
+
blueprint: blueprint_file,
|
151
|
+
service_logging: logging_file,
|
152
|
+
service_monitoring: monitoring_file,
|
153
|
+
service_backup: backup_file,
|
154
|
+
type: deploy_type,
|
155
|
+
provider: provider_file
|
156
|
+
}
|
157
|
+
|
158
|
+
instance = Models::Instance.new($credential)
|
159
|
+
instance.deploy(parameters)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
c.desc "List and filter my instance"
|
164
|
+
c.command :list do |list|
|
165
|
+
|
166
|
+
list.switch [:register_type, :r], :desc => "Filter registered instances, option(all, registered, unregistered)"
|
167
|
+
list.flag [:type, :t], :desc => "Filter based deploy type of instance, option(all, test, manual, provider)"
|
168
|
+
list.flag [:cloud, :c], :desc => "Filter based Cloud Provider, option(all, aws, gcompute, docean, openstack, XenServer)"
|
169
|
+
list.flag [:page, :p], :desc => "Filter based number of page", :default_value => 1
|
170
|
+
|
171
|
+
list.action do |global_options, options, args|
|
172
|
+
|
173
|
+
cli = HighLine.new
|
174
|
+
register_type = options[:register_type] || cli.choose do |menu|
|
175
|
+
menu.prompt = "Please choose filter of register type? "
|
176
|
+
menu.choice(:all)
|
177
|
+
menu.choices(:registered)
|
178
|
+
menu.choices(:unregistered)
|
179
|
+
menu.default = :all
|
180
|
+
end
|
181
|
+
register_type = register_type.to_s == "all" ? nil : register_type
|
182
|
+
type = options[:type] || cli.choose do |menu|
|
183
|
+
menu.prompt = "Please choose filter of instance deployment type? "
|
184
|
+
menu.choice(:all)
|
185
|
+
menu.choices(:test)
|
186
|
+
menu.choices(:manual)
|
187
|
+
menu.choices(:provider)
|
188
|
+
menu.default = :all
|
189
|
+
end
|
190
|
+
type = type.to_s == "all" ? nil : type
|
191
|
+
|
192
|
+
if type.to_s == "provider"
|
193
|
+
provider = options[:cloud] || cli.choose do |menu|
|
194
|
+
menu.prompt = "Please choose filter of instance provider? "
|
195
|
+
menu.choice(:all)
|
196
|
+
menu.choices(:aws)
|
197
|
+
menu.choices(:gcompute)
|
198
|
+
menu.choices(:docean)
|
199
|
+
menu.choices(:openstack)
|
200
|
+
menu.choices(:XenServer)
|
201
|
+
menu.default = :all
|
202
|
+
end
|
203
|
+
|
204
|
+
provider = provider.to_s == "all" ? nil : provider
|
205
|
+
end
|
206
|
+
|
207
|
+
filter = { register_type: register_type, type: type, provider: provider, page: options[:page] }
|
208
|
+
|
209
|
+
instance = Models::Instance.new($credential)
|
210
|
+
instance.all(filter)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
c.desc "Search and filter my instance"
|
215
|
+
c.command :search do |search|
|
216
|
+
|
217
|
+
search.switch [:register_type, :r], :desc => "Filter registered instances option(all, registered, unregistered)"
|
218
|
+
search.flag [:type, :t], :desc => "Filter based deploy type of instance option(all, test, manual, provider)"
|
219
|
+
search.flag [:cloud, :c], :desc => "Filter based Cloud Provider option(all, aws, gcompute, docean, openstack, XenServer)"
|
220
|
+
search.flag [:page, :p], :desc => "Filter based number of page", :default_value => 1
|
221
|
+
search.flag [:keyword, :k], :desc => "Search instance based keyword"
|
222
|
+
|
223
|
+
search.action do |global_options, options, args|
|
224
|
+
|
225
|
+
cli = HighLine.new
|
226
|
+
|
227
|
+
register_type = options[:register_type] || cli.choose do |menu|
|
228
|
+
menu.prompt = "Please choose filter of register type? "
|
229
|
+
menu.choice(:all)
|
230
|
+
menu.choices(:registered)
|
231
|
+
menu.choices(:unregistered)
|
232
|
+
menu.default = :all
|
233
|
+
end
|
234
|
+
register_type = register_type.to_s == "all" ? nil : register_type
|
235
|
+
type = options[:type] || cli.choose do |menu|
|
236
|
+
menu.prompt = "Please choose filter of instance deployment type? "
|
237
|
+
menu.choice(:all)
|
238
|
+
menu.choices(:test)
|
239
|
+
menu.choices(:manual)
|
240
|
+
menu.choices(:provider)
|
241
|
+
menu.default = :all
|
242
|
+
end
|
243
|
+
type = type.to_s == "all" ? nil : type
|
244
|
+
|
245
|
+
if type.to_s == "provider"
|
246
|
+
provider = options[:cloud] || cli.choose do |menu|
|
247
|
+
menu.prompt = "Please choose filter of instance provider? "
|
248
|
+
menu.choice(:all)
|
249
|
+
menu.choices(:aws)
|
250
|
+
menu.choices(:gcompute)
|
251
|
+
menu.choices(:docean)
|
252
|
+
menu.choices(:openstack)
|
253
|
+
menu.choices(:XenServer)
|
254
|
+
menu.default = :all
|
255
|
+
end
|
256
|
+
|
257
|
+
provider = provider.to_s == "all" ? nil : provider
|
258
|
+
end
|
259
|
+
keyword = options[:keyword] || cli.ask("Search keyword: ")
|
260
|
+
|
261
|
+
filter = { register_type: register_type, type: type, provider: provider, page: options[:page], keyword: keyword, search: true }
|
262
|
+
|
263
|
+
instance = Models::Instance.new($credential)
|
264
|
+
instance.all(filter)
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
c.desc "Show detail my instance"
|
269
|
+
c.command :show do |show|
|
270
|
+
|
271
|
+
show.flag [:id, :i], :desc => "Instance id or name"
|
272
|
+
show.action do |global_options, options, args|
|
273
|
+
|
274
|
+
cli = HighLine.new
|
275
|
+
name_or_id = options[:id] || cli.ask("Name or ID of Instance: ")
|
276
|
+
|
277
|
+
instance = Models::Instance.new($credential, name_or_id)
|
278
|
+
instance.show
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
desc "Manage blueprint or custom blueprint"
|
284
|
+
command :blueprint do |c|
|
285
|
+
|
286
|
+
c.desc 'List and filter available blueprint'
|
287
|
+
c.command :list do |list|
|
288
|
+
|
289
|
+
list.switch [:custom, :c], :desc => "Define custom blueprint", :default_value => false
|
290
|
+
list.flag [:os, :o], :desc => "Filter based operating system option(all, linux, windows)"
|
291
|
+
list.flag [:page, :p], :desc => "Filter based number of page", :default_value => 1
|
292
|
+
|
293
|
+
list.action do |global_options,options,args|
|
294
|
+
|
295
|
+
cli = HighLine.new
|
296
|
+
os = options[:os] || cli.choose do |menu|
|
297
|
+
menu.prompt = "Please choose filter of instance provider? "
|
298
|
+
menu.choice(:all)
|
299
|
+
menu.choices(:linux)
|
300
|
+
menu.choices(:windows)
|
301
|
+
menu.default = :all
|
302
|
+
end
|
303
|
+
os = os.to_s == "all" ? nil : os
|
304
|
+
|
305
|
+
filter = { custom: options[:custom], os: os, page: options[:page] }
|
306
|
+
blueprints = Models::Blueprint.new($credential, nil, options[:custom])
|
307
|
+
|
308
|
+
blueprints.all(filter)
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
c.desc 'Search and filter blueprint'
|
313
|
+
c.command :search do |search|
|
314
|
+
search.switch [:custom, :c], :desc => "Define custom blueprint", :default_value => false
|
315
|
+
search.flag [:os, :o], :desc => "Filter based operating system option(all, linux, windows)"
|
316
|
+
search.flag [:page, :p], :desc => "Filter based number of page", :default_value => 1
|
317
|
+
search.flag [:keyword, :k], :desc => "Search blueprint based keyword"
|
318
|
+
|
319
|
+
search.action do |global_options,options,args|
|
320
|
+
|
321
|
+
cli = HighLine.new
|
322
|
+
os = options[:os] || cli.choose do |menu|
|
323
|
+
menu.prompt = "Please choose os filter? "
|
324
|
+
menu.choice(:all)
|
325
|
+
menu.choices(:linux)
|
326
|
+
menu.choices(:windows)
|
327
|
+
menu.default = :all
|
328
|
+
end
|
329
|
+
os = os.to_s == "all" ? nil : os
|
330
|
+
keyword = options[:keyword] || cli.ask("Search keyword: ")
|
331
|
+
|
332
|
+
filter = { custom: options[:custom], os: os, page: options[:page], keyword: keyword }
|
333
|
+
blueprints = Models::Blueprint.new($credential, nil, options[:custom])
|
334
|
+
blueprints.all(filter)
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
c.desc 'Show detail blueprint'
|
339
|
+
c.command :show do |show|
|
340
|
+
show.flag [:id, :i], :desc => "Blueprint id or slug"
|
341
|
+
show.switch [:custom, :c], :desc => "Define custom blueprint", :default_value => false
|
342
|
+
|
343
|
+
show.action do |global_options, options, args|
|
344
|
+
|
345
|
+
cli = HighLine.new
|
346
|
+
slug_or_id = options[:id] || cli.ask("ID or Slug of blueprint: ")
|
347
|
+
|
348
|
+
blueprint = Models::Blueprint.new($credential, slug_or_id, options[:custom])
|
349
|
+
blueprint.show
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
353
|
+
c.desc 'Delete custom blueprint'
|
354
|
+
c.command :delete do |delete|
|
355
|
+
delete.desc 'Blueprint id or slug'
|
356
|
+
delete.flag [:id, :i]
|
357
|
+
|
358
|
+
delete.action do |global_options,options,args|
|
359
|
+
|
360
|
+
cli = HighLine.new
|
361
|
+
id = options[:id] || cli.ask("Id or Slug Custom Blueprint: ")
|
362
|
+
|
363
|
+
blueprints = Models::Blueprint.new($credential, id)
|
364
|
+
blueprints.delete
|
365
|
+
end
|
366
|
+
end
|
367
|
+
|
368
|
+
c.desc 'Create custom blueprint'
|
369
|
+
c.command :create do |create|
|
370
|
+
|
371
|
+
create.desc 'Blueprint name'
|
372
|
+
create.flag [:name, :n]
|
373
|
+
create.desc 'Blueprint operating system, option(linux, windows)'
|
374
|
+
create.flag [:operating_system, :o]
|
375
|
+
create.desc 'Blueprint description'
|
376
|
+
create.flag [:description, :d]
|
377
|
+
create.desc 'Blueprint specifig system'
|
378
|
+
create.flag [:system, :s]
|
379
|
+
create.desc 'Blueprint profiles'
|
380
|
+
create.flag [:profile, :p]
|
381
|
+
|
382
|
+
create.action do |global_options,options,args|
|
383
|
+
cli = HighLine.new
|
384
|
+
name = options[:name] || cli.ask("Name of blueprint: ")
|
385
|
+
os = options[:operating_system] || cli.choose do |menu|
|
386
|
+
menu.prompt = "Please choose your blueprint operating system? "
|
387
|
+
menu.choice(:linux)
|
388
|
+
menu.choices(:windows)
|
389
|
+
menu.default = :linux
|
390
|
+
end
|
391
|
+
description = options[:description] || cli.ask("Description: ")
|
392
|
+
systems = Models::System.new($credential)
|
393
|
+
data = systems.retrieve_data
|
394
|
+
system = options[:system] || cli.choose do |menu|
|
395
|
+
menu.prompt = "Please choose your blueprint system? "
|
396
|
+
data.each do |system|
|
397
|
+
menu.choice(system["name"])
|
398
|
+
end
|
399
|
+
end
|
400
|
+
profiles = options[:profile] || cli.ask("Add profiles (call #{Helpers::AlertMessage.show_information_message('list_profiles', true)} to show profiles) eg: 'Ruby, Postgresql': ")
|
401
|
+
|
402
|
+
blueprints = Models::Blueprint.new($credential)
|
403
|
+
blueprints.create!(name: name, description: description, os: os, system: system, profiles: profiles)
|
404
|
+
end
|
405
|
+
end
|
406
|
+
|
407
|
+
c.desc 'Export blueprint parameters'
|
408
|
+
c.command :export do |export|
|
409
|
+
|
410
|
+
export.flag [:id, :i], desc: 'Blueprint name or id'
|
411
|
+
export.switch [:custom, :c], desc: "Define custom blueprint", :default_value => false
|
412
|
+
|
413
|
+
export.action do |global_options,options,args|
|
414
|
+
|
415
|
+
cli = HighLine.new
|
416
|
+
name_or_id = options[:id] || cli.ask("ID or Slug of Blueprint: ")
|
417
|
+
|
418
|
+
blueprint = Models::Blueprint.new($credential, name_or_id, options[:custom])
|
419
|
+
blueprint.export
|
420
|
+
end
|
421
|
+
end
|
422
|
+
|
423
|
+
c.desc 'Validate blueprint parameters'
|
424
|
+
c.command :valid do |validate|
|
425
|
+
|
426
|
+
validate.desc 'Directory file of blueprint json'
|
427
|
+
validate.flag [:file, :f]
|
428
|
+
|
429
|
+
validate.action do |global_options,options,args|
|
430
|
+
|
431
|
+
cli = HighLine.new
|
432
|
+
file_path = options[:file] || cli.ask("Directory of Blueprint: ")
|
433
|
+
|
434
|
+
blueprint = Models::Blueprint.new($credential)
|
435
|
+
blueprint.validate(file_path)
|
436
|
+
|
437
|
+
end
|
438
|
+
end
|
439
|
+
end
|
440
|
+
|
441
|
+
desc "Manage stack template"
|
442
|
+
command :stack_template do |c|
|
443
|
+
|
444
|
+
c.desc "List stack template"
|
445
|
+
c.command :list do |list|
|
446
|
+
list.action do |global_options, options, args|
|
447
|
+
|
448
|
+
umbreo_stack_template = Models::UmbreoStackTemplate::new($credential)
|
449
|
+
umbreo_stack_template.all
|
450
|
+
|
451
|
+
end
|
452
|
+
end
|
453
|
+
|
454
|
+
c.desc "Export blueprint parameters from stack template"
|
455
|
+
c.command :blueprint_export do |export|
|
456
|
+
|
457
|
+
export.desc "Stack template id or name"
|
458
|
+
export.flag [:id, :i]
|
459
|
+
|
460
|
+
export.action do |global_options, options, args|
|
461
|
+
|
462
|
+
cli = HighLine.new
|
463
|
+
name_or_id = options[GLI::Command::PARENT][:id] || cli.ask("Name or ID of Stack Template: ")
|
464
|
+
|
465
|
+
umbreo_stack_template = Models::UmbreoStackTemplate.new($credential, name_or_id)
|
466
|
+
umbreo_stack_template.export_bluprints
|
467
|
+
|
468
|
+
end
|
469
|
+
end
|
470
|
+
|
471
|
+
c.desc "Search stack template"
|
472
|
+
c.command :search do |search|
|
473
|
+
|
474
|
+
search.desc "Keyword for search"
|
475
|
+
search.flag [:keyword, :k]
|
476
|
+
|
477
|
+
search.action do |global_options, options, args|
|
478
|
+
|
479
|
+
cli = HighLine.new
|
480
|
+
keyword = options[:keyword] || cli.ask("Keyword of Stack Template: ")
|
481
|
+
|
482
|
+
umbreo_stack_template = Models::UmbreoStackTemplate.new($credential)
|
483
|
+
umbreo_stack_template.search(keyword)
|
484
|
+
|
485
|
+
end
|
486
|
+
end
|
487
|
+
|
488
|
+
c.desc "Show detail stack template"
|
489
|
+
c.command :show do |search|
|
490
|
+
|
491
|
+
search.desc "Keyword for search"
|
492
|
+
search.flag [:id, :i]
|
493
|
+
|
494
|
+
search.action do |global_options, options, args|
|
495
|
+
|
496
|
+
cli = HighLine.new
|
497
|
+
name_or_id = options[:id] || cli.ask("Name or id of Stack Template: ")
|
498
|
+
|
499
|
+
umbreo_stack_template = Models::UmbreoStackTemplate.new($credential, name_or_id)
|
500
|
+
umbreo_stack_template.show
|
501
|
+
|
502
|
+
end
|
503
|
+
end
|
504
|
+
|
505
|
+
c.desc "Export stack template parameters"
|
506
|
+
c.command :export do |export|
|
507
|
+
|
508
|
+
export.desc "Stack template id or name"
|
509
|
+
export.flag [:id, :i]
|
510
|
+
|
511
|
+
export.action do |global_options, options, args|
|
512
|
+
|
513
|
+
cli = HighLine.new
|
514
|
+
name_or_id = options[GLI::Command::PARENT][:id] || cli.ask("Name or ID of Stack Template: ")
|
515
|
+
|
516
|
+
umbreo_stack_template = Models::UmbreoStackTemplate.new($credential, name_or_id)
|
517
|
+
umbreo_stack_template.export
|
518
|
+
|
519
|
+
end
|
520
|
+
end
|
521
|
+
end
|
522
|
+
|
523
|
+
desc "Manage my stack"
|
524
|
+
command :stack do |c|
|
525
|
+
|
526
|
+
c.desc 'List available stack'
|
527
|
+
c.command :list do |list|
|
528
|
+
list.action do |global_options,options,args|
|
529
|
+
|
530
|
+
stacks = Models::Stack.new($credential)
|
531
|
+
stacks.all
|
532
|
+
end
|
533
|
+
end
|
534
|
+
|
535
|
+
c.desc 'Search stack'
|
536
|
+
c.command :search do |search|
|
537
|
+
|
538
|
+
search.desc 'Stack keyword'
|
539
|
+
search.flag [:keyword, :k]
|
540
|
+
|
541
|
+
search.action do |global_options,options,args|
|
542
|
+
|
543
|
+
cli = HighLine.new
|
544
|
+
keyword = options[:keyword] || cli.ask("Keyword of Stack: ")
|
545
|
+
|
546
|
+
stacks = Models::Stack.new($credential)
|
547
|
+
stacks.search(keyword)
|
548
|
+
|
549
|
+
end
|
550
|
+
end
|
551
|
+
|
552
|
+
c.desc 'Show detail stack'
|
553
|
+
c.command :show do |show|
|
554
|
+
show.desc 'Stack name or id'
|
555
|
+
show.flag [:id, :i]
|
556
|
+
|
557
|
+
show.action do |global_options,options,args|
|
558
|
+
|
559
|
+
cli = HighLine.new
|
560
|
+
name = options[:id] || cli.ask("Name or ID of Stack: ")
|
561
|
+
|
562
|
+
stack = Models::Stack.new($credential, name)
|
563
|
+
stack.show
|
564
|
+
end
|
565
|
+
end
|
566
|
+
|
567
|
+
c.desc 'Create stack'
|
568
|
+
c.command :create do |create|
|
569
|
+
|
570
|
+
create.desc 'Stack template name or id'
|
571
|
+
create.flag [:id, :i]
|
572
|
+
|
573
|
+
create.desc 'Stack name'
|
574
|
+
create.flag [:name, :n]
|
575
|
+
|
576
|
+
create.desc 'Stack description'
|
577
|
+
create.flag [:desc, :d]
|
578
|
+
|
579
|
+
create.action do |global_options,options,args|
|
580
|
+
|
581
|
+
cli = HighLine.new
|
582
|
+
name_or_id = options[:id] || cli.ask("Name or ID of Stack template: ")
|
583
|
+
name = options[:name] || cli.ask("Name of Stack: ")
|
584
|
+
desc = options[:desc] || cli.ask("Description of Stack: ")
|
585
|
+
|
586
|
+
umbreo_stack_template = Models::UmbreoStackTemplate.new($credential, name_or_id)
|
587
|
+
roles = umbreo_stack_template.show(true)["roles"] rescue nil
|
588
|
+
|
589
|
+
stack_parameter = { umbreo_stack_template_id: name_or_id, name: name, desc: desc }
|
590
|
+
|
591
|
+
if roles.present?
|
592
|
+
roles_cli = []
|
593
|
+
|
594
|
+
i = 0
|
595
|
+
roles.each_with_index do |role, index|
|
596
|
+
|
597
|
+
answer = cli.choose do |menu|
|
598
|
+
menu.prompt = "Will you add #{role["name"]}? "
|
599
|
+
menu.choice(:yes)
|
600
|
+
menu.choices(:no)
|
601
|
+
menu.default = :no
|
602
|
+
end
|
603
|
+
|
604
|
+
if answer == :yes
|
605
|
+
|
606
|
+
(1..role["max_server"]).each do |role_server|
|
607
|
+
|
608
|
+
instance_name = cli.ask("Name of new instance: ")
|
609
|
+
instance_desc = cli.ask("Description of new instance: ")
|
610
|
+
instance_blueprint_file = cli.ask("Blueprint directory File JSON: ")
|
611
|
+
instance_logging_file = cli.ask("Service logging directory File JSON (optional): ")
|
612
|
+
instance_monitoring_file = cli.ask("Service monitoring directory File JSON (optional): ")
|
613
|
+
instance_backup_file = cli.ask("Service backup directory File JSON (optional): ")
|
614
|
+
instance_deploy_type = cli.choose do |menu|
|
615
|
+
menu.prompt = "Please choose deployment type? "
|
616
|
+
menu.choices(:test)
|
617
|
+
menu.choices(:manual)
|
618
|
+
menu.choices(:provider)
|
619
|
+
end
|
620
|
+
|
621
|
+
if instance_deploy_type.present?
|
622
|
+
if instance_deploy_type.to_s == "provider"
|
623
|
+
instance_provider_file = cli.ask("Compute provider directory File JSON: ")
|
624
|
+
end
|
625
|
+
end
|
626
|
+
|
627
|
+
instance_deploy_type = instance_deploy_type == 'manual' ? 'barebone' : instance_deploy_type
|
628
|
+
parameters = {
|
629
|
+
roleable_id: role["id"],
|
630
|
+
roleable_type: 'UmbreoRole',
|
631
|
+
name: instance_name,
|
632
|
+
desc: instance_desc,
|
633
|
+
blueprint: instance_blueprint_file,
|
634
|
+
service_logging: instance_logging_file,
|
635
|
+
service_monitoring: instance_monitoring_file,
|
636
|
+
service_backup: instance_backup_file,
|
637
|
+
type: instance_deploy_type,
|
638
|
+
provider: instance_provider_file
|
639
|
+
}
|
640
|
+
|
641
|
+
roles_cli[i] = parameters
|
642
|
+
i += 1
|
643
|
+
end
|
644
|
+
end
|
645
|
+
end
|
646
|
+
|
647
|
+
stack_parameter[:user_node_attributes] = roles_cli
|
648
|
+
|
649
|
+
stack = Models::Stack.new($credential)
|
650
|
+
stack.deploy(stack_parameter)
|
651
|
+
else
|
652
|
+
Helpers::AlertMessage.show_error_message("Stack template no have blueprints.")
|
653
|
+
end
|
654
|
+
end
|
655
|
+
end
|
656
|
+
end
|
657
|
+
|
658
|
+
desc 'Manage cloud provider'
|
659
|
+
command :cloud_provider do |c|
|
660
|
+
|
661
|
+
c.desc 'List available cloud provider'
|
662
|
+
c.command :list do |list|
|
663
|
+
list.action do |global_options, options, args|
|
664
|
+
cloud_provider = Models::CloudProvider.new($credential)
|
665
|
+
cloud_provider.all
|
666
|
+
end
|
667
|
+
end
|
668
|
+
|
669
|
+
c.desc 'Export cloud provider parameters'
|
670
|
+
c.command :export do |export|
|
671
|
+
|
672
|
+
export.flag [:id, :i], :desc => "Cloud provider id or slug"
|
673
|
+
|
674
|
+
export.action do |global_options, options, args|
|
675
|
+
|
676
|
+
cli = HighLine.new
|
677
|
+
slug_or_id = options[:id] || cli.ask("ID or Slug of Cloud Provider: ")
|
678
|
+
|
679
|
+
cloud_provider = Models::CloudProvider.new($credential, slug_or_id)
|
680
|
+
cloud_provider.export
|
681
|
+
end
|
682
|
+
end
|
683
|
+
|
684
|
+
c.desc 'Validate cloud provider parameters'
|
685
|
+
c.command :valid do |validate|
|
686
|
+
|
687
|
+
validate.desc 'Directory file of cloud provider json'
|
688
|
+
validate.flag [:file, :f]
|
689
|
+
|
690
|
+
validate.action do |global_options,options,args|
|
691
|
+
|
692
|
+
cli = HighLine.new
|
693
|
+
file_path = options[:file] || cli.ask("Directory File JSON: ")
|
694
|
+
|
695
|
+
blueprint = Models::CloudProvider.new($credential)
|
696
|
+
blueprint.validate(file_path)
|
697
|
+
|
698
|
+
end
|
699
|
+
end
|
700
|
+
end
|
701
|
+
|
702
|
+
desc 'Create my provder'
|
703
|
+
command "provider:create" do |c|
|
704
|
+
|
705
|
+
Models::CloudProvider::CLOUDS.each do |cloud|
|
706
|
+
c.desc "Create #{cloud} provider"
|
707
|
+
c.command cloud.downcase.to_sym do |create|
|
708
|
+
|
709
|
+
create.flag [:file, :f], desc: 'Directory file of cloud provider json'
|
710
|
+
create.flag [:name, :n], desc: "Provider name", type: String
|
711
|
+
create.flag [:desc, :d], desc: "Provider description", type: String
|
712
|
+
|
713
|
+
create.action do |global_options,options,args|
|
714
|
+
|
715
|
+
cli = HighLine.new
|
716
|
+
name = options[:name] || cli.ask("Provider Name: ")
|
717
|
+
description = options[:desc] || cli.ask("Description (optional): ")
|
718
|
+
file_path = options[:file] || cli.ask("Directory of File: ")
|
719
|
+
|
720
|
+
provider = Models::Provider.new($credential)
|
721
|
+
provider.create(cloud.to_sym, name, description, file_path)
|
722
|
+
|
723
|
+
end
|
724
|
+
end
|
725
|
+
end
|
726
|
+
end
|
727
|
+
|
728
|
+
desc "Manage to show my provider"
|
729
|
+
command :provider do |c|
|
730
|
+
|
731
|
+
c.desc "List and filter my provider"
|
732
|
+
c.command :list do |list|
|
733
|
+
|
734
|
+
list.flag [:cloud, :c], :desc => "Cloud provider id or slug"
|
735
|
+
list.flag [:page, :p], :desc => "Filter list based number of page", :default_value => 1
|
736
|
+
|
737
|
+
list.action do |global_options, options, args|
|
738
|
+
|
739
|
+
cli = HighLine.new
|
740
|
+
cloud = options[:cloud] || cli.choose do |menu|
|
741
|
+
menu.prompt = "Please choose Cloud Provider filter? "
|
742
|
+
menu.choice(:all)
|
743
|
+
Models::CloudProvider::CLOUDS.each do |cloud|
|
744
|
+
menu.choice(cloud)
|
745
|
+
end
|
746
|
+
menu.default = :all
|
747
|
+
end
|
748
|
+
cloud = cloud.to_s == "all" ? nil : cloud
|
749
|
+
|
750
|
+
filter = { page: options[:page], umbreo_cloud_provider_id: cloud }
|
751
|
+
|
752
|
+
providers = Models::Provider.new($credential)
|
753
|
+
providers.all(filter)
|
754
|
+
end
|
755
|
+
end
|
756
|
+
|
757
|
+
c.desc "Search and filter my provider"
|
758
|
+
c.command :search do |search|
|
759
|
+
|
760
|
+
search.flag [:cloud, :c], :desc => "Cloud provider id or slug"
|
761
|
+
search.flag [:keyword, :k], :desc => "Search my provider based keyword"
|
762
|
+
search.flag [:page, :p], :desc => "Filter list based number of page", :default_value => 1
|
763
|
+
|
764
|
+
search.action do |global_options, options, args|
|
765
|
+
|
766
|
+
cli = HighLine.new
|
767
|
+
cloud = options[:cloud] || cli.choose do |menu|
|
768
|
+
menu.prompt = "Please choose Cloud Provider filter? "
|
769
|
+
menu.choice(:all)
|
770
|
+
Models::CloudProvider::CLOUDS.each do |cloud|
|
771
|
+
menu.choice(cloud)
|
772
|
+
end
|
773
|
+
menu.default = :all
|
774
|
+
end
|
775
|
+
keyword = options[:keyword] || cli.ask("Search keyword: ")
|
776
|
+
cloud = cloud.to_s == "all" ? nil : cloud
|
777
|
+
|
778
|
+
filter = { page: options[:page], umbreo_cloud_provider_id: cloud, keyword: keyword }
|
779
|
+
|
780
|
+
providers = Models::Provider.new($credential)
|
781
|
+
providers.all(filter)
|
782
|
+
end
|
783
|
+
end
|
784
|
+
|
785
|
+
c.desc "Show details my provider"
|
786
|
+
c.command :show do |show|
|
787
|
+
|
788
|
+
show.flag [:id, :i], :desc => "Provider id or name"
|
789
|
+
show.action do |global_options, options, args|
|
790
|
+
|
791
|
+
cli = HighLine.new
|
792
|
+
name_or_id = options[:id] || cli.ask("Name or ID of Provider: ")
|
793
|
+
|
794
|
+
provider = Models::Provider.new($credential, name_or_id)
|
795
|
+
provider.show
|
796
|
+
end
|
797
|
+
end
|
798
|
+
end
|
799
|
+
|
800
|
+
desc "Manage Digital ocean cloud provider"
|
801
|
+
command "provider:digital_ocean" do |c|
|
802
|
+
|
803
|
+
c.desc 'Export digital ocean provider parameters'
|
804
|
+
c.command :export do |list|
|
805
|
+
|
806
|
+
list.flag [:id, :i], :desc => "My digital ocean provider id or name"
|
807
|
+
|
808
|
+
list.action do |global_options, options, args|
|
809
|
+
|
810
|
+
cli = HighLine.new
|
811
|
+
id_or_name = options[:id] || cli.ask("Name or ID of Provider: ")
|
812
|
+
|
813
|
+
provider = Models::DigitalOceanProvider.new($credential, id_or_name)
|
814
|
+
provider.export
|
815
|
+
|
816
|
+
end
|
817
|
+
end
|
818
|
+
|
819
|
+
c.desc 'Validate compute provider parameters'
|
820
|
+
c.command :valid do |validate|
|
821
|
+
|
822
|
+
validate.desc 'Directory file of compute provider json'
|
823
|
+
validate.flag [:file, :f]
|
824
|
+
|
825
|
+
validate.action do |global_options,options,args|
|
826
|
+
|
827
|
+
cli = HighLine.new
|
828
|
+
file_path = options[:file] || cli.ask("Directory of File: ")
|
829
|
+
|
830
|
+
serviceprovider = Models::DigitalOceanProvider.new($credential)
|
831
|
+
serviceprovider.validate(file_path)
|
832
|
+
|
833
|
+
end
|
834
|
+
end
|
835
|
+
|
836
|
+
c.desc 'List digital ocean available image'
|
837
|
+
c.command :images do |list|
|
838
|
+
|
839
|
+
list.flag [:id, :i], :desc => "Provider name or id"
|
840
|
+
|
841
|
+
list.action do |global_options, options, args|
|
842
|
+
|
843
|
+
cli = HighLine.new
|
844
|
+
id_or_name = options[:id] || cli.ask("Name or ID of Provider: ")
|
845
|
+
|
846
|
+
provider = Models::DigitalOceanProvider.new($credential, id_or_name)
|
847
|
+
provider.digital_ocean_image_list
|
848
|
+
|
849
|
+
end
|
850
|
+
end
|
851
|
+
|
852
|
+
c.desc 'List digital ocean available flavor'
|
853
|
+
c.command :flavors do |list|
|
854
|
+
|
855
|
+
list.flag [:id, :i], :desc => "Provider name or id"
|
856
|
+
list.flag [:image, :m], :desc => "Digital ocean image"
|
857
|
+
|
858
|
+
list.action do |global_options, options, args|
|
859
|
+
|
860
|
+
cli = HighLine.new
|
861
|
+
id_or_name = options[:id] || cli.ask("Name or ID of digital ocean Provider: ")
|
862
|
+
image = options[:image] || cli.ask("Image of digital ocean Provider: ")
|
863
|
+
|
864
|
+
provider = Models::DigitalOceanProvider.new($credential, id_or_name)
|
865
|
+
provider.digital_ocean_flavor_list(image)
|
866
|
+
|
867
|
+
end
|
868
|
+
end
|
869
|
+
|
870
|
+
c.desc 'List digital ocean available region'
|
871
|
+
c.command :regions do |list|
|
872
|
+
|
873
|
+
list.flag [:id, :i], :desc => "Provider name or id"
|
874
|
+
list.flag [:image, :m], :desc => "Digital ocean image"
|
875
|
+
|
876
|
+
list.action do |global_options, options, args|
|
877
|
+
|
878
|
+
cli = HighLine.new
|
879
|
+
id_or_name = options[:id] || cli.ask("Name or ID of digital ocean Provider: ")
|
880
|
+
image = options[:image] || cli.ask("Image of digital ocean provider: ")
|
881
|
+
|
882
|
+
provider = Models::DigitalOceanProvider.new($credential, id_or_name)
|
883
|
+
provider.digital_ocean_region_list(image)
|
884
|
+
|
885
|
+
end
|
886
|
+
end
|
887
|
+
end
|
888
|
+
|
889
|
+
desc "Manage amazon web service cloud provider"
|
890
|
+
command "provider:amazon_web_service" do |c|
|
891
|
+
|
892
|
+
c.desc 'List amazon web service available image'
|
893
|
+
c.command :images do |list|
|
894
|
+
|
895
|
+
list.flag [:id, :i], :desc => "Provider name or id"
|
896
|
+
|
897
|
+
list.action do |global_options, options, args|
|
898
|
+
|
899
|
+
cli = HighLine.new
|
900
|
+
id_or_name = options[:id] || cli.ask("Name or ID of Provider: ")
|
901
|
+
|
902
|
+
provider = Models::AmazonWebServiceProvider.new($credential, id_or_name)
|
903
|
+
provider.aws_image_list
|
904
|
+
|
905
|
+
end
|
906
|
+
end
|
907
|
+
|
908
|
+
c.desc 'List amazon web service available size storage'
|
909
|
+
c.command :sizes do |list|
|
910
|
+
|
911
|
+
list.flag [:id, :i], :desc => "Provider name or id"
|
912
|
+
|
913
|
+
list.action do |global_options, options, args|
|
914
|
+
|
915
|
+
cli = HighLine.new
|
916
|
+
id_or_name = options[:id] || cli.ask("Name or ID of Provider: ")
|
917
|
+
|
918
|
+
provider = Models::AmazonWebServiceProvider.new($credential, id_or_name)
|
919
|
+
provider.aws_size_list
|
920
|
+
|
921
|
+
end
|
922
|
+
end
|
923
|
+
|
924
|
+
c.desc 'List amazon web service available region'
|
925
|
+
c.command :regions do |list|
|
926
|
+
|
927
|
+
list.flag [:id, :i], :desc => "Provider name or id"
|
928
|
+
|
929
|
+
list.action do |global_options, options, args|
|
930
|
+
|
931
|
+
cli = HighLine.new
|
932
|
+
id_or_name = options[:id] || cli.ask("Name or ID of Provider: ")
|
933
|
+
|
934
|
+
provider = Models::AmazonWebServiceProvider.new($credential, id_or_name)
|
935
|
+
provider.region_list
|
936
|
+
|
937
|
+
end
|
938
|
+
end
|
939
|
+
|
940
|
+
c.desc 'List amazon web service available keypair'
|
941
|
+
c.command :keypairs do |list|
|
942
|
+
|
943
|
+
list.flag [:id, :i], :desc => "Provider name or id"
|
944
|
+
|
945
|
+
list.action do |global_options, options, args|
|
946
|
+
|
947
|
+
cli = HighLine.new
|
948
|
+
id_or_name = options[:id] || cli.ask("Name or ID of Provider: ")
|
949
|
+
|
950
|
+
provider = Models::AmazonWebServiceProvider.new($credential, id_or_name)
|
951
|
+
provider.keypairs_list
|
952
|
+
|
953
|
+
end
|
954
|
+
end
|
955
|
+
|
956
|
+
c.desc 'List amazon web service available security group'
|
957
|
+
c.command :security_groups do |list|
|
958
|
+
|
959
|
+
list.flag [:id, :i], :desc => "Provider name or id"
|
960
|
+
|
961
|
+
list.action do |global_options, options, args|
|
962
|
+
|
963
|
+
cli = HighLine.new
|
964
|
+
id_or_name = options[:id] || cli.ask("Name or ID of Provider: ")
|
965
|
+
|
966
|
+
provider = Models::AmazonWebServiceProvider.new($credential, id_or_name)
|
967
|
+
provider.security_group_list
|
968
|
+
|
969
|
+
end
|
970
|
+
end
|
971
|
+
|
972
|
+
c.desc 'Export amazon web service provider parameters'
|
973
|
+
c.command :export do |list|
|
974
|
+
|
975
|
+
list.flag [:id, :i], :desc => "Provider name or id"
|
976
|
+
|
977
|
+
list.action do |global_options, options, args|
|
978
|
+
|
979
|
+
cli = HighLine.new
|
980
|
+
id_or_name = options[:id] || cli.ask("Name or ID of Provider: ")
|
981
|
+
|
982
|
+
provider = Models::AmazonWebServiceProvider.new($credential, id_or_name)
|
983
|
+
provider.export
|
984
|
+
|
985
|
+
end
|
986
|
+
end
|
987
|
+
|
988
|
+
c.desc 'Validate compute provider parameters'
|
989
|
+
c.command :valid do |validate|
|
990
|
+
|
991
|
+
validate.desc 'File Name'
|
992
|
+
validate.flag [:file, :f]
|
993
|
+
|
994
|
+
validate.action do |global_options,options,args|
|
995
|
+
|
996
|
+
cli = HighLine.new
|
997
|
+
file_path = options[:file] || cli.ask("Directory of File: ")
|
998
|
+
|
999
|
+
serviceprovider = Models::AmazonWebServiceProvider.new($credential)
|
1000
|
+
serviceprovider.validate(file_path)
|
1001
|
+
|
1002
|
+
end
|
1003
|
+
end
|
1004
|
+
end
|
1005
|
+
|
1006
|
+
desc "Manage Google compute engine cloud provider"
|
1007
|
+
command "provider:google_ce" do |c|
|
1008
|
+
|
1009
|
+
c.command :regions do |list|
|
1010
|
+
|
1011
|
+
list.flag [:id, :i], :desc => "Provider name or id"
|
1012
|
+
|
1013
|
+
list.action do |global_options, options, args|
|
1014
|
+
|
1015
|
+
cli = HighLine.new
|
1016
|
+
id_or_name = options[:id] || cli.ask("Name or ID of Provider: ")
|
1017
|
+
|
1018
|
+
provider = Models::GoogleComputeEngineProvider.new($credential, id_or_name)
|
1019
|
+
provider.region_list
|
1020
|
+
|
1021
|
+
end
|
1022
|
+
end
|
1023
|
+
|
1024
|
+
c.command :machines do |list|
|
1025
|
+
|
1026
|
+
list.flag [:id, :i], :desc => "Provider name or id"
|
1027
|
+
|
1028
|
+
list.action do |global_options, options, args|
|
1029
|
+
|
1030
|
+
cli = HighLine.new
|
1031
|
+
id_or_name = options[:id] || cli.ask("Name or ID of Provider: ")
|
1032
|
+
|
1033
|
+
provider = Models::GoogleComputeEngineProvider.new($credential, id_or_name)
|
1034
|
+
provider.machine_list
|
1035
|
+
|
1036
|
+
end
|
1037
|
+
end
|
1038
|
+
|
1039
|
+
c.command :images do |list|
|
1040
|
+
|
1041
|
+
list.flag [:id, :i], :desc => "Provider name or id"
|
1042
|
+
|
1043
|
+
list.action do |global_options, options, args|
|
1044
|
+
|
1045
|
+
cli = HighLine.new
|
1046
|
+
id_or_name = options[:id] || cli.ask("Name or ID of Provider: ")
|
1047
|
+
|
1048
|
+
provider = Models::GoogleComputeEngineProvider.new($credential, id_or_name)
|
1049
|
+
provider.image_list
|
1050
|
+
|
1051
|
+
end
|
1052
|
+
end
|
1053
|
+
|
1054
|
+
c.command :networks do |list|
|
1055
|
+
|
1056
|
+
list.flag [:id, :i], :desc => "Provider name or id"
|
1057
|
+
|
1058
|
+
list.action do |global_options, options, args|
|
1059
|
+
|
1060
|
+
cli = HighLine.new
|
1061
|
+
id_or_name = options[:id] || cli.ask("Name or ID of Provider: ")
|
1062
|
+
|
1063
|
+
provider = Models::GoogleComputeEngineProvider.new($credential, id_or_name)
|
1064
|
+
provider.network_list
|
1065
|
+
|
1066
|
+
end
|
1067
|
+
end
|
1068
|
+
|
1069
|
+
c.command :export do |list|
|
1070
|
+
|
1071
|
+
list.flag [:id, :i], :desc => "Provider name or id"
|
1072
|
+
|
1073
|
+
list.action do |global_options, options, args|
|
1074
|
+
|
1075
|
+
cli = HighLine.new
|
1076
|
+
id_or_name = options[:id] || cli.ask("Name or ID of Provider: ")
|
1077
|
+
|
1078
|
+
provider = Models::GoogleComputeEngineProvider.new($credential, id_or_name)
|
1079
|
+
provider.export
|
1080
|
+
|
1081
|
+
end
|
1082
|
+
end
|
1083
|
+
|
1084
|
+
c.desc 'Validate Compute Json Provider'
|
1085
|
+
c.command :valid do |validate|
|
1086
|
+
|
1087
|
+
validate.desc 'File Name'
|
1088
|
+
validate.flag [:file, :f]
|
1089
|
+
|
1090
|
+
validate.action do |global_options,options,args|
|
1091
|
+
|
1092
|
+
cli = HighLine.new
|
1093
|
+
file_path = options[:file] || cli.ask("Directory of File: ")
|
1094
|
+
|
1095
|
+
serviceprovider = Models::GoogleComputeEngineProvider.new($credential)
|
1096
|
+
serviceprovider.validate(file_path)
|
1097
|
+
|
1098
|
+
end
|
1099
|
+
end
|
1100
|
+
end
|
1101
|
+
|
1102
|
+
desc "Manage Openstack cloud provider"
|
1103
|
+
command "provider:openstack" do |c|
|
1104
|
+
|
1105
|
+
c.command :zones do |list|
|
1106
|
+
|
1107
|
+
list.flag [:id, :i], :desc => "Provider name or id"
|
1108
|
+
|
1109
|
+
list.action do |global_options, options, args|
|
1110
|
+
|
1111
|
+
cli = HighLine.new
|
1112
|
+
id_or_name = options[:id] || cli.ask("Name or ID of Provider: ")
|
1113
|
+
|
1114
|
+
provider = Models::OpenstackProvider.new($credential, id_or_name)
|
1115
|
+
provider.zone_list
|
1116
|
+
|
1117
|
+
end
|
1118
|
+
end
|
1119
|
+
|
1120
|
+
c.command :flavors do |list|
|
1121
|
+
|
1122
|
+
list.flag [:id, :i], :desc => "Provider name or id"
|
1123
|
+
|
1124
|
+
list.action do |global_options, options, args|
|
1125
|
+
|
1126
|
+
cli = HighLine.new
|
1127
|
+
id_or_name = options[:id] || cli.ask("Name or ID of Provider: ")
|
1128
|
+
|
1129
|
+
provider = Models::OpenstackProvider.new($credential, id_or_name)
|
1130
|
+
provider.flavor_list
|
1131
|
+
|
1132
|
+
end
|
1133
|
+
end
|
1134
|
+
|
1135
|
+
c.command :images do |list|
|
1136
|
+
|
1137
|
+
list.flag [:id, :i], :desc => "Provider name or id"
|
1138
|
+
|
1139
|
+
list.action do |global_options, options, args|
|
1140
|
+
|
1141
|
+
cli = HighLine.new
|
1142
|
+
id_or_name = options[:id] || cli.ask("Name or ID of Provider: ")
|
1143
|
+
|
1144
|
+
provider = Models::OpenstackProvider.new($credential, id_or_name)
|
1145
|
+
provider.image_list
|
1146
|
+
|
1147
|
+
end
|
1148
|
+
end
|
1149
|
+
|
1150
|
+
c.command :groups do |list|
|
1151
|
+
|
1152
|
+
list.flag [:id, :i], :desc => "Provider name or id"
|
1153
|
+
|
1154
|
+
list.action do |global_options, options, args|
|
1155
|
+
|
1156
|
+
cli = HighLine.new
|
1157
|
+
id_or_name = options[:id] || cli.ask("Name or ID of Provider: ")
|
1158
|
+
|
1159
|
+
provider = Models::OpenstackProvider.new($credential, id_or_name)
|
1160
|
+
provider.group_list
|
1161
|
+
|
1162
|
+
end
|
1163
|
+
end
|
1164
|
+
|
1165
|
+
c.command :keypairs do |list|
|
1166
|
+
|
1167
|
+
list.flag [:id, :i], :desc => "Provider name or id"
|
1168
|
+
|
1169
|
+
list.action do |global_options, options, args|
|
1170
|
+
|
1171
|
+
cli = HighLine.new
|
1172
|
+
id_or_name = options[:id] || cli.ask("Name or ID of Provider: ")
|
1173
|
+
|
1174
|
+
provider = Models::OpenstackProvider.new($credential, id_or_name)
|
1175
|
+
provider.keypair_list
|
1176
|
+
|
1177
|
+
end
|
1178
|
+
end
|
1179
|
+
|
1180
|
+
c.command :export do |list|
|
1181
|
+
|
1182
|
+
list.flag [:id, :i], :desc => "Provider name or id"
|
1183
|
+
|
1184
|
+
list.action do |global_options, options, args|
|
1185
|
+
|
1186
|
+
cli = HighLine.new
|
1187
|
+
id_or_name = options[:id] || cli.ask("Name or ID of Provider: ")
|
1188
|
+
|
1189
|
+
provider = Models::OpenstackProvider.new($credential, id_or_name)
|
1190
|
+
provider.export
|
1191
|
+
|
1192
|
+
end
|
1193
|
+
end
|
1194
|
+
|
1195
|
+
c.desc 'Validate Compute Json Provider'
|
1196
|
+
c.command :valid do |validate|
|
1197
|
+
|
1198
|
+
validate.desc 'File Name'
|
1199
|
+
validate.flag [:file, :f]
|
1200
|
+
|
1201
|
+
validate.action do |global_options,options,args|
|
1202
|
+
|
1203
|
+
cli = HighLine.new
|
1204
|
+
file_path = options[:file] || cli.ask("Directory of File: ")
|
1205
|
+
|
1206
|
+
serviceprovider = Models::OpenstackProvider.new($credential)
|
1207
|
+
serviceprovider.validate(file_path)
|
1208
|
+
|
1209
|
+
end
|
1210
|
+
end
|
1211
|
+
end
|
1212
|
+
|
1213
|
+
desc "Manage Xenserver cloud provider"
|
1214
|
+
command "provider:xenserver" do |c|
|
1215
|
+
|
1216
|
+
c.command :storages do |list|
|
1217
|
+
|
1218
|
+
list.flag [:id, :i], :desc => "Provider name or id"
|
1219
|
+
|
1220
|
+
list.action do |global_options, options, args|
|
1221
|
+
|
1222
|
+
cli = HighLine.new
|
1223
|
+
id_or_name = options[:id] || cli.ask("Name or ID of Provider: ")
|
1224
|
+
|
1225
|
+
provider = Models::XenserverProvider.new($credential, id_or_name)
|
1226
|
+
provider.storage_list
|
1227
|
+
|
1228
|
+
end
|
1229
|
+
end
|
1230
|
+
|
1231
|
+
c.command :vhdfiles do |list|
|
1232
|
+
|
1233
|
+
list.flag [:id, :i], :desc => "Provider name or id"
|
1234
|
+
|
1235
|
+
list.action do |global_options, options, args|
|
1236
|
+
|
1237
|
+
cli = HighLine.new
|
1238
|
+
id_or_name = options[:id] || cli.ask("Name or ID of Provider: ")
|
1239
|
+
|
1240
|
+
provider = Models::XenserverProvider.new($credential, id_or_name)
|
1241
|
+
provider.vhd_list
|
1242
|
+
|
1243
|
+
end
|
1244
|
+
end
|
1245
|
+
|
1246
|
+
c.command :netlist do |list|
|
1247
|
+
|
1248
|
+
list.flag [:id, :i], :desc => "Provider name or id"
|
1249
|
+
|
1250
|
+
list.action do |global_options, options, args|
|
1251
|
+
|
1252
|
+
cli = HighLine.new
|
1253
|
+
id_or_name = options[:id] || cli.ask("Name or ID of Provider: ")
|
1254
|
+
|
1255
|
+
provider = Models::XenserverProvider.new($credential, id_or_name)
|
1256
|
+
provider.net_list
|
1257
|
+
|
1258
|
+
end
|
1259
|
+
end
|
1260
|
+
|
1261
|
+
c.command :export do |list|
|
1262
|
+
|
1263
|
+
list.flag [:id, :i], :desc => "Provider name or id"
|
1264
|
+
|
1265
|
+
list.action do |global_options, options, args|
|
1266
|
+
|
1267
|
+
cli = HighLine.new
|
1268
|
+
id_or_name = options[:id] || cli.ask("Name or ID of Provider: ")
|
1269
|
+
|
1270
|
+
provider = Models::XenserverProvider.new($credential, id_or_name)
|
1271
|
+
provider.export
|
1272
|
+
|
1273
|
+
end
|
1274
|
+
end
|
1275
|
+
|
1276
|
+
c.desc 'Validate Compute Json Provider'
|
1277
|
+
c.command :valid do |validate|
|
1278
|
+
|
1279
|
+
validate.desc 'File Name'
|
1280
|
+
validate.flag [:file, :f]
|
1281
|
+
|
1282
|
+
validate.action do |global_options,options,args|
|
1283
|
+
|
1284
|
+
cli = HighLine.new
|
1285
|
+
file_path = options[:file] || cli.ask("Directory of File: ")
|
1286
|
+
|
1287
|
+
serviceprovider = Models::XenserverProvider.new($credential)
|
1288
|
+
serviceprovider.validate(file_path)
|
1289
|
+
|
1290
|
+
end
|
1291
|
+
end
|
1292
|
+
end
|
1293
|
+
|
1294
|
+
desc "Manage Blueprint for Service Provider"
|
1295
|
+
command :service_provider do |c|
|
1296
|
+
|
1297
|
+
c.desc "List Service Provider"
|
1298
|
+
c.command :list do |list|
|
1299
|
+
|
1300
|
+
list.flag [:type, :t], :desc => "Filter based service provider type, option(all, logging, monitoring, backup)"
|
1301
|
+
list.flag [:resource, :r], :desc => "Filter based resource type, option(all, master, client)"
|
1302
|
+
list.flag [:page, :p], :desc => "Filter based number of page", :default_value => 1
|
1303
|
+
|
1304
|
+
list.action do |global_options, options, args|
|
1305
|
+
|
1306
|
+
cli = HighLine.new
|
1307
|
+
type = options[:type] || cli.choose do |menu|
|
1308
|
+
menu.prompt = "Please choose filter of service provider type? "
|
1309
|
+
menu.choice(:all)
|
1310
|
+
Models::ServiceProvider::TYPE.each do |type|
|
1311
|
+
menu.choice(type)
|
1312
|
+
end
|
1313
|
+
menu.default = :all
|
1314
|
+
end
|
1315
|
+
type = type.to_s == "all" ? nil : type
|
1316
|
+
|
1317
|
+
resource = options[:resource] || cli.choose do |menu|
|
1318
|
+
menu.prompt = "Please choose filter of resource? "
|
1319
|
+
menu.choice(:all)
|
1320
|
+
menu.choice(:master)
|
1321
|
+
menu.choice(:client)
|
1322
|
+
menu.default = :all
|
1323
|
+
end
|
1324
|
+
|
1325
|
+
resource = resource.to_s == "all" ? nil : resource.to_s
|
1326
|
+
|
1327
|
+
filter = { type: type, resource: resource, page: options[:page] }
|
1328
|
+
|
1329
|
+
serviceprovider = Models::ServiceProvider.new($credential)
|
1330
|
+
serviceprovider.all(filter)
|
1331
|
+
end
|
1332
|
+
end
|
1333
|
+
|
1334
|
+
c.desc "Search Service Provider"
|
1335
|
+
c.command :search do |search|
|
1336
|
+
|
1337
|
+
search.flag [:type, :t], :desc => "Filter based service provider type, options(all, logging, monitoring, backup)"
|
1338
|
+
search.flag [:resource, :r], :desc => "Filter based resource type, options(all, master, client)"
|
1339
|
+
search.flag [:page, :p], :desc => "Filter based number of page", :default_value => 1
|
1340
|
+
search.flag [:keyword, :k], :desc => "Filter based keyword"
|
1341
|
+
|
1342
|
+
search.action do |global_options, options, args|
|
1343
|
+
|
1344
|
+
cli = HighLine.new
|
1345
|
+
type = options[:type] || cli.choose do |menu|
|
1346
|
+
menu.prompt = "Please choose filter of service provider type? "
|
1347
|
+
menu.choice(:all)
|
1348
|
+
Models::ServiceProvider::TYPE.each do |type|
|
1349
|
+
menu.choice(type)
|
1350
|
+
end
|
1351
|
+
menu.default = :all
|
1352
|
+
end
|
1353
|
+
type = type.to_s == "all" ? nil : type
|
1354
|
+
|
1355
|
+
resource = options[:resource] || cli.choose do |menu|
|
1356
|
+
menu.prompt = "Please choose filter of resource? "
|
1357
|
+
menu.choice(:all)
|
1358
|
+
menu.choice(:master)
|
1359
|
+
menu.choice(:client)
|
1360
|
+
menu.default = :all
|
1361
|
+
end
|
1362
|
+
resource = resource.to_s == "all" ? nil : resource
|
1363
|
+
keyword = options[:keyword] || cli.ask("Search Keyword: ")
|
1364
|
+
|
1365
|
+
filter = { type: type, resource: resource, page: options[:page], search: true, keyword: keyword }
|
1366
|
+
|
1367
|
+
serviceprovider = Models::ServiceProvider.new($credential)
|
1368
|
+
serviceprovider.all(filter)
|
1369
|
+
end
|
1370
|
+
end
|
1371
|
+
|
1372
|
+
c.desc "Show details service provider"
|
1373
|
+
c.command :show do |show|
|
1374
|
+
|
1375
|
+
show.flag [:id, :i], :desc => "Service provider id or name"
|
1376
|
+
show.action do |global_options, options, args|
|
1377
|
+
|
1378
|
+
cli = HighLine.new
|
1379
|
+
name_or_id = options[:id] || cli.ask("Name or ID of Service Provider: ")
|
1380
|
+
|
1381
|
+
serviceprovider = Models::ServiceProvider.new($credential, name_or_id)
|
1382
|
+
serviceprovider.show
|
1383
|
+
end
|
1384
|
+
end
|
1385
|
+
|
1386
|
+
c.desc "Export parameters of service provider"
|
1387
|
+
c.command :export do |export|
|
1388
|
+
|
1389
|
+
export.desc "Service provider id or name"
|
1390
|
+
export.flag [:id, :i]
|
1391
|
+
|
1392
|
+
export.action do |global_options, options, args|
|
1393
|
+
|
1394
|
+
cli = HighLine.new
|
1395
|
+
name_or_id = options[:id] || cli.ask("Name or ID of Service provider: ")
|
1396
|
+
|
1397
|
+
service_provider = Models::ServiceProvider.new($credential, name_or_id)
|
1398
|
+
service_provider.export
|
1399
|
+
|
1400
|
+
end
|
1401
|
+
end
|
1402
|
+
|
1403
|
+
c.desc 'Validate Service Provider'
|
1404
|
+
c.command :valid do |validate|
|
1405
|
+
validate.desc 'Directory file of service provider json'
|
1406
|
+
validate.flag [:file, :f]
|
1407
|
+
|
1408
|
+
validate.action do |global_options,options,args|
|
1409
|
+
|
1410
|
+
cli = HighLine.new
|
1411
|
+
file_path = options[:file] || cli.ask("Directory of Service Provider: ")
|
1412
|
+
|
1413
|
+
serviceprovider = Models::ServiceProvider.new($credential)
|
1414
|
+
serviceprovider.validate(file_path)
|
1415
|
+
|
1416
|
+
end
|
1417
|
+
end
|
1418
|
+
end
|
1419
|
+
|
1420
|
+
desc "Manage my service"
|
1421
|
+
command :service do |c|
|
1422
|
+
|
1423
|
+
c.desc "List service"
|
1424
|
+
c.command :list do |list|
|
1425
|
+
|
1426
|
+
list.flag [:state, :s], :desc => "Filter based service state, option(all, active, nonactive)"
|
1427
|
+
list.flag [:type, :t], :desc => "Service Provider id or slug (optional)"
|
1428
|
+
list.flag [:page, :p], :desc => "Filter based number of page", :default_value => 1
|
1429
|
+
|
1430
|
+
list.action do |global_options, options, args|
|
1431
|
+
|
1432
|
+
cli = HighLine.new
|
1433
|
+
state = options[:state] || cli.choose do |menu|
|
1434
|
+
menu.prompt = "Please choose filter of state service? "
|
1435
|
+
menu.choice(:all)
|
1436
|
+
menu.choice(:active)
|
1437
|
+
menu.choice(:unactive)
|
1438
|
+
menu.default = :all
|
1439
|
+
end
|
1440
|
+
state = state.to_s == "all" ? nil : state
|
1441
|
+
|
1442
|
+
umbreo_service_id = options[:type] || cli.ask("ID or Slug of Service provider (Optional): ")
|
1443
|
+
|
1444
|
+
filter = { state: state, umbreo_service_id: umbreo_service_id, page: options[:page] }
|
1445
|
+
|
1446
|
+
service = Models::Service.new($credential)
|
1447
|
+
service.all(filter)
|
1448
|
+
end
|
1449
|
+
end
|
1450
|
+
|
1451
|
+
c.desc "Search Service Provider"
|
1452
|
+
c.command :search do |search|
|
1453
|
+
|
1454
|
+
search.flag [:state, :s], :desc => "Filter based service state, option(all, active, nonactive)"
|
1455
|
+
search.flag [:type, :t], :desc => "Service Provider id or slug"
|
1456
|
+
search.flag [:keyword, :k], :desc => "Search keyword"
|
1457
|
+
search.flag [:page, :p], :desc => "Filter based number of page", :default_value => 1
|
1458
|
+
|
1459
|
+
search.action do |global_options, options, args|
|
1460
|
+
|
1461
|
+
cli = HighLine.new
|
1462
|
+
state = options[:state] || cli.choose do |menu|
|
1463
|
+
menu.prompt = "Please choose filter of state service? "
|
1464
|
+
menu.choice(:all)
|
1465
|
+
menu.choice(:active)
|
1466
|
+
menu.choice(:unactive)
|
1467
|
+
menu.default = :all
|
1468
|
+
end
|
1469
|
+
state = state.to_s == "all" ? nil : state
|
1470
|
+
|
1471
|
+
umbreo_service_id = options[:type] || cli.ask("(*) ID or Slug of Service provider: ")
|
1472
|
+
keyword = options[:keyword] || cli.ask("Search keyword: ")
|
1473
|
+
|
1474
|
+
filter = { state: state, umbreo_service_id: umbreo_service_id, page: options[:page], keyword: keyword }
|
1475
|
+
|
1476
|
+
service = Models::Service.new($credential)
|
1477
|
+
service.all(filter)
|
1478
|
+
end
|
1479
|
+
end
|
1480
|
+
|
1481
|
+
c.desc "Show details provider"
|
1482
|
+
c.command :show do |show|
|
1483
|
+
|
1484
|
+
show.flag [:id, :i], :desc => "Service provider id or name"
|
1485
|
+
show.action do |global_options, options, args|
|
1486
|
+
|
1487
|
+
cli = HighLine.new
|
1488
|
+
name_or_id = options[:id] || cli.ask("Name or ID of Service: ")
|
1489
|
+
|
1490
|
+
service = Models::Service.new($credential, name_or_id)
|
1491
|
+
service.show
|
1492
|
+
end
|
1493
|
+
end
|
1494
|
+
|
1495
|
+
c.desc "Export parameters of service"
|
1496
|
+
c.command :export do |export|
|
1497
|
+
|
1498
|
+
export.desc "Service name or id"
|
1499
|
+
export.flag [:id, :i]
|
1500
|
+
|
1501
|
+
export.action do |global_options, options, args|
|
1502
|
+
|
1503
|
+
cli = HighLine.new
|
1504
|
+
name_or_id = options[:id] || cli.ask("Name or ID of Service: ")
|
1505
|
+
|
1506
|
+
service_provider = Models::Service.new($credential, name_or_id)
|
1507
|
+
service_provider.export
|
1508
|
+
|
1509
|
+
end
|
1510
|
+
end
|
1511
|
+
|
1512
|
+
c.desc 'Validate Service Provider'
|
1513
|
+
c.command :valid do |validate|
|
1514
|
+
|
1515
|
+
validate.desc 'Directory file of service provider json'
|
1516
|
+
validate.flag [:file, :f]
|
1517
|
+
|
1518
|
+
validate.action do |global_options,options,args|
|
1519
|
+
|
1520
|
+
cli = HighLine.new
|
1521
|
+
file_path = options[:file] || cli.ask("Directory of Service: ")
|
1522
|
+
|
1523
|
+
service = Models::Service.new($credential)
|
1524
|
+
service.validate(file_path)
|
1525
|
+
|
1526
|
+
end
|
1527
|
+
end
|
1528
|
+
|
1529
|
+
c.desc 'Create Service'
|
1530
|
+
c.command :create do |create|
|
1531
|
+
|
1532
|
+
create.switch [:external, :e], desc: "Define External Service", default_value: false
|
1533
|
+
create.flag [:file, :f], desc: 'Directory file of service json'
|
1534
|
+
create.flag [:id, :i], desc: 'Service provider id or slug'
|
1535
|
+
create.flag [:name, :n], desc: 'Service name'
|
1536
|
+
create.flag [:desc, :d], desc: 'Service description'
|
1537
|
+
|
1538
|
+
create.action do |global_options,options,args|
|
1539
|
+
|
1540
|
+
cli = HighLine.new
|
1541
|
+
is_external = options[:external]
|
1542
|
+
file_path = options[:file] || cli.ask("Json Directory of Service: ")
|
1543
|
+
slug_or_id = options[:id] || cli.ask("Slug or ID of Service Provider: ")
|
1544
|
+
name = options[:name] || cli.ask("Name of Service: ")
|
1545
|
+
desc = options[:desc] || cli.ask("Description of Service: ")
|
1546
|
+
|
1547
|
+
service_parameter = {
|
1548
|
+
name: name,
|
1549
|
+
desc: desc,
|
1550
|
+
umbreo_service_id: slug_or_id,
|
1551
|
+
link_type: (is_external ? "external" : "new_server"),
|
1552
|
+
params: file_path,
|
1553
|
+
user_node_attributes: {}
|
1554
|
+
}
|
1555
|
+
|
1556
|
+
if !is_external
|
1557
|
+
|
1558
|
+
serviceprovider = Models::ServiceProvider.new($credential, slug_or_id)
|
1559
|
+
serviceprovider = serviceprovider.show(false)
|
1560
|
+
|
1561
|
+
instance_name = name
|
1562
|
+
instance_desc = desc
|
1563
|
+
instance_blueprint_file = file_path
|
1564
|
+
instance_logging_file = cli.ask("Service logging directory File JSON (optional): ") if serviceprovider["umbreo_service_type"] != "logging"
|
1565
|
+
instance_monitoring_file = cli.ask("Service monitoring directory File JSON (optional): ") if serviceprovider["umbreo_service_type"] != "monitoring"
|
1566
|
+
instance_backup_file = cli.ask("Service backup directory File JSON (optional): ") if serviceprovider["umbreo_service_type"] != "backup"
|
1567
|
+
instance_deploy_type = cli.choose do |menu|
|
1568
|
+
menu.prompt = "Please choose deployment type? "
|
1569
|
+
menu.choices(:test)
|
1570
|
+
menu.choices(:manual)
|
1571
|
+
menu.choices(:provider)
|
1572
|
+
end
|
1573
|
+
|
1574
|
+
if instance_deploy_type.present?
|
1575
|
+
if instance_deploy_type.to_s == "provider"
|
1576
|
+
instance_provider_file = cli.ask("Compute provider directory File JSON: ")
|
1577
|
+
end
|
1578
|
+
end
|
1579
|
+
|
1580
|
+
instance_deploy_type = instance_deploy_type == 'manual' ? 'barebone' : instance_deploy_type
|
1581
|
+
|
1582
|
+
parameters = {
|
1583
|
+
name: instance_name,
|
1584
|
+
desc: instance_desc,
|
1585
|
+
blueprint: instance_blueprint_file,
|
1586
|
+
service_logging: instance_logging_file,
|
1587
|
+
service_monitoring: instance_monitoring_file,
|
1588
|
+
service_backup: instance_backup_file,
|
1589
|
+
type: instance_deploy_type,
|
1590
|
+
provider: instance_provider_file
|
1591
|
+
}
|
1592
|
+
|
1593
|
+
service_parameter[:user_node_attributes] = parameters
|
1594
|
+
end
|
1595
|
+
|
1596
|
+
service = Models::Service.new($credential)
|
1597
|
+
service.create(service_parameter)
|
1598
|
+
|
1599
|
+
end
|
1600
|
+
end
|
1601
|
+
end
|
1602
|
+
|
1603
|
+
desc "Manage blueprint module"
|
1604
|
+
command :module do |c|
|
1605
|
+
|
1606
|
+
c.command :list do |list|
|
1607
|
+
|
1608
|
+
list.flag [:page, :p], :desc => "Filter based number of page", :default_value => 1
|
1609
|
+
|
1610
|
+
list.action do |global_options, options, args|
|
1611
|
+
modules = Models::Module.new($credential)
|
1612
|
+
filter = { page: options[:page] }
|
1613
|
+
|
1614
|
+
modules.all(filter)
|
1615
|
+
end
|
1616
|
+
end
|
1617
|
+
|
1618
|
+
c.command :search do |search|
|
1619
|
+
|
1620
|
+
search.flag [:keyword, :k], :desc => "Search Module Based keyword"
|
1621
|
+
search.flag [:page, :p], :desc => "Filter based number of page", :default_value => 1
|
1622
|
+
|
1623
|
+
search.action do |global_options, options, args|
|
1624
|
+
|
1625
|
+
cli = HighLine.new
|
1626
|
+
keyword = options[:keyword] || cli.ask("Search keyword: ")
|
1627
|
+
|
1628
|
+
modules = Models::Module.new($credential)
|
1629
|
+
filter = { page: options[:page], keyword: keyword, search: true }
|
1630
|
+
|
1631
|
+
modules.all(filter)
|
1632
|
+
end
|
1633
|
+
end
|
1634
|
+
end
|
1635
|
+
|
1636
|
+
desc "Manage blueprint profile"
|
1637
|
+
command :profile do |c|
|
1638
|
+
|
1639
|
+
c.command :list do |list|
|
1640
|
+
|
1641
|
+
list.flag [:page, :p], :desc => "Filter number of page", :default_value => 1
|
1642
|
+
|
1643
|
+
list.action do |global_options, options, args|
|
1644
|
+
cli = HighLine.new
|
1645
|
+
|
1646
|
+
profiles = Models::Profile.new($credential)
|
1647
|
+
filter = { page: options[:page] }
|
1648
|
+
profiles.all(filter)
|
1649
|
+
end
|
1650
|
+
end
|
1651
|
+
|
1652
|
+
c.command :search do |search|
|
1653
|
+
|
1654
|
+
search.flag [:keyword, :k], :desc => "Search Profile based keyword"
|
1655
|
+
search.flag [:page, :p], :desc => "Filter based number of page", :default_value => 1
|
1656
|
+
|
1657
|
+
search.action do |global_options, options, args|
|
1658
|
+
profiles = Models::Profile.new($credential)
|
1659
|
+
|
1660
|
+
keyword = options[:keyword] || cli.ask("Search keyword: ")
|
1661
|
+
filter = { page: options[:page], keyword: keyword, search: true }
|
1662
|
+
profiles.all(filter)
|
1663
|
+
end
|
1664
|
+
end
|
1665
|
+
end
|
1666
|
+
|
1667
|
+
desc "Manage operating system"
|
1668
|
+
command :system do |c|
|
1669
|
+
|
1670
|
+
c.command :list do |list|
|
1671
|
+
list.action do |global_options, options, args|
|
1672
|
+
systems = Models::System.new($credential)
|
1673
|
+
systems.all
|
1674
|
+
end
|
1675
|
+
end
|
1676
|
+
end
|
1677
|
+
|
1678
|
+
exit run(ARGV)
|
1679
|
+
|
1680
|
+
end
|
1681
|
+
end
|
1682
|
+
|
1683
|
+
|
1684
|
+
|