dtk-client 0.5.17 → 0.5.18
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 +8 -8
- data/lib/command_helpers/git_repo.rb +82 -48
- data/lib/command_helpers/service_importer.rb +26 -17
- data/lib/command_helpers/test_module_creator.rb +6 -5
- data/lib/commands/common/thor/access_control.rb +5 -4
- data/lib/commands/common/thor/assembly_template.rb +75 -0
- data/lib/commands/common/thor/assembly_workspace.rb +86 -71
- data/lib/commands/common/thor/clone.rb +9 -7
- data/lib/commands/common/thor/common.rb +17 -10
- data/lib/commands/common/thor/edit.rb +65 -6
- data/lib/commands/common/thor/list_diffs.rb +4 -3
- data/lib/commands/common/thor/module.rb +86 -89
- data/lib/commands/common/thor/pull_clone_changes.rb +3 -2
- data/lib/commands/common/thor/pull_from_remote.rb +9 -5
- data/lib/commands/common/thor/purge_clone.rb +2 -2
- data/lib/commands/common/thor/push_clone_changes.rb +39 -16
- data/lib/commands/common/thor/push_to_remote.rb +3 -3
- data/lib/commands/thor/account.rb +16 -4
- data/lib/commands/thor/assembly.rb +66 -89
- data/lib/commands/thor/component_module.rb +40 -24
- data/lib/commands/thor/node.rb +7 -0
- data/lib/commands/thor/provider.rb +45 -23
- data/lib/commands/thor/service.rb +4 -7
- data/lib/commands/thor/service_module.rb +45 -20
- data/lib/commands/thor/test_module.rb +36 -22
- data/lib/commands/thor/workspace.rb +6 -6
- data/lib/core.rb +18 -17
- data/lib/domain/git_adapter.rb +30 -9
- data/lib/dtk-client/version.rb +1 -1
- data/lib/parser/adapters/thor.rb +47 -25
- data/lib/shell/context.rb +10 -2
- data/lib/shell.rb +18 -12
- data/lib/util/module_util.rb +41 -0
- data/lib/util/os_util.rb +25 -7
- metadata +4 -2
@@ -3,7 +3,7 @@ module DTK::Client
|
|
3
3
|
module PushToRemoteMixin
|
4
4
|
|
5
5
|
def push_to_remote_aux(remote_module_info, module_type)
|
6
|
-
|
6
|
+
full_module_name = remote_module_info.data(:full_module_name)
|
7
7
|
version = remote_module_info.data(:version)
|
8
8
|
|
9
9
|
opts = {
|
@@ -13,12 +13,12 @@ module DTK::Client
|
|
13
13
|
:local_branch => remote_module_info.data(:workspace_branch)
|
14
14
|
}
|
15
15
|
|
16
|
-
response = Helper(:git_repo).push_changes(module_type,
|
16
|
+
response = Helper(:git_repo).push_changes(module_type,full_module_name,version,opts)
|
17
17
|
return response unless response.ok?
|
18
18
|
if response.data(:diffs).empty?
|
19
19
|
raise DtkError, "No changes to push"
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
Response::Ok.new()
|
23
23
|
end
|
24
24
|
|
@@ -89,7 +89,7 @@ module DTK::Client
|
|
89
89
|
new_pass_prompt = password_prompt("Enter new password: ")
|
90
90
|
return if new_pass_prompt.nil?
|
91
91
|
confirm_pass_prompt = password_prompt("Confirm new password: ")
|
92
|
-
|
92
|
+
|
93
93
|
if new_pass_prompt.eql?(confirm_pass_prompt)
|
94
94
|
post_body = {:new_password => new_pass_prompt}
|
95
95
|
response = post rest_url("account/set_password"), post_body
|
@@ -123,7 +123,7 @@ module DTK::Client
|
|
123
123
|
DTK::Client::OsUtil.print("Provided ssh pub key has already been added.", :yellow)
|
124
124
|
elsif matched_username
|
125
125
|
DTK::Client::OsUtil.print("User ('#{matched_username}') already exists.", :yellow)
|
126
|
-
else
|
126
|
+
else
|
127
127
|
DTK::Client::Configurator.add_current_user_to_direct_access() if response.ok?
|
128
128
|
end
|
129
129
|
|
@@ -133,7 +133,7 @@ module DTK::Client
|
|
133
133
|
desc "delete-ssh-key KEYPAIR-NAME ","Deletes the named ssh key from your user account"
|
134
134
|
def delete_ssh_key(context_params)
|
135
135
|
name = context_params.retrieve_arguments([:option_1!],method_argument_names)
|
136
|
-
post_body = {:username => name.chomp}
|
136
|
+
post_body = { :username => name.chomp }
|
137
137
|
|
138
138
|
response = post rest_url("account/remove_user_direct_access"), post_body
|
139
139
|
return response unless response.ok?
|
@@ -142,6 +142,18 @@ module DTK::Client
|
|
142
142
|
nil
|
143
143
|
end
|
144
144
|
|
145
|
+
desc "set-default-namespace NAMESPACE", "Sets default namespace for your user account"
|
146
|
+
def set_default_namespace(context_params)
|
147
|
+
default_namespace = context_params.retrieve_arguments([:option_1!],method_argument_names)
|
148
|
+
post_body = { :namespace => default_namespace.chomp }
|
149
|
+
|
150
|
+
response = post rest_url("account/set_default_namespace"), post_body
|
151
|
+
return response unless response.ok?
|
152
|
+
|
153
|
+
OsUtil.print("Your default namespace has been set to '#{default_namespace}'!", :yellow)
|
154
|
+
nil
|
155
|
+
end
|
156
|
+
|
145
157
|
|
146
158
|
|
147
159
|
# Will leave this commented for now until we check if above commands work as expected
|
@@ -164,7 +176,7 @@ module DTK::Client
|
|
164
176
|
# response, key_exists_already = Account.internal_add_user_access("component_module/add_user_direct_access", post_body, 'component module')
|
165
177
|
# return response unless (response.ok? || key_exists_already)
|
166
178
|
# proper_response = response if response.ok?
|
167
|
-
|
179
|
+
|
168
180
|
# # if either of request passed we will add to known hosts
|
169
181
|
# if proper_response
|
170
182
|
# repo_manager_fingerprint,repo_manager_dns = proper_response.data_ret_and_remove!(:repo_manager_fingerprint,:repo_manager_dns)
|
@@ -1,48 +1,9 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
dtk_require_from_base("shell/status_monitor")
|
2
|
+
dtk_require_common_commands('thor/assembly_template')
|
3
3
|
module DTK::Client
|
4
4
|
class Assembly < CommandBaseThor
|
5
5
|
no_tasks do
|
6
|
-
|
7
|
-
name = nil
|
8
|
-
3.times do
|
9
|
-
name = get_name_from_id_helper(assembly_id)
|
10
|
-
break if name
|
11
|
-
end
|
12
|
-
|
13
|
-
name
|
14
|
-
end
|
15
|
-
|
16
|
-
def get_assembly_stage_name(assembly_list,assembly_template_name)
|
17
|
-
name = nil
|
18
|
-
current_list = assembly_list.select{|e| e.include?(assembly_template_name)}
|
19
|
-
|
20
|
-
if current_list.empty?
|
21
|
-
name = assembly_template_name
|
22
|
-
else
|
23
|
-
numbers = []
|
24
|
-
base_name = nil
|
25
|
-
|
26
|
-
assembly_list.each do |assembly|
|
27
|
-
match = assembly.match(/#{assembly_template_name}(-)(\d*)/)
|
28
|
-
base_name = assembly_template_name if assembly_template_name.include?(assembly)
|
29
|
-
numbers << match[2].to_i if match
|
30
|
-
end
|
31
|
-
|
32
|
-
unless base_name
|
33
|
-
name = assembly_template_name
|
34
|
-
else
|
35
|
-
highest = numbers.max||1
|
36
|
-
new_highest = highest+1
|
37
|
-
|
38
|
-
all = (2..new_highest).to_a
|
39
|
-
nums = all - numbers
|
40
|
-
name = assembly_template_name + "-#{nums.first}"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
name
|
45
|
-
end
|
6
|
+
include AssemblyTemplateMixin
|
46
7
|
end
|
47
8
|
|
48
9
|
def self.whoami()
|
@@ -55,10 +16,13 @@ module DTK::Client
|
|
55
16
|
response = DTK::Client::CommandBaseThor.get_cached_response(:assembly, "assembly/list", {:subtype => 'template' })
|
56
17
|
# response = DTK::Client::CommandBaseThor.get_cached_response(:module, "service_module/list")
|
57
18
|
|
19
|
+
service_namespace = service.split(":").first
|
20
|
+
service_name = service.split(":").last
|
21
|
+
|
58
22
|
if response.ok?
|
59
23
|
unless response['data'].nil?
|
60
24
|
response['data'].each do |module_item|
|
61
|
-
if ("#{
|
25
|
+
if ("#{service_name.to_s}::#{assembly_template_name.to_s}" == (module_item['display_name']) && service_namespace == module_item['namespace'])
|
62
26
|
assembly_template_id = module_item['id']
|
63
27
|
break
|
64
28
|
end
|
@@ -206,7 +170,21 @@ module DTK::Client
|
|
206
170
|
end
|
207
171
|
end
|
208
172
|
|
209
|
-
desc "ASSEMBLY-NAME/ID
|
173
|
+
desc "ASSEMBLY-NAME/ID list-settings", "List all settings for given assembly."
|
174
|
+
def list_settings(context_params)
|
175
|
+
assembly_template_id = context_params.retrieve_arguments([:assembly_id!],method_argument_names)
|
176
|
+
|
177
|
+
post_body = {
|
178
|
+
:assembly_id => assembly_template_id
|
179
|
+
}
|
180
|
+
|
181
|
+
response = post rest_url("assembly/list_settings"), post_body
|
182
|
+
response.render_table(:service_setting) unless options.list?
|
183
|
+
|
184
|
+
response
|
185
|
+
end
|
186
|
+
|
187
|
+
desc "ASSEMBLY-NAME/ID stage [INSTANCE-NAME] [-t TARGET-NAME/ID] [--settings SETTINGS-NAME1[,..]]", "Stage assembly in target."
|
210
188
|
method_option "in-target",:aliases => "-t" ,
|
211
189
|
:type => :string,
|
212
190
|
:banner => "TARGET-NAME/ID",
|
@@ -214,7 +192,7 @@ module DTK::Client
|
|
214
192
|
#hidden option
|
215
193
|
method_option "instance-bindings",
|
216
194
|
:type => :string
|
217
|
-
|
195
|
+
method_option :settings, :type => :string, :aliases => '-s'
|
218
196
|
def stage(context_params)
|
219
197
|
assembly_template_id, name = context_params.retrieve_arguments([:assembly_id!, :option_1],method_argument_names)
|
220
198
|
post_body = {
|
@@ -228,9 +206,9 @@ module DTK::Client
|
|
228
206
|
assembly_template_name = get_assembly_name(assembly_template_id)
|
229
207
|
assembly_template_name.gsub!('::','-') if assembly_template_name
|
230
208
|
|
231
|
-
|
232
|
-
in_target = options["in-target"] || context_params.get_forwarded_thor_option("in-target")
|
209
|
+
in_target = options["in-target"]
|
233
210
|
instance_bindings = options["instance-bindings"]
|
211
|
+
settings = parse_service_settings(options["settings"])
|
234
212
|
assembly_list = Assembly.assembly_list()
|
235
213
|
|
236
214
|
if name
|
@@ -242,6 +220,7 @@ module DTK::Client
|
|
242
220
|
post_body.merge!(:target_id => in_target) if in_target
|
243
221
|
post_body.merge!(:name => name) if name
|
244
222
|
post_body.merge!(:instance_bindings => instance_bindings) if instance_bindings
|
223
|
+
post_body.merge!(:settings_json_form => JSON.generate(settings)) if settings
|
245
224
|
|
246
225
|
response = post rest_url("assembly/stage"), post_body
|
247
226
|
return response unless response.ok?
|
@@ -252,66 +231,64 @@ module DTK::Client
|
|
252
231
|
return response
|
253
232
|
end
|
254
233
|
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
desc "ASSEMBLY-NAME/ID deploy [INSTANCE-NAME] [
|
259
|
-
|
260
|
-
|
261
|
-
:
|
262
|
-
|
234
|
+
|
235
|
+
# desc "ASSEMBLY-NAME/ID deploy [INSTANCE-NAME] [-t TARGET-NAME/ID] [--settings SETTINGS-NAME1[,..]]", "Stage assembly in target."
|
236
|
+
# version_method_option
|
237
|
+
desc "ASSEMBLY-NAME/ID deploy [INSTANCE-NAME] [--settings SETTINGS-NAME1[,..]] [-m COMMIT-MSG]", "Stage and deploy assembly in target."
|
238
|
+
#hidden option
|
239
|
+
method_option "instance-bindings",
|
240
|
+
:type => :string
|
241
|
+
# method_option "in-target",:aliases => "-t" ,
|
242
|
+
# :type => :string,
|
243
|
+
# :banner => "TARGET-NAME/ID",
|
244
|
+
# :desc => "Target (id) to create assembly in"
|
263
245
|
method_option "commit_msg",:aliases => "-m" ,
|
264
246
|
:type => :string,
|
265
247
|
:banner => "COMMIT-MSG",
|
266
248
|
:desc => "Commit message"
|
249
|
+
method_option :settings, :type => :string, :aliases => '-s'
|
267
250
|
def deploy(context_params)
|
268
251
|
context_params.forward_options(options)
|
269
|
-
|
270
|
-
|
271
|
-
return response unless response.ok?
|
272
|
-
|
273
|
-
# create task
|
274
|
-
# commented assemlby_id until we implement json to yaml parsing on client side instead of server side
|
275
|
-
# assembly_id = response.data(:assembly_id)
|
276
|
-
|
277
|
-
# temp solution just to make deploy to work, since response we get from 'stage' command is simple string presented as yaml
|
278
|
-
assembly_id = response.data.match(/(id:)\s*(\d+)/)[2]
|
279
|
-
|
252
|
+
assembly_template_id, name = context_params.retrieve_arguments([:assembly_id!, :option_1],method_argument_names)
|
280
253
|
post_body = {
|
281
|
-
:assembly_id =>
|
282
|
-
:commit_msg => options["commit_msg"]||"Initial deploy"
|
254
|
+
:assembly_id => assembly_template_id
|
283
255
|
}
|
284
|
-
|
285
|
-
|
286
|
-
return response unless response.ok?
|
287
|
-
if response.data and response.data.size > 0
|
288
|
-
error_message = "The following violations were found; they must be corrected before the assembly can be deployed"
|
289
|
-
DTK::Client::OsUtil.print(error_message, :red)
|
290
|
-
return response.render_table(:violation)
|
256
|
+
if commit_msg = options["commit_msg"]
|
257
|
+
post_body.merge!(:commit_msg => commit_msg)
|
291
258
|
end
|
292
259
|
|
293
|
-
|
294
|
-
|
295
|
-
|
260
|
+
# using this to make sure cache will be invalidated after new assembly is created from other commands e.g.
|
261
|
+
# 'assembly-create', 'install' etc.
|
262
|
+
@@invalidate_map << :assembly
|
263
|
+
|
264
|
+
assembly_template_name = get_assembly_name(assembly_template_id)
|
265
|
+
assembly_template_name.gsub!('::','-') if assembly_template_name
|
296
266
|
|
297
|
-
#
|
298
|
-
|
299
|
-
|
267
|
+
# we check current options and forwarded options (from deploy method)
|
268
|
+
in_target = options["in-target"] || context_params.get_forwarded_thor_option("in-target")
|
269
|
+
instance_bindings = options["instance-bindings"]
|
270
|
+
settings = options["settings"]
|
271
|
+
assembly_list = Assembly.assembly_list()
|
300
272
|
|
301
|
-
|
302
|
-
|
303
|
-
|
273
|
+
if name
|
274
|
+
raise DTK::Client::DtkValidationError, "Unable to deploy service with name '#{name}'. Service with specified name exists already!" if assembly_list.include?(name)
|
275
|
+
else
|
276
|
+
name = get_assembly_stage_name(assembly_list,assembly_template_name)
|
304
277
|
end
|
278
|
+
|
279
|
+
post_body.merge!(:target_id => in_target) if in_target
|
280
|
+
post_body.merge!(:name => name) if name
|
281
|
+
post_body.merge!(:instance_bindings => instance_bindings) if instance_bindings
|
282
|
+
post_body.merge!(:settings_json_form => JSON.generate(settings)) if settings
|
305
283
|
|
284
|
+
response = post rest_url("assembly/deploy"), post_body
|
306
285
|
return response unless response.ok?
|
307
|
-
ret.add_data_value!(:task_id,task_id)
|
308
|
-
|
309
286
|
# when changing context send request for getting latest assemblies instead of getting from cache
|
310
287
|
@@invalidate_map << :service
|
311
|
-
|
312
|
-
|
288
|
+
@@invalidate_map << :assembly
|
289
|
+
response
|
313
290
|
end
|
314
|
-
|
291
|
+
|
315
292
|
|
316
293
|
desc "delete ASSEMBLY-ID", "Delete assembly"
|
317
294
|
method_option :force, :aliases => '-y', :type => :boolean, :default => false
|
@@ -33,7 +33,7 @@ module DTK::Client
|
|
33
33
|
{
|
34
34
|
:command_only => {
|
35
35
|
:self => [
|
36
|
-
["list"," list [--remote] [--diff]","# List loaded or remote component modules. Use --diff to compare loaded and remote component modules."]
|
36
|
+
["list"," list [--remote] [--diff] [-n NAMESPACE]","# List loaded or remote component modules. Use --diff to compare loaded and remote component modules."]
|
37
37
|
],
|
38
38
|
:"component" => [
|
39
39
|
["list","list","# List all component templates."],
|
@@ -114,27 +114,25 @@ TODO: might deprecate
|
|
114
114
|
response.render_custom_info("module")
|
115
115
|
end
|
116
116
|
=end
|
117
|
-
|
118
|
-
desc "list [--remote] [--diff]", "List loaded or remote component modules. Use --diff to compare loaded and remote component modules."
|
117
|
+
desc "list [--remote] [--diff] [-n NAMESPACE]", "List loaded or remote component modules. Use --diff to compare loaded and remote component modules."
|
119
118
|
method_option :remote, :type => :boolean, :default => false
|
120
119
|
method_option :diff, :type => :boolean, :default => false
|
120
|
+
method_option :namespace, :aliases => "-n" ,
|
121
|
+
:type => :string,
|
122
|
+
:banner => "NAMESPACE",
|
123
|
+
:desc => "List modules only in specific namespace."
|
121
124
|
def list(context_params)
|
122
|
-
|
123
|
-
#if context_params.is_there_command?(:attribute)
|
124
|
-
# return module_info_about(context_params, :attributes, :attribute)
|
125
|
-
#elsif context_params.is_there_command?(:"component-template")
|
126
|
-
# if context_params.is_there_command?(:"component-template")
|
127
|
-
if context_params.is_there_command?(:"component")
|
128
|
-
return module_info_about(context_params, :components, :component)
|
129
|
-
end
|
125
|
+
return module_info_about(context_params, :components, :component) if context_params.is_there_command?(:"component")
|
130
126
|
|
131
127
|
forwarded_remote = context_params.get_forwarded_options()["remote"] if context_params.get_forwarded_options()
|
132
128
|
remote = options.remote? || forwarded_remote
|
133
129
|
action = (remote ? "list_remote" : "list")
|
134
|
-
|
130
|
+
|
135
131
|
post_body = (remote ? { :rsa_pub_key => SSHUtil.rsa_pub_key_content() } : {:detail_to_include => ["remotes"]})
|
136
132
|
post_body[:diff] = options.diff? ? options.diff : {}
|
137
|
-
|
133
|
+
post_body.merge!(:module_namespace => options.namespace)
|
134
|
+
|
135
|
+
response = post rest_url("component_module/#{action}"),post_body
|
138
136
|
|
139
137
|
return response unless response.ok?
|
140
138
|
response.render_table()
|
@@ -175,14 +173,22 @@ TODO: might deprecate
|
|
175
173
|
#### commands to interact with remote repo ###
|
176
174
|
|
177
175
|
|
178
|
-
desc "import COMPONENT-MODULE-NAME", "Create new component module from local clone"
|
176
|
+
desc "import [NAMESPACE:]COMPONENT-MODULE-NAME", "Create new component module from local clone"
|
179
177
|
def import(context_params)
|
180
178
|
response = import_module_aux(context_params)
|
181
|
-
@@invalidate_map << :component_module if response && response.ok?
|
179
|
+
@@invalidate_map << :component_module if (response && response.ok?)
|
182
180
|
|
183
181
|
response
|
184
182
|
end
|
185
183
|
|
184
|
+
#
|
185
|
+
# Creates component module from input git repo, removing .git dir to rid of pointing to user github, and creates component module
|
186
|
+
#
|
187
|
+
desc "import-git GIT-SSH-REPO-URL [NAMESPACE:]COMPONENT-MODULE-NAME", "Create new local component module by importing from provided git repo URL"
|
188
|
+
def import_git(context_params)
|
189
|
+
import_git_module_aux(context_params)
|
190
|
+
end
|
191
|
+
|
186
192
|
=begin
|
187
193
|
# desc "COMPONENT-MODULE-NAME/ID validate-model [-v VERSION]", "Check the DSL model for errors"
|
188
194
|
# version_method_option
|
@@ -209,7 +215,7 @@ TODO: might deprecate
|
|
209
215
|
# TODO: put in doc REMOTE-MODULE havs namespace and optionally version information; e.g. r8/hdp or r8/hdp/v1.1
|
210
216
|
# if multiple items and failire; stops on first failure
|
211
217
|
# desc "install [NAMESPACE/]REMOTE-COMPONENT-MODULE-NAME [-r DTK-REPO-MANAGER]","Install remote component module into local environment"
|
212
|
-
desc "install
|
218
|
+
desc "install NAMESPACE/REMOTE-COMPONENT-MODULE-NAME","Install remote component module into local environment"
|
213
219
|
method_option "repo-manager",:aliases => "-r" ,
|
214
220
|
:type => :string,
|
215
221
|
:banner => "REPO-MANAGER",
|
@@ -221,13 +227,6 @@ TODO: might deprecate
|
|
221
227
|
response
|
222
228
|
end
|
223
229
|
|
224
|
-
#
|
225
|
-
# Creates component module from input git repo, removing .git dir to rid of pointing to user github, and creates component module
|
226
|
-
#
|
227
|
-
desc "import-git GIT-SSH-REPO-URL COMPONENT-MODULE-NAME", "Create new local component module by importing from provided git repo URL"
|
228
|
-
def import_git(context_params)
|
229
|
-
import_git_module_aux(context_params)
|
230
|
-
end
|
231
230
|
|
232
231
|
=begin
|
233
232
|
=> DUE TO DEPENDENCY TO PUPPET GEM WE OMMIT THIS <=
|
@@ -271,7 +270,7 @@ TODO: might deprecate
|
|
271
270
|
end
|
272
271
|
=end
|
273
272
|
|
274
|
-
desc "delete-from-catalog
|
273
|
+
desc "delete-from-catalog NAMESPACE/REMOTE-COMPONENT-MODULE-NAME [-y]", "Delete the component module from the DTK Network catalog"
|
275
274
|
method_option :force, :aliases => '-y', :type => :boolean, :default => false
|
276
275
|
def delete_from_catalog(context_params)
|
277
276
|
delete_from_catalog_aux(context_params)
|
@@ -456,6 +455,23 @@ TODO: might deprecate
|
|
456
455
|
list_diffs_module_aux(context_params)
|
457
456
|
end
|
458
457
|
|
458
|
+
#
|
459
|
+
# DEVELOPMENT MODE METHODS
|
460
|
+
#
|
461
|
+
if DTK::Configuration.get(:development_mode)
|
462
|
+
|
463
|
+
desc "delete-all","Delete all service modules"
|
464
|
+
def delete_all(context_params)
|
465
|
+
return unless Console.confirmation_prompt("This will DELETE ALL component modules, are you sure"+'?')
|
466
|
+
response = list(context_params)
|
467
|
+
|
468
|
+
response.data().each do |e|
|
469
|
+
run_shell_command("delete #{e['display_name']} -y -p")
|
470
|
+
end
|
471
|
+
end
|
472
|
+
|
473
|
+
end
|
474
|
+
|
459
475
|
#### end: commands related to cloning to and pushing from local clone
|
460
476
|
end
|
461
477
|
end
|
data/lib/commands/thor/node.rb
CHANGED
@@ -35,6 +35,13 @@ module DTK::Client
|
|
35
35
|
{
|
36
36
|
:context => {
|
37
37
|
:add_component => "component_template"
|
38
|
+
},
|
39
|
+
:command => {
|
40
|
+
:delete_component => {
|
41
|
+
:endpoint => "assembly",
|
42
|
+
:url => "assembly/info_about",
|
43
|
+
:opts => {:subtype=>"instance", :about=>"components"}
|
44
|
+
}
|
38
45
|
}
|
39
46
|
}
|
40
47
|
end
|
@@ -35,47 +35,69 @@ module DTK::Client
|
|
35
35
|
return Provider.valid_children().include?(name_of_sub_context.to_sym)
|
36
36
|
end
|
37
37
|
|
38
|
-
desc "create-provider PROVIDER-
|
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,...)"
|
39
39
|
method_option :keypair, :type => :string
|
40
40
|
method_option :security_group, :type => :string, :aliases => '--security-groups'
|
41
41
|
method_option :bootstrap, :type => :boolean, :default => false
|
42
|
-
def
|
43
|
-
|
42
|
+
def create_ec2_provider(context_params)
|
43
|
+
provider_name = context_params.retrieve_arguments([:option_1!],method_argument_names)
|
44
|
+
provider_type = 'ec2'
|
44
45
|
|
45
|
-
provider_type, provider_name = decompose_provider_type_and_name(composed_provider_name)
|
46
46
|
iaas_properties = Hash.new
|
47
47
|
#TODO: data-driven check if legal provider type and then what options needed depending on provider type
|
48
|
-
unless provider_type.eql?('physical')
|
49
|
-
security_groups = []
|
50
|
-
keypair, security_group = context_params.retrieve_thor_options([:keypair!, :security_group!], options)
|
51
48
|
|
52
|
-
|
49
|
+
security_groups = []
|
50
|
+
keypair, security_group = context_params.retrieve_thor_options([:keypair!, :security_group!], options)
|
53
51
|
|
54
|
-
|
55
|
-
iaas_properties.merge!(:keypair_name => keypair)#,:security_group => security_group)
|
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?(',')
|
56
53
|
|
57
|
-
|
58
|
-
|
59
|
-
else
|
60
|
-
iaas_properties.merge!(:security_group_set => security_groups)
|
61
|
-
end
|
54
|
+
security_groups = security_group.split(',')
|
55
|
+
iaas_properties.merge!(:keypair_name => keypair)#,:security_group => security_group)
|
62
56
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
]}})
|
68
|
-
access_key, secret_key = result['IAAS Credentials'].values_at(:key, :secret)
|
69
|
-
iaas_properties.merge!(:key => access_key,:secret => secret_key)
|
57
|
+
if (security_groups.empty? || security_groups.size==1)
|
58
|
+
iaas_properties.merge!(:security_group => security_group)#,:security_group => security_group)
|
59
|
+
else
|
60
|
+
iaas_properties.merge!(:security_group_set => security_groups)
|
70
61
|
end
|
71
62
|
|
63
|
+
result = DTK::Shell::InteractiveWizard::interactive_user_input(
|
64
|
+
{'IAAS Credentials' => { :type => :group, :options => [
|
65
|
+
{:key => {}},
|
66
|
+
{:secret => {}}
|
67
|
+
]}})
|
68
|
+
access_key, secret_key = result['IAAS Credentials'].values_at(:key, :secret)
|
69
|
+
iaas_properties.merge!(:key => access_key,:secret => secret_key)
|
70
|
+
|
72
71
|
# Remove sensitive readline history
|
73
72
|
OsUtil.pop_readline_history(2)
|
74
73
|
|
75
74
|
post_body = {
|
76
75
|
:iaas_properties => iaas_properties,
|
77
76
|
:provider_name => provider_name,
|
78
|
-
:iaas_type => provider_type
|
77
|
+
:iaas_type => provider_type,
|
78
|
+
:no_bootstrap => ! options.bootstrap?
|
79
|
+
}
|
80
|
+
|
81
|
+
response = post rest_url("target/create_provider"), post_body
|
82
|
+
@@invalidate_map << :provider
|
83
|
+
|
84
|
+
return response
|
85
|
+
end
|
86
|
+
|
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)
|
92
|
+
provider_name = context_params.retrieve_arguments([:option_1!],method_argument_names)
|
93
|
+
provider_type = 'physical'
|
94
|
+
|
95
|
+
# Remove sensitive readline history
|
96
|
+
OsUtil.pop_readline_history(2)
|
97
|
+
|
98
|
+
post_body = {
|
99
|
+
:provider_name => provider_name,
|
100
|
+
:iaas_type => provider_type,
|
79
101
|
:no_bootstrap => ! options.bootstrap?
|
80
102
|
}
|
81
103
|
|
@@ -202,7 +202,7 @@ TODO: overlaps with different meaning
|
|
202
202
|
cancel_task_aux(context_params)
|
203
203
|
end
|
204
204
|
|
205
|
-
desc "SERVICE-NAME/ID create-assembly SERVICE-MODULE-NAME ASSEMBLY-NAME", "Create a new assembly from this service instance in the designated service module."
|
205
|
+
desc "SERVICE-NAME/ID create-assembly [NAMESPACE:]SERVICE-MODULE-NAME ASSEMBLY-NAME", "Create a new assembly from this service instance in the designated service module."
|
206
206
|
def create_assembly(context_params)
|
207
207
|
assembly_id, service_module_name, assembly_template_name = context_params.retrieve_arguments([:service_id!,:option_1!,:option_2!],method_argument_names)
|
208
208
|
response = promote_assembly_aux(:create,assembly_id,service_module_name,assembly_template_name)
|
@@ -223,7 +223,7 @@ TODO: overlaps with different meaning
|
|
223
223
|
converge_aux(context_params)
|
224
224
|
end
|
225
225
|
|
226
|
-
desc "SERVICE-NAME/ID push-assembly-updates [SERVICE-MODULE-NAME/ASSEMBLY-NAME]", "Push changes made to this service instance to the designated assembly; default is parent assembly."
|
226
|
+
desc "SERVICE-NAME/ID push-assembly-updates [NAMESPACE:SERVICE-MODULE-NAME/ASSEMBLY-NAME]", "Push changes made to this service instance to the designated assembly; default is parent assembly."
|
227
227
|
def push_assembly_updates(context_params)
|
228
228
|
assembly_id, qualified_assembly_name = context_params.retrieve_arguments([:service_id!,:option_1],method_argument_names)
|
229
229
|
service_module_name, assembly_template_name =
|
@@ -258,12 +258,10 @@ TODO: overlaps with different meaning
|
|
258
258
|
edit_workflow_aux(context_params)
|
259
259
|
end
|
260
260
|
|
261
|
-
=begin
|
262
261
|
desc "SERVICE-NAME/ID edit-attributes", "Edit service's attributes."
|
263
262
|
def edit_attributes(context_params)
|
264
263
|
edit_attributes_aux(context_params)
|
265
264
|
end
|
266
|
-
=end
|
267
265
|
|
268
266
|
# desc "ASSEMBLY-NAME/ID promote-module-updates COMPONENT-MODULE-NAME [--force]", "Promotes changes made to component module in assembly to base component module"
|
269
267
|
# method_option :force, :type => :boolean, :default => false, :aliases => '-f'
|
@@ -409,7 +407,7 @@ TODO: will put in dot release and will rename to 'extend'
|
|
409
407
|
about, data_type = get_type_and_raise_error_if_invalid(about, "nodes", ["attributes", "components", "nodes", "tasks"])
|
410
408
|
else
|
411
409
|
data_type = :assembly
|
412
|
-
post_body = { :subtype => 'instance', :detail_level => 'nodes' }
|
410
|
+
post_body = { :subtype => 'instance', :detail_level => 'nodes',:include_namespaces => true}
|
413
411
|
rest_endpoint = "assembly/list"
|
414
412
|
end
|
415
413
|
end
|
@@ -524,8 +522,7 @@ TODO: will put in dot release and will rename to 'extend'
|
|
524
522
|
unless options.force?
|
525
523
|
# Ask user if really want to delete assembly, if not then return to dtk-shell without deleting
|
526
524
|
# used form "+'?' because ?" confused emacs ruby rendering
|
527
|
-
|
528
|
-
return unless Console.confirmation_prompt("Are you sure you want to delete and destroy #{what} '#{assembly_name}' and its nodes"+'?')
|
525
|
+
return unless Console.confirmation_prompt("Are you sure you want to delete and destroy service '#{assembly_name}' and its nodes"+'?')
|
529
526
|
end
|
530
527
|
|
531
528
|
# purge local clone
|