dtk-client 0.5.14 → 0.5.15
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 +5 -13
- data/lib/commands/common/thor/assembly_workspace.rb +95 -0
- data/lib/commands/common/thor/common.rb +7 -4
- data/lib/commands/common/thor/edit.rb +1 -1
- data/lib/commands/common/thor/inventory_parser.rb +78 -0
- data/lib/commands/common/thor/pull_from_remote.rb +14 -10
- data/lib/commands/common/thor/push_to_remote.rb +0 -21
- data/lib/commands/thor/account.rb +2 -2
- data/lib/commands/thor/component_module.rb +45 -42
- data/lib/commands/thor/library.rb +2 -1
- data/lib/commands/thor/provider.rb +42 -36
- data/lib/commands/thor/service.rb +39 -30
- data/lib/commands/thor/service_module.rb +59 -60
- data/lib/commands/thor/target.rb +85 -15
- data/lib/commands/thor/workspace.rb +1 -1
- data/lib/config/disk_cacher.rb +4 -1
- data/lib/configurator.rb +1 -8
- data/lib/core.rb +4 -2
- data/lib/domain/response.rb +13 -2
- data/lib/dtk-client/version.rb +1 -1
- data/lib/dtk_logger.rb +4 -4
- data/lib/shell/context.rb +96 -77
- data/lib/shell/help_monkey_patch.rb +19 -17
- data/lib/util/os_util.rb +12 -12
- data/lib/util/remote_dependency_util.rb +36 -0
- data/lib/util/ssh_util.rb +2 -1
- data/spec/component_module_spec.rb +34 -0
- data/spec/dtk_spec.rb +1 -1
- data/spec/node_template_spec.rb +0 -1
- data/spec/service_module_spec.rb +38 -0
- data/spec/service_spec.rb +20 -11
- metadata +12 -16
- data/spec/assembly_spec.rb +0 -50
- data/spec/assembly_template_spec.rb +0 -51
- data/spec/component_template_spec.rb +0 -40
- data/spec/module_spec.rb +0 -35
- data/spec/node_spec.rb +0 -43
@@ -17,6 +17,7 @@ module DTK::Client
|
|
17
17
|
class ComponentModule < CommandBaseThor
|
18
18
|
|
19
19
|
DEFAULT_COMMIT_MSG = "Initial commit."
|
20
|
+
PULL_CATALOGS = ["dtkn"]
|
20
21
|
|
21
22
|
def self.valid_children()
|
22
23
|
# [:"component-template"]
|
@@ -48,7 +49,7 @@ module DTK::Client
|
|
48
49
|
:"component" => [
|
49
50
|
["list","list","# List all component templates."],
|
50
51
|
["list-attributes","list-attributes", "# List all attributes for given component."]
|
51
|
-
]
|
52
|
+
]
|
52
53
|
#:attribute => [
|
53
54
|
# ['list',"list","List attributes for given component"]
|
54
55
|
#]
|
@@ -140,7 +141,7 @@ module DTK::Client
|
|
140
141
|
return unless Console.confirmation_prompt("Are you sure you want to delete component-module #{version.nil? ? '' : 'version '}'#{component_module_name}#{version.nil? ? '' : ('-' + version.to_s)}' and all items contained in it"+'?')
|
141
142
|
end
|
142
143
|
|
143
|
-
response =
|
144
|
+
response =
|
144
145
|
if options.purge?
|
145
146
|
opts = {:module_name => component_module_name}
|
146
147
|
if version then opts.merge!(:version => version)
|
@@ -157,10 +158,10 @@ module DTK::Client
|
|
157
158
|
}
|
158
159
|
action = (version ? "delete_version" : "delete")
|
159
160
|
post_body[:version] = version if version
|
160
|
-
|
161
|
+
|
161
162
|
response = post(rest_url("component_module/#{action}"), post_body)
|
162
163
|
return response unless response.ok?
|
163
|
-
|
164
|
+
|
164
165
|
# when changing context send request for getting latest modules instead of getting from cache
|
165
166
|
@@invalidate_map << :component_module
|
166
167
|
|
@@ -189,7 +190,7 @@ module DTK::Client
|
|
189
190
|
:attribute_value => value,
|
190
191
|
:component_module_id => component_module_id
|
191
192
|
}
|
192
|
-
|
193
|
+
|
193
194
|
post rest_url("attribute/set"), post_body
|
194
195
|
end
|
195
196
|
|
@@ -201,7 +202,7 @@ TODO: might deprecate
|
|
201
202
|
desc "COMPONENT-MODULE-NAME/ID info", "Get information about given component module."
|
202
203
|
def info(context_params)
|
203
204
|
component_module_id = context_params.retrieve_arguments([:component_module_id!],method_argument_names)
|
204
|
-
|
205
|
+
|
205
206
|
post_body = {
|
206
207
|
:component_module_id => component_module_id
|
207
208
|
}
|
@@ -231,7 +232,7 @@ TODO: might deprecate
|
|
231
232
|
post_body = (remote ? { :rsa_pub_key => SSHUtil.rsa_pub_key_content() } : {:detail_to_include => ["remotes"]})
|
232
233
|
post_body[:diff] = options.diff? ? options.diff : {}
|
233
234
|
response = post rest_url("component_module/#{action}"),post_body
|
234
|
-
|
235
|
+
|
235
236
|
return response unless response.ok?
|
236
237
|
response.render_table()
|
237
238
|
end
|
@@ -276,7 +277,7 @@ TODO: might deprecate
|
|
276
277
|
git_import = context_params.get_forwarded_options()[:git_import] if context_params.get_forwarded_options()
|
277
278
|
name_option = git_import ? :option_2! : :option_1!
|
278
279
|
module_name = context_params.retrieve_arguments([name_option],method_argument_names)
|
279
|
-
|
280
|
+
|
280
281
|
# first check that there is a directory there and it is not already a git repo, and it ha appropriate content
|
281
282
|
response = Helper(:git_repo).check_local_dir_exists_with_content(:component_module,module_name)
|
282
283
|
return response unless response.ok?
|
@@ -292,7 +293,7 @@ TODO: might deprecate
|
|
292
293
|
|
293
294
|
repo_url,repo_id,module_id,branch = response.data(:repo_url,:repo_id,:module_id,:workspace_branch)
|
294
295
|
response = Helper(:git_repo).initialize_client_clone_and_push(:component_module,module_name,branch,repo_url,module_directory)
|
295
|
-
|
296
|
+
|
296
297
|
return response unless response.ok?
|
297
298
|
repo_obj,commit_sha = response.data(:repo_obj,:commit_sha)
|
298
299
|
|
@@ -311,7 +312,7 @@ TODO: might deprecate
|
|
311
312
|
# which will always be called from this method
|
312
313
|
# if error = response.data(:dsl_parsed_info)
|
313
314
|
# dsl_parsed_message = ServiceImporter.error_message(module_name, error)
|
314
|
-
# DTK::Client::OsUtil.print(dsl_parsed_message, :red)
|
315
|
+
# DTK::Client::OsUtil.print(dsl_parsed_message, :red)
|
315
316
|
# end
|
316
317
|
|
317
318
|
dsl_created_info = response.data(:dsl_created_info)
|
@@ -325,9 +326,9 @@ TODO: might deprecate
|
|
325
326
|
# we push clone changes anyway, user can change and push again
|
326
327
|
context_params.add_context_to_params(module_name, :"component-module", module_id)
|
327
328
|
response = push(context_params, true)
|
328
|
-
|
329
|
+
|
329
330
|
if git_import
|
330
|
-
response[:module_id] = module_id
|
331
|
+
response[:module_id] = module_id
|
331
332
|
response.add_data_value!(:external_dependencies,external_dependencies) if external_dependencies
|
332
333
|
end
|
333
334
|
|
@@ -355,14 +356,14 @@ TODO: might deprecate
|
|
355
356
|
reparse_aux(module_location)
|
356
357
|
end
|
357
358
|
=end
|
358
|
-
|
359
|
+
|
359
360
|
# TODO: put in back support for:desc "import REMOTE-MODULE[,...] [LIBRARY-NAME/ID]", "Import remote component module(s) into library"
|
360
361
|
# TODO: put in doc REMOTE-MODULE havs namespace and optionally version information; e.g. r8/hdp or r8/hdp/v1.1
|
361
362
|
# if multiple items and failire; stops on first failure
|
362
363
|
# desc "install [NAMESPACE/]REMOTE-COMPONENT-MODULE-NAME [-r DTK-REPO-MANAGER]","Install remote component module into local environment"
|
363
364
|
desc "install [NAMESPACE/]REMOTE-COMPONENT-MODULE-NAME","Install remote component module into local environment"
|
364
365
|
method_option "repo-manager",:aliases => "-r" ,
|
365
|
-
:type => :string,
|
366
|
+
:type => :string,
|
366
367
|
:banner => "REPO-MANAGER",
|
367
368
|
:desc => "DTK Repo Manager from which to resolve requested module."
|
368
369
|
def install(context_params)
|
@@ -374,7 +375,7 @@ TODO: might deprecate
|
|
374
375
|
do_not_raise = context_params.get_forwarded_options()[:do_not_raise] if context_params.get_forwarded_options()
|
375
376
|
ignore_component_error = context_params.get_forwarded_options()[:ignore_component_error] if context_params.get_forwarded_options()
|
376
377
|
additional_message = context_params.get_forwarded_options()[:additional_message] if context_params.get_forwarded_options()
|
377
|
-
|
378
|
+
|
378
379
|
remote_namespace, local_module_name = get_namespace_and_name(remote_module_name)
|
379
380
|
if clone_dir = Helper(:git_repo).local_clone_dir_exists?(:component_module,local_module_name,version)
|
380
381
|
message = "Component module's directory (#{clone_dir}) exists on client. To install this needs to be renamed or removed"
|
@@ -390,16 +391,16 @@ TODO: might deprecate
|
|
390
391
|
post_body.merge!(:do_not_raise => do_not_raise) if do_not_raise
|
391
392
|
post_body.merge!(:ignore_component_error => ignore_component_error) if ignore_component_error
|
392
393
|
post_body.merge!(:additional_message => additional_message) if additional_message
|
393
|
-
|
394
|
+
|
394
395
|
response = post rest_url("component_module/import"), post_body
|
395
396
|
return response unless response.ok?
|
396
397
|
|
397
|
-
return response if response.data(:does_not_exist)
|
398
|
+
return response if response.data(:does_not_exist)
|
398
399
|
module_name,repo_url,branch,version = response.data(:module_name,:repo_url,:workspace_branch,:version)
|
399
|
-
|
400
|
+
|
400
401
|
if error = response.data(:dsl_parsed_info)
|
401
402
|
dsl_parsed_message = ServiceImporter.error_message(module_name, error)
|
402
|
-
DTK::Client::OsUtil.print(dsl_parsed_message, :red)
|
403
|
+
DTK::Client::OsUtil.print(dsl_parsed_message, :red)
|
403
404
|
end
|
404
405
|
|
405
406
|
response = ""
|
@@ -417,21 +418,21 @@ TODO: might deprecate
|
|
417
418
|
desc "import-git GIT-SSH-REPO-URL COMPONENT-MODULE-NAME", "Create new local component module by importing from provided git repo URL"
|
418
419
|
def import_git(context_params)
|
419
420
|
git_repo_url, module_name = context_params.retrieve_arguments([:option_1!, :option_2!],method_argument_names)
|
420
|
-
|
421
|
+
|
421
422
|
# Create component module from user's input git repo
|
422
423
|
response = Helper(:git_repo).create_clone_with_branch(:component_module, module_name, git_repo_url)
|
423
|
-
|
424
|
+
|
424
425
|
# Raise error if git repository is invalid
|
425
426
|
# raise DtkError,"Git repository URL '#{git_repo_url}' is invalid." unless response.ok?
|
426
427
|
return response unless response.ok?
|
427
428
|
|
428
429
|
# Remove .git directory to rid of git pointing to user's github
|
429
430
|
FileUtils.rm_rf("#{response['data']['module_directory']}/.git")
|
430
|
-
|
431
|
+
|
431
432
|
context_params.forward_options({:git_import => true})
|
432
433
|
# Reuse module create method to create module from local component_module
|
433
434
|
create_response = import(context_params)
|
434
|
-
|
435
|
+
|
435
436
|
if create_response.ok?
|
436
437
|
if external_dependencies = create_response.data(:external_dependencies)
|
437
438
|
inconsistent = external_dependencies["inconsistent"]
|
@@ -445,11 +446,11 @@ TODO: might deprecate
|
|
445
446
|
delete(context_params,:force_delete => true, :no_error_msg => true)
|
446
447
|
return create_response
|
447
448
|
end
|
448
|
-
|
449
|
+
|
449
450
|
Response::Ok.new()
|
450
451
|
end
|
451
452
|
|
452
|
-
=begin
|
453
|
+
=begin
|
453
454
|
=> DUE TO DEPENDENCY TO PUPPET GEM WE OMMIT THIS <=
|
454
455
|
desc "import-puppet-forge PUPPET-FORGE-MODULE-NAME", "Imports puppet module from puppet forge via puppet gem"
|
455
456
|
def import_puppet_forge(context_params)
|
@@ -483,14 +484,14 @@ TODO: might deprecate
|
|
483
484
|
|
484
485
|
if error = response.data(:dsl_parsed_info)
|
485
486
|
dsl_parsed_message = ServiceImporter.error_message(module_name, error)
|
486
|
-
DTK::Client::OsUtil.print(dsl_parsed_message, :red)
|
487
|
+
DTK::Client::OsUtil.print(dsl_parsed_message, :red)
|
487
488
|
end
|
488
489
|
|
489
490
|
#TODO: need to check if local clone directory exists
|
490
491
|
Helper(:git_repo).create_clone_with_branch(:component_module,module_name,repo_url,branch,version)
|
491
492
|
end
|
492
493
|
=end
|
493
|
-
|
494
|
+
|
494
495
|
desc "delete-from-catalog [NAMESPACE/]REMOTE-COMPONENT-MODULE-NAME [-y]", "Delete the component module from the DTK Network catalog"
|
495
496
|
method_option :force, :aliases => '-y', :type => :boolean, :default => false
|
496
497
|
def delete_from_catalog(context_params)
|
@@ -522,8 +523,8 @@ TODO: might deprecate
|
|
522
523
|
# }
|
523
524
|
|
524
525
|
# response = post rest_url("component_module/export"), post_body
|
525
|
-
|
526
|
-
# return response
|
526
|
+
|
527
|
+
# return response
|
527
528
|
# end
|
528
529
|
|
529
530
|
desc "COMPONENT-MODULE-NAME/ID publish [[NAMESPACE/]REMOTE-COMPONENT-MODULE-NAME]", "Publish component module to remote repository."
|
@@ -537,21 +538,22 @@ TODO: might deprecate
|
|
537
538
|
}
|
538
539
|
|
539
540
|
response = post rest_url("component_module/export"), post_body
|
540
|
-
|
541
|
-
|
541
|
+
return response unless response.ok?
|
542
|
+
DTK::Client::RemoteDependencyUtil.print_dependency_warnings(response, "Module has been successfully published!")
|
543
|
+
nil
|
542
544
|
end
|
543
545
|
|
544
546
|
desc "COMPONENT-MODULE-NAME/ID pull-dtkn [-n NAMESPACE]", "Update local component module from remote repository."
|
545
547
|
method_option "namespace",:aliases => "-n",
|
546
|
-
:type => :string,
|
548
|
+
:type => :string,
|
547
549
|
:banner => "NAMESPACE",
|
548
550
|
:desc => "Remote namespace"
|
549
|
-
def pull_dtkn(context_params)
|
551
|
+
def pull_dtkn(context_params)
|
550
552
|
component_module_id, component_module_name = context_params.retrieve_arguments([:component_module_id!,:component_module_name,:option_1],method_argument_names)
|
551
553
|
catalog = 'dtkn'
|
552
554
|
version = options["version"]
|
553
555
|
|
554
|
-
raise DtkValidationError, "You have to provide valid catalog to pull changes from! Valid catalogs: #{
|
556
|
+
raise DtkValidationError, "You have to provide valid catalog to pull changes from! Valid catalogs: #{PULL_CATALOGS}" unless catalog
|
555
557
|
|
556
558
|
if component_module_name.to_s =~ /^[0-9]+$/
|
557
559
|
component_module_id = component_module_name
|
@@ -573,18 +575,19 @@ TODO: might deprecate
|
|
573
575
|
#elsif catalog.to_s.eql?("origin")
|
574
576
|
#needs to be implemented
|
575
577
|
else
|
576
|
-
raise DtkValidationError, "You have to provide valid catalog to pull changes from! Valid catalogs: #{
|
578
|
+
raise DtkValidationError, "You have to provide valid catalog to pull changes from! Valid catalogs: #{PULL_CATALOGS}"
|
577
579
|
end
|
578
580
|
end
|
579
581
|
|
580
|
-
PullCatalogs = ["dtkn"]
|
581
582
|
|
583
|
+
=begin
|
582
584
|
desc "COMPONENT-MODULE-NAME/ID chown REMOTE-USER", "Set remote module owner"
|
583
585
|
method_option "namespace", :aliases => "-n", :type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
|
584
586
|
def chown(context_params)
|
585
587
|
component_module_id, remote_user = context_params.retrieve_arguments([:component_module_id!,:option_1!],method_argument_names)
|
586
588
|
chown_aux(component_module_id, remote_user, options.namespace)
|
587
589
|
end
|
590
|
+
=end
|
588
591
|
|
589
592
|
desc "COMPONENT-MODULE-NAME/ID chmod PERMISSION-SELECTOR", "Update remote permissions e.g. ug+rw , user and group get RW permissions"
|
590
593
|
method_option "namespace", :aliases => "-n", :type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
|
@@ -675,7 +678,7 @@ TODO: might deprecate
|
|
675
678
|
##
|
676
679
|
#
|
677
680
|
# internal_trigger: this flag means that other method (internal) has trigger this.
|
678
|
-
# This will change behaviour of method in such way that edit will not be
|
681
|
+
# This will change behaviour of method in such way that edit will not be
|
679
682
|
# triggered after it.
|
680
683
|
#
|
681
684
|
#desc "COMPONENT-MODULE-NAME/ID clone [-v VERSION] [-n]", "Locally clone component module and component files. Use -n to skip edit prompt"
|
@@ -687,7 +690,7 @@ TODO: might deprecate
|
|
687
690
|
component_module_id = context_params.retrieve_arguments([:component_module_id!],method_argument_names)
|
688
691
|
module_name = context_params.retrieve_arguments([:component_module_name],method_argument_names)
|
689
692
|
version = thor_options["version"]
|
690
|
-
internal_trigger = true if thor_options['skip_edit']
|
693
|
+
internal_trigger = true if thor_options['skip_edit']
|
691
694
|
|
692
695
|
# if this is not name it will not work, we need module name
|
693
696
|
if module_name.to_s =~ /^[0-9]+$/
|
@@ -729,7 +732,7 @@ TODO: might deprecate
|
|
729
732
|
desc "COMPONENT-MODULE-NAME/ID push", "Push changes from local copy of component module to server"
|
730
733
|
version_method_option
|
731
734
|
method_option "message",:aliases => "-m" ,
|
732
|
-
:type => :string,
|
735
|
+
:type => :string,
|
733
736
|
:banner => "COMMIT-MSG",
|
734
737
|
:desc => "Commit message"
|
735
738
|
# hidden option for dev
|
@@ -752,11 +755,11 @@ TODO: might deprecate
|
|
752
755
|
# desc "COMPONENT-MODULE-NAME/ID push-dtkn [-n NAMESPACE] [-m COMMIT-MSG]", "Push changes from local copy of component module to remote repository (dtkn)."
|
753
756
|
desc "COMPONENT-MODULE-NAME/ID push-dtkn [-n NAMESPACE]", "Push changes from local copy of component module to remote repository (dtkn)."
|
754
757
|
method_option "message",:aliases => "-m" ,
|
755
|
-
:type => :string,
|
758
|
+
:type => :string,
|
756
759
|
:banner => "COMMIT-MSG",
|
757
760
|
:desc => "Commit message"
|
758
761
|
method_option "namespace",:aliases => "-n",
|
759
|
-
:type => :string,
|
762
|
+
:type => :string,
|
760
763
|
:banner => "NAMESPACE",
|
761
764
|
:desc => "Remote namespace"
|
762
765
|
#hidden option for dev
|
@@ -821,7 +824,7 @@ TODO: might deprecate
|
|
821
824
|
modules_path = OsUtil.module_clone_location()
|
822
825
|
module_location = "#{modules_path}/#{module_name}#{version && "-#{version}"}"
|
823
826
|
|
824
|
-
# check if there is repository cloned
|
827
|
+
# check if there is repository cloned
|
825
828
|
if File.directory?(module_location)
|
826
829
|
list_diffs_aux(:component_module, component_module_id, options.remote?, version)
|
827
830
|
else
|
@@ -68,7 +68,8 @@ module DTK::Client
|
|
68
68
|
def import_service_module(context_params)
|
69
69
|
library_id, service_modules = context_params.retrieve_arguments([:library_id, :option_1!],method_argument_names)
|
70
70
|
post_body = {
|
71
|
-
|
71
|
+
:remote_module_name => service_modules,
|
72
|
+
:rsa_pub_key => SSHUtil.rsa_pub_key_content()
|
72
73
|
}
|
73
74
|
post_body.merge!(:library_id => library_id) if library_id
|
74
75
|
|
@@ -18,7 +18,7 @@ module DTK::Client
|
|
18
18
|
:command_only => {
|
19
19
|
:target => [
|
20
20
|
['delete-target',"delete-target TARGET-IDENTIFIER","# Deletes target"],
|
21
|
-
['list
|
21
|
+
['list',"list","# Lists available targets."]
|
22
22
|
|
23
23
|
]
|
24
24
|
},
|
@@ -35,37 +35,36 @@ module DTK::Client
|
|
35
35
|
return Provider.valid_children().include?(name_of_sub_context.to_sym)
|
36
36
|
end
|
37
37
|
|
38
|
-
desc "create-provider PROVIDER-TYPE:PROVIDER-NAME --keypair KEYPAIR --security-group SECURITY-GROUP [--
|
38
|
+
desc "create-provider PROVIDER-TYPE:PROVIDER-NAME [--keypair KEYPAIR] [--security-group SECURITY-GROUP] [--bootstrap]", "Create provider"
|
39
39
|
method_option :keypair, :type => :string
|
40
40
|
method_option :security_group, :type => :string
|
41
|
-
method_option :
|
41
|
+
method_option :bootstrap, :type => :boolean, :default => false
|
42
42
|
def create_provider(context_params)
|
43
43
|
composed_provider_name = context_params.retrieve_arguments([:option_1!],method_argument_names)
|
44
44
|
|
45
45
|
provider_type, provider_name = decompose_provider_type_and_name(composed_provider_name)
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
46
|
+
iaas_properties = Hash.new
|
47
|
+
#TODO: daat-driven check if legal provider type and then what options needed depending on provider type
|
48
|
+
unless provider_type.eql?('physical')
|
49
|
+
keypair, security_group = context_params.retrieve_thor_options([:keypair!, :security_group!], options)
|
50
|
+
iaas_properties.merge!(:keypair_name => keypair,:security_group => security_group)
|
51
|
+
result = DTK::Shell::InteractiveWizard::interactive_user_input(
|
52
|
+
{'IAAS Credentials' => { :type => :group, :options => [
|
53
|
+
{:key => {}},
|
54
|
+
{:secret => {}}
|
55
|
+
]}})
|
56
|
+
access_key, secret_key = result['IAAS Credentials'].values_at(:key, :secret)
|
57
|
+
iaas_properties.merge!(:key => access_key,:secret => secret_key)
|
58
|
+
end
|
55
59
|
|
56
60
|
# Remove sensitive readline history
|
57
61
|
OsUtil.pop_readline_history(2)
|
58
62
|
|
59
|
-
post_body =
|
60
|
-
:iaas_properties =>
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
:security_group => security_group
|
65
|
-
},
|
66
|
-
:provider_name => provider_name,
|
67
|
-
:iaas_type => provider_type.downcase,
|
68
|
-
:no_bootstrap => options.no_bootstrap?
|
63
|
+
post_body = {
|
64
|
+
:iaas_properties => iaas_properties,
|
65
|
+
:provider_name => provider_name,
|
66
|
+
:iaas_type => provider_type.downcase,
|
67
|
+
:no_bootstrap => ! options.bootstrap?
|
69
68
|
}
|
70
69
|
|
71
70
|
response = post rest_url("target/create_provider"), post_body
|
@@ -98,31 +97,38 @@ module DTK::Client
|
|
98
97
|
|
99
98
|
desc "list","Lists available providers."
|
100
99
|
def list(context_params)
|
101
|
-
|
102
|
-
|
100
|
+
if context_params.is_there_command?(:"target")
|
101
|
+
list_targets(context_params)
|
102
|
+
else
|
103
|
+
response = post rest_url("target/list"), { :subtype => :template }
|
104
|
+
response.render_table(:provider)
|
105
|
+
end
|
103
106
|
end
|
104
107
|
|
105
108
|
#TODO: Aldin; wanted to name this list_targets, but did not know how to do so w/o conflicting with desc "PROVIDER-ID/NAME list-targets
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
109
|
+
# Aldin: moved this to target base context (target>list)
|
110
|
+
#
|
111
|
+
# desc "list-all-targets","Lists all targets for all providers."
|
112
|
+
# def list_all_targets(context_params)
|
113
|
+
# response = post rest_url("target/list"), { :subtype => :instance }
|
114
|
+
# response.render_table(:target)
|
115
|
+
# end
|
111
116
|
|
112
117
|
desc "PROVIDER-ID/NAME list-targets", "List targets"
|
113
118
|
def list_targets(context_params)
|
114
119
|
provider_id = context_params.retrieve_arguments([:provider_id!],method_argument_names)
|
115
120
|
|
116
|
-
response
|
117
|
-
|
121
|
+
response = post rest_url("target/list"), { :subtype => :instance, :parent_id => provider_id }
|
118
122
|
response.render_table(:target)
|
119
123
|
end
|
120
124
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
125
|
+
# Aldin: moved to target base context (target>set-default-target)
|
126
|
+
#
|
127
|
+
# desc "set-default-target TARGET-NAME/ID","Sets the default target."
|
128
|
+
# def set_default_target(context_params)
|
129
|
+
# target_id = context_params.retrieve_arguments([:option_1!],method_argument_names)
|
130
|
+
# post rest_url("target/set_default"), { :target_id => target_id }
|
131
|
+
# end
|
126
132
|
|
127
133
|
desc "delete-provider PROVIDER-IDENTIFIER [-y]","Deletes targets provider"
|
128
134
|
method_option :force, :aliases => '-y', :type => :boolean, :default => false
|
@@ -46,7 +46,7 @@ module DTK::Client
|
|
46
46
|
end
|
47
47
|
|
48
48
|
|
49
|
-
|
49
|
+
|
50
50
|
end
|
51
51
|
|
52
52
|
def self.whoami()
|
@@ -66,24 +66,24 @@ module DTK::Client
|
|
66
66
|
end
|
67
67
|
|
68
68
|
# using extended_context when we want to use autocomplete from other context
|
69
|
-
# e.g. we are in assembly/apache context and want to create-component we will use extended context to add
|
69
|
+
# e.g. we are in assembly/apache context and want to create-component we will use extended context to add
|
70
70
|
# component-templates to autocomplete
|
71
71
|
def self.extended_context()
|
72
72
|
{
|
73
73
|
:context => {
|
74
74
|
:add_component => "component_template",
|
75
75
|
:create_node => "node_template",
|
76
|
-
:add_component_dependency => "component_template"
|
76
|
+
:add_component_dependency => "component_template"
|
77
77
|
},
|
78
78
|
:command => {
|
79
79
|
:edit_component_module => {
|
80
|
-
:endpoint => "assembly",
|
81
|
-
:url => "assembly/info_about",
|
80
|
+
:endpoint => "assembly",
|
81
|
+
:url => "assembly/info_about",
|
82
82
|
:opts => {:subtype=>"instance", :about=>"modules"}
|
83
83
|
},
|
84
84
|
:push_component_module_updates => {
|
85
|
-
:endpoint => "assembly",
|
86
|
-
:url => "assembly/info_about",
|
85
|
+
:endpoint => "assembly",
|
86
|
+
:url => "assembly/info_about",
|
87
87
|
:opts => {:subtype=>"instance", :about=>"modules"}
|
88
88
|
}
|
89
89
|
}
|
@@ -143,8 +143,9 @@ TODO: overlaps with different meaning
|
|
143
143
|
['delete',"delete COMPONENT-NAME/ID [-y] ","# Delete component from workspace."],
|
144
144
|
['list-components',"list-components","# List components."]
|
145
145
|
],
|
146
|
-
:utils => [
|
146
|
+
:utils => [
|
147
147
|
['execute-tests',"execute-tests [--component COMPONENT-NAME] [--timeout TIMEOUT]","# Execute tests. --component filters execution per component, --timeout changes default execution timeout."],
|
148
|
+
['execute-tests-v2',"execute-tests-v2 [--component COMPONENT-NAME] [--timeout TIMEOUT]","# Execute tests. --component filters execution per component, --timeout changes default execution timeout."],
|
148
149
|
['get-netstats',"get-netstats","# Get netstats."],
|
149
150
|
['get-ps',"get-ps [--filter PATTERN]","# Get ps."],
|
150
151
|
['grep',"grep LOG-PATH NODE-ID-PATTERN GREP-PATTERN [--first]","# Grep log from multiple nodes. --first option returns first match (latest log entry)."],
|
@@ -213,19 +214,19 @@ TODO: overlaps with different meaning
|
|
213
214
|
|
214
215
|
Response::Ok.new()
|
215
216
|
end
|
216
|
-
|
217
|
+
|
217
218
|
desc "SERVICE-NAME/ID converge [-m COMMIT-MSG]", "Converge service instance."
|
218
219
|
method_option "commit_msg",:aliases => "-m" ,
|
219
220
|
:type => :string,
|
220
221
|
:banner => "COMMIT-MSG",
|
221
|
-
:desc => "Commit message"
|
222
|
+
:desc => "Commit message"
|
222
223
|
def converge(context_params)
|
223
224
|
converge_aux(context_params)
|
224
225
|
end
|
225
226
|
|
226
227
|
desc "SERVICE-NAME/ID push-assembly-updates [SERVICE-MODULE-NAME/ASSEMBLY-NAME]", "Push changes made to this service instance to the designated assembly; default is parent assembly."
|
227
228
|
def push_assembly_updates(context_params)
|
228
|
-
assembly_id, qualified_assembly_name = context_params.retrieve_arguments([:service_id!,:option_1],method_argument_names)
|
229
|
+
assembly_id, qualified_assembly_name = context_params.retrieve_arguments([:service_id!,:option_1],method_argument_names)
|
229
230
|
service_module_name, assembly_template_name =
|
230
231
|
if qualified_assembly_name
|
231
232
|
if qualified_assembly_name =~ /(^[^\/]*)\/([^\/]*$)/
|
@@ -275,7 +276,7 @@ TODO: overlaps with different meaning
|
|
275
276
|
TODO: will put in dot release and will rename to 'extend'
|
276
277
|
desc "ASSEMBLY-NAME/ID add EXTENSION-TYPE [-n COUNT]", "Adds a sub assembly template to the assembly"
|
277
278
|
method_option "count",:aliases => "-n" ,
|
278
|
-
:type => :string, #integer
|
279
|
+
:type => :string, #integer
|
279
280
|
:banner => "COUNT",
|
280
281
|
:desc => "Number of sub-assemblies to add"
|
281
282
|
def add_node(context_params)
|
@@ -296,7 +297,7 @@ TODO: will put in dot release and will rename to 'extend'
|
|
296
297
|
return response
|
297
298
|
end
|
298
299
|
|
299
|
-
desc "ASSEMBLY-NAME/ID possible-extensions", "Lists the possible extensions to the assembly"
|
300
|
+
desc "ASSEMBLY-NAME/ID possible-extensions", "Lists the possible extensions to the assembly"
|
300
301
|
def possible_extensions(context_params)
|
301
302
|
assembly_id = context_params.retrieve_arguments([:assembly_id!],method_argument_names)
|
302
303
|
|
@@ -377,7 +378,7 @@ TODO: will put in dot release and will rename to 'extend'
|
|
377
378
|
data_type = :task
|
378
379
|
else
|
379
380
|
raise_validation_error_method_usage('list')
|
380
|
-
end
|
381
|
+
end
|
381
382
|
end
|
382
383
|
|
383
384
|
post_body = {
|
@@ -389,7 +390,7 @@ TODO: will put in dot release and will rename to 'extend'
|
|
389
390
|
post_body.merge!(:detail_to_include => detail_to_include) if detail_to_include
|
390
391
|
rest_endpoint = "assembly/info_about"
|
391
392
|
|
392
|
-
if context_params.is_last_command_eql_to?(:attribute)
|
393
|
+
if context_params.is_last_command_eql_to?(:attribute)
|
393
394
|
raise DTK::Client::DtkError, "Not supported command for current context level." if attribute_id
|
394
395
|
about, data_type = get_type_and_raise_error_if_invalid(about, "attributes", ["attributes"])
|
395
396
|
elsif context_params.is_last_command_eql_to?(:component)
|
@@ -411,7 +412,7 @@ TODO: will put in dot release and will rename to 'extend'
|
|
411
412
|
data_type = :assembly
|
412
413
|
post_body = { :subtype => 'instance', :detail_level => 'nodes' }
|
413
414
|
rest_endpoint = "assembly/list"
|
414
|
-
end
|
415
|
+
end
|
415
416
|
end
|
416
417
|
|
417
418
|
post_body[:about] = about
|
@@ -446,12 +447,12 @@ TODO: will put in dot release and will rename to 'extend'
|
|
446
447
|
|
447
448
|
path_to_rsa_pub_key ||= SSHUtil.default_rsa_pub_key_path()
|
448
449
|
rsa_pub_key_content = SSHUtil.read_and_validate_pub_key(path_to_rsa_pub_key)
|
449
|
-
|
450
|
+
|
450
451
|
response = post_file rest_url("assembly/initiate_ssh_pub_access"), {
|
451
452
|
:agent_action => :grant_access,
|
452
|
-
:system_user => system_user,
|
453
|
-
:rsa_pub_name => rsa_key_name,
|
454
|
-
:rsa_pub_key => rsa_pub_key_content,
|
453
|
+
:system_user => system_user,
|
454
|
+
:rsa_pub_name => rsa_key_name,
|
455
|
+
:rsa_pub_key => rsa_pub_key_content,
|
455
456
|
:assembly_id => service_id,
|
456
457
|
:target_nodes => options.nodes
|
457
458
|
}
|
@@ -469,10 +470,10 @@ TODO: will put in dot release and will rename to 'extend'
|
|
469
470
|
method_option :nodes, :type => :string, :default => nil
|
470
471
|
def revoke_access(context_params)
|
471
472
|
service_id, system_user, rsa_key_name = context_params.retrieve_arguments([:service_id!,:option_1!, :option_2!],method_argument_names)
|
472
|
-
|
473
|
-
response = post_file rest_url("assembly/initiate_ssh_pub_access"), {
|
473
|
+
|
474
|
+
response = post_file rest_url("assembly/initiate_ssh_pub_access"), {
|
474
475
|
:agent_action => :revoke_access,
|
475
|
-
:system_user => system_user,
|
476
|
+
:system_user => system_user,
|
476
477
|
:rsa_pub_name => rsa_key_name,
|
477
478
|
:assembly_id => service_id,
|
478
479
|
:target_nodes => options.nodes
|
@@ -487,12 +488,12 @@ TODO: will put in dot release and will rename to 'extend'
|
|
487
488
|
nil
|
488
489
|
end
|
489
490
|
|
490
|
-
desc "SERVICE-NAME/ID list-ssh-access", "List SSH access for each of the nodes"
|
491
|
+
desc "SERVICE-NAME/ID list-ssh-access", "List SSH access for each of the nodes"
|
491
492
|
def list_ssh_access(context_params)
|
492
493
|
service_id = context_params.retrieve_arguments([:service_id!],method_argument_names)
|
493
494
|
|
494
|
-
response = post_file rest_url("assembly/list_ssh_access"), {
|
495
|
-
:assembly_id => service_id
|
495
|
+
response = post_file rest_url("assembly/list_ssh_access"), {
|
496
|
+
:assembly_id => service_id
|
496
497
|
}
|
497
498
|
|
498
499
|
response.render_table(:ssh_access)
|
@@ -538,7 +539,7 @@ TODO: will put in dot release and will rename to 'extend'
|
|
538
539
|
}
|
539
540
|
|
540
541
|
response = post rest_url("assembly/delete"), post_body
|
541
|
-
|
542
|
+
|
542
543
|
# when changing context send request for getting latest assemblies instead of getting from cache
|
543
544
|
@@invalidate_map << :service
|
544
545
|
@@invalidate_map << :assembly
|
@@ -624,7 +625,7 @@ TODO: will put in dot release and will rename to 'extend'
|
|
624
625
|
method_option :force, :aliases => '-y', :type => :boolean, :default => false
|
625
626
|
def delete_component(context_params)
|
626
627
|
response = delete_component_aux(context_params)
|
627
|
-
|
628
|
+
|
628
629
|
@@invalidate_map << :service
|
629
630
|
@@invalidate_map << :service_node
|
630
631
|
@@invalidate_map << :service_node_component
|
@@ -640,12 +641,20 @@ TODO: will put in dot release and will rename to 'extend'
|
|
640
641
|
|
641
642
|
# using HIDE_FROM_BASE to hide this command from base context (dtk:/assembly>)
|
642
643
|
desc "HIDE_FROM_BASE execute-tests [--component COMPONENT-NAME] [--timeout TIMEOUT]", "Execute tests. --component filters execution per component, --timeout changes default execution timeout"
|
643
|
-
method_option :component, :type => :string, :desc => "Component name"
|
644
|
+
method_option :component, :type => :string, :desc => "Component name"
|
644
645
|
method_option :timeout, :type => :string, :desc => "Timeout"
|
645
646
|
def execute_tests(context_params)
|
646
647
|
execute_tests_aux(context_params)
|
647
648
|
end
|
648
649
|
|
650
|
+
# using HIDE_FROM_BASE to hide this command from base context (dtk:/assembly>)
|
651
|
+
desc "HIDE_FROM_BASE execute-tests-v2 [--component COMPONENT-NAME] [--timeout TIMEOUT]", "Execute tests. --component filters execution per component, --timeout changes default execution timeout"
|
652
|
+
method_option :component, :type => :string, :desc => "Component name"
|
653
|
+
method_option :timeout, :type => :string, :desc => "Timeout"
|
654
|
+
def execute_tests_v2(context_params)
|
655
|
+
execute_tests_v2_aux(context_params)
|
656
|
+
end
|
657
|
+
|
649
658
|
# using HIDE_FROM_BASE to hide this command from base context (dtk:/assembly>)
|
650
659
|
desc "HIDE_FROM_BASE get-ps [--filter PATTERN]", "Get ps"
|
651
660
|
method_option :filter, :type => :boolean, :default => false, :aliases => '-f'
|
@@ -673,7 +682,7 @@ TODO: will put in dot release and will rename to 'extend'
|
|
673
682
|
grep_aux(context_params)
|
674
683
|
end
|
675
684
|
|
676
|
-
|
685
|
+
|
677
686
|
end
|
678
687
|
end
|
679
688
|
|