dtk-client 0.7.3 → 0.7.4

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,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f5b684856babcaa9d925ad089f311461b8ea4c6
4
- data.tar.gz: 952f5d25a660b8c17936cdc20ef80d1cd1c13ec7
3
+ metadata.gz: 9c2082aad673f9f8c447569657217f0649a15744
4
+ data.tar.gz: 5ccfc71b0d65e0e3e3d003ae6ab859ad1d770982
5
5
  SHA512:
6
- metadata.gz: 12d06bf9def6875592c3bbf2daf4c31c175d426875672854d4c1c4d8ad25bb14b2f0db998e45cd4c906ef24ad96352b76d1daeb769bde35bcb637bd0acdf1840
7
- data.tar.gz: 6dfd454ecc21eeba533d4ccb1ac130dfa9d7235055f133551bd320ff5d24366ad3f197da1b3a3eab572745bf11ba4352a36c63ae6f9e3653b5f645a4cea14467
6
+ metadata.gz: 4be06f509b412e40853aa433f1c8259ed5cda041fbf4386106d9ccdc27681a05b285fd93f14b03553ee794bc15d89b408e9e87f29680d28f216e33e635f160ae
7
+ data.tar.gz: fb600d5f4c54c9c01364c24175be7170a49804846330f0d2d4efaa2a210bd85ba07e6a0dc3bad590bf063ba3d8154b9fe34f333ea3d576e7d295f1ad93893f7f
@@ -45,9 +45,8 @@ module DTK::Client
45
45
  ##
46
46
  # Method will trigger import for each missing module component
47
47
  #
48
- def trigger_module_auto_import(missing_modules, required_modules, opts={})
48
+ def trigger_module_auto_import(modules_to_import, required_modules, opts={})
49
49
  puts "Auto-importing missing module(s)"
50
- modules_to_import = missing_modules
51
50
 
52
51
  # Print out installed modules
53
52
  required_modules.each do |r_module|
@@ -62,12 +61,27 @@ module DTK::Client
62
61
  module_name = full_module_name(m_module)
63
62
  module_type = m_module['type']
64
63
 
65
- print "Importing #{module_type.gsub('_',' ')} '#{module_name}' ... "
66
- new_context_params = ::DTK::Shell::ContextParams.new([module_name])
67
- new_context_params.override_method_argument!('option_2', m_module['version'])
68
- new_context_params.forward_options( { :skip_cloning => false, :skip_auto_install => true, :module_type => module_type}).merge!(opts)
64
+ # we check if there is module_url if so we install from git
65
+ module_url = m_module['module_url']
66
+
67
+ # descriptive message
68
+ import_msg = "Importing #{module_type.gsub('_',' ')} '#{module_name}'"
69
+ import_msg += " from git source #{module_url}" if module_url
70
+ print "#{import_msg} ... "
71
+
72
+ unless module_url
73
+ # import from Repo Manager
74
+ new_context_params = ::DTK::Shell::ContextParams.new([module_name])
75
+ new_context_params.override_method_argument!('option_2', m_module['version'])
76
+ new_context_params.forward_options( { :skip_cloning => false, :skip_auto_install => true, :module_type => module_type}).merge!(opts)
77
+ response = ContextRouter.routeTask(module_type, "install", new_context_params, @conn)
78
+ else
79
+ # import from Git source
80
+ new_context_params = ::DTK::Shell::ContextParams.new([module_url, module_name])
81
+ new_context_params.forward_options( { :internal_trigger => true })
82
+ response = ContextRouter.routeTask(module_type, "import_git", new_context_params, @conn)
83
+ end
69
84
 
70
- response = ContextRouter.routeTask(module_type, "install", new_context_params, @conn)
71
85
  puts(response.data(:does_not_exist) ? response.data(:does_not_exist) : "Done.")
72
86
  raise DTK::Client::DtkError, response.error_message unless response.ok?
73
87
  end
@@ -270,7 +270,7 @@ module DTK::Client
270
270
  if dsl_parsing_errors = response.data(:dsl_parsing_errors)
271
271
  error_message = "Module '#{component_module_name}' parsing errors found:\n#{dsl_parsing_errors}\nYou can fix errors using 'edit' command from module context and invoke promote-module-updates again.\n"
272
272
  OsUtil.print(error_message, :red)
273
- return Response::Error.new()
273
+ return Response::NoOp.new()
274
274
  end
275
275
  module_name,namespace,branch,ff_change = response.data(:module_name,:module_namespace,:workspace_branch,:fast_forward_change)
276
276
  ff_change ||= true
@@ -323,7 +323,7 @@ module DTK::Client
323
323
  response = Helper(:git_repo).pull_changes?(:component_module, module_name, edit_opts.merge!(opts))
324
324
  return response unless response.ok?()
325
325
 
326
- edit_opts.merge!(:force_parse => true, :update_from_includes => true, :print_dependencies => true)
326
+ edit_opts.merge!(:force_parse => true, :update_from_includes => true, :print_dependencies => true, :remote_branch => local_branch)
327
327
  response = push_clone_changes_aux(:component_module, module_id, nil, "Pull base module updates", true, edit_opts)
328
328
 
329
329
  unless response.ok?()
@@ -1201,6 +1201,7 @@ module DTK::Client
1201
1201
  def grep_aux(context_params)
1202
1202
  if context_params.is_there_identifier?(:node)
1203
1203
  mapping = [REQ_ASSEMBLY_OR_WS_ID,:option_1!,:node_id!,:option_2!]
1204
+ is_node = true
1204
1205
  else
1205
1206
  mapping = [REQ_ASSEMBLY_OR_WS_ID,:option_1!,:option_2!,:option_3!]
1206
1207
  end
@@ -1263,7 +1264,7 @@ module DTK::Client
1263
1264
  console_width.times do
1264
1265
  print "="
1265
1266
  end
1266
- puts "NODE-ID: #{message_colorized}\n"
1267
+ puts "NODE-ID: #{message_colorized}\n" unless is_node
1267
1268
  puts "Log output:\n"
1268
1269
  puts r[1]["output"].gsub(/`/,'\'')
1269
1270
  end
@@ -10,7 +10,9 @@ module DTK::Client
10
10
  include PushCloneChangesMixin
11
11
  include ReparseMixin
12
12
 
13
- def from_git()
13
+ def from_git(internal_trigger = false)
14
+ OsUtil.print('Retrieving git module data, please wait ...') unless internal_trigger
15
+
14
16
  git_repo_url, module_name = retrieve_arguments([:option_1!, :option_2!])
15
17
  namespace, local_module_name = get_namespace_and_name(module_name, ModuleUtil::NAMESPACE_SEPERATOR)
16
18
 
@@ -59,7 +61,9 @@ module DTK::Client
59
61
  print_external_dependencies(external_dependencies, 'in the git repo')
60
62
  end
61
63
 
62
- OsUtil.print("Successfully installed #{ModuleUtil.module_name(module_type)} '#{ModuleUtil.join_name(@module_name, @module_namespace)}' from git.", :green)
64
+ unless internal_trigger
65
+ OsUtil.print("Successfully installed #{ModuleUtil.module_name(module_type)} '#{ModuleUtil.join_name(@module_name, @module_namespace)}' from git.", :green)
66
+ end
63
67
  end
64
68
 
65
69
  def from_file()
@@ -193,6 +193,7 @@ module DTK::Client
193
193
 
194
194
  git_import = opts[:git_import]
195
195
  opts.merge!(:update_from_includes => true, :force_parse => true) unless git_import
196
+ opts.merge!(:force => options.force?)
196
197
 
197
198
  reparse_aux(module_location)
198
199
  push_clone_changes_aux(module_type.to_sym, module_id, version, options["message"]||DEFAULT_COMMIT_MSG, internal_trigger, opts)
@@ -222,8 +223,7 @@ module DTK::Client
222
223
  end
223
224
 
224
225
  def import_git_module_aux(context_params)
225
- OsUtil.print('Retrieving git module data, please wait ...')
226
- CommonModule::Import.new(self, context_params).from_git()
226
+ CommonModule::Import.new(self, context_params).from_git(context_params.get_forwarded_options()[:internal_trigger])
227
227
  end
228
228
 
229
229
  def import_module_aux(context_params)
@@ -310,17 +310,18 @@ module DTK::Client
310
310
  module_type = get_module_type(context_params)
311
311
  remote_module_name = context_params.retrieve_arguments([:option_1!],method_argument_names)
312
312
 
313
- # for service_module we are doing this on server side
314
- remote_namespace, remote_module_name = get_namespace_and_name(remote_module_name,'/') unless module_type.eql?('service_module')
313
+ # remote_module_name can be namespace:name or namespace/name
314
+ remote_namespace, remote_module_name = get_namespace_and_name(remote_module_name, ':')
315
315
 
316
- unless options.force?
316
+ unless options.force? || options.confirmed?
317
317
  return unless Console.confirmation_prompt("Are you sure you want to delete remote #{module_type} '#{remote_namespace.nil? ? '' : remote_namespace+'/'}#{remote_module_name}' and all items contained in it"+'?')
318
318
  end
319
319
 
320
320
  post_body = {
321
321
  :rsa_pub_key => SSHUtil.rsa_pub_key_content(),
322
322
  :remote_module_name => remote_module_name,
323
- :remote_module_namespace => remote_namespace
323
+ :remote_module_namespace => remote_namespace,
324
+ :force_delete => options.force?
324
325
  }
325
326
 
326
327
  post rest_url("#{module_type}/delete_remote"), post_body
@@ -7,7 +7,7 @@ module DTK::Client
7
7
  ##
8
8
  #
9
9
  # module_type: will be :component_module or :service_module
10
- def push_clone_changes_aux(module_type,module_id,version,commit_msg,internal_trigger=false,opts={})
10
+ def push_clone_changes_aux(module_type, module_id, version, commit_msg, internal_trigger=false, opts={})
11
11
  module_name, module_namespace, repo_url, branch, not_ok_response = workspace_branch_info(module_type, module_id, version, opts)
12
12
  return not_ok_response if not_ok_response
13
13
 
@@ -37,6 +37,7 @@ module DTK::Client
37
37
  post_body.merge!(:update_from_includes => true) if opts[:update_from_includes]
38
38
  post_body.merge!(:service_instance_module => true) if opts[:service_instance_module]
39
39
  post_body.merge!(:current_branch_sha => opts[:current_branch_sha]) if opts[:current_branch_sha]
40
+ post_body.merge!(:force => opts[:force]) if opts[:force]
40
41
 
41
42
  if opts[:set_parsed_false]
42
43
  post_body.merge!(:set_parsed_false => true)
@@ -138,7 +138,7 @@ module DTK::Client
138
138
  # Creates component module from input git repo, removing .git dir to rid of pointing to user github, and creates component module
139
139
  #
140
140
  method_option :branch, :aliases => '-b'
141
- desc "import-git GIT-SSH-REPO-URL [-b BRANCH/TAG] [NAMESPACE:]COMPONENT-MODULE-NAME", "Create new local component module by importing from provided git repo URL"
141
+ desc "import-git GIT-SSH-REPO-URL [NAMESPACE:]COMPONENT-MODULE-NAME [-b BRANCH/TAG]", "Create new local component module by importing from provided git repo URL"
142
142
  def import_git(context_params)
143
143
  response = import_git_module_aux(context_params)
144
144
  @@invalidate_map << :component_module
@@ -236,8 +236,9 @@ module DTK::Client
236
236
  end
237
237
  =end
238
238
 
239
- desc "delete-from-catalog NAMESPACE/REMOTE-COMPONENT-MODULE-NAME [-y]", "Delete the component module from the DTK Network catalog"
240
- method_option :force, :aliases => '-y', :type => :boolean, :default => false
239
+ desc "delete-from-catalog NAMESPACE/REMOTE-COMPONENT-MODULE-NAME [-y] [--force]", "Delete the component module from the DTK Network catalog"
240
+ method_option :confirmed, :aliases => '-y', :type => :boolean, :default => false
241
+ method_option :force, :type => :boolean, :default => false
241
242
  def delete_from_catalog(context_params)
242
243
  delete_from_catalog_aux(context_params)
243
244
  end
@@ -400,14 +401,14 @@ module DTK::Client
400
401
 
401
402
  # desc "COMPONENT-MODULE-NAME/ID push [-v VERSION] [-m COMMIT-MSG]", "Push changes from local copy of component module to server"
402
403
  # desc "COMPONENT-MODULE-NAME/ID push [-m COMMIT-MSG]", "Push changes from local copy of component module to server"
403
- desc "COMPONENT-MODULE-NAME/ID push", "Push changes from local copy of component module to server"
404
+ desc "COMPONENT-MODULE-NAME/ID push [--force]", "Push changes from local copy of component module to server"
404
405
  version_method_option
405
406
  method_option "message",:aliases => "-m" ,
406
407
  :type => :string,
407
408
  :banner => "COMMIT-MSG",
408
409
  :desc => "Commit message"
409
410
  # hidden option for dev
410
- method_option 'force-parse', :aliases => '-f', :type => :boolean, :default => false
411
+ method_option :force, :type => :boolean, :default => false, :aliases => '-f'
411
412
  def push(context_params, internal_trigger=false)
412
413
  push_module_aux(context_params, internal_trigger)
413
414
  end
@@ -159,7 +159,13 @@ module DTK::Client
159
159
  ['get-netstats',"get-netstats","# Get netstats."],
160
160
  ['get-ps',"get-ps [--filter PATTERN]","# Get ps."],
161
161
  ['grep',"grep LOG-PATH NODE-ID-PATTERN GREP-PATTERN [--first]","# Grep log from multiple nodes. --first option returns first match (latest log entry)."],
162
- ['tail',"tail NODE-NAME LOG-PATH [REGEX-PATTERN] [--more]","# Tail specified number of lines from log."]
162
+ ['tail',"tail NODE-NAME LOG-PATH [REGEX-PATTERN] [--more]","# Tail log from specified node."]
163
+ ],
164
+ :node_utils => [
165
+ ['get-netstats',"get-netstats","# Get netstats."],
166
+ ['get-ps',"get-ps [--filter PATTERN]","# Get ps."],
167
+ ['grep',"grep LOG-PATH GREP-PATTERN [--first]","# Grep log from node. --first option returns first match (latest log entry)."],
168
+ ['tail',"tail LOG-PATH [REGEX-PATTERN] [--more]","# Tail log from node."]
163
169
  ]
164
170
  },
165
171
  :identifier_only => {
@@ -299,7 +299,7 @@ module DTK::Client
299
299
  :banner => "NAMESPACE",
300
300
  :desc => "Remote namespace"
301
301
  method_option :force,:aliases => '-f',
302
- :type => :boolean,
302
+ :type => :boolean,
303
303
  :desc => "Force pull",
304
304
  :default => false
305
305
  def pull_dtkn(context_params)
@@ -524,13 +524,12 @@ module DTK::Client
524
524
  =end
525
525
 
526
526
  # desc "SERVICE-MODULE-NAME/ID push [-m COMMIT-MSG]", "Push changes from local copy to server (origin)."
527
- desc "SERVICE-MODULE-NAME/ID push", "Push changes from local copy to server."
527
+ desc "SERVICE-MODULE-NAME/ID push [--force]", "Push changes from local copy to server."
528
528
  method_option "message",:aliases => "-m" ,
529
529
  :type => :string,
530
530
  :banner => "COMMIT-MSG",
531
531
  :desc => "Commit message"
532
- #hidden option for dev
533
- method_option 'force-parse', :aliases => '-f', :type => :boolean, :default => false
532
+ method_option :force, :type => :boolean, :default => false, :aliases => '-f'
534
533
  def push(context_params, internal_trigger=false)
535
534
  push_module_aux(context_params, internal_trigger)
536
535
  end
@@ -569,8 +568,9 @@ module DTK::Client
569
568
  response
570
569
  end
571
570
 
572
- desc "delete-from-catalog NAMESPACE/REMOTE-SERVICE-MODULE-NAME [-y]", "Delete the service module from the DTK Network catalog"
573
- method_option :force, :aliases => '-y', :type => :boolean, :default => false
571
+ desc "delete-from-catalog NAMESPACE/REMOTE-SERVICE-MODULE-NAME [-y] [--force]", "Delete the service module from the DTK Network catalog"
572
+ method_option :confirmed, :aliases => '-y', :type => :boolean, :default => false
573
+ method_option :force, :type => :boolean, :default => false
574
574
  def delete_from_catalog(context_params)
575
575
  delete_from_catalog_aux(context_params)
576
576
  end
@@ -138,8 +138,9 @@ module DTK::Client
138
138
  create_test_module_aux(context_params)
139
139
  end
140
140
 
141
- desc "delete-from-catalog NAMESPACE/REMOTE-TEST-MODULE-NAME [-y]", "Delete the test module from the DTK Network catalog"
142
- method_option :force, :aliases => '-y', :type => :boolean, :default => false
141
+ desc "delete-from-catalog NAMESPACE/REMOTE-TEST-MODULE-NAME [-y] [--force]", "Delete the test module from the DTK Network catalog"
142
+ method_option :confirmed, :aliases => '-y', :type => :boolean, :default => false
143
+ method_option :force, :type => :boolean, :default => false
143
144
  def delete_from_catalog(context_params)
144
145
  delete_from_catalog_aux(context_params)
145
146
  end
data/lib/core.rb CHANGED
@@ -475,7 +475,7 @@ module DTK
475
475
  DefaultRestOpts = {:timeout => 2000, :open_timeout => 10, :error_response_class => Client::Response::Error}
476
476
  # DefaultRestOpts = {:timeout => 50, :open_timeout => 2, :error_response_class => Client::Response::Error}
477
477
  else
478
- DefaultRestOpts = {:timeout => 100, :open_timeout => 10, :error_response_class => Client::Response::Error}
478
+ DefaultRestOpts = {:timeout => 150, :open_timeout => 10, :error_response_class => Client::Response::Error}
479
479
  end
480
480
 
481
481
  # enable SSL verification
@@ -1,3 +1,3 @@
1
1
  module DtkClient
2
- VERSION="0.7.3"
2
+ VERSION="0.7.4"
3
3
  end
@@ -174,6 +174,12 @@ class Thor
174
174
  if override_tasks_obj && is_n_level_context
175
175
  last_entity_name = active_context.last_context_entity_name.to_sym
176
176
 
177
+ # special case for node_id/utils (we don't want to use utils from service context)
178
+ command_list = active_context.command_list
179
+ if (command_list.size > 2) && command_list.last.eql?('utils')
180
+ last_entity_name = command_list.last(2).join('_').to_sym
181
+ end
182
+
177
183
  # we get commands task, and identifier tasks for given entity (e.g. :assembly)
178
184
  command_o_tasks, identifier_o_tasks = override_tasks_obj.get_all_tasks(last_entity_name)
179
185
 
data/lib/util/console.rb CHANGED
@@ -39,7 +39,7 @@ module DTK::Client
39
39
  def confirmation_prompt_simple(message, add_options=true)
40
40
  # used to disable skip with ctrl+c
41
41
  trap("INT", "SIG_IGN")
42
- message += " (y/n)" if add_options
42
+ message += " (Y/n)" if add_options
43
43
 
44
44
  while line = Readline.readline("#{message}: ", true)
45
45
  if (line.eql?("yes") || line.eql?("y") || line.empty?)
@@ -15,7 +15,7 @@ module DTK
15
15
  end
16
16
 
17
17
  def self.module_name(module_type)
18
- module_type.gsub('_',' ')
18
+ module_type.to_s.gsub('_',' ')
19
19
  end
20
20
 
21
21
  # returns [namespace,name]; namespace can be null if cant determine it
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dtk-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.7.4
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-04-30 00:00:00.000000000 Z
11
+ date: 2015-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mime-types