dtk-client 0.5.12 → 0.5.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTZhMDBlMWM1ZWUzYjFiNWFlNTg2NDJmZTE2MjQ2ZGU4YmFjYmZiMQ==
4
+ NmJlZDdmMWJjOGQ1ZGQ3YWFiMjE0N2RiZmUyOGQzMTQ1NGM2ZmI0Ng==
5
5
  data.tar.gz: !binary |-
6
- NWNkODg5NjU2NWJmN2Q4YzkzNDZmZTE1NzU1OTE5YWExZmJhNzVmZA==
6
+ NzAzNTJiNDNhYmE4NTNlZGJlYWFiYjBhNGQ1MjQxMWUxMTJiZWM0ZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MzQ0ZmVmYmM0NmY4NmJlMGZiYWFmODY0NWYyOTI5YWFmYmJjZWViZDliNGY5
10
- YTFlMjRmZTZlZTI0NWI3OTFlNDIyZGNkZmIyYTZlODgyMWZhNGRmZDNlNDZj
11
- NzRmMzMyYzgzMTllOWMyOTZlZTFhMWJkNGQwM2VhZjI1NmIyZGQ=
9
+ ZmM1MzkxMzEwNDVlYzZiNzQwZDAyYTM5N2VhZjEzZmQzNDJiNDhkOWVmNTI0
10
+ NWQyNTYzNDkzNWViM2Q0MDRjZWQ3NjU1YTQxZjQ0ZmU5YjNjMzgwOTA4OWJh
11
+ MThkNzBhN2RlZDQxZDg1YTRhOWNiMGRiMTdiYjZiMDMyMTFlYjA=
12
12
  data.tar.gz: !binary |-
13
- MTUwYzA1Y2E0NzEwY2Y0ZGZkMDcwNzRkNTVlOWNmZDBkZTkwY2M5NjQ3NzUz
14
- MWY5ZTEzMmNlOGQ5NGNlY2EwYzg3ZTU3ZjQ2M2ExNTcyNzA0YmZmOGY5ZmIy
15
- YTkxNzQ0OGVkMTYxZmI3MDZiZmRkYzk1Y2I3YjM5M2M3N2RkYTQ=
13
+ MWJmYjViNmE2MmQwNWY4NTFkYWU3NzVlNWY5M2MwNzg2ODU1MTNlYWFjMjVl
14
+ MjA5NDdmOWY2ZWE4OWFmOTllMjdmYTQzOTQ0OTc4ZjlhOGQ3MGVlNWEwZTI1
15
+ OGEzNzA3OWRhYmQ2ZjVlYTEzMzk0NmU3MWRiY2EyMjE2NjY5N2Y=
@@ -277,7 +277,8 @@ module DTK; module Client; class CommandHelper
277
277
  repo.fetch(remote(opts[:remote_repo]))
278
278
  end
279
279
 
280
- local_branch = repo.branch
280
+ local_branch = repo.current_branch_name
281
+
281
282
  remote_branch_ref = remote_branch_ref(local_branch, opts)
282
283
 
283
284
  commit_shas = Hash.new
@@ -13,6 +13,7 @@ LOG_SLEEP_TIME_W = DTK::Configuration.get(:tail_log_frequency)
13
13
  module DTK::Client
14
14
  module AssemblyWorkspaceMixin
15
15
  REQ_ASSEMBLY_OR_WS_ID = [:service_id!, :workspace_id!]
16
+
16
17
  def get_name(assembly_or_workspace_id)
17
18
  get_name_from_id_helper(assembly_or_workspace_id)
18
19
  end
@@ -722,10 +723,18 @@ module DTK::Client
722
723
  end
723
724
 
724
725
  def execute_tests_aux(context_params)
725
- execute_test_tries = 10
726
+ assembly_or_workspace_id,node_id = context_params.retrieve_arguments([REQ_ASSEMBLY_OR_WS_ID,:node_id],method_argument_names)
727
+
728
+ execute_test_tries = 30
726
729
  execute_test_sleep = 1
727
730
 
728
- assembly_or_workspace_id,node_id = context_params.retrieve_arguments([REQ_ASSEMBLY_OR_WS_ID,:node_id],method_argument_names)
731
+ if !options['timeout'].nil?
732
+ begin
733
+ execute_test_tries = Integer(options['timeout'])
734
+ rescue
735
+ raise DTK::Client::DtkValidationError, "Timeout value is not valid"
736
+ end
737
+ end
729
738
 
730
739
  #Get list of components on particular node
731
740
  post_body = {
@@ -755,10 +764,7 @@ module DTK::Client
755
764
  end
756
765
  end
757
766
  end
758
-
759
- if components.empty?
760
- components = nil
761
- end
767
+ components = nil if components.empty?
762
768
 
763
769
  post_body = {
764
770
  :assembly_id => assembly_or_workspace_id,
@@ -767,6 +773,7 @@ module DTK::Client
767
773
  }
768
774
 
769
775
  response = post(rest_url("assembly/initiate_execute_tests"),post_body)
776
+
770
777
  raise DTK::Client::DtkValidationError, response.data(:errors).first if response.data(:errors)
771
778
  return response unless response.ok?
772
779
 
@@ -783,6 +790,13 @@ module DTK::Client
783
790
  response = post(rest_url("assembly/get_action_results"),post_body)
784
791
  count += 1
785
792
  if count > execute_test_tries or response.data(:is_complete)
793
+ error_msg = ""
794
+ response.data(:results).each do |k,v|
795
+ unless v.nil?
796
+ error_msg << v['test_error'] if v.to_s.include?('test_error')
797
+ end
798
+ end
799
+ raise DTK::Client::DtkError, "Error while executing test script:\n" + error_msg + "Please fix test script with edit-component-module command and try again." unless error_msg.empty?
786
800
  end_loop = true
787
801
  else
788
802
  #last time in loop return whetever is there
@@ -793,8 +807,14 @@ module DTK::Client
793
807
  end
794
808
  end
795
809
 
796
- response.set_data(*response.data(:results))
797
- response.render_table(:execute_tests_data)
810
+ if (response.data(:results).empty? && options['timeout'].nil?)
811
+ raise DTK::Client::DtkValidationError, "Could not finish execution of tests in default timeframe (#{execute_test_tries} seconds). Try again with passing --timeout TIMEOUT parameter"
812
+ elsif (response.data(:results).empty? && !options['timeout'].nil?)
813
+ raise DTK::Client::DtkValidationError, "Could not finish execution of tests in set timeframe (#{execute_test_tries} seconds). Try again with increasing --timeout TIMEOUT parameter"
814
+ else
815
+ response.set_data(*response.data(:results))
816
+ response.render_table(:execute_tests_data)
817
+ end
798
818
  end
799
819
 
800
820
  def get_ps_aux(context_params)
@@ -56,6 +56,11 @@ module DTK::Client
56
56
  Console.unix_shell(module_location, module_id, module_type, version)
57
57
  end
58
58
 
59
+ unless grit_adapter.repo_exists?
60
+ puts "Local module has been removed, skipping changes."
61
+ return Response::Ok.new()
62
+ end
63
+
59
64
  unless grit_adapter.changed?
60
65
  puts "No changes to repository"
61
66
  return Response::Ok.new()
@@ -79,15 +84,19 @@ module DTK::Client
79
84
  end
80
85
  confirmed_ok = Console.confirmation_prompt(confirm_msg)
81
86
  end
82
-
83
87
  if (auto_commit || confirmed_ok)
84
88
  if auto_commit
85
89
  puts "[NOTICE] You are using auto-commit option, all changes you have made will be commited."
86
90
  end
87
91
  commit_msg = user_input("Commit message")
92
+
93
+ # remove qoutes if they are not closed properly in commit_msg
94
+ commit_msg.gsub!(/\"/,'') unless commit_msg.count('"') % 2 ==0
95
+
88
96
  internal_trigger=true
89
97
  reparse_aux(module_location)
90
98
  response = push_clone_changes_aux(module_type,module_id,version,commit_msg,internal_trigger,opts)
99
+
91
100
  # if error return
92
101
  return response unless response.ok?
93
102
  end
@@ -21,7 +21,7 @@ module DTK::Client
21
21
  remote_params = response.data_hash_form(:remote_repo_url,:remote_repo,:remote_branch)
22
22
  remote_params.merge!(:version => version) if version
23
23
 
24
- #check and import component module dependencies before importing service itself
24
+ # check and import component module dependencies before importing service itself
25
25
  if (module_type == :service_module)
26
26
  import_module_component_dependencies(module_id,remote_namespace)
27
27
  end
@@ -11,6 +11,16 @@ module DTK::Client
11
11
  module_name,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
 
14
+ module_location = OsUtil.module_location(module_type,module_name,version,opts)
15
+
16
+ unless File.directory?(module_location)
17
+ if Console.confirmation_prompt("Push not possible, module '#{module_name}#{version && "-#{version}"}' has not been cloned. Would you like to clone module now"+'?')
18
+ clone_aux(module_type,module_id, version, true, true, opts)
19
+ else
20
+ return
21
+ end
22
+ end
23
+
14
24
  push_opts = opts.merge(:commit_msg => commit_msg, :local_branch => branch)
15
25
  response = Helper(:git_repo).push_changes(module_type,module_name,version,push_opts)
16
26
  return response unless response.ok?
@@ -138,7 +138,7 @@ module DTK::Client
138
138
  response = post rest_url("account/remove_user_direct_access"), post_body
139
139
  return response unless response.ok?
140
140
 
141
- OsUtil.print("Ssh key '#{name}' removed successfully!", :yellow)
141
+ OsUtil.print("SSH key '#{name}' removed successfully!", :yellow)
142
142
  nil
143
143
  end
144
144
 
@@ -171,7 +171,7 @@ module DTK::Client
171
171
  Response::Ok.new()
172
172
  end
173
173
 
174
- =begin
174
+
175
175
  desc "COMPONENT-MODULE-NAME/ID set-attribute ATTRIBUTE-ID VALUE", "Set value of component module attributes"
176
176
  def set_attribute(context_params)
177
177
  if context_params.is_there_identifier?(:attribute)
@@ -184,12 +184,13 @@ module DTK::Client
184
184
 
185
185
  post_body = {
186
186
  :attribute_id => attribute_id,
187
- :attribute_value => value
187
+ :attribute_value => value,
188
+ :component_module_id => component_module_id
188
189
  }
189
190
 
190
191
  post rest_url("attribute/set"), post_body
191
192
  end
192
- =end
193
+
193
194
  #### end: create and delete commands ###
194
195
 
195
196
  =begin
@@ -584,26 +585,28 @@ TODO: might deprecate
584
585
  :type => :string,
585
586
  :banner => "NAMESPACE",
586
587
  :desc => "Remote namespace"
587
-
588
588
  def pull_dtkn(context_params)
589
589
  component_module_id, component_module_name = context_params.retrieve_arguments([:component_module_id!,:component_module_name,:option_1],method_argument_names)
590
590
  catalog = 'dtkn'
591
591
  version = options["version"]
592
+
592
593
  raise DtkValidationError, "You have to provide valid catalog to pull changes from! Valid catalogs: #{PullCatalogs}" unless catalog
593
594
 
595
+ if component_module_name.to_s =~ /^[0-9]+$/
596
+ component_module_id = component_module_name
597
+ component_module_name = get_module_name(component_module_id)
598
+ end
599
+
600
+ modules_path = OsUtil.module_clone_location()
601
+ module_location = "#{modules_path}/#{component_module_name}#{version && "-#{version}"}"
602
+
594
603
  if catalog.to_s.eql?("dtkn")
604
+ clone_aux(:component_module, component_module_id, version, true, true) unless File.directory?(module_location)
605
+
595
606
  opts = {:version => version, :remote_namespace => options.namespace}
596
607
  response = pull_from_remote_aux(:component_module,component_module_id,opts)
597
608
  return response unless response.ok?
598
609
 
599
- if component_module_name.to_s =~ /^[0-9]+$/
600
- component_module_id = component_module_name
601
- component_module_name = get_module_name(component_module_id)
602
- end
603
-
604
- modules_path = OsUtil.module_clone_location()
605
- module_location = "#{modules_path}/#{component_module_name}#{version && "-#{version}"}"
606
-
607
610
  push_clone_changes_aux(:component_module,component_module_id,version,nil,true) if File.directory?(module_location)
608
611
  Response::Ok.new()
609
612
  #elsif catalog.to_s.eql?("origin")
@@ -143,8 +143,8 @@ 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 => [
147
- ['execute-tests',"execute-tests [--component COMPONENT-NAME]","# Execute tests. --component filters results per component."],
146
+ :utils => [
147
+ ['execute-tests',"execute-tests [--component COMPONENT-NAME] [--timeout TIMEOUT]","# Execute tests. --component filters execution per component, --timeout changes default execution timeout."],
148
148
  ['get-netstats',"get-netstats","# Get netstats."],
149
149
  ['get-ps',"get-ps [--filter PATTERN]","# Get ps."],
150
150
  ['grep',"grep LOG-PATH NODE-ID-PATTERN GREP-PATTERN [--first]","# Grep log from multiple nodes. --first option returns first match (latest log entry)."],
@@ -635,8 +635,9 @@ TODO: will put in dot release and will rename to 'extend'
635
635
  end
636
636
 
637
637
  # using HIDE_FROM_BASE to hide this command from base context (dtk:/assembly>)
638
- desc "HIDE_FROM_BASE execute-tests [--component COMPONENT-NAME]", "Execute tests. --component filters results per component"
638
+ desc "HIDE_FROM_BASE execute-tests [--component COMPONENT-NAME] [--timeout TIMEOUT]", "Execute tests. --component filters execution per component, --timeout changes default execution timeout"
639
639
  method_option :component, :type => :string, :desc => "Component name"
640
+ method_option :timeout, :type => :string, :desc => "Timeout"
640
641
  def execute_tests(context_params)
641
642
  execute_tests_aux(context_params)
642
643
  end
@@ -360,19 +360,21 @@ module DTK::Client
360
360
 
361
361
  raise DtkValidationError, "You have to provide valid catalog to pull changes from! Valid catalogs: #{PullCatalogs}" unless catalog
362
362
 
363
+ if service_module_name.to_s =~ /^[0-9]+$/
364
+ service_module_id = service_module_name
365
+ service_module_name = get_service_module_name(service_module_id)
366
+ end
367
+
368
+ modules_path = OsUtil.service_clone_location()
369
+ module_location = "#{modules_path}/#{service_module_name}#{version && "-#{version}"}"
370
+
363
371
  if catalog.to_s.eql?("dtkn")
372
+ clone_aux(:service_module, service_module_id, version, true, true) unless File.directory?(module_location)
373
+
364
374
  opts = {:version => version, :remote_namespace => options.namespace}
365
375
  response = pull_from_remote_aux(:service_module,service_module_id,opts)
366
376
  return response unless response.ok?
367
377
 
368
- if service_module_name.to_s =~ /^[0-9]+$/
369
- service_module_id = service_module_name
370
- service_module_name = get_service_module_name(service_module_id)
371
- end
372
-
373
- modules_path = OsUtil.service_clone_location()
374
- module_location = "#{modules_path}/#{service_module_name}#{version && "-#{version}"}"
375
-
376
378
  # server repo needs to be sync with local clone, so we will use push-clone-changes when pull changes from remote to local
377
379
  # to automatically sync local with server repo
378
380
  push_clone_changes_aux(:service_module,service_module_id,version,nil,true) if File.directory?(module_location)
@@ -116,7 +116,7 @@ module DTK::Client
116
116
  ['list-components',"list-components","# List components."]
117
117
  ],
118
118
  :utils => [
119
- ['execute-tests',"execute-tests [--component COMPONENT-NAME]","# Execute tests. --component filters results per component."],
119
+ ['execute-tests',"execute-tests [--component COMPONENT-NAME] [--timeout TIMEOUT]","# Execute tests. --component filters execution per component, --timeout changes default execution timeout."],
120
120
  ['get-netstats',"get-netstats","# Get netstats."],
121
121
  ['get-ps',"get-ps [--filter PATTERN]","# Get ps."],
122
122
  ['grep',"grep LOG-PATH NODE-ID-PATTERN GREP-PATTERN [--first]","# Grep log from multiple nodes. --first option returns first match (latest log entry)."],
@@ -315,8 +315,9 @@ module DTK::Client
315
315
  end
316
316
 
317
317
  # using HIDE_FROM_BASE to hide this command from base context (dtk:/workspace>)
318
- desc "HIDE_FROM_BASE execute-tests [--component COMPONENT-NAME]", "Execute tests. --component filters results per component"
319
- method_option :component, :type => :string, :desc => "Component name"
318
+ desc "HIDE_FROM_BASE execute-tests [--component COMPONENT-NAME] [--timeout TIMEOUT]", "Execute tests. --component filters execution per component, --timeout changes default execution timeout"
319
+ method_option :component, :type => :string, :desc => "Component name"
320
+ method_option :timeout, :type => :string, :desc => "Timeout"
320
321
  def execute_tests(context_params)
321
322
  execute_tests_aux(context_params)
322
323
  end
data/lib/core.rb CHANGED
@@ -199,7 +199,7 @@ module DTK
199
199
  raise DTK::Client::DtkError.new("[#{where} INTERNAL ERROR] #{error_msg}", :backtrace => error_backtrace)
200
200
  else
201
201
  # if usage error occurred, display message to console and display that same message to log
202
- raise DTK::Client::DtkError, "[ERROR] #{error_msg}."
202
+ raise DTK::Client::DtkError, "[ERROR] #{error_msg}"
203
203
  end
204
204
  end
205
205
  end
@@ -191,6 +191,10 @@ module DTK
191
191
  @git_repo.dir.path
192
192
  end
193
193
 
194
+ def repo_exists?
195
+ Dir.exists?(repo_dir)
196
+ end
197
+
194
198
  def current_branch_name
195
199
  current_branch.name
196
200
  end
@@ -1,3 +1,3 @@
1
1
  module DtkClient
2
- VERSION="0.5.12"
2
+ VERSION="0.5.13"
3
3
  end
data/lib/util/console.rb CHANGED
@@ -82,12 +82,14 @@ module DTK::Client
82
82
  Dir.chdir(path)
83
83
  puts "[NOTICE] You are switching to unix-shell, to path #{path}"
84
84
 
85
- prompt = DTK::Client::OsUtil.colorize("$dtk:unix-shell ", :yellow)
85
+ # prompt = DTK::Client::OsUtil.colorize("$dtk:unix-shell ", :yellow)
86
+ prompt = DTK::Client::OsUtil.colorize("$:", :yellow)
87
+
86
88
  Readline.completion_append_character = ""
87
89
  Readline.completion_proc = Proc.new do |str|
88
90
  Dir[str+'*'].grep(/^#{Regexp.escape(str)}/)
89
91
  end
90
- while line = Readline.readline("#{prompt}#{Dir.getwd()}>", true)
92
+ while line = Readline.readline("#{prompt}#{OsUtil.current_dir}>", true)
91
93
  begin
92
94
  line = line.chomp()
93
95
  break if line.eql?('exit')
data/lib/util/os_util.rb CHANGED
@@ -79,6 +79,11 @@ module DTK
79
79
  return (is_windows? ? "#{genv(:homedrive)}#{genv(:homepath)}" : "#{genv(:home)}")
80
80
  end
81
81
 
82
+ def current_dir
83
+ current_dir = Dir.getwd()
84
+ current_dir.gsub(home_dir, '~')
85
+ end
86
+
82
87
  def genv(name)
83
88
  return ENV[name.to_s.upcase].gsub(/\\/,'/')
84
89
  end
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.5.12
4
+ version: 0.5.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rich PELAVIN
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-08 00:00:00.000000000 Z
11
+ date: 2014-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -187,21 +187,22 @@ executables:
187
187
  extensions: []
188
188
  extra_rdoc_files: []
189
189
  files:
190
- - README.md
191
190
  - Gemfile
192
191
  - Gemfile_dev
193
- - dtk-client.gemspec
192
+ - README.md
194
193
  - bin/dtk
195
194
  - bin/dtk-shell
195
+ - dtk-client.gemspec
196
196
  - lib/auxiliary.rb
197
197
  - lib/bundler_monkey_patch.rb
198
198
  - lib/client.rb
199
199
  - lib/command_helper.rb
200
200
  - lib/command_helpers/git_repo.rb
201
- - lib/command_helpers/jenkins_client/config_xml.rb
202
201
  - lib/command_helpers/jenkins_client.rb
202
+ - lib/command_helpers/jenkins_client/config_xml.rb
203
203
  - lib/command_helpers/service_importer.rb
204
204
  - lib/command_helpers/service_link.rb
205
+ - lib/commands.rb
205
206
  - lib/commands/common/thor/action_result_handler.rb
206
207
  - lib/commands/common/thor/assembly_workspace.rb
207
208
  - lib/commands/common/thor/clone.rb
@@ -239,7 +240,6 @@ files:
239
240
  - lib/commands/thor/task.rb
240
241
  - lib/commands/thor/utils.rb
241
242
  - lib/commands/thor/workspace.rb
242
- - lib/commands.rb
243
243
  - lib/config/cacert.pem
244
244
  - lib/config/client.conf.header
245
245
  - lib/config/configuration.rb
@@ -257,10 +257,11 @@ files:
257
257
  - lib/error.rb
258
258
  - lib/git-logs/git.log
259
259
  - lib/parser/adapters/option_parser.rb
260
- - lib/parser/adapters/thor/common_option_defs.rb
261
260
  - lib/parser/adapters/thor.rb
261
+ - lib/parser/adapters/thor/common_option_defs.rb
262
262
  - lib/require_first.rb
263
263
  - lib/search_hash.rb
264
+ - lib/shell.rb
264
265
  - lib/shell/context.rb
265
266
  - lib/shell/context_aux.rb
266
267
  - lib/shell/domain.rb
@@ -269,16 +270,15 @@ files:
269
270
  - lib/shell/interactive_wizard.rb
270
271
  - lib/shell/parse_monkey_patch.rb
271
272
  - lib/shell/status_monitor.rb
272
- - lib/shell.rb
273
273
  - lib/util/console.rb
274
274
  - lib/util/dtk_puppet.rb
275
275
  - lib/util/os_util.rb
276
276
  - lib/util/ssh_util.rb
277
+ - lib/view_processor.rb
277
278
  - lib/view_processor/augmented_simple_list.rb
278
279
  - lib/view_processor/hash_pretty_print.rb
279
280
  - lib/view_processor/simple_list.rb
280
281
  - lib/view_processor/table_print.rb
281
- - lib/view_processor.rb
282
282
  - puppet/manifests/init.pp
283
283
  - puppet/manifests/params.pp
284
284
  - puppet/r8meta.puppet.yml
@@ -327,7 +327,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
327
327
  version: '0'
328
328
  requirements: []
329
329
  rubyforge_project:
330
- rubygems_version: 2.1.9
330
+ rubygems_version: 2.2.2
331
331
  signing_key:
332
332
  specification_version: 4
333
333
  summary: DTK CLI client for DTK server interaction.