Class: DTK::Client::ServiceModule
Constant Summary
collapse
- PULL_CATALOGS =
["dtkn"]
CommandBaseThor::ALT_IDENTIFIER_SEPARATOR, CommandBaseThor::EXTENDED_TIMEOUT, CommandBaseThor::HIDE_FROM_BASE_CONTEXT, CommandBaseThor::TIME_DIFF
CommandHelperMixin::Loaded
ReparseMixin::YamlDTKMetaFiles
Constants included
from Poller
Poller::PERIOD_WAIT_TIME
Constants inherited
from Thor
Thor::HIDE_FROM_BASE_CONTEXT_HELP
Class Method Summary
collapse
Instance Method Summary
collapse
-
#add_collaborators(context_params) ⇒ Object
-
#add_remote(context_params) ⇒ Object
-
#chmod(context_params) ⇒ Object
-
#clone(context_params, internal_trigger = false) ⇒ Object
-
#create_new_version(context_params) ⇒ Object
-
#delete(context_params) ⇒ Object
-
#delete_all(context_params) ⇒ Object
-
#delete_assembly(context_params) ⇒ Object
-
#delete_from_catalog(context_params) ⇒ Object
-
#delete_version(context_params, method_opts = {}) ⇒ Object
-
#deploy(context_params) ⇒ Object
method_option :settings, :type => :string, :aliases => ‘-s’.
-
#deploy_target(context_params) ⇒ Object
method_option :settings, :type => :string, :aliases => ‘-s’.
-
#edit(context_params) ⇒ Object
-
#fork(context_params) ⇒ Object
-
#import(context_params) ⇒ Object
-
#info(context_params) ⇒ Object
-
#install(context_params) ⇒ Object
-
#list(context_params) ⇒ Object
method_option :with_versions, :type => :boolean, :default => false, :aliases => “with-versions”.
-
#list_assemblies(context_params) ⇒ Object
-
#list_collaborators(context_params) ⇒ Object
-
#list_component_modules(context_params) ⇒ Object
-
#list_diffs(context_params) ⇒ Object
-
#list_instances(context_params) ⇒ Object
-
#list_remote_versions(context_params) ⇒ Object
-
#list_remotes(context_params) ⇒ Object
-
#list_versions(context_params) ⇒ Object
-
#make_private(context_params) ⇒ Object
-
#make_public(context_params) ⇒ Object
-
#publish(context_params) ⇒ Object
-
#pull_dtkn(context_params) ⇒ Object
-
#push(context_params, internal_trigger = false) ⇒ Object
-
#push_dtkn(context_params, internal_trigger = false) ⇒ Object
-
#push_remote(context_params) ⇒ Object
-
#remove_collaborators(context_params) ⇒ Object
-
#remove_remote(context_params) ⇒ Object
-
#stage(context_params) ⇒ Object
-
#stage_target(context_params) ⇒ Object
action_on_revalidation_response, basename, create_context_arguments, execute_from_cli, generate_cached_id, get_cached_response, get_identifiers, get_usage_info, #help, #initialize, invalidate_entities, invisible_context_list, list_method_supported?, task_names, tiered_task_names, valid_id?
#get, #get_connection, handle_argument_error, #post, #post_file, #rest_url, #rotate_args
#list_task_info_aux, #task_status_aux, #task_status_stream
Methods included from Console
confirmation_prompt, confirmation_prompt_additional_options, confirmation_prompt_multiple_choice, confirmation_prompt_simple, unix_shell, wait_animation
#Helper
#reparse_aux
#push_clone_changes_aux
#version_method_option
Methods included from Poller
#poller_response, #print_response, #resolve_type
Methods inherited from Thor
get_alternative_identifiers, help, match_help_item_changes, overriden_help, printable_tasks, replace_if_matched!, set_context
Class Method Details
.all_children ⇒ Object
191
192
193
|
# File 'lib/commands/thor/service_module.rb', line 191
def self.all_children()
[:assembly]
end
|
.extended_context ⇒ Object
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
# File 'lib/commands/thor/service_module.rb', line 160
def self.extended_context()
{
:command => {
:stage => {
:endpoint => "service_module",
:url => "service_module/list_assemblies",
:opts => {}
},
:stage_target => {
:endpoint => "service_module",
:url => "service_module/list_assemblies",
:opts => {}
},
:deploy_target => {
:endpoint => "service_module",
:url => "service_module/list_assemblies",
:opts => {}
},
:deploy => {
:endpoint => "service_module",
:url => "service_module/list_assemblies",
:opts => {}
}
}
}
end
|
.multi_context_children ⇒ Object
195
196
197
|
# File 'lib/commands/thor/service_module.rb', line 195
def self.multi_context_children()
[[:assembly], [:remotes], [:assembly, :remotes]]
end
|
.override_allowed_methods ⇒ Object
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
# File 'lib/commands/thor/service_module.rb', line 215
def self.override_allowed_methods()
return DTK::Shell::OverrideTasks.new({
:command_only => {
:self => [
["list"," list [--remote] [--diff] [-n NAMESPACE]","# List service modules (local/remote). Use --diff to compare loaded and remote modules."]
],
:assembly => [
["list","list","# List assemblies for given service module."]
],
:remotes => [
["push-remote", "push-remote [REMOTE-NAME] [--force]", "# Push local changes to remote git repository"],
["list-remotes", "list-remotes", "# List git remotes for given module"],
["add-remote", "add-remote REMOTE-NAME REMOTE-URL", "# Add git remote for given module"],
["remove-remote", "remove-remote REPO-NAME [-y]", "# Remove git remote for given module"]
]
},
:identifier_only => {
:self => [
["list-assemblies","list-assemblies","# List assemblies associated with service module."],
["list-modules","list-modules","# List modules associated with service module."]
],
:assembly => [
["info","info","# Info for given assembly in current service module."],
["stage-target","stage-target [INSTANCE-NAME] [-t PARENT-SERVICE-INSTANCE-NAME/ID] [-v VERSION] [--no-auto-complete]", "# Stage assembly as target instance."],
["stage","stage [INSTANCE-NAME] [-t PARENT-SERVICE-INSTANCE-NAME/ID] [-v VERSION] [--no-auto-complete]", "# Stage assembly in target."],
["deploy-target","deploy-target [INSTANCE-NAME] [-v VERSION] [--no-auto-complete]", "# Deploy assembly as target instance."],
["deploy","deploy [INSTANCE-NAME] [-t PARENT-SERVICE-INSTANCE-NAME/ID] [-v VERSION] [--no-auto-complete]", "# Deploy assembly in target."],
["list-nodes","list-nodes", "# List all nodes for given assembly."],
["list-components","list-components", "# List all components for given assembly."],
["list-settings","list-settings", "# List all settings for given assembly."]
]
}
})
end
|
.pretty_print_cols ⇒ Object
203
204
205
|
# File 'lib/commands/thor/service_module.rb', line 203
def self.pretty_print_cols()
PPColumns.get(:service_module)
end
|
.valid_child?(name_of_sub_context) ⇒ Boolean
199
200
201
|
# File 'lib/commands/thor/service_module.rb', line 199
def self.valid_child?(name_of_sub_context)
return ServiceModule.valid_children().include?(name_of_sub_context.to_sym)
end
|
.valid_children ⇒ Object
187
188
189
|
# File 'lib/commands/thor/service_module.rb', line 187
def self.valid_children()
[:assembly, :remotes]
end
|
.validation_list(context_params) ⇒ Object
207
208
209
|
# File 'lib/commands/thor/service_module.rb', line 207
def self.validation_list(context_params)
get_cached_response(:service_module, "service_module/list", {})
end
|
.whoami ⇒ Object
211
212
213
|
# File 'lib/commands/thor/service_module.rb', line 211
def self.whoami()
return :service_module, "service_module/list", nil
end
|
Instance Method Details
#add_collaborators(context_params) ⇒ Object
532
533
534
|
# File 'lib/commands/thor/service_module.rb', line 532
def add_collaborators(context_params)
add_collaborators_module_aux(context_params)
end
|
#add_remote(context_params) ⇒ Object
805
806
807
|
# File 'lib/commands/thor/service_module.rb', line 805
def add_remote(context_params)
remote_add_aux(context_params)
end
|
#chmod(context_params) ⇒ Object
512
513
514
|
# File 'lib/commands/thor/service_module.rb', line 512
def chmod(context_params)
chmod_module_aux(context_params)
end
|
#clone(context_params, internal_trigger = false) ⇒ Object
560
561
562
|
# File 'lib/commands/thor/service_module.rb', line 560
def clone(context_params, internal_trigger=false)
clone_module_aux(context_params, internal_trigger)
end
|
#create_new_version(context_params) ⇒ Object
821
822
823
|
# File 'lib/commands/thor/service_module.rb', line 821
def create_new_version(context_params)
create_new_version_aux(context_params)
end
|
#delete(context_params) ⇒ Object
766
767
768
769
770
771
|
# File 'lib/commands/thor/service_module.rb', line 766
def delete(context_params)
response = delete_module_aux(context_params, :delete_all => true)
@@invalidate_map << :service_module if response && response.ok?
response
end
|
#delete_all(context_params) ⇒ Object
867
868
869
870
871
872
873
874
|
# File 'lib/commands/thor/service_module.rb', line 867
def delete_all(context_params)
return unless Console.confirmation_prompt("This will DELETE ALL service modules, are you sure"+'?')
response = list(context_params)
response.data().each do |e|
run_shell_command("delete #{e['display_name']} -y -p")
end
end
|
#delete_assembly(context_params) ⇒ Object
783
784
785
786
787
788
|
# File 'lib/commands/thor/service_module.rb', line 783
def delete_assembly(context_params)
response = delete_assembly_aux(context_params)
@@invalidate_map << :assembly if response && response.ok?
response
end
|
#delete_from_catalog(context_params) ⇒ Object
777
778
779
|
# File 'lib/commands/thor/service_module.rb', line 777
def delete_from_catalog(context_params)
delete_from_catalog_aux(context_params)
end
|
#delete_version(context_params, method_opts = {}) ⇒ Object
756
757
758
759
760
761
|
# File 'lib/commands/thor/service_module.rb', line 756
def delete_version(context_params, method_opts = {})
response = delete_module_aux(context_params, method_opts)
@@invalidate_map << :service_module if response && response.ok?
response
end
|
#deploy(context_params) ⇒ Object
method_option :settings, :type => :string, :aliases => ‘-s’
851
852
853
854
855
856
857
858
859
|
# File 'lib/commands/thor/service_module.rb', line 851
def deploy(context_params)
response = deploy_aux(context_params)
return response unless response.ok?
@@invalidate_map << :service
@@invalidate_map << :assembly
response
end
|
#deploy_target(context_params) ⇒ Object
method_option :settings, :type => :string, :aliases => ‘-s’
833
834
835
836
837
838
839
840
841
|
# File 'lib/commands/thor/service_module.rb', line 833
def deploy_target(context_params)
response = deploy_aux(context_params)
return response unless response.ok?
@@invalidate_map << :service
@@invalidate_map << :assembly
response
end
|
#edit(context_params) ⇒ Object
567
568
569
|
# File 'lib/commands/thor/service_module.rb', line 567
def edit(context_params)
edit_module_aux(context_params)
end
|
#fork(context_params) ⇒ Object
816
817
818
|
# File 'lib/commands/thor/service_module.rb', line 816
def fork(context_params)
fork_aux(context_params)
end
|
#import(context_params) ⇒ Object
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
|
# File 'lib/commands/thor/service_module.rb', line 573
def import(context_params)
module_name = context_params.retrieve_arguments([:option_1!],method_argument_names)
namespace, local_module_name = get_namespace_and_name(module_name, ':')
response = Helper(:git_repo).check_local_dir_exists_with_content(:service_module, local_module_name, nil, namespace)
return response unless response.ok?
service_directory = response.data(:module_directory)
reparse_aux(service_directory)
response = post rest_url("service_module/create"), { :module_name => local_module_name, :module_namespace => namespace }
return response unless response.ok?
@@invalidate_map << :service_module
service_module_id, repo_info = response.data(:service_module_id, :repo_info)
repo_url,repo_id,module_id,branch,new_module_name = [:repo_url,:repo_id,:module_id,:workspace_branch,:full_module_name].map { |k| repo_info[k.to_s] }
response = Helper(:git_repo).rename_and_initialize_clone_and_push(:service_module, local_module_name, new_module_name,branch,repo_url,service_directory)
return response unless (response && response.ok?)
repo_obj,commit_sha = response.data(:repo_obj,:commit_sha)
module_final_dir = repo_obj.repo_dir
old_dir = response.data[:old_dir]
context_params.add_context_to_params(local_module_name, :"service-module", module_id)
response = push(context_params,true)
unless response.ok?
if old_dir and (old_dir != module_final_dir)
FileUtils.rm_rf(module_final_dir) unless namespace
end
return response
end
if old_dir and (old_dir != module_final_dir)
FileUtils.rm_rf(old_dir) unless namespace
end
DTK::Client::OsUtil.print("Module '#{new_module_name}' has been created and module directory moved to #{repo_obj.repo_dir}",:yellow) unless namespace
response
end
|
#info(context_params) ⇒ Object
257
258
259
|
# File 'lib/commands/thor/service_module.rb', line 257
def info(context_params)
module_info_aux(context_params)
end
|
#install(context_params) ⇒ Object
387
388
389
390
391
392
|
# File 'lib/commands/thor/service_module.rb', line 387
def install(context_params)
response = install_module_aux(context_params)
@@invalidate_map << :service_module if response && response.ok?
response
end
|
#list(context_params) ⇒ Object
method_option :with_versions, :type => :boolean, :default => false, :aliases => “with-versions”
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
|
# File 'lib/commands/thor/service_module.rb', line 289
def list(context_params)
service_module_id, about, service_module_name = context_params.retrieve_arguments([:service_module_id, :option_1, :option_2],method_argument_names)
datatype = nil
if context_params.is_there_command?(:"assembly")
about = "assembly"
end
if service_module_id.nil? && !service_module_name.nil?
service_module_id = service_module_name
end
remote = options.remote?
namespace = options.namespace
if (context_params.last_entity_name == :"service-module") and about.nil?
action = remote ? "list_remote" : "list"
post_body = (remote ? { :rsa_pub_key => SSHUtil.rsa_pub_key_content() } : {:detail_to_include => ["remotes"]})
post_body[:diff] = options.diffs? ? options.diffs : {}
post_body.merge!(:module_namespace => namespace) if namespace
if post_body[:detail_to_include]
post_body[:detail_to_include] << 'versions' else
post_body[:detail_to_include]
end
response = post rest_url("service_module/#{action}"), post_body
else
raise DTK::Client::DtkValidationError.new("Not supported type '#{about}' for list for current context level. Possible type options: 'assembly'", true) unless(about == "assembly" || about == "modules")
post_body = { :service_module_id => service_module_id }
if about
case about
when "assembly"
version = options.version
data_type = :assembly_template_description
action = "list_assemblies"
post_body.merge!(:version => version) if version
if remote
data_type = :remote_assembly_template_description
action = "list_remote_assemblies"
path_to_key = SSHUtil.default_rsa_pub_key_path()
rsa_pub_key = File.file?(path_to_key) && File.open(path_to_key){|f|f.read}.chomp
post_body.merge!(:remote_namespace => namespace) if namespace
post_body.merge!(:rsa_pub_key => rsa_pub_key)
end
when "modules"
data_type = remote ? :component_remote : :component_module
action = "list_component_modules"
else
raise_validation_error_method_usage('list')
end
end
response = post rest_url("service_module/#{action}"), post_body
end
unless response.nil?
if options.with_versions?
response.render_table(:module_with_versions, true)
else
response.render_table(data_type)
end
end
response
end
|
#list_assemblies(context_params) ⇒ Object
264
265
266
267
268
269
270
271
272
|
# File 'lib/commands/thor/service_module.rb', line 264
def list_assemblies(context_params)
context_params.method_arguments = ["assembly"]
if version = options.version
check_version_format(options.version) if !version.eql?('master') && !version.eql?('base')
end
list(context_params)
end
|
#list_collaborators(context_params) ⇒ Object
546
547
548
|
# File 'lib/commands/thor/service_module.rb', line 546
def list_collaborators(context_params)
list_collaborators_module_aux(context_params)
end
|
#list_component_modules(context_params) ⇒ Object
276
277
278
279
|
# File 'lib/commands/thor/service_module.rb', line 276
def list_component_modules(context_params)
context_params.method_arguments = ["modules"]
list(context_params)
end
|
#list_diffs(context_params) ⇒ Object
747
748
749
750
|
# File 'lib/commands/thor/service_module.rb', line 747
def list_diffs(context_params)
list_remote_module_diffs(context_params)
end
|
#list_instances(context_params) ⇒ Object
363
364
365
|
# File 'lib/commands/thor/service_module.rb', line 363
def list_instances(context_params)
list_instances_aux(context_params)
end
|
#list_remote_versions(context_params) ⇒ Object
375
376
377
378
379
|
# File 'lib/commands/thor/service_module.rb', line 375
def list_remote_versions(context_params)
response = list_remote_versions_aux(context_params)
return response unless response.ok?
response.render_table(:list_versions, true)
end
|
#list_remotes(context_params) ⇒ Object
800
801
802
|
# File 'lib/commands/thor/service_module.rb', line 800
def list_remotes(context_params)
remote_list_aux(context_params)
end
|
#list_versions(context_params) ⇒ Object
368
369
370
371
372
|
# File 'lib/commands/thor/service_module.rb', line 368
def list_versions(context_params)
response = list_versions_aux(context_params)
return response unless response.ok?
response.render_table(:list_versions, true)
end
|
#make_private(context_params) ⇒ Object
524
525
526
|
# File 'lib/commands/thor/service_module.rb', line 524
def make_private(context_params)
make_private_module_aux(context_params)
end
|
#make_public(context_params) ⇒ Object
518
519
520
|
# File 'lib/commands/thor/service_module.rb', line 518
def make_public(context_params)
make_public_module_aux(context_params)
end
|
#publish(context_params) ⇒ Object
454
455
456
|
# File 'lib/commands/thor/service_module.rb', line 454
def publish(context_params)
publish_module_aux(context_params)
end
|
#pull_dtkn(context_params) ⇒ Object
506
507
508
|
# File 'lib/commands/thor/service_module.rb', line 506
def pull_dtkn(context_params)
pull_dtkn_aux(context_params)
end
|
#push(context_params, internal_trigger = false) ⇒ Object
726
727
728
|
# File 'lib/commands/thor/service_module.rb', line 726
def push(context_params, internal_trigger=false)
push_module_aux(context_params, internal_trigger)
end
|
#push_dtkn(context_params, internal_trigger = false) ⇒ Object
741
742
743
|
# File 'lib/commands/thor/service_module.rb', line 741
def push_dtkn(context_params, internal_trigger=false)
push_dtkn_module_aux(context_params, internal_trigger)
end
|
#push_remote(context_params) ⇒ Object
795
796
797
|
# File 'lib/commands/thor/service_module.rb', line 795
def push_remote(context_params)
push_remote_module_aux(context_params)
end
|
#remove_collaborators(context_params) ⇒ Object
540
541
542
|
# File 'lib/commands/thor/service_module.rb', line 540
def remove_collaborators(context_params)
remove_collaborators_module_aux(context_params)
end
|
#remove_remote(context_params) ⇒ Object
811
812
813
|
# File 'lib/commands/thor/service_module.rb', line 811
def remove_remote(context_params)
remote_remove_aux(context_params)
end
|
#stage(context_params) ⇒ Object
650
651
652
653
654
655
656
657
658
659
|
# File 'lib/commands/thor/service_module.rb', line 650
def stage(context_params)
response = stage_aux(context_params)
return response unless response.ok?
@@invalidate_map << :service
@@invalidate_map << :assembly
return response
end
|
#stage_target(context_params) ⇒ Object
632
633
634
635
636
637
638
639
640
641
|
# File 'lib/commands/thor/service_module.rb', line 632
def stage_target(context_params)
response = stage_aux(context_params)
return response unless response.ok?
@@invalidate_map << :service
@@invalidate_map << :assembly
return response
end
|