dtk-client 0.7.1.1 → 0.7.2

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.
Files changed (41) hide show
  1. checksums.yaml +5 -13
  2. data/Gemfile +1 -1
  3. data/Gemfile_dev +1 -0
  4. data/bin/dtk-execute +1 -18
  5. data/dtk-client.gemspec +1 -1
  6. data/lib/client.rb +0 -5
  7. data/lib/command_helpers/git_repo.rb +43 -12
  8. data/lib/commands/common/thor/assembly_workspace.rb +3 -3
  9. data/lib/commands/common/thor/module.rb +81 -7
  10. data/lib/commands/common/thor/module/import.rb +14 -4
  11. data/lib/commands/common/thor/pull_from_remote.rb +2 -0
  12. data/lib/commands/common/thor/push_clone_changes.rb +1 -1
  13. data/lib/commands/common/thor/push_to_remote.rb +18 -4
  14. data/lib/commands/common/thor/remotes.rb +54 -0
  15. data/lib/commands/common/thor/{set_required_params.rb → set_required_attributes.rb} +1 -1
  16. data/lib/commands/thor/component.rb +2 -2
  17. data/lib/commands/thor/component_module.rb +56 -7
  18. data/lib/commands/thor/dtk.rb +7 -7
  19. data/lib/commands/thor/node.rb +4 -4
  20. data/lib/commands/thor/node_group.rb +4 -4
  21. data/lib/commands/thor/remotes.rb +32 -0
  22. data/lib/commands/thor/service.rb +9 -5
  23. data/lib/commands/thor/service_module.rb +41 -5
  24. data/lib/commands/thor/test_module.rb +43 -3
  25. data/lib/commands/thor/workspace.rb +8 -4
  26. data/lib/core.rb +3 -0
  27. data/lib/domain/git_adapter.rb +15 -8
  28. data/lib/domain/response.rb +39 -26
  29. data/lib/dtk-client/version.rb +1 -1
  30. data/lib/execute.rb +1 -1
  31. data/lib/execute/command/api_call/service.rb +1 -0
  32. data/lib/execute/script.rb +50 -0
  33. data/lib/execute/script/add_tenant.rb +91 -0
  34. data/lib/execute/script/add_tenant_without_router.rb +87 -0
  35. data/lib/shell/context.rb +15 -9
  36. data/lib/shell/domain/context_params.rb +2 -0
  37. data/lib/shell/help_monkey_patch.rb +4 -0
  38. data/lib/util/os_util.rb +2 -1
  39. metadata +27 -24
  40. data/lib/execute/examples.rb +0 -3
  41. data/lib/execute/examples/add_tenant.rb +0 -42
@@ -0,0 +1,87 @@
1
+ class DTK::Client::Execute::Script
2
+ class AddTenantWithoutRouter < self
3
+ def self.ret_params_from_argv()
4
+ banner = "Usage: dtk-execute add-tenant-no-router TENANT-NAME CATALOG-USERNAME -p PASSWORD [-s SERVICE-INSTANCE]"
5
+ tenant_name = catalog_username = tenant_number = nil
6
+ if ARGV.size > 2
7
+ tenant_name = ARGV[1]
8
+ if tenant_name =~ /^dtk([0-9]+)$/
9
+ tenant_number = $1
10
+ else
11
+ raise ErrorUsage.new("TENANT-NAME must be of form 'dtkNUMs', like dtk601")
12
+ end
13
+ catalog_username = ARGV[2]
14
+ else
15
+ show_help_and_exit(banner)
16
+ end
17
+
18
+ params = Hash.new
19
+ process_params_from_options(banner) do |opts|
20
+ opts.on( '-p', '--password PASSWORD', "Password for tenant and catalog" ) do |pw|
21
+ params[:password] = pw
22
+ end
23
+ opts.on( '-s', '--service SERVICE-INSTANCE', "Name of Service instance" ) do |s|
24
+ params[:service_instance] = s
25
+ end
26
+ end
27
+
28
+ # TODO: use opt parser to enforce that :password option is manditory
29
+ unless password = params[:password]
30
+ raise ErrorUsage.new("Password is mandatory; use -p commnd line option")
31
+ end
32
+ service_instance = params[:service_instance] || "dtkhost#{tenant_number[0]}"
33
+ to_add = {
34
+ :tenant_name => tenant_name,
35
+ :catalog_username => catalog_username,
36
+ :service_instance => service_instance
37
+ }
38
+ params.merge(to_add)
39
+ end
40
+
41
+ def self.execute_with_params(params)
42
+ tenant_name = params[:tenant_name]
43
+ catalog_username = params[:catalog_username]
44
+ service = params[:service_instance]
45
+ password = params[:password]
46
+ node = params[:node_name] || 'server'
47
+
48
+ component_with_namespace = "dtk-meta-user:dtk_tenant[#{tenant_name}]"
49
+ component_namespace, component = (component_with_namespace =~ /(^[^:]+):(.+$)/; [$1,$2])
50
+
51
+ av_pairs = {
52
+ :catalog_username => catalog_username,
53
+ :tenant_password => password,
54
+ :catalog_password => password
55
+ }
56
+
57
+ ExecuteContext(:print_results => true) do
58
+ result = call 'service/add_component',
59
+ :service => service,
60
+ :node => node,
61
+ :component => component,
62
+ :namespace => component_namespace,
63
+ :donot_update_workflow => true
64
+
65
+ av_pairs.each_pair do |a,v|
66
+ result = call 'service/set_attribute',
67
+ :service => service,
68
+ :attribute_path => "#{node}/#{component}/#{a}",
69
+ :value => v
70
+ end
71
+
72
+ ['dtk_postgresql::databases'].each do |shared_service_component|
73
+ result = call 'service/link_components',
74
+ :service => service,
75
+ :input_component => "#{node}/#{component}",
76
+ :output_component => "#{node}/#{shared_service_component}"
77
+ end
78
+
79
+ result = call 'service/execute_workflow',
80
+ :service => service,
81
+ :workflow_name => 'add_tenant_without_router',
82
+ :workflow_params => {'name' => tenant_name}
83
+
84
+ end
85
+ end
86
+ end
87
+ end
data/lib/shell/context.rb CHANGED
@@ -172,14 +172,6 @@ module DTK
172
172
  # component-templates to autocomplete
173
173
  extended_candidates, new_context, line_buffer_first = {}, nil, nil
174
174
  command_clazz = Context.get_command_class(active_context_copy.last_command_name)
175
- # require 'debugger'
176
- # Debugger.start
177
- # debugger
178
- # unless (line_buffer.empty? || line_buffer.strip().empty?)
179
- # line_buffer_last = line_buffer.split(' ').last
180
- # line_buffer = line_buffer.split(' ').first
181
- # line_buffer.gsub!('-','_') unless (line_buffer.nil? || line_buffer.empty?)
182
- # end
183
175
 
184
176
  unless (line_buffer.empty? || line_buffer.strip().empty?)
185
177
  line_buffer = line_buffer.split(' ')
@@ -336,6 +328,16 @@ module DTK
336
328
  clazz = DTK::Shell::Context.get_command_class(command)
337
329
  error_message, invalid_context = validate_command(clazz, current_context_clazz, command, active_context_copy)
338
330
 
331
+ # restrict utils subcontext in service/service_name/node_group only
332
+ if active_context_copy.last_context_is_shadow_entity? && active_context_copy.last_context.shadow_entity().eql?('node_group')
333
+ if current_context_clazz.respond_to?(:multi_context_children)
334
+ multi_context_children = current_context_clazz.multi_context_children()
335
+ if command.eql?('utils') && multi_context_children.include?(command.to_sym)
336
+ return active_context_copy, "'#{command}' context is not valid.", invalid_context
337
+ end
338
+ end
339
+ end
340
+
339
341
  break if error_message
340
342
  # if we are dealing with new entries add them to active_context
341
343
  active_context_copy.push_new_context(command, command) if (i >= ac_size)
@@ -748,6 +750,11 @@ module DTK
748
750
  n_level_ac_candidates.concat(node_names)
749
751
  end
750
752
 
753
+ # restrict autocomple to utils subcontext in service/service_name/node_group only
754
+ if active_context_copy.last_context_is_shadow_entity? && active_context_copy.last_context().shadow_entity().eql?('node_group')
755
+ n_level_ac_candidates.delete('utils')
756
+ end
757
+
751
758
  n_level_ac_candidates
752
759
  end
753
760
  else
@@ -911,7 +918,6 @@ module DTK
911
918
  options_param_args = nil
912
919
  invalid_options << e
913
920
  break
914
- # raise DTK::Client::DtkValidationError, "Option '#{e}' is not valid for current command!"
915
921
  else
916
922
  options_param_args << e
917
923
  options_param_args << args[i+1] unless type == :boolean
@@ -8,6 +8,8 @@ module DTK::Shell
8
8
  @current_context = ActiveContext.new
9
9
  @method_arguments = override_method_arguments
10
10
  @thor_options = Hash.new
11
+
12
+ @method_arguments
11
13
  end
12
14
 
13
15
  def add_context_to_params(context_name, entity_name, context_value = nil)
@@ -237,6 +237,10 @@ class Thor
237
237
  if @@shell_context && @@shell_context.active_context.current_identifier?
238
238
  sub_children += command_clazz.valid_children() if command_clazz.respond_to?(:valid_children)
239
239
  sub_children += command_clazz.invisible_context_list()
240
+ # remove utils subcontext from help in service/service_name/node_group only
241
+ if @@shell_context.active_context.last_context_is_shadow_entity? && @@shell_context.active_context.shadow_entity().eql?('node_group')
242
+ sub_children.delete(:utils)
243
+ end
240
244
  else
241
245
  if command_clazz.respond_to?(:validation_list)
242
246
  sub_children += ["#{last_command_name}-identifier"]
data/lib/util/os_util.rb CHANGED
@@ -233,7 +233,7 @@ module DTK
233
233
  # color - Symbol describing the color to be used on STDOUT
234
234
  #
235
235
  # Void
236
- def print(message, color)
236
+ def print(message, color = :white)
237
237
  puts colorize(message, color)
238
238
  end
239
239
 
@@ -286,6 +286,7 @@ module DTK
286
286
  load File.expand_path('../../lib/shell/domain/active_context.rb', File.dirname(__FILE__))
287
287
  load File.expand_path('../../lib/shell/domain/context_params.rb', File.dirname(__FILE__))
288
288
  load File.expand_path('../../lib/shell/domain/override_tasks.rb', File.dirname(__FILE__))
289
+ load File.expand_path('../../lib/shell.rb', File.dirname(__FILE__))
289
290
  load File.expand_path('../../lib/shell/context.rb', File.dirname(__FILE__))
290
291
  load File.expand_path('../../lib/domain/git_adapter.rb', File.dirname(__FILE__))
291
292
  load File.expand_path('../../lib/command_helpers/git_repo.rb', File.dirname(__FILE__))
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.1.1
4
+ version: 0.7.2
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-03-31 00:00:00.000000000 Z
11
+ date: 2015-04-08 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
@@ -114,40 +114,40 @@ dependencies:
114
114
  requirements:
115
115
  - - '='
116
116
  - !ruby/object:Gem::Version
117
- version: 0.7.0.1
117
+ version: 0.7.1
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - '='
123
123
  - !ruby/object:Gem::Version
124
- version: 0.7.0.1
124
+ version: 0.7.1
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: git
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ~>
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
131
  version: 1.2.6
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ~>
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: 1.2.6
139
139
  - !ruby/object:Gem::Dependency
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
@@ -228,8 +228,9 @@ files:
228
228
  - lib/commands/common/thor/purge_clone.rb
229
229
  - lib/commands/common/thor/push_clone_changes.rb
230
230
  - lib/commands/common/thor/push_to_remote.rb
231
+ - lib/commands/common/thor/remotes.rb
231
232
  - lib/commands/common/thor/reparse.rb
232
- - lib/commands/common/thor/set_required_params.rb
233
+ - lib/commands/common/thor/set_required_attributes.rb
233
234
  - lib/commands/common/thor/task_status.rb
234
235
  - lib/commands/common/thor/test_action_agent.rb
235
236
  - lib/commands/thor/account.rb
@@ -247,6 +248,7 @@ files:
247
248
  - lib/commands/thor/node_template.rb
248
249
  - lib/commands/thor/project.rb
249
250
  - lib/commands/thor/provider.rb
251
+ - lib/commands/thor/remotes.rb
250
252
  - lib/commands/thor/repo.rb
251
253
  - lib/commands/thor/service.rb
252
254
  - lib/commands/thor/service_module.rb
@@ -281,10 +283,11 @@ files:
281
283
  - lib/execute/command_processor.rb
282
284
  - lib/execute/command_processor/rest_call.rb
283
285
  - lib/execute/error_usage.rb
284
- - lib/execute/examples.rb
285
- - lib/execute/examples/add_tenant.rb
286
286
  - lib/execute/execute_context.rb
287
287
  - lib/execute/execute_context/result_store.rb
288
+ - lib/execute/script.rb
289
+ - lib/execute/script/add_tenant.rb
290
+ - lib/execute/script/add_tenant_without_router.rb
288
291
  - lib/git-logs/git.log
289
292
  - lib/parser/adapters/option_parser.rb
290
293
  - lib/parser/adapters/thor.rb
@@ -353,17 +356,17 @@ require_paths:
353
356
  - lib
354
357
  required_ruby_version: !ruby/object:Gem::Requirement
355
358
  requirements:
356
- - - ! '>='
359
+ - - ">="
357
360
  - !ruby/object:Gem::Version
358
361
  version: '0'
359
362
  required_rubygems_version: !ruby/object:Gem::Requirement
360
363
  requirements:
361
- - - ! '>='
364
+ - - ">="
362
365
  - !ruby/object:Gem::Version
363
366
  version: '0'
364
367
  requirements: []
365
368
  rubyforge_project:
366
- rubygems_version: 2.2.2
369
+ rubygems_version: 2.4.1
367
370
  signing_key:
368
371
  specification_version: 4
369
372
  summary: DTK CLI client for DTK server interaction.
@@ -1,3 +0,0 @@
1
- class DTK::Client::Execute
2
- dtk_require('examples/add_tenant')
3
- end
@@ -1,42 +0,0 @@
1
- class DTK::Client::Execute
2
-
3
- def self.add_tenant(tenant_name,params={})
4
- component = "dtk_tenant[#{tenant_name}]"
5
- service = 'dtkhost5'
6
- node = 'server'
7
- tenant_password = params[:tenant_password] || 'foo'
8
- catalog_user_name = params[:catalog_user_name] || tenant_name
9
-
10
- ExecuteContext(:print_results => true) do
11
- result = call 'service/add_component',
12
- :service => service,
13
- :node => node,
14
- :component => component,
15
- :donot_update_workflow => true
16
-
17
- result = call 'service/set_attribute',
18
- :service => service,
19
- :attribute_path => "#{node}/#{component}/tenant_password",
20
- :value => tenant_password
21
-
22
- result = call 'service/set_attribute',
23
- :service => service,
24
- :attribute_path => "#{node}/#{component}/catalog_user_name",
25
- :value => catalog_user_name
26
-
27
- ['dtk_postgresql::databases'].each do |shared_service_component|
28
- result = call 'service/link_components',
29
- :service => service,
30
- :input_component => "#{node}/#{component}",
31
- :output_component => "#{node}/#{shared_service_component}"
32
- end
33
-
34
- result = call 'service/execute_workflow',
35
- :service => service,
36
- :workflow_name => 'add_tenant',
37
- :workflow_params => {'name' => tenant_name}
38
-
39
-
40
- end
41
- end
42
- end