dtk-client 0.7.2.1 → 0.7.3

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.
@@ -17,7 +17,7 @@ module DTK::Client
17
17
  return DTK::Shell::OverrideTasks.new({
18
18
  :command_only => {
19
19
  :target => [
20
- ['delete-target',"delete-target TARGET-IDENTIFIER","# Deletes target"],
20
+ ['delete-and-destroy',"delete-and-destroy TARGET-NAME","# Deletes target"],
21
21
  ['list',"list","# Lists available targets."]
22
22
 
23
23
  ]
@@ -32,32 +32,35 @@ module DTK::Client
32
32
  end
33
33
 
34
34
  def self.valid_child?(name_of_sub_context)
35
- return Provider.valid_children().include?(name_of_sub_context.to_sym)
35
+ Provider.valid_children().include?(name_of_sub_context.to_sym)
36
36
  end
37
37
 
38
- desc "create-ec2-provider PROVIDER-NAME --keypair KEYPAIR --security-group SECURITY-GROUP(S) [--bootstrap]", "Create ec2 provider. Multiple security groups separated with ',' (gr1,gr2,gr3,...)"
38
+ desc "create-provider-ec2 PROVIDER-NAME [--keypair KEYPAIR] [--security-group SECURITY-GROUP(S)]", "Create provider for ec2 vpc or classic. Multiple security groups separated with ',' (gr1,gr2,gr3,...)"
39
39
  method_option :keypair, :type => :string
40
40
  method_option :security_group, :type => :string, :aliases => '--security-groups'
41
+ # TODO: made this a hidden option; needs to be updated because now choice if vpc or classic
41
42
  method_option :bootstrap, :type => :boolean, :default => false
42
- def create_ec2_provider(context_params)
43
+ def create_provider_ec2(context_params)
43
44
  provider_name = context_params.retrieve_arguments([:option_1!],method_argument_names)
44
45
  provider_type = 'ec2'
45
46
 
46
47
  iaas_properties = Hash.new
47
- #TODO: data-driven check if legal provider type and then what options needed depending on provider type
48
48
 
49
- security_groups = []
50
- keypair, security_group = context_params.retrieve_thor_options([:keypair!, :security_group!], options)
49
+ keypair, security_group = context_params.retrieve_thor_options([:keypair, :security_group], options)
51
50
 
52
- raise ::DTK::Client::DtkValidationError.new("Multiple security groups should be separated with ',' and without spaces between them (e.g. --security_groups gr1,gr2,gr3,...) ") if security_group.end_with?(',')
51
+ iaas_properties.merge!(:keypair => keypair) if keypair
52
+ if security_group
53
+ if security_group.end_with?(',')
54
+ raise ::DTK::Client::DtkValidationError.new("Multiple security groups should be separated with ',' and without spaces between them (e.g. --security_groups gr1,gr2,gr3,...) ")
55
+ end
53
56
 
54
- security_groups = security_group.split(',')
55
- iaas_properties.merge!(:keypair_name => keypair)
57
+ security_groups = security_group.split(',')
56
58
 
57
- if (security_groups.empty? || security_groups.size==1)
58
- iaas_properties.merge!(:security_group => security_group)
59
- else
60
- iaas_properties.merge!(:security_group_set => security_groups)
59
+ if (security_groups.empty? || security_groups.size==1)
60
+ iaas_properties.merge!(:security_group => security_group)
61
+ else
62
+ iaas_properties.merge!(:security_group_set => security_groups)
63
+ end
61
64
  end
62
65
 
63
66
  result = DTK::Shell::InteractiveWizard::interactive_user_input(
@@ -73,40 +76,37 @@ module DTK::Client
73
76
 
74
77
  post_body = {
75
78
  :iaas_properties => iaas_properties,
76
- :provider_name => provider_name,
77
- :iaas_type => provider_type,
78
- :no_bootstrap => ! options.bootstrap?
79
+ :provider_name => provider_name,
80
+ :iaas_type => 'ec2',
81
+ :no_bootstrap => ! options.bootstrap?
79
82
  }
80
83
 
81
84
  response = post rest_url("target/create_provider"), post_body
82
85
  @@invalidate_map << :provider
83
86
 
84
- return response
87
+ response
85
88
  end
86
89
 
87
- desc "create-physical-provider PROVIDER-NAME", "Create physical provider."
88
- method_option :keypair, :type => :string
89
- method_option :security_group, :type => :string, :aliases => '--security-groups'
90
- method_option :bootstrap, :type => :boolean, :default => false
91
- def create_physical_provider(context_params)
90
+ desc "create-provider-physical PROVIDER-NAME", "Create provider to manage physical nodes."
91
+ def create_provider_physical(context_params)
92
92
  provider_name = context_params.retrieve_arguments([:option_1!],method_argument_names)
93
- provider_type = 'physical'
94
93
 
95
94
  # Remove sensitive readline history
96
95
  OsUtil.pop_readline_history(2)
97
96
 
98
97
  post_body = {
99
98
  :provider_name => provider_name,
100
- :iaas_type => provider_type,
101
- :no_bootstrap => ! options.bootstrap?
99
+ :iaas_type => 'physical'
102
100
  }
103
101
 
104
102
  response = post rest_url("target/create_provider"), post_body
105
103
  @@invalidate_map << :provider
106
104
 
107
- return response
105
+ response
108
106
  end
109
107
 
108
+ =begin
109
+ TODO: deprecated until this can be in sync with create-targets from target context where params depend on type
110
110
 
111
111
  desc "PROVIDER-ID/NAME create-target [TARGET-NAME] --region REGION --keypair KEYPAIR --security-group SECURITY-GROUP(S)", "Create target based on given provider"
112
112
  method_option :region, :type => :string
@@ -142,9 +142,9 @@ module DTK::Client
142
142
  response = post rest_url("target/create"), post_body
143
143
  @@invalidate_map << :target
144
144
 
145
- return response
145
+ response
146
146
  end
147
-
147
+ =end
148
148
 
149
149
  desc "list","Lists available providers."
150
150
  def list(context_params)
@@ -173,33 +173,26 @@ module DTK::Client
173
173
  response.render_table(:target)
174
174
  end
175
175
 
176
- # Aldin: moved to target base context (target>set-default-target)
177
- #
178
- # desc "set-default-target TARGET-NAME/ID","Sets the default target."
179
- # def set_default_target(context_params)
180
- # target_id = context_params.retrieve_arguments([:option_1!],method_argument_names)
181
- # post rest_url("target/set_default"), { :target_id => target_id }
182
- # end
183
-
184
- desc "delete-provider PROVIDER-IDENTIFIER [-y]","Deletes targets provider"
185
- method_option :force, :aliases => '-y', :type => :boolean, :default => false
186
- def delete_provider(context_params)
176
+ desc "delete-and-destroy PROVIDER-NAME","Deletes target provider, its targets, and their assemblies"
177
+ def delete_and_destroy(context_params)
187
178
  provider_id = context_params.retrieve_arguments([:option_1!],method_argument_names)
188
179
 
189
- unless options.force?
190
- return unless Console.confirmation_prompt("Are you sure you want to delete provider with identifier '#{provider_id}'"+'?')
191
- end
192
-
193
- # this goes to provider
194
- # Console.confirmation_prompt("Are you sure you want to delete target '#{target_id}' (all assemblies that belong to this target will be deleted as well)'"+'?')
180
+ # require explicit acknowldegement since deletes all targtes under it
181
+ return unless Console.confirmation_prompt("Are you sure you want to delete provider '#{provider_id}' and all target and service instances under it" +'?')
195
182
 
196
183
  post_body = {
197
- :provider_id => provider_id
184
+ :target_id => provider_id,
185
+ :type => 'template'
198
186
  }
199
187
 
200
188
  @@invalidate_map << :provider
201
189
 
202
- post rest_url("target/delete_provider"), post_body
190
+ response = post(rest_url("target/delete_and_destroy"),post_body)
191
+ return response unless response.ok?
192
+ if info_array = response.data['info']
193
+ info_array.each{|info_msg|OsUtil.print(info_msg, :yellow)}
194
+ end
195
+ Response::Ok.new()
203
196
  end
204
197
 
205
198
  no_tasks do
@@ -94,6 +94,11 @@ module DTK::Client
94
94
  :delete_node_group => {
95
95
  :endpoint => "assembly",
96
96
  :url => "assembly/get_node_groups"
97
+ },
98
+ :pull_base_component_module => {
99
+ :endpoint => "assembly",
100
+ :url => "assembly/info_about",
101
+ :opts => {:subtype=>"instance", :about=>"modules"}
97
102
  }
98
103
  }
99
104
  }
@@ -271,6 +276,13 @@ module DTK::Client
271
276
  Response::Ok.new()
272
277
  end
273
278
 
279
+ desc "SERVICE-NAME/ID pull-base-component-module COMPONENT-MODULE-NAME [--force] [--revert]", "Pull base component module changes to component module in the service"
280
+ method_option :force, :type => :boolean, :default => false, :aliases => '-f'
281
+ method_option :revert, :type => :boolean, :default => false, :aliases => '-r'
282
+ def pull_base_component_module(context_params)
283
+ pull_base_component_module_aux(context_params)
284
+ end
285
+
274
286
  desc "SERVICE-NAME/ID push-component-module-updates COMPONENT-MODULE-NAME [--force]", "Push changes made to a component module in the service to its base component module."
275
287
  method_option :force, :type => :boolean, :default => false, :aliases => '-f'
276
288
  def push_component_module_updates(context_params)
@@ -293,11 +293,15 @@ module DTK::Client
293
293
  # end
294
294
 
295
295
  # desc "SERVICE-MODULE-NAME/ID pull-from-dtkn [-n NAMESPACE] [-v VERSION]", "Update local service module from remote repository."
296
- desc "SERVICE-MODULE-NAME/ID pull-dtkn [-n NAMESPACE]", "Update local service module from remote repository."
297
- method_option "namespace",:aliases => "-n",
298
- :type => :string,
296
+ desc "SERVICE-MODULE-NAME/ID pull-dtkn [-n NAMESPACE] [--force]", "Update local service module from remote repository."
297
+ method_option :namespace,:aliases => '-n',
298
+ :type => :string,
299
299
  :banner => "NAMESPACE",
300
- :desc => "Remote namespace"
300
+ :desc => "Remote namespace"
301
+ method_option :force,:aliases => '-f',
302
+ :type => :boolean,
303
+ :desc => "Force pull",
304
+ :default => false
301
305
  def pull_dtkn(context_params)
302
306
  pull_dtkn_aux(context_params)
303
307
  end
@@ -605,6 +609,11 @@ module DTK::Client
605
609
  remote_remove_aux(context_params)
606
610
  end
607
611
 
612
+ desc "SERVICE-MODULE-NAME/ID fork NAMESPACE", "Fork service module to new namespace"
613
+ def fork(context_params)
614
+ fork_aux(context_params)
615
+ end
616
+
608
617
  #
609
618
  # DEVELOPMENT MODE METHODS
610
619
  #
@@ -1,8 +1,11 @@
1
+ dtk_require_common_commands('thor/common_base')
1
2
  dtk_require_common_commands('thor/inventory_parser')
3
+ dtk_require_common_commands('thor/create_target')
2
4
  module DTK::Client
3
5
  class Target < CommandBaseThor
6
+ include Commands
4
7
  include InventoryParserMixin
5
-
8
+
6
9
  def self.pretty_print_cols()
7
10
  PPColumns.get(:target)
8
11
  end
@@ -31,8 +34,7 @@ module DTK::Client
31
34
  target_id = context_params.retrieve_arguments([:target_id!],method_argument_names)
32
35
 
33
36
  post_body = {:target_id => target_id}
34
- response = post rest_url('target/info'), post_body
35
- response.render_custom_info("target")
37
+ post rest_url('target/info'), post_body
36
38
  end
37
39
 
38
40
  desc "TARGET-NAME/ID import-nodes --source SOURCE","Reads from inventory dsl and populates the node instance objects (SOURCE: file:/path/to/file.yaml)."
@@ -42,12 +44,12 @@ module DTK::Client
42
44
  source = context_params.retrieve_thor_options([:source!], options)
43
45
 
44
46
  parsed_source = source.match(/^(\w+):(.+)/)
45
- raise DTK::Client::DtkValidationError, "Invalid source! Valid source should contain source_type:source_path (e.g. --source file:path/to/file.yaml)." unless parsed_source
47
+ raise DtkValidationError, "Invalid source! Valid source should contain source_type:source_path (e.g. --source file:path/to/file.yaml)." unless parsed_source
46
48
 
47
49
  import_type = parsed_source[1]
48
50
  path = parsed_source[2]
49
51
 
50
- raise DTK::Client::DtkValidationError, "We do not support '#{import_type}' as import source at the moment. Valid sources: #{ValidImportTypes}" unless ValidImportTypes.include?(import_type)
52
+ raise DtkValidationError, "We do not support '#{import_type}' as import source at the moment. Valid sources: #{ValidImportTypes}" unless ValidImportTypes.include?(import_type)
51
53
 
52
54
  post_body = {:target_id => target_id}
53
55
 
@@ -70,7 +72,7 @@ module DTK::Client
70
72
  end
71
73
  ValidImportTypes = ["file"]
72
74
 
73
- desc "set-default-target TARGET-IDENTIFIER","Sets the default target."
75
+ desc "set-default-target TARGET-NAME","Sets the default target."
74
76
  def set_default_target(context_params)
75
77
  target_id = context_params.retrieve_arguments([:option_1!],method_argument_names)
76
78
  post rest_url("target/set_default"), { :target_id => target_id }
@@ -84,44 +86,32 @@ module DTK::Client
84
86
  post rest_url("target/install_agents"), post_body
85
87
  end
86
88
 
87
- desc "create-target [TARGET-NAME] --provider PROVIDER --region REGION --keypair KEYPAIR --security-group SECURITY-GROUP(S)", "Create target based on given provider"
89
+ desc "create-target-ec2-classic [TARGET-NAME] --provider PROVIDER --region REGION [--keypair KEYPAIR] [--security-group SECURITY-GROUP(S)]", "Create target based on given provider"
88
90
  method_option :provider, :type => :string
89
91
  method_option :region, :type => :string
90
92
  method_option :keypair, :type => :string
91
93
  method_option :security_group, :type => :string, :aliases => '--security-groups'
92
- def create_target(context_params)
93
- # we use :target_id but that will retunr provider_id (another name for target template ID)
94
- target_name = context_params.retrieve_arguments([:option_1],method_argument_names)
95
- provider, region, keypair, security_group = context_params.retrieve_thor_options([:provider!, :region, :keypair!, :security_group!], options)
96
-
97
- #TODO: data-driven check if legal provider type and then what options needed depending on provider type
98
- iaas_properties = Hash.new
99
- DTK::Shell::InteractiveWizard.validate_region(region) if region
100
-
101
- security_groups = []
102
- raise ::DTK::Client::DtkValidationError.new("Multiple security groups should be separated with ',' and without spaces between them (e.g. --security_groups gr1,gr2,gr3,...) ") if security_group.end_with?(',')
103
-
104
- security_groups = security_group.split(',')
105
- iaas_properties.merge!(:keypair => keypair)
106
-
107
- if (security_groups.empty? || security_groups.size==1)
108
- iaas_properties.merge!(:security_group => security_group)
109
- else
110
- iaas_properties.merge!(:security_group_set => security_groups)
111
- end
112
-
113
- post_body = {
114
- :provider_id => provider,
115
- :iaas_properties => iaas_properties
116
- }
117
- post_body.merge!(:target_name => target_name) if target_name
118
- post_body.merge!(:region => region) if region
119
- response = post rest_url("target/create"), post_body
94
+ def create_target_ec2_classic(context_params)
95
+ option_list = [:provider!, :region!, :keypair, :security_group]
96
+ response = Common::CreateTarget.new(self,context_params).execute(:ec2_classic,option_list)
97
+ @@invalidate_map << :target
98
+ response
99
+ end
120
100
 
101
+ desc "create-target-ec2-vpc [TARGET-NAME] --provider PROVIDER --region REGION --subnet SUBNET-ID [--keypair KEYPAIR] [--security-group SECURITY-GROUP(S)]", "Create target based on given provider"
102
+ method_option :provider, :type => :string
103
+ method_option :subnet, :type => :string
104
+ method_option :region, :type => :string
105
+ method_option :keypair, :type => :string
106
+ method_option :security_group, :type => :string, :aliases => '--security-groups'
107
+ def create_target_ec2_vpc(context_params)
108
+ option_list = [:provider!, :subnet!, :region!, :keypair, :security_group]
109
+ response = Common::CreateTarget.new(self,context_params).execute(:ec2_vpc,option_list)
121
110
  @@invalidate_map << :target
122
- return response
111
+ response
123
112
  end
124
113
 
114
+
125
115
  desc "TARGET-NAME/ID list-services","Lists service instances in given targets."
126
116
  def list_services(context_params)
127
117
  context_params.method_arguments = ["assemblies"]
@@ -181,27 +171,36 @@ module DTK::Client
181
171
  end
182
172
  end
183
173
 
184
- desc "delete-target TARGET-IDENTIFIER","Deletes target or provider"
185
- method_option :force, :aliases => '-y', :type => :boolean, :default => false
186
- def delete_target(context_params)
187
- target_id = context_params.retrieve_arguments([:option_1!],method_argument_names)
174
+ desc "delete-and-destroy TARGET-NAME","Deletes target or provider"
175
+ def delete_and_destroy(context_params)
176
+ target_id = context_params.retrieve_arguments([:option_1!],method_argument_names)
188
177
 
189
178
  # No -y options since risk is too great
190
179
  return unless Console.confirmation_prompt("Are you sure you want to delete target '#{target_id}' (all assemblies/nodes that belong to this target will be deleted as well)'"+'?')
191
180
 
192
181
  post_body = {
193
- :target_id => target_id
182
+ :target_id => target_id,
183
+ :type => 'instance'
194
184
  }
195
185
 
196
186
  @@invalidate_map << :target
197
187
 
198
- return post rest_url("target/delete"), post_body
188
+ response = post(rest_url("target/delete_and_destroy"),post_body)
189
+ return response unless response.ok?
190
+ if info_array = response.data['info']
191
+ info_array.each{|info_msg|OsUtil.print(info_msg, :yellow)}
192
+ end
193
+ Response::Ok.new()
199
194
  end
200
195
 
201
- desc "TARGET-NAME/ID edit-target [--keypair KEYPAIR] [--security-group SECURITY-GROUP(S)]","Edit keypair or security-group for given target"
196
+ =begin
197
+ # TODO: DTK-2056: rewite
198
+ also put in list property
199
+ desc "TARGET-NAME/ID set-property PROPERTY VALUE
202
200
  method_option :keypair, :type => :string
203
201
  method_option :security_group, :type => :string, :aliases => '--security-groups'
204
- def edit_target(context_params)
202
+ def set_property(context_params)
203
+ raise "change so that param is seperated key value parts"
205
204
  target_id = context_params.retrieve_arguments([:target_id!],method_argument_names)
206
205
  keypair, security_group = context_params.retrieve_thor_options([:keypair, :security_group], options)
207
206
 
@@ -225,7 +224,8 @@ module DTK::Client
225
224
  :target_id => target_id,
226
225
  :iaas_properties => iaas_properties
227
226
  }
228
- return post rest_url("target/edit_target"), post_body
227
+ post rest_url("target/set_properties"), post_body
229
228
  end
229
+ =end
230
230
  end
231
231
  end
@@ -116,7 +116,9 @@ module DTK::Client
116
116
  #
117
117
  desc "import-git GIT-SSH-REPO-URL [NAMESPACE:]TEST-MODULE-NAME", "Create new local test module by importing from provided git repo URL"
118
118
  def import_git(context_params)
119
- import_git_module_aux(context_params)
119
+ response = import_git_module_aux(context_params)
120
+ @@invalidate_map << :test_module
121
+ response
120
122
  end
121
123
 
122
124
  desc "install NAMESPACE/REMOTE-TEST-MODULE-NAME","Install remote test module into local environment"
@@ -147,11 +149,15 @@ module DTK::Client
147
149
  publish_module_aux(context_params)
148
150
  end
149
151
 
150
- desc "TEST-MODULE-NAME/ID pull-dtkn [-n NAMESPACE]", "Update local test module from remote repository."
151
- method_option "namespace",:aliases => "-n",
152
- :type => :string,
152
+ desc "TEST-MODULE-NAME/ID pull-dtkn [-n NAMESPACE] [--force]", "Update local test module from remote repository."
153
+ method_option :namespace,:aliases => '-n',
154
+ :type => :string,
153
155
  :banner => "NAMESPACE",
154
- :desc => "Remote namespace"
156
+ :desc => "Remote namespace"
157
+ method_option :force,:aliases => '-f',
158
+ :type => :boolean,
159
+ :desc => "Force pull",
160
+ :default => false
155
161
  def pull_dtkn(context_params)
156
162
  pull_dtkn_aux(context_params)
157
163
  end
@@ -281,4 +287,4 @@ module DTK::Client
281
287
  end
282
288
  end
283
289
  end
284
- end
290
+ end
@@ -72,6 +72,11 @@ module DTK::Client
72
72
  :delete_node_group => {
73
73
  :endpoint => "assembly",
74
74
  :url => "assembly/get_node_groups"
75
+ },
76
+ :pull_base_component_module => {
77
+ :endpoint => "assembly",
78
+ :url => "assembly/info_about",
79
+ :opts => {:subtype=>"instance", :about=>"modules"}
75
80
  }
76
81
  }
77
82
  }
@@ -191,6 +196,13 @@ module DTK::Client
191
196
  push_module_updates_aux(context_params)
192
197
  end
193
198
 
199
+ desc "WORKSPACE-NAME/ID pull-base-component-module COMPONENT-MODULE-NAME [--force] [--revert]", "Pull base component module changes to component module in workspace"
200
+ method_option :force, :type => :boolean, :default => false, :aliases => '-f'
201
+ method_option :revert, :type => :boolean, :default => false, :aliases => '-r'
202
+ def pull_base_component_module(context_params)
203
+ pull_base_component_module_aux(context_params)
204
+ end
205
+
194
206
  desc "WORKSPACE-NAME/ID push-assembly-updates [NAMESPACE:]SERVICE-MODULE-NAME/ASSEMBLY-NAME", "Push changes made to this workspace to the designated assembly."
195
207
  def push_assembly_updates(context_params)
196
208
  workspace_id, qualified_assembly_name = context_params.retrieve_arguments([:workspace_id!,:option_1!],method_argument_names)
data/lib/core.rb CHANGED
@@ -131,7 +131,7 @@ end
131
131
  def resolve_direct_access(params, config_exists=nil)
132
132
  return if params[:username_exists]
133
133
 
134
- puts "Processing..." if config_exists
134
+ puts "Processing ..." if config_exists
135
135
  # check to see if catalog credentials are set
136
136
  conn = DTK::Client::Session.get_connection()
137
137
  response = conn.post DTK::Client::CommandBase.class, conn.rest_url("account/check_catalog_credentials"), {}
@@ -279,6 +279,10 @@ module DTK
279
279
  end
280
280
  end
281
281
 
282
+ def reset_hard(current_branch_sha)
283
+ @git_repo.reset_hard(current_branch_sha)
284
+ end
285
+
282
286
  private
283
287
  def handle_git_error(&block)
284
288
  self.class.handle_git_error(&block)
@@ -148,14 +148,6 @@ module DTK
148
148
  "dsl_parsed" => "DSL PARSED:"
149
149
  }
150
150
 
151
- mappings["target"] = {
152
- "id" => "ID:",
153
- "display_name" => "NAME:",
154
- "type" => "TYPE:",
155
- "iaas_type" => "PROVIDER_TYPE:",
156
- "provider_name" => "PROVIDER_NAME:"
157
- }
158
-
159
151
  mappings[type][label] if mappings[type]
160
152
  end
161
153
 
@@ -1,3 +1,3 @@
1
1
  module DtkClient
2
- VERSION="0.7.2.1"
2
+ VERSION="0.7.3"
3
3
  end
@@ -1,14 +1,14 @@
1
1
  class DTK::Client::Execute::Script
2
2
  class AddTenant < self
3
3
  def self.ret_params_from_argv()
4
- banner = "Usage: dtk-execute add-tenant TENANT-NAME CATALOG-USERNAME -p PASSWORD [-s SERVICE-INSTANCE]"
5
- tenant_name = catalog_username = tenant_number = nil
6
- if ARGV.size > 2
4
+ banner = "Usage: dtk-execute add-tenant TENANT-NAME CATALOG-USERNAME -p PASSWORD -v VERSION [-s SERVICE-INSTANCE]"
5
+ version = tenant_name = catalog_username = tenant_number = nil
6
+ if ARGV.size > 3
7
7
  tenant_name = ARGV[1]
8
8
  if tenant_name =~ /^dtk([0-9]+)$/
9
9
  tenant_number = $1
10
10
  else
11
- raise ErrorUsage.new("TENANT-NAME must be of form 'dtkNUMs', like dtk601")
11
+ raise ErrorUsage.new("TENANT-NAME must be of form 'dtkNUM', like dtk601")
12
12
  end
13
13
  catalog_username = ARGV[2]
14
14
  else
@@ -23,12 +23,19 @@ class DTK::Client::Execute::Script
23
23
  opts.on( '-s', '--service SERVICE-INSTANCE', "Name of Service instance" ) do |s|
24
24
  params[:service_instance] = s
25
25
  end
26
+ opts.on( '-v', '--version VERSION', "Version of code" ) do |v|
27
+ params[:version] = v
28
+ end
26
29
  end
27
30
 
28
- # TODO: use opt parser to enforce that :password option is manditory
29
- unless password = params[:password]
31
+ # TODO: use opt parser to enforce that :password and :version options are manditory
32
+ unless params[:password]
30
33
  raise ErrorUsage.new("Password is mandatory; use -p commnd line option")
31
34
  end
35
+ unless params[:version]
36
+ raise ErrorUsage.new("Version is mandatory; use -v commnd line option")
37
+ end
38
+
32
39
  service_instance = params[:service_instance] || "dtkhost#{tenant_number[0]}"
33
40
  to_add = {
34
41
  :tenant_name => tenant_name,
@@ -43,6 +50,7 @@ class DTK::Client::Execute::Script
43
50
  catalog_username = params[:catalog_username]
44
51
  service = params[:service_instance]
45
52
  password = params[:password]
53
+ version = params[:version]
46
54
  server_node = params[:server_node_name] || 'server'
47
55
  router_node = params[:router_node_name] || 'router'
48
56
 
@@ -52,8 +60,16 @@ class DTK::Client::Execute::Script
52
60
  av_pairs = {
53
61
  :catalog_username => catalog_username,
54
62
  :tenant_password => password,
55
- :catalog_password => password
63
+ :catalog_password => password,
64
+ :server_branch => version,
56
65
  }
66
+
67
+ linked_component_instances =
68
+ [
69
+ "#{router_node}/dtk_nginx::vhosts_for_router",
70
+ "#{server_node}/dtk_postgresql::databases",
71
+ "#{server_node}/host::hostname"
72
+ ]
57
73
 
58
74
  ExecuteContext(:print_results => true) do
59
75
  result = call 'service/add_component',
@@ -70,16 +86,13 @@ class DTK::Client::Execute::Script
70
86
  :value => v
71
87
  end
72
88
 
89
+ linked_component_instances.each do |linked_component_instance|
73
90
  result = call 'service/link_components',
74
91
  :service => service,
75
92
  :input_component => "#{server_node}/#{component}",
76
- :output_component => "#{server_node}/dtk_postgresql::databases"
93
+ :output_component => linked_component_instance
94
+ end
77
95
 
78
- result = call 'service/link_components',
79
- :service => service,
80
- :input_component => "#{server_node}/#{component}",
81
- :output_component => "#{router_node}/dtk_nginx::vhosts_for_router"
82
-
83
96
  result = call 'service/execute_workflow',
84
97
  :service => service,
85
98
  :workflow_name => 'add_tenant',
@@ -1,7 +1,6 @@
1
1
  class DTK::Client::Execute
2
2
  class Script < self
3
3
  dtk_require('script/add_tenant')
4
- dtk_require('script/add_tenant_without_router')
5
4
  def self.execute()
6
5
  script_class().execute_script()
7
6
  end
@@ -9,7 +8,6 @@ class DTK::Client::Execute
9
8
  private
10
9
  Scripts = {
11
10
  'add-tenant' => AddTenant,
12
- 'add-tenant-without-router' => AddTenantWithoutRouter
13
11
  }
14
12
 
15
13
  def self.script_class()
data/lib/shell/context.rb CHANGED
@@ -297,9 +297,23 @@ module DTK
297
297
  # we remove '..' from our entries
298
298
  entries = entries.select { |e| !(e.empty? || DTK::Shell::ContextAux.is_double_dot?(e)) }
299
299
 
300
+ # need this for autocomplete from service/node to service/utils
301
+ is_utils = active_context_copy.last_command_name.eql?('utils')
302
+
300
303
  # we go back in context based on '..'
301
304
  active_context_copy.pop_context(double_dots_count)
302
305
 
306
+ # if cd ../utils from service/node
307
+ if active_context_copy.current_command? && active_context_copy.last_command_name.eql?('node')
308
+ active_context_copy.pop_context(1)
309
+ entries = Context.check_invisible_context(active_context_copy, entries, root?, line_buffer, args, self)
310
+ end
311
+
312
+ # need this for autocomplete from service/node to service/utils
313
+ if is_utils
314
+ entries = Context.check_invisible_context(active_context_copy, entries, root?, line_buffer, args, self)
315
+ end
316
+
303
317
  # if cd .. back to node, skip node context and go to assembly/workspace context
304
318
  if (active_context_copy.last_context && entries)
305
319
  active_context_copy.pop_context(1) if (node_specific && active_context_copy.last_context.is_command? && active_context_copy.last_command_name.eql?("node") && on_complete)
@@ -9,8 +9,7 @@ module DTK::Shell
9
9
  @method_arguments = override_method_arguments
10
10
  @thor_options = Hash.new
11
11
 
12
- # freeze this - removed because we try to make a modification on this array later which raises error
13
- #@method_arguments.freeze
12
+ @method_arguments
14
13
  end
15
14
 
16
15
  def add_context_to_params(context_name, entity_name, context_value = nil)
data/lib/util/console.rb CHANGED
@@ -33,6 +33,25 @@ module DTK::Client
33
33
  end
34
34
  end
35
35
 
36
+ #
37
+ # Display confirmation prompt and repeat message until expected answer is given
38
+ #
39
+ def confirmation_prompt_simple(message, add_options=true)
40
+ # used to disable skip with ctrl+c
41
+ trap("INT", "SIG_IGN")
42
+ message += " (y/n)" if add_options
43
+
44
+ while line = Readline.readline("#{message}: ", true)
45
+ if (line.eql?("yes") || line.eql?("y") || line.empty?)
46
+ trap("INT",false)
47
+ return true
48
+ elsif (line.eql?("no") || line.eql?("n"))
49
+ trap("INT",false)
50
+ return false
51
+ end
52
+ end
53
+ end
54
+
36
55
  # Loading output used to display waiting status
37
56
  def wait_animation(message, time_seconds)
38
57
  print message