dtk-client 0.7.6 → 0.7.7

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 CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c80ce06a9a9d822a933c7613d0d2e608e68bf8ea
4
- data.tar.gz: 516e42bae79455ea32c275236df7720ef683a4a2
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ M2QzNTFhNjlhMWNlN2YwMmM5NGMwYzY5YTViMjQ4Y2ZkYmIwNmZjOA==
5
+ data.tar.gz: !binary |-
6
+ ZWIyZTI1NjYzYTY3MTU3NjU2MTZhY2I5YTU1N2I3NmI4OTE5OWI4ZA==
5
7
  SHA512:
6
- metadata.gz: 4d4df462ad21ae5516dfcb89de0949d7c6537814365d93b44a666a099853f17521b5f20c31aa1b286293dff22bffcaabff76bdd8aba9f655fbd879b53a546bd7
7
- data.tar.gz: 28cd24c15adab48e77f888ff9205954b479866d9a532d69785218c638e51d57ccc69d62517d16109e7c8eac8f8a25f090e10c2625c0c1405bd4ec26df76661e0
8
+ metadata.gz: !binary |-
9
+ ODRlMzA2ZmQxMWE3NjQxMjEwN2U5YzNjOTlhYTYxNzhhMzI3MzFlZDFhOWYz
10
+ NDg1ZDRjMzNlYWMwZDY0YWYyMGU5ZjBlN2Y0NjFlYWY1Y2JkYmM0M2JhZGVi
11
+ Y2E0MzlkM2VkYzMwOGVlMjM4YWY3NTYxZDdhOTVhZDE3MDllNzI=
12
+ data.tar.gz: !binary |-
13
+ M2E5YzEwMTFiMDI5ODdhYjQ0MTllNDg2YmJmMDM0MmMxM2JlYmI1NjA2MTc0
14
+ ZDRkN2M5ZGQzNzNlYzA2MjFlYTJiNGE3M2VkNGE0YmVjMGFhMDVjNTM5Y2Iw
15
+ MTYzNzcxNjdhOGNhYmVlZTAyYzRmYTViMmI2YmUwM2FiNDdlMDI=
data/bin/dtk-shell CHANGED
@@ -11,4 +11,4 @@ config_exists = ::DTK::Client::Configurator.check_config_exists
11
11
  # check if .add_direct_access file exists, if not then add direct access and create .add_direct_access file
12
12
  resolve_direct_access(::DTK::Client::Configurator.check_direct_access, config_exists)
13
13
 
14
- run_shell_command()
14
+ run_shell_command()
data/dtk-client.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |gem|
20
20
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
21
21
  gem.name = "dtk-client"
22
22
  gem.require_paths = ["lib"]
23
- gem.version = "#{DtkClient::VERSION}.#{ARGV[3]}".chomp(".")
23
+ gem.version = DtkClient::VERSION
24
24
 
25
25
  gem.add_dependency 'mime-types','~> 1.25'
26
26
  gem.add_dependency 'bundler','>= 1.2.4'
@@ -1,22 +1,24 @@
1
1
  module DTK; module Client; class CommandHelper
2
2
  class GitRepo
3
3
  class Merge
4
+
4
5
  def initialize(repo, remote_branch_ref, opts = {})
5
- @repo = repo
6
+ @repo = repo
6
7
  @remote_branch_ref = remote_branch_ref
7
- @local_branch = repo.local_branch_name
8
+ @local_branch = repo.local_branch_name
9
+
8
10
  # options
9
11
  @opts_commit_sha = opts[:commit_sha]
10
12
  @opts_force = opts[:force]
11
- @opts_merge_if_no_conflict = opts[:merge_if_no_conflict]
12
13
  @opts_ignore_dependency_merge_conflict = opts[:ignore_dependency_merge_conflict]
13
14
  @opts_full_module_name = opts[:full_module_name]
15
+ @opts_command = opts[:command]
14
16
  end
15
17
 
16
18
  def self.merge(repo, remote_branch_ref, opts = {})
17
19
  new(repo, remote_branch_ref, opts).merge
18
20
  end
19
-
21
+
20
22
  def merge
21
23
  if @opts_force
22
24
  merge_force()
@@ -24,18 +26,18 @@ module DTK; module Client; class CommandHelper
24
26
  # check if merge needed
25
27
  merge_rel = merge_relationship()
26
28
  case merge_rel
27
- when :equal
28
- response__no_diffs()
29
- when :local_ahead, :branchpoint
30
- merge_not_fast_forward(merge_rel)
31
- when :local_behind
32
- merge_simple()
33
- else
34
- raise Error.new("Unexpected merge_rel (#{merge_rel})")
29
+ when :equal
30
+ response__no_diffs()
31
+ when :local_ahead, :branchpoint
32
+ merge_not_fast_forward(merge_rel)
33
+ when :local_behind
34
+ merge_simple()
35
+ else
36
+ raise Error.new("Unexpected merge_rel (#{merge_rel})")
35
37
  end
36
38
  end
37
39
  end
38
-
40
+
39
41
  private
40
42
 
41
43
  def merge_force
@@ -46,31 +48,25 @@ module DTK; module Client; class CommandHelper
46
48
  end
47
49
 
48
50
  def merge_not_fast_forward(merge_rel)
49
- if @opts_merge_if_no_conflict
50
- if any_conflicts?
51
- msg = 'Unable to do pull-dtkn merge without conflicts. Options are:'
52
- msg << " a) command 'pull-dtkn --force', but all local changes will be lost or"
53
- msg << " b) use command 'edit' to get in linux shell and directly use git commands."
54
- raise ErrorUsage.new(msg)
51
+ if any_conflicts?
52
+ # @opts_ignore_dependency_merge_conflict means called indirectly
53
+ if @opts_ignore_dependency_merge_conflict
54
+ # TODO: hard-wired that dependency is a component module in message: 'component-module/..
55
+ custom_message = "Unable to do fast-forward merge. You can go to 'component-module/#{@opts_full_module_name}' and pull with --force option but all local changes will be lost."
56
+ response(compute_diffs, :custom_message => custom_message)
55
57
  else
56
- if merge_rel == :local_ahead
57
- response__no_diffs(:custom_message => 'No op because local module is ahead')
58
- else
59
- merge_simple()
60
- end
58
+ err_msg = 'Unable to do fast-forward merge. You can use --force'
59
+ err_msg << " on #{@opts_command}" if @opts_command
60
+ err_msg << ', but all local changes will be lost on target that is being pushed to.'
61
+ raise ErrorUsage.new(err_msg)
61
62
  end
62
- elsif @opts_force
63
- merge_force()
64
- elsif @opts_ignore_dependency_merge_conflict
65
- custom_message = "Unable to do fast-forward merge. You can go to '#{@opts_full_module_name}' and pull with --force option but all changes will be lost."
66
- # TODO: should this instead by ErrorUsage.new like below
67
- response(:custom_message => :custom_message)
63
+ elsif merge_rel == :local_ahead
64
+ response__no_diffs(:custom_message => 'No op because local module is ahead')
68
65
  else
69
- # this will only be reached if opts_merge_if_no_conflict is false
70
- raise ErrorUsage.new('Unable to do fast-forward merge. You can use --force on pull-dtkn, but all local changes will be lost.')
66
+ merge_simple()
71
67
  end
72
68
  end
73
-
69
+
74
70
  def merge_simple
75
71
  # see if any diffs between fetched remote and local branch
76
72
  # this has be done after commit
@@ -134,6 +130,7 @@ module DTK; module Client; class CommandHelper
134
130
  nil
135
131
  end
136
132
  end
133
+
137
134
  end
138
135
  end
139
136
  end; end; end
@@ -7,12 +7,16 @@ module DTK::Client
7
7
  #
8
8
  module ServiceImporter
9
9
  def create_missing_clone_dirs()
10
- ::DTK::Client::Configurator.create_missing_clone_dirs
10
+ Configurator.create_missing_clone_dirs
11
11
  end
12
12
 
13
- def self.error_message(name, errors)
14
- #TODO: it is contingent whether solution is to fix errors using 'edit' command
15
- "Module '#{name}' has errors:\n #{errors.to_s}\nYou can fix errors in the DSL by invoking the 'edit' command.\n"
13
+ def self.error_message(name, errors, opts = {})
14
+ prefix = ''
15
+ unless opts[:module_type] == :service_module
16
+ prefix = "Module '#{name}' has errors:\n "
17
+ end
18
+ command = opts[:command] || 'edit'
19
+ "#{prefix}#{errors.to_s}\nYou can fix errors by invoking the '#{command}' command.\n"
16
20
  end
17
21
 
18
22
  ##
@@ -42,7 +46,7 @@ module DTK::Client
42
46
  if opts[:do_not_raise]
43
47
  OsUtil.print("#{response.error_message}", :red)
44
48
  else
45
- raise DTK::Client::DtkError, response.error_message
49
+ raise DtkError, response.error_message
46
50
  end
47
51
  end
48
52
  end
@@ -114,7 +118,7 @@ module DTK::Client
114
118
 
115
119
  ignore_component_error = (new_context_params.get_forwarded_options() || {})[:ignore_component_error] && module_type.eql?('component_module')
116
120
  puts(response.data(:does_not_exist) ? response.data(:does_not_exist) : 'Done.')
117
- raise DTK::Client::DtkError, response.error_message if !response.ok? && !ignore_component_error
121
+ raise DtkError, response.error_message if !response.ok? && !ignore_component_error
118
122
  end
119
123
 
120
124
  Response::Ok.new()
@@ -161,7 +165,7 @@ module DTK::Client
161
165
 
162
166
  begin
163
167
  response = ContextRouter.routeTask("component_module", "clone", new_context_params, @conn)
164
- rescue DTK::Client::DtkValidationError => e
168
+ rescue DtkValidationError => e
165
169
  # ignoring this
166
170
  end
167
171
  # puts "Done."
@@ -192,7 +196,7 @@ module DTK::Client
192
196
  private
193
197
 
194
198
  def full_module_name(module_hash)
195
- ::DTK::Client::ModuleUtil.join_name(module_hash['name'], module_hash['namespace'])
199
+ ModuleUtil.join_name(module_hash['name'], module_hash['namespace'])
196
200
  end
197
201
 
198
202
  end
@@ -277,6 +277,7 @@ module DTK::Client
277
277
 
278
278
  assembly_name,service_module_id,service_module_name,version,repo_url,branch,branch_head_sha,edit_file = response.data(:assembly_name,:module_id,:full_module_name,:version,:repo_url,:workspace_branch,:branch_head_sha,:edit_file)
279
279
  edit_opts = {
280
+ :command => 'edit-workflow',
280
281
  :automatically_clone => true,
281
282
  :assembly_module => {
282
283
  :assembly_name => assembly_name,
@@ -1,7 +1,7 @@
1
1
  dtk_require_common_commands('thor/common')
2
2
  module DTK::Client
3
3
  module CloneMixin
4
- extend ::DTK::Client::Console
4
+ extend Console
5
5
  include CommonMixin
6
6
  ##
7
7
  #
@@ -167,6 +167,7 @@ module DTK::Client
167
167
  git_import = opts[:git_import]
168
168
  opts.merge!(:update_from_includes => true, :force_parse => true) unless git_import
169
169
  opts.merge!(:force => options.force?)
170
+ opts.merge!(:generate_docs => options.docs?)
170
171
 
171
172
  reparse_aux(module_location)
172
173
  push_clone_changes_aux(module_type.to_sym, module_id, version, options['message'] || DEFAULT_COMMIT_MSG, internal_trigger, opts)
@@ -350,7 +351,7 @@ module DTK::Client
350
351
  response = pull_from_remote_aux(module_type.to_sym, module_id, opts)
351
352
  return response unless response.ok?
352
353
 
353
- push_clone_changes_aux(module_type.to_sym, module_id, version, nil, true) if File.directory?(module_location)
354
+ push_clone_changes_aux(module_type.to_sym, module_id, version, nil, true, {:update_from_includes => true}) if File.directory?(module_location)
354
355
  response.skip_render = true
355
356
  response
356
357
  else
@@ -0,0 +1,36 @@
1
+ module DTK::Client
2
+ module NodeMixin
3
+ def get_node_info_for_ssh_login(node_id, context_params)
4
+ context_params.forward_options(:json_return => true)
5
+ response = info_aux(context_params)
6
+ return response unless response.ok?
7
+ # Should only have info about the specfic node_id
8
+
9
+ unless node_info = response.data(:nodes).find{ |node| node_id == (node['node_properties'] || {})['node_id'] }
10
+ raise DtkError, "Cannot find info about node with id '#{node_id}'"
11
+ end
12
+
13
+ data = {}
14
+ node_properties = node_info['node_properties'] || {}
15
+ if public_dns = node_properties['ec2_public_address']
16
+ data.merge!('public_dns' => public_dns)
17
+ end
18
+ if default_login_user = NodeMixin.default_login_user?(node_properties)
19
+ data.merge!('default_login_user' => default_login_user)
20
+ end
21
+
22
+ Response::Ok.new(data)
23
+ end
24
+
25
+ def self.default_login_user?(node_properties)
26
+ if os_type = node_properties['os_type']
27
+ DefaultLoginByOSType[os_type]
28
+ end
29
+ end
30
+
31
+ DefaultLoginByOSType = {
32
+ 'ubuntu' => 'ubuntu',
33
+ 'amazon-linux' => 'ec2-user'
34
+ }
35
+ end
36
+ end
@@ -34,12 +34,9 @@ module DTK::Client
34
34
  unless rsa_pub_key
35
35
  raise DtkError,"No File found at (#{path_to_key}). Path is wrong or it is necessary to generate the public rsa key (e.g., run ssh-keygen -t rsa)"
36
36
  end
37
- # making :merge_if_no_conflict the default (when force not set)
38
- merge_if_no_conflict = (opts[:force] ? nil : true)
39
37
  opts_perform_locally = remote_params.merge(
40
38
  :full_module_name => full_module_name,
41
39
  :force => opts[:force],
42
- :merge_if_no_conflict => merge_if_no_conflict,
43
40
  :do_not_raise => opts[:do_not_raise],
44
41
  :ignore_dependency_merge_conflict => opts[:ignore_dependency_merge_conflict]
45
42
  )
@@ -40,6 +40,7 @@ module DTK::Client
40
40
  post_body.merge!(:current_branch_sha => opts[:current_branch_sha]) if opts[:current_branch_sha]
41
41
  post_body.merge!(:force => opts[:force]) if opts[:force]
42
42
  post_body.merge!(:task_action => opts[:task_action]) if opts[:task_action]
43
+ post_body.merge!(:generate_docs => true) if opts[:generate_docs]
43
44
 
44
45
  if opts[:set_parsed_false]
45
46
  post_body.merge!(:set_parsed_false => true)
@@ -49,21 +50,35 @@ module DTK::Client
49
50
  response = post(rest_url("#{module_type}/update_model_from_clone"), post_body)
50
51
  return response unless response.ok?
51
52
 
53
+ external_dependencies = response.data(:external_dependencies)
54
+ dsl_parse_error = response.data(:dsl_parse_error)
55
+ dsl_updated_info = response.data(:dsl_updated_info)
56
+ dsl_created_info = response.data(:dsl_created_info)
57
+ component_module_refs = response.data(:component_module_refs)
58
+
52
59
  ret = Response::Ok.new()
53
- external_dependencies = response.data('external_dependencies')
54
60
 
55
61
  # check if any errors
56
- if dsl_parse_error = response.data(:dsl_parse_error)
62
+ if dsl_parse_error
57
63
  if parsed_external_dependencies = dsl_parse_error['external_dependencies']
58
64
  external_dependencies = parsed_external_dependencies
59
- elsif err_message = ServiceImporter.error_message(module_name, dsl_parse_error)
60
- DTK::Client::OsUtil.print(err_message, :red)
61
- ret = Response::NoOp.new()
65
+ else
66
+ err_msg_opts = { :module_type => module_type }
67
+ err_msg_opts.merge!(:command => opts[:command]) if opts[:command]
68
+ if err_message = ServiceImporter.error_message(module_name, dsl_parse_error, err_msg_opts)
69
+ DTK::Client::OsUtil.print(err_message, :red)
70
+ ret = Response::NoOp.new()
71
+ end
62
72
  end
63
73
  end
64
74
 
75
+ has_code_been_pulled = false
76
+
65
77
  # check if server pushed anything that needs to be pulled
66
- dsl_updated_info = response.data(:dsl_updated_info)
78
+
79
+ # we need to pull latest code in case docs where generated
80
+ OsUtil.print("Pulling generated documentation on your local repository ...", :yellow) if opts[:generate_docs]
81
+
67
82
  if dsl_updated_info and !dsl_updated_info.empty?
68
83
  if msg = dsl_updated_info["msg"]
69
84
  DTK::Client::OsUtil.print(msg,:yellow)
@@ -72,10 +87,18 @@ module DTK::Client
72
87
  unless new_commit_sha and new_commit_sha == commit_sha
73
88
  opts_pull = opts.merge(:local_branch => branch,:namespace => module_namespace)
74
89
  resp = Helper(:git_repo).pull_changes(module_type, module_name, opts_pull)
90
+ has_code_been_pulled = true
75
91
  return resp unless resp.ok?
76
92
  end
77
93
  end
78
94
 
95
+ # unless DSL was updated we pull latest code due to changes on documentation
96
+ if opts[:generate_docs] && !has_code_been_pulled
97
+ opts_pull = opts.merge(:local_branch => branch,:namespace => module_namespace)
98
+ resp = Helper(:git_repo).pull_changes(module_type, module_name, opts_pull)
99
+ return resp unless resp.ok?
100
+ end
101
+
79
102
  if opts[:print_dependencies] || !internal_trigger
80
103
  if external_dependencies
81
104
  ambiguous = external_dependencies["ambiguous"]||[]
@@ -89,7 +112,6 @@ module DTK::Client
89
112
  end
90
113
 
91
114
  # check if server sent any file that should be added
92
- dsl_created_info = response.data(:dsl_created_info)
93
115
  if dsl_created_info and !dsl_created_info.empty?
94
116
  path = dsl_created_info["path"]
95
117
  content = dsl_created_info["content"]
@@ -100,22 +122,23 @@ module DTK::Client
100
122
  end
101
123
  end
102
124
 
103
- service_component_refs = response.data['component_module_refs']
104
- unless (service_component_refs||{}).empty?
105
- print_using_dependencies(service_component_refs)
125
+ unless (component_module_refs||{}).empty?
126
+ print_using_dependencies(component_module_refs)
106
127
  end
107
128
 
108
129
  ret
109
130
  end
110
131
 
111
132
  private
133
+
112
134
  def print_using_dependencies(component_refs)
113
- component_refs.each do |k, value|
114
- namespace = value['namespace_info']
115
- name = value['module_name']
116
- puts "Using component module '#{namespace}:#{name}'"
135
+ # TODO: This just prints out dircetly included modules
136
+ unless component_refs.empty?
137
+ puts 'Using component modules:'
138
+ component_refs.values.map { |r| "#{r['namespace_info']}:#{r['module_name']}" }.sort.each do |name|
139
+ puts " #{name}"
140
+ end
117
141
  end
118
142
  end
119
-
120
143
  end
121
144
  end
@@ -184,15 +184,16 @@ module DTK::Client
184
184
  response
185
185
  end
186
186
 
187
- desc "ASSEMBLY-NAME/ID stage [INSTANCE-NAME] [-t TARGET-NAME/ID] [--settings SETTINGS-NAME1[,..]]", "Stage assembly in target."
187
+ desc "ASSEMBLY-NAME/ID stage [INSTANCE-NAME] [-t TARGET-NAME/ID] [--node-size NODE-SIZE-SPEC] [--os-type OS-TYPE]", "Stage assembly in target."
188
188
  method_option "in-target",:aliases => "-t" ,
189
189
  :type => :string,
190
190
  :banner => "TARGET-NAME/ID",
191
191
  :desc => "Target (id) to create assembly in"
192
192
  #hidden option
193
- method_option "instance-bindings",
194
- :type => :string
193
+ method_option "instance-bindings", :type => :string
195
194
  method_option :settings, :type => :string, :aliases => '-s'
195
+ method_option :node_size, :type => :string, :aliases => "--node-size"
196
+ method_option :os_type, :type => :string, :aliases => "--os-type"
196
197
  def stage(context_params)
197
198
  assembly_template_id, service_module_id, name = context_params.retrieve_arguments([:assembly_id!, :service_module_id, :option_1],method_argument_names)
198
199
  post_body = {
@@ -211,10 +212,12 @@ module DTK::Client
211
212
  assembly_template_name.gsub!(/(::)|(\/)/,'-')
212
213
  end
213
214
 
214
- in_target = options["in-target"]
215
+ in_target = options["in-target"]
215
216
  instance_bindings = options["instance-bindings"]
216
- settings = parse_service_settings(options["settings"])
217
- assembly_list = Assembly.assembly_list()
217
+ settings = parse_service_settings(options["settings"])
218
+ node_size = options.node_size
219
+ os_type = options.os_type
220
+ assembly_list = Assembly.assembly_list()
218
221
 
219
222
  if name
220
223
  raise DTK::Client::DtkValidationError, "Unable to stage service with name '#{name}'. Service with specified name exists already!" if assembly_list.include?(name)
@@ -226,6 +229,8 @@ module DTK::Client
226
229
  post_body.merge!(:name => name) if name
227
230
  post_body.merge!(:instance_bindings => instance_bindings) if instance_bindings
228
231
  post_body.merge!(:settings_json_form => JSON.generate(settings)) if settings
232
+ post_body.merge!(:node_size => node_size) if node_size
233
+ post_body.merge!(:os_type => os_type) if os_type
229
234
 
230
235
  response = post rest_url("assembly/stage"), post_body
231
236
  return response unless response.ok?
@@ -336,8 +336,6 @@ module DTK::Client
336
336
  # version_method_option
337
337
  desc "COMPONENT-MODULE-NAME/ID clone [-n]", "Locally clone component module and component files. Use -n to skip edit prompt"
338
338
  method_option :skip_edit, :aliases => '-n', :type => :boolean, :default => false
339
- # DEBUG SNIPPET >>> REMOVE <<<
340
- # REMOVE TRIGGER!!!!
341
339
  def clone(context_params, internal_trigger=true)
342
340
  clone_module_aux(context_params, internal_trigger)
343
341
  end
@@ -349,19 +347,18 @@ module DTK::Client
349
347
  edit_module_aux(context_params)
350
348
  end
351
349
 
352
- # desc "COMPONENT-MODULE-NAME/ID push [-v VERSION] [-m COMMIT-MSG]", "Push changes from local copy of component module to server"
353
- # desc "COMPONENT-MODULE-NAME/ID push [-m COMMIT-MSG]", "Push changes from local copy of component module to server"
354
- desc "COMPONENT-MODULE-NAME/ID push [--force]", "Push changes from local copy of component module to server"
355
- version_method_option
356
- method_option "message",:aliases => "-m" ,
357
- :type => :string,
358
- :banner => "COMMIT-MSG",
359
- :desc => "Commit message"
360
- # hidden option for dev
361
- method_option :force, :type => :boolean, :default => false, :aliases => '-f'
362
- def push(context_params, internal_trigger=false)
350
+ desc "COMPONENT-MODULE-NAME/ID push [--force] [--docs]", "Push changes from local copy of component module to server"
351
+ version_method_option
352
+ method_option "message",:aliases => "-m" ,
353
+ :type => :string,
354
+ :banner => "COMMIT-MSG",
355
+ :desc => "Commit message"
356
+ # hidden option for dev
357
+ method_option :force, :type => :boolean, :default => false, :aliases => '-f'
358
+ method_option :docs, :type => :boolean, :default => false, :aliases => '-d'
359
+ def push(context_params, internal_trigger=false)
363
360
  push_module_aux(context_params, internal_trigger)
364
- end
361
+ end
365
362
 
366
363
  # desc "COMPONENT-MODULE-NAME/ID push-dtkn [-n NAMESPACE] [-m COMMIT-MSG]", "Push changes from local copy of component module to remote repository (dtkn)."
367
364
  desc "COMPONENT-MODULE-NAME/ID push-dtkn [-n NAMESPACE] [--force]", "Push changes from local copy of component module to remote repository (dtkn)."
@@ -1,4 +1,5 @@
1
1
  dtk_require_from_base('task_status')
2
+ dtk_require_common_commands('thor/node')
2
3
  dtk_require_common_commands('thor/set_required_attributes')
3
4
  dtk_require_common_commands('thor/assembly_workspace')
4
5
 
@@ -6,6 +7,7 @@ module DTK::Client
6
7
  class Node < CommandBaseThor
7
8
 
8
9
  include AssemblyWorkspaceMixin
10
+ include NodeMixin
9
11
 
10
12
  no_tasks do
11
13
  include TaskStatusMixin
@@ -95,7 +97,7 @@ module DTK::Client
95
97
  post rest_url("node/info"), post_body
96
98
  end
97
99
 
98
- desc "NODE-NAME/ID ssh REMOTE-USER [-i PATH-TO-PEM]","SSH into node, optional parameters are path to indentity file."
100
+ desc "NODE-NAME/ID ssh [LINUX-LOGIN-USER] [-i PATH-TO-PEM]","SSH into node."
99
101
  method_option "--identity-file",:aliases => '-i',:type => :string, :desc => "Identity-File used for connection, if not provided default is used", :banner => "IDENTITY-FILE"
100
102
  def ssh(context_params)
101
103
  if OsUtil.is_windows?
@@ -103,11 +105,11 @@ module DTK::Client
103
105
  return
104
106
  end
105
107
 
106
- node_id, remote_user = context_params.retrieve_arguments([:node_id!,:option_1!],method_argument_names)
108
+ node_id, login_user = context_params.retrieve_arguments([:node_id!,:option_1],method_argument_names)
107
109
 
108
110
  if identity_file_location = options['identity-file']
109
111
  unless File.exists?(identity_file_location)
110
- raise ::DTK::Client::DtkError, "Not able to find identity file, '#{identity_file_location}'"
112
+ raise DtkError, "Not able to find identity file, '#{identity_file_location}'"
111
113
  end
112
114
  elsif default_identity_file = OsUtil.dtk_identity_file_location()
113
115
  if File.exists?(default_identity_file)
@@ -115,42 +117,35 @@ module DTK::Client
115
117
  end
116
118
  end
117
119
 
118
- context_params.forward_options({ :json_return => true })
119
- # TODO: should call something taht just returns info about nodes, rather than info_aux
120
- # also info that comes back should indicate whether a node group and if so error message is that
121
- # ssh cannot be called on node group
122
- response = info_aux(context_params)
123
- if response.ok?
124
- node_info = {}
125
- response.data['nodes'].each do |node|
126
- properties = node['node_properties']
127
- node_info = properties if node_id == properties['node_id']
128
- end
129
- public_dns = node_info ? node_info['ec2_public_address'] : nil
130
-
131
- raise ::DTK::Client::DtkError, "Not able to resolve instance address, has instance been stopped?" unless public_dns
132
-
133
- connection_string = "#{remote_user}@#{public_dns}"
120
+ response = get_node_info_for_ssh_login(node_id, context_params)
121
+ return response unless response.ok?
134
122
 
123
+ unless public_dns = response.data(:public_dns)
124
+ raise DtkError, "Not able to resolve instance address, has instance been stopped?"
125
+ end
126
+
127
+ unless login_user ||= response.data(:default_login_user)
128
+ raise DtkError, "Retry command with a specfic login user (a default login user could not be computed)"
129
+ end
135
130
 
136
- ssh_command = nil
131
+ connection_string = "#{login_user}@#{public_dns}"
137
132
 
133
+ ssh_command =
138
134
  if identity_file_location
139
135
  # provided PEM key
140
- ssh_command = "ssh -o \"StrictHostKeyChecking no\" -o \"UserKnownHostsFile /dev/null\" -i #{identity_file_location} #{connection_string}"
141
- elsif SSHUtil.ssh_reachable?(remote_user, public_dns)
136
+ "ssh -o \"StrictHostKeyChecking no\" -o \"UserKnownHostsFile /dev/null\" -i #{identity_file_location} #{connection_string}"
137
+ elsif SSHUtil.ssh_reachable?(login_user, public_dns)
142
138
  # it has PUB key access
143
- ssh_command = "ssh -o \"StrictHostKeyChecking no\" -o \"UserKnownHostsFile /dev/null\" #{connection_string}"
139
+ "ssh -o \"StrictHostKeyChecking no\" -o \"UserKnownHostsFile /dev/null\" #{connection_string}"
144
140
  end
145
141
 
146
- raise ::DTK::Client::DtkError, "No public key access or PEM provided, please grant access or provide valid PEM key" if ssh_command.nil?
147
-
148
- OsUtil.print("You are entering SSH terminal (#{connection_string}) ...", :yellow)
149
- Kernel.system(ssh_command)
150
- OsUtil.print("You are leaving SSH terminal, and returning to DTK Shell ...", :yellow)
151
- else
152
- response
142
+ unless ssh_command
143
+ raise DtkError, "No public key access or PEM provided, please grant access or provide valid PEM key"
153
144
  end
145
+
146
+ OsUtil.print("You are entering SSH terminal (#{connection_string}) ...", :yellow)
147
+ Kernel.system(ssh_command)
148
+ OsUtil.print("You are leaving SSH terminal, and returning to DTK Shell ...", :yellow)
154
149
  end
155
150
 
156
151
  desc "NODE-NAME/ID list-components","List components that are on the node instance."
@@ -267,7 +262,7 @@ module DTK::Client
267
262
  if response.data and response.data.size > 0
268
263
  #TODO: may not directly print here; isntead use a lower level fn
269
264
  error_message = "The following violations were found; they must be corrected before the node can be converged"
270
- DTK::Client::OsUtil.print(error_message, :red)
265
+ OsUtil.print(error_message, :red)
271
266
  return response.render_table(:violation)
272
267
  end
273
268
 
@@ -310,7 +305,7 @@ module DTK::Client
310
305
  }
311
306
  unless options.force?
312
307
  # Ask user if really want to delete and destroy, if not then return to dtk-shell without deleting
313
- return unless Console.confirmation_prompt("Are you sure you want to destroy and delete node '#{node_id}'?")
308
+ return unless Console.confirmation_prompt("Are you sure you want to destroy and delete node '#{node_id}'"+"?")
314
309
  end
315
310
 
316
311
  response = post rest_url("node/destroy_and_delete"), post_body
@@ -460,7 +455,7 @@ module DTK::Client
460
455
  end
461
456
 
462
457
  if response.data(:result).nil?
463
- raise DTK::Client::DtkError, "Server seems to be taking too long to start node(s)."
458
+ raise DtkError, "Server seems to be taking too long to start node(s)."
464
459
  end
465
460
 
466
461
  task_id = response.data(:result)['task_id']
@@ -478,7 +473,7 @@ module DTK::Client
478
473
  def get_assembly_and_node_id(context_params)
479
474
  response = info(context_params)
480
475
  unless response.ok?
481
- raise DTK::Client::DtkError, "Unable to retrive node information, please try again."
476
+ raise DtkError, "Unable to retrive node information, please try again."
482
477
  end
483
478
 
484
479
  return response.data(:assembly_id), response.data(:id)
@@ -76,7 +76,7 @@ module DTK::Client
76
76
  ],
77
77
  :assembly => [
78
78
  ["info","info","# Info for given assembly in current service module."],
79
- ["stage", "stage [INSTANCE-NAME] [-t TARGET-NAME/ID]", "# Stage assembly in target."],
79
+ ["stage", "stage [INSTANCE-NAME] [-t TARGET-NAME/ID] [--node-size NODE-SIZE-SPEC] [--os-type OS-TYPE]", "# Stage assembly in target."],
80
80
  # ["deploy","deploy [-v VERSION] [INSTANCE-NAME] [-t TARGET-NAME/ID] [-m COMMIT-MSG]", "# Stage and deploy assembly in target."],
81
81
  # ["deploy","deploy [INSTANCE-NAME] [-t TARGET-NAME/ID] [-m COMMIT-MSG]", "# Stage and deploy assembly in target."],
82
82
  ["deploy","deploy [INSTANCE-NAME] [-m COMMIT-MSG]", "# Stage and deploy assembly in target."],
@@ -478,12 +478,13 @@ module DTK::Client
478
478
  =end
479
479
 
480
480
  # desc "SERVICE-MODULE-NAME/ID push [-m COMMIT-MSG]", "Push changes from local copy to server (origin)."
481
- desc "SERVICE-MODULE-NAME/ID push [--force]", "Push changes from local copy to server."
481
+ desc "SERVICE-MODULE-NAME/ID push [--force] [--docs]", "Push changes from local copy to server."
482
482
  method_option "message",:aliases => "-m" ,
483
483
  :type => :string,
484
484
  :banner => "COMMIT-MSG",
485
485
  :desc => "Commit message"
486
486
  method_option :force, :type => :boolean, :default => false, :aliases => '-f'
487
+ method_option :docs, :type => :boolean, :default => false, :aliases => '-d'
487
488
  def push(context_params, internal_trigger=false)
488
489
  push_module_aux(context_params, internal_trigger)
489
490
  end
@@ -214,7 +214,7 @@ module DTK::Client
214
214
  edit_module_aux(context_params)
215
215
  end
216
216
 
217
- desc "TEST-MODULE-NAME/ID push", "Push changes from local copy of test module to server"
217
+ desc "TEST-MODULE-NAME/ID push [--force] [--docs]", "Push changes from local copy of test module to server"
218
218
  version_method_option
219
219
  method_option "message",:aliases => "-m" ,
220
220
  :type => :string,
@@ -222,6 +222,8 @@ module DTK::Client
222
222
  :desc => "Commit message"
223
223
  # hidden option for dev
224
224
  method_option 'force-parse', :aliases => '-f', :type => :boolean, :default => false
225
+ method_option :force, :type => :boolean, :default => false
226
+ method_option :docs, :type => :boolean, :default => false, :aliases => '-d'
225
227
  def push(context_params, internal_trigger=false)
226
228
  push_module_aux(context_params, internal_trigger)
227
229
  end
@@ -1,3 +1,3 @@
1
1
  module DtkClient
2
- VERSION="0.7.6"
2
+ VERSION="0.7.7"
3
3
  end
@@ -112,7 +112,7 @@ module DTK
112
112
 
113
113
  val = value_of(structured_element,'dtk_type')||''
114
114
  # extract e.g. 3.1.1.1 from '3.1.1.1 action' etc.
115
- error_index = "[ #{val.scan( /\d+[,.]\d?[,.]?\d?[,.]?\d?[,.]?\d?/ ).first} ]"
115
+ error_index = "[ #{val.scan( /\d+[,.]?\d?[,.]?\d?[,.]?\d?[,.]?\d?/ ).first} ]"
116
116
 
117
117
  # original table takes that index
118
118
  evaluated_element.send("#{k}=", error_index)
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dtk-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.6
4
+ version: 0.7.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rich PELAVIN
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-04 00:00:00.000000000 Z
11
+ date: 2015-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mime-types
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.25'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.25'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.2.4
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.2.4
41
41
  - !ruby/object:Gem::Dependency
@@ -70,42 +70,42 @@ dependencies:
70
70
  name: hirb
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
75
  version: 0.7.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.7.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: thor
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ~>
88
88
  - !ruby/object:Gem::Version
89
89
  version: 0.15.4
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ~>
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.15.4
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: erubis
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ~>
102
102
  - !ruby/object:Gem::Version
103
103
  version: 2.7.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ~>
109
109
  - !ruby/object:Gem::Version
110
110
  version: 2.7.0
111
111
  - !ruby/object:Gem::Dependency
@@ -140,14 +140,14 @@ dependencies:
140
140
  name: colorize
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - "~>"
143
+ - - ~>
144
144
  - !ruby/object:Gem::Version
145
145
  version: 0.5.8
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - "~>"
150
+ - - ~>
151
151
  - !ruby/object:Gem::Version
152
152
  version: 0.5.8
153
153
  - !ruby/object:Gem::Dependency
@@ -225,6 +225,7 @@ files:
225
225
  - lib/commands/common/thor/list_diffs.rb
226
226
  - lib/commands/common/thor/module.rb
227
227
  - lib/commands/common/thor/module/import.rb
228
+ - lib/commands/common/thor/node.rb
228
229
  - lib/commands/common/thor/poller.rb
229
230
  - lib/commands/common/thor/pull_clone_changes.rb
230
231
  - lib/commands/common/thor/pull_from_remote.rb
@@ -381,17 +382,17 @@ require_paths:
381
382
  - lib
382
383
  required_ruby_version: !ruby/object:Gem::Requirement
383
384
  requirements:
384
- - - ">="
385
+ - - ! '>='
385
386
  - !ruby/object:Gem::Version
386
387
  version: '0'
387
388
  required_rubygems_version: !ruby/object:Gem::Requirement
388
389
  requirements:
389
- - - ">="
390
+ - - ! '>='
390
391
  - !ruby/object:Gem::Version
391
392
  version: '0'
392
393
  requirements: []
393
394
  rubyforge_project:
394
- rubygems_version: 2.4.1
395
+ rubygems_version: 2.4.8
395
396
  signing_key:
396
397
  specification_version: 4
397
398
  summary: DTK CLI client for DTK server interaction.