dtk-client 0.5.10 → 0.5.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/bin/dtk +2 -3
- data/bin/dtk-shell +2 -3
- data/dtk-client.gemspec +1 -1
- data/lib/auxiliary.rb +32 -0
- data/lib/command_helpers/service_importer.rb +46 -6
- data/lib/commands/common/thor/action_result_handler.rb +52 -0
- data/lib/commands/common/thor/assembly_workspace.rb +21 -12
- data/lib/commands/common/thor/common.rb +17 -0
- data/lib/commands/common/thor/list_diffs.rb +1 -1
- data/lib/commands/common/thor/pull_from_remote.rb +39 -32
- data/lib/commands/common/thor/push_to_remote.rb +22 -20
- data/lib/commands/thor/account.rb +10 -19
- data/lib/commands/thor/component.rb +2 -1
- data/lib/commands/thor/component_module.rb +36 -48
- data/lib/commands/thor/developer.rb +1 -1
- data/lib/commands/thor/node.rb +31 -15
- data/lib/commands/thor/node_template.rb +4 -4
- data/lib/commands/thor/provider.rb +4 -4
- data/lib/commands/thor/service.rb +64 -64
- data/lib/commands/thor/service_module.rb +33 -54
- data/lib/commands/thor/workspace.rb +2 -1
- data/lib/configurator.rb +6 -1
- data/lib/core.rb +5 -5
- data/lib/domain/git_error_handler.rb +2 -0
- data/lib/domain/response.rb +2 -1
- data/lib/dtk-client/version.rb +1 -1
- data/lib/parser/adapters/thor.rb +1 -2
- data/lib/shell/domain.rb +8 -1
- data/lib/shell/help_monkey_patch.rb +33 -15
- data/lib/util/console.rb +2 -1
- data/lib/util/os_util.rb +1 -0
- data/lib/util/ssh_util.rb +76 -0
- metadata +7 -6
- data/lib/command_helpers/ssh_processing.rb +0 -43
@@ -1,4 +1,3 @@
|
|
1
|
-
dtk_require_from_base('command_helpers/ssh_processing')
|
2
1
|
dtk_require_common_commands('thor/clone')
|
3
2
|
dtk_require_common_commands('thor/list_diffs')
|
4
3
|
dtk_require_common_commands('thor/push_to_remote')
|
@@ -7,6 +6,7 @@ dtk_require_common_commands('thor/push_clone_changes')
|
|
7
6
|
dtk_require_common_commands('thor/edit')
|
8
7
|
dtk_require_common_commands('thor/reparse')
|
9
8
|
dtk_require_common_commands('thor/purge_clone')
|
9
|
+
dtk_require_common_commands('thor/common')
|
10
10
|
dtk_require_from_base('configurator')
|
11
11
|
dtk_require_from_base('command_helpers/service_importer')
|
12
12
|
|
@@ -127,6 +127,12 @@ module DTK::Client
|
|
127
127
|
version = options.version
|
128
128
|
component_module_name = get_module_name(component_module_id)
|
129
129
|
|
130
|
+
# if called from import-git first param will be git_url and second one will be component_module_id
|
131
|
+
git_import = context_params.get_forwarded_options()[:git_import] if context_params.get_forwarded_options()
|
132
|
+
if git_import
|
133
|
+
component_module_id = context_params.retrieve_arguments([:option_2!],method_argument_names)
|
134
|
+
end
|
135
|
+
|
130
136
|
unless (options.force? || method_opts[:force_delete])
|
131
137
|
# Ask user if really want to delete component module and all items contained in it, if not then return to dtk-shell without deleting
|
132
138
|
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"+'?')
|
@@ -215,9 +221,11 @@ TODO: might deprecate
|
|
215
221
|
return module_info_about(context_params, :components, :component)
|
216
222
|
end
|
217
223
|
|
218
|
-
|
219
|
-
|
220
|
-
|
224
|
+
forwarded_remote = context_params.get_forwarded_options()["remote"] if context_params.get_forwarded_options()
|
225
|
+
remote = options.remote? || forwarded_remote
|
226
|
+
action = (remote ? "list_remote" : "list")
|
227
|
+
# post_body = (options.remote? ? { :rsa_pub_key => SSHUtil.rsa_pub_key_content() } : {:detail_to_include => ["remotes","versions"]})
|
228
|
+
post_body = (remote ? { :rsa_pub_key => SSHUtil.rsa_pub_key_content() } : {:detail_to_include => ["remotes"]})
|
221
229
|
post_body[:diff] = options.diff? ? options.diff : {}
|
222
230
|
response = post rest_url("component_module/#{action}"),post_body
|
223
231
|
|
@@ -232,7 +240,7 @@ TODO: might deprecate
|
|
232
240
|
post_body = {
|
233
241
|
:component_module_id => component_module_id,
|
234
242
|
:detail_to_include => ["remotes"],
|
235
|
-
:rsa_pub_key =>
|
243
|
+
:rsa_pub_key => SSHUtil.rsa_pub_key_content()
|
236
244
|
}
|
237
245
|
response = post rest_url("component_module/versions"), post_body
|
238
246
|
|
@@ -374,7 +382,7 @@ TODO: might deprecate
|
|
374
382
|
post_body = {
|
375
383
|
:remote_module_name => remote_module_name,
|
376
384
|
:local_module_name => local_module_name,
|
377
|
-
:rsa_pub_key =>
|
385
|
+
:rsa_pub_key => SSHUtil.rsa_pub_key_content()
|
378
386
|
}
|
379
387
|
post_body.merge!(:do_not_raise => do_not_raise) if do_not_raise
|
380
388
|
post_body.merge!(:ignore_component_error => ignore_component_error) if ignore_component_error
|
@@ -420,7 +428,6 @@ TODO: might deprecate
|
|
420
428
|
context_params.forward_options({:git_import => true})
|
421
429
|
# Reuse module create method to create module from local component_module
|
422
430
|
create_response = import(context_params)
|
423
|
-
|
424
431
|
|
425
432
|
if create_response.ok?
|
426
433
|
if external_dependencies = create_response.data(:external_dependencies)
|
@@ -495,7 +502,7 @@ TODO: might deprecate
|
|
495
502
|
post_body = {
|
496
503
|
:remote_module_name => remote_name,
|
497
504
|
:remote_module_namespace => remote_namespace,
|
498
|
-
:rsa_pub_key =>
|
505
|
+
:rsa_pub_key => SSHUtil.rsa_pub_key_content()
|
499
506
|
}
|
500
507
|
post rest_url("component_module/delete_remote"), post_body
|
501
508
|
end
|
@@ -508,7 +515,7 @@ TODO: might deprecate
|
|
508
515
|
# post_body = {
|
509
516
|
# :component_module_id => component_module_id,
|
510
517
|
# :remote_component_name => input_remote_name,
|
511
|
-
# :rsa_pub_key =>
|
518
|
+
# :rsa_pub_key => SSHUtil.rsa_pub_key_content()
|
512
519
|
# }
|
513
520
|
|
514
521
|
# response = post rest_url("component_module/export"), post_body
|
@@ -523,7 +530,7 @@ TODO: might deprecate
|
|
523
530
|
post_body = {
|
524
531
|
:component_module_id => component_module_id,
|
525
532
|
:remote_component_name => input_remote_name,
|
526
|
-
:rsa_pub_key =>
|
533
|
+
:rsa_pub_key => SSHUtil.rsa_pub_key_content()
|
527
534
|
}
|
528
535
|
|
529
536
|
response = post rest_url("component_module/export"), post_body
|
@@ -571,39 +578,22 @@ TODO: might deprecate
|
|
571
578
|
# push_to_remote_aux(:component_module, component_module_id, component_module_name, options["namespace"], version)
|
572
579
|
# end
|
573
580
|
|
574
|
-
#
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
# response = pull_from_remote_aux(:component_module,component_module_id,version)
|
582
|
-
# return response unless response.ok?
|
583
|
-
|
584
|
-
# if component_module_name.to_s =~ /^[0-9]+$/
|
585
|
-
# component_module_id = component_module_name
|
586
|
-
# component_module_name = get_module_name(component_module_id)
|
587
|
-
# end
|
588
|
-
|
589
|
-
# modules_path = OsUtil.module_clone_location()
|
590
|
-
# module_location = "#{modules_path}/#{component_module_name}#{version && "-#{version}"}"
|
591
|
-
|
592
|
-
# push_clone_changes_aux(:component_module,component_module_id,version,nil,true) if File.directory?(module_location)
|
593
|
-
# Response::Ok.new()
|
594
|
-
# end
|
581
|
+
# desc "COMPONENT-MODULE-NAME/ID pull-from-dtkn [-n NAMESPACE] [-v VERSION]", "Update local component module from remote repository."
|
582
|
+
desc "COMPONENT-MODULE-NAME/ID pull-dtkn [-n NAMESPACE]", "Update local component module from remote repository."
|
583
|
+
method_option "namespace",:aliases => "-n",
|
584
|
+
:type => :string,
|
585
|
+
:banner => "NAMESPACE",
|
586
|
+
:desc => "Remote namespace"
|
595
587
|
|
596
|
-
desc "COMPONENT-MODULE-NAME/ID pull-dtkn", "Update local component module from remote repository."
|
597
588
|
def pull_dtkn(context_params)
|
598
|
-
# component_module_id, component_module_name, catalog = context_params.retrieve_arguments([:component_module_id!,:component_module_name,:option_1],method_argument_names)
|
599
589
|
component_module_id, component_module_name = context_params.retrieve_arguments([:component_module_id!,:component_module_name,:option_1],method_argument_names)
|
600
590
|
catalog = 'dtkn'
|
601
591
|
version = options["version"]
|
602
|
-
|
603
592
|
raise DtkValidationError, "You have to provide valid catalog to pull changes from! Valid catalogs: #{PullCatalogs}" unless catalog
|
604
593
|
|
605
594
|
if catalog.to_s.eql?("dtkn")
|
606
|
-
|
595
|
+
opts = {:version => version, :remote_namespace => options.namespace}
|
596
|
+
response = pull_from_remote_aux(:component_module,component_module_id,opts)
|
607
597
|
return response unless response.ok?
|
608
598
|
|
609
599
|
if component_module_name.to_s =~ /^[0-9]+$/
|
@@ -634,7 +624,7 @@ TODO: might deprecate
|
|
634
624
|
|
635
625
|
post_body = {
|
636
626
|
:component_module_id => component_module_id,
|
637
|
-
:rsa_pub_key =>
|
627
|
+
:rsa_pub_key => SSHUtil.rsa_pub_key_content()
|
638
628
|
}
|
639
629
|
response = post rest_url("component_module/versions"), post_body
|
640
630
|
return response unless response.ok?
|
@@ -770,23 +760,21 @@ TODO: might deprecate
|
|
770
760
|
# if catalog.to_s.eql?("origin")
|
771
761
|
# push_clone_changes_aux(:component_module,component_module_id,version,options["message"]||DEFAULT_COMMIT_MSG,internal_trigger)
|
772
762
|
if catalog.to_s.eql?("dtkn")
|
763
|
+
remote_module_info = get_remote_module_info_aux(:component_module, component_module_id, options["namespace"], version)
|
764
|
+
return remote_module_info unless remote_module_info.ok?
|
765
|
+
|
773
766
|
unless File.directory?(module_location)
|
774
|
-
|
775
|
-
response = clone_aux(:component_module,component_module_id,version,false)
|
776
|
-
|
777
|
-
if(response.nil? || response.ok?)
|
778
|
-
reparse_aux(module_location)
|
779
|
-
push_to_remote_aux(:component_module, component_module_id, component_module_name, options["namespace"], version) if Console.confirmation_prompt("Would you like to push changes to remote"+'?')
|
780
|
-
end
|
767
|
+
response = clone_aux(:component_module, component_module_id, version, true, true)
|
781
768
|
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
return
|
769
|
+
if(response.nil? || response.ok?)
|
770
|
+
reparse_aux(module_location)
|
771
|
+
response = push_to_remote_aux(remote_module_info, :component_module)
|
786
772
|
end
|
773
|
+
|
774
|
+
return response
|
787
775
|
end
|
788
776
|
|
789
|
-
push_to_remote_aux(:component_module
|
777
|
+
push_to_remote_aux(remote_module_info, :component_module)
|
790
778
|
else
|
791
779
|
raise DtkValidationError, "You have to provide valid catalog to push changes to! Valid catalogs: #{PushCatalogs}"
|
792
780
|
end
|
@@ -15,7 +15,7 @@ module DTK::Client
|
|
15
15
|
|
16
16
|
ids = []
|
17
17
|
# get all nodes which id starts with node_pattern
|
18
|
-
nodes["data"].collect{|a| ids<<a["id"].to_i if a["id"].to_s.
|
18
|
+
nodes["data"].collect{|a| ids<<a["id"].to_i if a["id"].to_s.match(Regexp.new(node_pattern.to_s)) }
|
19
19
|
raise DTK::Client::DtkValidationError, "Unable to find nodes to match this pattern: '#{node_pattern}'." if ids.empty?
|
20
20
|
|
21
21
|
# if it doesn't contain extension upload both *.rb and *.ddl
|
data/lib/commands/thor/node.rb
CHANGED
@@ -15,7 +15,8 @@ module DTK::Client
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.valid_children()
|
18
|
-
[:component, :utils]
|
18
|
+
# [:component, :utils]
|
19
|
+
[:utils]
|
19
20
|
end
|
20
21
|
|
21
22
|
def self.multi_context_children()
|
@@ -85,32 +86,26 @@ module DTK::Client
|
|
85
86
|
post rest_url("node/info"), post_body
|
86
87
|
end
|
87
88
|
|
88
|
-
desc "NODE-NAME/ID ssh [--keypair
|
89
|
+
desc "NODE-NAME/ID ssh REMOTE-USER [--keypair PATH-TO-PEM]","SSH into node, optional parameters are path to keypair and remote user."
|
89
90
|
method_option "--keypair",:type => :string, :desc => "Keypair used for connection, if not provided default is used", :banner => "KEYPAIR"
|
90
|
-
method_option "--remote-user",:type => :string, :desc => "Remote user used for connection", :banner => "REMOTE USER"
|
91
91
|
def ssh(context_params)
|
92
92
|
if OsUtil.is_windows?
|
93
93
|
puts "[NOTICE] SSH functionality is currenly not supported on Windows."
|
94
94
|
return
|
95
95
|
end
|
96
96
|
|
97
|
-
node_id = context_params.retrieve_arguments([:node_id!],method_argument_names)
|
98
|
-
|
99
|
-
|
100
|
-
keypair_location = options.keypair || OsUtil.dtk_keypair_location()
|
97
|
+
node_id, remote_user = context_params.retrieve_arguments([:node_id!,:option_1!],method_argument_names)
|
98
|
+
keypair_location = options.keypair
|
101
99
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
error_message = keypair_location ? "Not able to find keypair, '#{keypair_location}'" : "Default keypair not set, please provide one in 'ssh' command"
|
107
|
-
raise ::DTK::Client::DtkError, error_message
|
100
|
+
if keypair_location
|
101
|
+
unless File.exists?(keypair_location)
|
102
|
+
raise ::DTK::Client::DtkError, "Not able to find keypair, '#{keypair_location}'"
|
103
|
+
end
|
108
104
|
end
|
109
105
|
|
110
106
|
context_params.forward_options({ :json_return => true })
|
111
107
|
response = info_aux(context_params)
|
112
108
|
|
113
|
-
|
114
109
|
if response.ok?
|
115
110
|
node_info = response.data['nodes'].find { |n| node_id == n['node_id'] }
|
116
111
|
public_dns = node_info ? node_info['external_ref']['ec2_public_address'] : nil
|
@@ -118,7 +113,28 @@ module DTK::Client
|
|
118
113
|
raise ::DTK::Client::DtkError, "Not able to resolve instance address, has instance been stopped?" unless public_dns
|
119
114
|
|
120
115
|
connection_string = "#{remote_user}@#{public_dns}"
|
121
|
-
|
116
|
+
|
117
|
+
default_keypair = OsUtil.dtk_keypair_location()
|
118
|
+
|
119
|
+
# vanilla ssh command using only pub key
|
120
|
+
vanilla_ssh =
|
121
|
+
|
122
|
+
ssh_command = nil
|
123
|
+
|
124
|
+
if keypair_location
|
125
|
+
# provided PEM key
|
126
|
+
ssh_command = "ssh -o \"StrictHostKeyChecking no\" -o \"UserKnownHostsFile /dev/null\" -i #{keypair_location} #{connection_string}"
|
127
|
+
elsif SSHUtil.ssh_reachable?(remote_user, public_dns)
|
128
|
+
# it has PUB key access
|
129
|
+
ssh_command = "ssh -o \"StrictHostKeyChecking no\" -o \"UserKnownHostsFile /dev/null\" #{connection_string}"
|
130
|
+
else
|
131
|
+
# using default keypair
|
132
|
+
if default_keypair
|
133
|
+
ssh_command = "ssh -o \"StrictHostKeyChecking no\" -o \"UserKnownHostsFile /dev/null\" -i #{default_keypair} #{connection_string}"
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
raise ::DTK::Client::DtkError, "No public key access or PEM provided, please grant access or provide valid PEM key" if ssh_command.nil?
|
122
138
|
|
123
139
|
OsUtil.print("You are entering SSH terminal (#{connection_string}) ...", :yellow)
|
124
140
|
Kernel.system(ssh_command)
|
@@ -5,10 +5,6 @@ module DTK::Client
|
|
5
5
|
PPColumns.get(:node)
|
6
6
|
end
|
7
7
|
|
8
|
-
def self.whoami()
|
9
|
-
return :node_template, "node/list", {:subtype => 'template'}
|
10
|
-
end
|
11
|
-
|
12
8
|
def self.extended_context()
|
13
9
|
{
|
14
10
|
:context => {
|
@@ -16,6 +12,10 @@ module DTK::Client
|
|
16
12
|
}
|
17
13
|
}
|
18
14
|
end
|
15
|
+
|
16
|
+
def self.validation_list(context_params)
|
17
|
+
get_cached_response(:node_template, "node/list", {:subtype => 'template'})
|
18
|
+
end
|
19
19
|
=begin
|
20
20
|
#Not implemented yet
|
21
21
|
desc "NODE-TEMPLATE-NAME/ID info", "Get information about given node template."
|
@@ -1,10 +1,6 @@
|
|
1
1
|
module DTK::Client
|
2
2
|
class Provider < CommandBaseThor
|
3
3
|
|
4
|
-
def self.whoami()
|
5
|
-
return :provider, "target/list", { :subtype => :template }
|
6
|
-
end
|
7
|
-
|
8
4
|
def self.valid_children()
|
9
5
|
[:target]
|
10
6
|
end
|
@@ -13,6 +9,10 @@ module DTK::Client
|
|
13
9
|
[:target]
|
14
10
|
end
|
15
11
|
|
12
|
+
def self.validation_list(context_params)
|
13
|
+
get_cached_response(:provider, "target/list", {:subtype => :template })
|
14
|
+
end
|
15
|
+
|
16
16
|
def self.override_allowed_methods()
|
17
17
|
return DTK::Shell::OverrideTasks.new({
|
18
18
|
:command_only => {
|
@@ -10,6 +10,7 @@ dtk_require_common_commands('thor/set_required_params')
|
|
10
10
|
dtk_require_common_commands('thor/edit')
|
11
11
|
dtk_require_common_commands('thor/purge_clone')
|
12
12
|
dtk_require_common_commands('thor/assembly_workspace')
|
13
|
+
dtk_require_common_commands('thor/action_result_handler')
|
13
14
|
|
14
15
|
LOG_SLEEP_TIME = DTK::Configuration.get(:tail_log_frequency)
|
15
16
|
DEBUG_SLEEP_TIME = DTK::Configuration.get(:debug_task_frequency)
|
@@ -23,6 +24,7 @@ module DTK::Client
|
|
23
24
|
include EditMixin
|
24
25
|
include PurgeCloneMixin
|
25
26
|
include AssemblyWorkspaceMixin
|
27
|
+
include ActionResultHandler
|
26
28
|
|
27
29
|
def get_assembly_name(assembly_id)
|
28
30
|
get_name_from_id_helper(assembly_id)
|
@@ -42,6 +44,8 @@ module DTK::Client
|
|
42
44
|
raise DtkError,"[ERROR] Illegal name (#{assembly_name}) for service." unless assembly_id
|
43
45
|
assembly_id
|
44
46
|
end
|
47
|
+
|
48
|
+
|
45
49
|
|
46
50
|
end
|
47
51
|
|
@@ -158,7 +162,7 @@ TODO: overlaps with different meaning
|
|
158
162
|
['set-attribute',"set-attribute ATTRIBUTE-NAME [VALUE] [-u]","# (Un)Set attribute value. The option -u will unset the attribute's value."],
|
159
163
|
['start', "start", "# Start node instance."],
|
160
164
|
['stop', "stop", "# Stop node instance."],
|
161
|
-
['ssh', "ssh [--keypair
|
165
|
+
['ssh', "ssh REMOTE-USER [--keypair PATH-TO-PEM]", "# SSH into node, optional parameters are path to keypair and remote user."]
|
162
166
|
],
|
163
167
|
:component => [
|
164
168
|
['info',"info","# Return info about component instance belonging to given node."],
|
@@ -197,36 +201,6 @@ TODO: overlaps with different meaning
|
|
197
201
|
def cancel_task(context_params)
|
198
202
|
cancel_task_aux(context_params)
|
199
203
|
end
|
200
|
-
=begin
|
201
|
-
#TODO: until we investigate DTK-1349
|
202
|
-
desc "rename SERVICE-NAME NEW-SERVICE-NAME","Change service name."
|
203
|
-
def rename(context_params)
|
204
|
-
assembly_name, new_assembly_name = context_params.retrieve_arguments([:option_1!,:option_2!],method_argument_names)
|
205
|
-
|
206
|
-
if assembly_name.to_s =~ /^[0-9]+$/
|
207
|
-
assembly_id = assembly_name
|
208
|
-
else
|
209
|
-
assembly_id = get_assembly_id(assembly_name)
|
210
|
-
end
|
211
|
-
|
212
|
-
post_body = {
|
213
|
-
:assembly_id => assembly_id,
|
214
|
-
:assembly_name => assembly_name,
|
215
|
-
:new_assembly_name => new_assembly_name
|
216
|
-
}
|
217
|
-
|
218
|
-
response = post rest_url("assembly/rename"), post_body
|
219
|
-
return response unless response.ok?
|
220
|
-
|
221
|
-
@@invalidate_map << :service
|
222
|
-
response
|
223
|
-
end
|
224
|
-
=end
|
225
|
-
|
226
|
-
#desc "ASSEMBLY-NAME/ID clear-tasks", "Clears the tasks that have been run already."
|
227
|
-
#def clear_tasks(context_params)
|
228
|
-
# clear_tasks_aux(context_params)
|
229
|
-
#end
|
230
204
|
|
231
205
|
desc "SERVICE-NAME/ID create-assembly SERVICE-MODULE-NAME ASSEMBLY-NAME", "Create a new assembly from this service instance in the designated service module."
|
232
206
|
def create_assembly(context_params)
|
@@ -340,21 +314,6 @@ TODO: will put in dot release and will rename to 'extend'
|
|
340
314
|
task_status_aw_aux(context_params)
|
341
315
|
end
|
342
316
|
|
343
|
-
=begin
|
344
|
-
desc "ASSEMBLY-NAME/ID run-smoketests", "Run smoketests associated with assembly instance"
|
345
|
-
def run_smoketests(context_params)
|
346
|
-
assembly_id = context_params.retrieve_arguments([:assembly_id!],method_argument_names)
|
347
|
-
post_body = {
|
348
|
-
:assembly_id => assembly_id
|
349
|
-
}
|
350
|
-
# create smoke test
|
351
|
-
response = post rest_url("assembly/create_smoketests_task"), post_body
|
352
|
-
return response unless response.ok?
|
353
|
-
# execute
|
354
|
-
task_id = response.data(:task_id)
|
355
|
-
post rest_url("task/execute"), "task_id" => task_id
|
356
|
-
end
|
357
|
-
=end
|
358
317
|
|
359
318
|
desc "SERVICE-NAME/ID list-nodes","List nodes associated with service."
|
360
319
|
def list_nodes(context_params)
|
@@ -480,6 +439,63 @@ TODO: will put in dot release and will rename to 'extend'
|
|
480
439
|
# post rest_url("assembly/list_smoketests"), post_body
|
481
440
|
#end
|
482
441
|
|
442
|
+
desc "SERVICE-NAME/ID grant-access SYS-USER NAME [PATH-TO-PUB-KEY]", "Grant access to given service and its nodes"
|
443
|
+
def grant_access(context_params)
|
444
|
+
service_id, system_user, rsa_key_name, path_to_rsa_pub_key = context_params.retrieve_arguments([:service_id!,:option_1!, :option_2!, :option_3],method_argument_names)
|
445
|
+
|
446
|
+
path_to_rsa_pub_key ||= SSHUtil.default_rsa_pub_key_path()
|
447
|
+
rsa_pub_key_content = SSHUtil.read_and_validate_pub_key(path_to_rsa_pub_key)
|
448
|
+
|
449
|
+
response = post_file rest_url("assembly/initiate_ssh_pub_access"), {
|
450
|
+
:agent_action => :grant_access,
|
451
|
+
:system_user => system_user,
|
452
|
+
:rsa_pub_name => rsa_key_name,
|
453
|
+
:rsa_pub_key => rsa_pub_key_content,
|
454
|
+
:assembly_id => service_id
|
455
|
+
}
|
456
|
+
|
457
|
+
return response unless response.ok?
|
458
|
+
|
459
|
+
action_results_id = response.data(:action_results_id)
|
460
|
+
|
461
|
+
print_action_results(action_results_id)
|
462
|
+
|
463
|
+
nil
|
464
|
+
end
|
465
|
+
|
466
|
+
desc "SERVICE-NAME/ID revoke-access SYS-USER NAME", "Revoke access to given service and its nodes"
|
467
|
+
def revoke_access(context_params)
|
468
|
+
service_id, system_user, rsa_key_name = context_params.retrieve_arguments([:service_id!,:option_1!, :option_2!],method_argument_names)
|
469
|
+
|
470
|
+
response = post_file rest_url("assembly/initiate_ssh_pub_access"), {
|
471
|
+
:agent_action => :revoke_access,
|
472
|
+
:system_user => system_user,
|
473
|
+
:rsa_pub_name => rsa_key_name,
|
474
|
+
:assembly_id => service_id
|
475
|
+
}
|
476
|
+
|
477
|
+
return response unless response.ok?
|
478
|
+
|
479
|
+
action_results_id = response.data(:action_results_id)
|
480
|
+
|
481
|
+
print_action_results(action_results_id)
|
482
|
+
|
483
|
+
nil
|
484
|
+
end
|
485
|
+
|
486
|
+
desc "SERVICE-NAME/ID list-ssh-access", "List SSH access for each of the nodes"
|
487
|
+
def list_ssh_access(context_params)
|
488
|
+
service_id = context_params.retrieve_arguments([:service_id!],method_argument_names)
|
489
|
+
|
490
|
+
response = post_file rest_url("assembly/list_ssh_access"), {
|
491
|
+
:assembly_id => service_id
|
492
|
+
}
|
493
|
+
|
494
|
+
response.render_table(:ssh_access)
|
495
|
+
response
|
496
|
+
end
|
497
|
+
|
498
|
+
|
483
499
|
desc "SERVICE-NAME/ID info", "Get info about content of the service."
|
484
500
|
def info(context_params)
|
485
501
|
info_aux(context_params)
|
@@ -500,16 +516,15 @@ TODO: will put in dot release and will rename to 'extend'
|
|
500
516
|
else
|
501
517
|
assembly_id = get_assembly_id(assembly_name)
|
502
518
|
end
|
503
|
-
# assembly_name = get_assembly_name(assembly_id)
|
504
519
|
|
505
520
|
unless options.force?
|
506
521
|
# Ask user if really want to delete assembly, if not then return to dtk-shell without deleting
|
507
|
-
#used form "+'?' because ?" confused emacs ruby rendering
|
522
|
+
# used form "+'?' because ?" confused emacs ruby rendering
|
508
523
|
what = "service"
|
509
524
|
return unless Console.confirmation_prompt("Are you sure you want to delete and destroy #{what} '#{assembly_name}' and its nodes"+'?')
|
510
525
|
end
|
511
526
|
|
512
|
-
#purge local clone
|
527
|
+
# purge local clone
|
513
528
|
response = purge_clone_aux(:all,:assembly_module => {:assembly_name => assembly_name})
|
514
529
|
return response unless response.ok?
|
515
530
|
|
@@ -540,21 +555,6 @@ TODO: will put in dot release and will rename to 'extend'
|
|
540
555
|
create_attribute_aux(context_params)
|
541
556
|
end
|
542
557
|
|
543
|
-
# desc "ASSEMBLY-NAME/ID add-assembly ASSEMBLY-TEMPLATE-NAME/ID", "Add (stage) an assembly template to become part of this assembly instance"
|
544
|
-
# method_option "auto-complete",:aliases => "-a" ,
|
545
|
-
# :type => :boolean,
|
546
|
-
# :default=> false,
|
547
|
-
# :desc => "Automatically add in connections"
|
548
|
-
# def add_assembly(context_params)
|
549
|
-
# assembly_id,assembly_template_id = context_params.retrieve_arguments([:assembly_id,:option_1!],method_argument_names)
|
550
|
-
# post_body = {
|
551
|
-
# :assembly_id => assembly_id,
|
552
|
-
# :assembly_template_id => assembly_template_id
|
553
|
-
# }
|
554
|
-
# post_body.merge!(:auto_add_connections => true) if options.auto_complete?
|
555
|
-
# post rest_url("assembly/add_assembly_template"), post_body
|
556
|
-
# end
|
557
|
-
|
558
558
|
# using ^^ before NODE-NAME to remove this command from assembly/assembly_id/node/node_id but show in assembly/assembly_id
|
559
559
|
desc "SERVICE-NAME/ID create-node ^^NODE-NAME NODE-TEMPLATE", "Add (stage) a new node in the service."
|
560
560
|
def create_node(context_params)
|