dtk-client 0.5.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/Gemfile +5 -0
- data/Gemfile_dev +12 -0
- data/README.md +78 -0
- data/bin/dtk +54 -0
- data/bin/dtk-shell +15 -0
- data/dtk-client.gemspec +49 -0
- data/lib/auxiliary.rb +13 -0
- data/lib/bundler_monkey_patch.rb +9 -0
- data/lib/client.rb +48 -0
- data/lib/command_helper.rb +16 -0
- data/lib/command_helpers/git_repo.rb +391 -0
- data/lib/command_helpers/jenkins_client/config_xml.rb +271 -0
- data/lib/command_helpers/jenkins_client.rb +91 -0
- data/lib/command_helpers/service_importer.rb +99 -0
- data/lib/command_helpers/service_link.rb +18 -0
- data/lib/command_helpers/ssh_processing.rb +43 -0
- data/lib/commands/common/thor/assembly_workspace.rb +1089 -0
- data/lib/commands/common/thor/clone.rb +39 -0
- data/lib/commands/common/thor/common.rb +34 -0
- data/lib/commands/common/thor/edit.rb +168 -0
- data/lib/commands/common/thor/list_diffs.rb +84 -0
- data/lib/commands/common/thor/pull_clone_changes.rb +11 -0
- data/lib/commands/common/thor/pull_from_remote.rb +99 -0
- data/lib/commands/common/thor/purge_clone.rb +26 -0
- data/lib/commands/common/thor/push_clone_changes.rb +45 -0
- data/lib/commands/common/thor/push_to_remote.rb +45 -0
- data/lib/commands/common/thor/reparse.rb +36 -0
- data/lib/commands/common/thor/set_required_params.rb +29 -0
- data/lib/commands/common/thor/task_status.rb +81 -0
- data/lib/commands/thor/account.rb +213 -0
- data/lib/commands/thor/assembly.rb +329 -0
- data/lib/commands/thor/attribute.rb +62 -0
- data/lib/commands/thor/component.rb +52 -0
- data/lib/commands/thor/component_module.rb +829 -0
- data/lib/commands/thor/component_template.rb +153 -0
- data/lib/commands/thor/dependency.rb +18 -0
- data/lib/commands/thor/developer.rb +105 -0
- data/lib/commands/thor/dtk.rb +117 -0
- data/lib/commands/thor/library.rb +107 -0
- data/lib/commands/thor/node.rb +411 -0
- data/lib/commands/thor/node_group.rb +211 -0
- data/lib/commands/thor/node_template.rb +88 -0
- data/lib/commands/thor/project.rb +17 -0
- data/lib/commands/thor/provider.rb +155 -0
- data/lib/commands/thor/repo.rb +35 -0
- data/lib/commands/thor/service.rb +656 -0
- data/lib/commands/thor/service_module.rb +806 -0
- data/lib/commands/thor/state_change.rb +10 -0
- data/lib/commands/thor/target.rb +94 -0
- data/lib/commands/thor/task.rb +100 -0
- data/lib/commands/thor/utils.rb +4 -0
- data/lib/commands/thor/workspace.rb +437 -0
- data/lib/commands.rb +40 -0
- data/lib/config/cacert.pem +3785 -0
- data/lib/config/client.conf.header +18 -0
- data/lib/config/configuration.rb +82 -0
- data/lib/config/default.conf +14 -0
- data/lib/config/disk_cacher.rb +60 -0
- data/lib/configurator.rb +92 -0
- data/lib/context_router.rb +23 -0
- data/lib/core.rb +460 -0
- data/lib/domain/git_adapter.rb +221 -0
- data/lib/domain/response.rb +234 -0
- data/lib/dtk-client/version.rb +3 -0
- data/lib/dtk_constants.rb +23 -0
- data/lib/dtk_logger.rb +96 -0
- data/lib/error.rb +74 -0
- data/lib/git-logs/git.log +0 -0
- data/lib/parser/adapters/option_parser.rb +53 -0
- data/lib/parser/adapters/thor/common_option_defs.rb +12 -0
- data/lib/parser/adapters/thor.rb +509 -0
- data/lib/require_first.rb +87 -0
- data/lib/search_hash.rb +27 -0
- data/lib/shell/context.rb +975 -0
- data/lib/shell/context_aux.rb +29 -0
- data/lib/shell/domain.rb +447 -0
- data/lib/shell/header_shell.rb +27 -0
- data/lib/shell/help_monkey_patch.rb +221 -0
- data/lib/shell/interactive_wizard.rb +233 -0
- data/lib/shell/parse_monkey_patch.rb +22 -0
- data/lib/shell/status_monitor.rb +105 -0
- data/lib/shell.rb +219 -0
- data/lib/util/console.rb +143 -0
- data/lib/util/dtk_puppet.rb +46 -0
- data/lib/util/os_util.rb +265 -0
- data/lib/view_processor/augmented_simple_list.rb +27 -0
- data/lib/view_processor/hash_pretty_print.rb +106 -0
- data/lib/view_processor/simple_list.rb +139 -0
- data/lib/view_processor/table_print.rb +277 -0
- data/lib/view_processor.rb +112 -0
- data/puppet/manifests/init.pp +72 -0
- data/puppet/manifests/params.pp +16 -0
- data/puppet/r8meta.puppet.yml +18 -0
- data/puppet/templates/bash_profile.erb +2 -0
- data/puppet/templates/client.conf.erb +1 -0
- data/puppet/templates/dtkclient.erb +2 -0
- data/spec/assembly_spec.rb +50 -0
- data/spec/assembly_template_spec.rb +51 -0
- data/spec/component_template_spec.rb +40 -0
- data/spec/dependency_spec.rb +6 -0
- data/spec/dtk_shell_spec.rb +13 -0
- data/spec/dtk_spec.rb +33 -0
- data/spec/lib/spec_helper.rb +10 -0
- data/spec/lib/spec_thor.rb +105 -0
- data/spec/module_spec.rb +35 -0
- data/spec/node_spec.rb +43 -0
- data/spec/node_template_spec.rb +25 -0
- data/spec/project_spec.rb +6 -0
- data/spec/repo_spec.rb +7 -0
- data/spec/response_spec.rb +52 -0
- data/spec/service_spec.rb +41 -0
- data/spec/state_change_spec.rb +7 -0
- data/spec/table_print_spec.rb +48 -0
- data/spec/target_spec.rb +57 -0
- data/spec/task_spec.rb +28 -0
- data/views/assembly/augmented_simple_list.rb +12 -0
- data/views/assembly_template/augmented_simple_list.rb +12 -0
- data/views/list_task/augmented_simple_list.rb +12 -0
- metadata +351 -0
@@ -0,0 +1,656 @@
|
|
1
|
+
require 'rest_client'
|
2
|
+
require 'json'
|
3
|
+
require 'colorize'
|
4
|
+
|
5
|
+
dtk_require_from_base("dtk_logger")
|
6
|
+
dtk_require_from_base("util/os_util")
|
7
|
+
dtk_require_from_base("command_helper")
|
8
|
+
dtk_require_common_commands('thor/task_status')
|
9
|
+
dtk_require_common_commands('thor/set_required_params')
|
10
|
+
dtk_require_common_commands('thor/edit')
|
11
|
+
dtk_require_common_commands('thor/purge_clone')
|
12
|
+
dtk_require_common_commands('thor/assembly_workspace')
|
13
|
+
|
14
|
+
LOG_SLEEP_TIME = DTK::Configuration.get(:tail_log_frequency)
|
15
|
+
DEBUG_SLEEP_TIME = DTK::Configuration.get(:debug_task_frequency)
|
16
|
+
|
17
|
+
module DTK::Client
|
18
|
+
class Service < CommandBaseThor
|
19
|
+
|
20
|
+
no_tasks do
|
21
|
+
include TaskStatusMixin
|
22
|
+
include SetRequiredParamsMixin
|
23
|
+
include EditMixin
|
24
|
+
include PurgeCloneMixin
|
25
|
+
include AssemblyWorkspaceMixin
|
26
|
+
|
27
|
+
def get_assembly_name(assembly_id)
|
28
|
+
get_name_from_id_helper(assembly_id)
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_assembly_id(assembly_name)
|
32
|
+
assembly_id = nil
|
33
|
+
list = CommandBaseThor.get_cached_response(:service, "assembly/list", {})
|
34
|
+
|
35
|
+
list.data.each do |item|
|
36
|
+
if item["display_name"] == assembly_name
|
37
|
+
assembly_id = item["id"]
|
38
|
+
break
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
raise DtkError,"[ERROR] Illegal name (#{assembly_name}) for service." unless assembly_id
|
43
|
+
assembly_id
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.whoami()
|
49
|
+
return :service, "assembly/list", {:subtype => 'instance'}
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.pretty_print_cols()
|
53
|
+
PPColumns.get(:assembly)
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.valid_children()
|
57
|
+
[:utils]
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.invisible_context()
|
61
|
+
[:node]
|
62
|
+
end
|
63
|
+
|
64
|
+
# using extended_context when we want to use autocomplete from other context
|
65
|
+
# e.g. we are in assembly/apache context and want to create-component we will use extended context to add
|
66
|
+
# component-templates to autocomplete
|
67
|
+
def self.extended_context()
|
68
|
+
{
|
69
|
+
:context => {
|
70
|
+
:add_component => "component_template",
|
71
|
+
:create_node => "node_template",
|
72
|
+
:add_component_dependency => "component_template"
|
73
|
+
},
|
74
|
+
:command => {
|
75
|
+
:edit_component_module => {
|
76
|
+
:endpoint => "assembly",
|
77
|
+
:url => "assembly/info_about",
|
78
|
+
:opts => {:subtype=>"instance", :about=>"modules"}
|
79
|
+
},
|
80
|
+
:push_component_module_updates => {
|
81
|
+
:endpoint => "assembly",
|
82
|
+
:url => "assembly/info_about",
|
83
|
+
:opts => {:subtype=>"instance", :about=>"modules"}
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
87
|
+
end
|
88
|
+
|
89
|
+
# this includes children of children
|
90
|
+
def self.all_children()
|
91
|
+
# [:node, :component, :attribute]
|
92
|
+
[:node]
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.multi_context_children()
|
96
|
+
[[:utils],[:node, :utils]]
|
97
|
+
end
|
98
|
+
|
99
|
+
def self.valid_child?(name_of_sub_context)
|
100
|
+
return Service.valid_children().include?(name_of_sub_context.to_sym)
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.validation_list(context_params)
|
104
|
+
get_cached_response(:service, "assembly/list", {})
|
105
|
+
end
|
106
|
+
|
107
|
+
# TODO: Hack which is necessery for the specific problem (DTK-541), something to reconsider down the line
|
108
|
+
# at this point not sure what would be clenear solution
|
109
|
+
|
110
|
+
# :all => include both for commands with command and identifier
|
111
|
+
# :command_only => only on command level
|
112
|
+
# :identifier_only => only on identifier level for given entity (command)
|
113
|
+
#
|
114
|
+
def self.override_allowed_methods()
|
115
|
+
return DTK::Shell::OverrideTasks.new({
|
116
|
+
:all => {
|
117
|
+
# :node => [
|
118
|
+
# ['delete-component',"delete-component COMPONENT-ID","# Delete component from assembly's node"],
|
119
|
+
# ['list-components',"list-components","# List components associated with assembly's node."],
|
120
|
+
# ['list-attributes',"list-attributes","# List attributes associated with assembly's node."]
|
121
|
+
# ],
|
122
|
+
:component => [
|
123
|
+
['list-attributes',"list-attributes","# List attributes associated with given component."]
|
124
|
+
=begin
|
125
|
+
TODO: overlaps with different meaning
|
126
|
+
['create-attribute',"create-attribute SERVICE-TYPE DEP-ATTR ARROW BASE-ATTR","# Create an attribute to service link."],
|
127
|
+
=end
|
128
|
+
]
|
129
|
+
},
|
130
|
+
:command_only => {
|
131
|
+
:attribute => [
|
132
|
+
['list-attributes',"list-attributes","# List attributes."]
|
133
|
+
],
|
134
|
+
:node => [
|
135
|
+
['delete',"delete NODE-NAME/ID [-y] ","# Delete node, terminating it if the node has been spun up."],
|
136
|
+
['list',"list","# List nodes."]
|
137
|
+
],
|
138
|
+
:component => [
|
139
|
+
['delete',"delete COMPONENT-NAME/ID [-y] ","# Delete component from workspace."],
|
140
|
+
['list-components',"list-components","# List components."]
|
141
|
+
],
|
142
|
+
:utils => [
|
143
|
+
['get-netstats',"get-netstats","# Get netstats."],
|
144
|
+
['get-ps',"get-ps [--filter PATTERN]","# Get ps."],
|
145
|
+
['grep',"grep LOG-PATH NODE-ID-PATTERN GREP-PATTERN [--first]","# Grep log from multiple nodes. --first option returns first match (latest log entry)."],
|
146
|
+
['tail',"tail NODE-ID LOG-PATH [REGEX-PATTERN] [--more]","# Tail specified number of lines from log."]
|
147
|
+
]
|
148
|
+
},
|
149
|
+
:identifier_only => {
|
150
|
+
:node => [
|
151
|
+
['add-component',"add-component COMPONENT","# Add a component to the node."],
|
152
|
+
['delete-component',"delete-component COMPONENT-NAME [-y]","# Delete component from service's node"],
|
153
|
+
['info',"info","# Return info about node instance belonging to given workspace."],
|
154
|
+
# ['link-attributes', "link-attributes TARGET-ATTR-TERM SOURCE-ATTR-TERM", "# Set TARGET-ATTR-TERM to SOURCE-ATTR-TERM."],
|
155
|
+
['list-attributes',"list-attributes","# List attributes associated with service's node."],
|
156
|
+
['list-components',"list-components","# List components associated with service's node."],
|
157
|
+
['set-attribute',"set-attribute ATTRIBUTE-NAME [VALUE] [-u]","# (Un)Set attribute value. The option -u will unset the attribute's value."],
|
158
|
+
['start', "start", "# Start node instance."],
|
159
|
+
['stop', "stop", "# Stop node instance."]
|
160
|
+
],
|
161
|
+
:component => [
|
162
|
+
['info',"info","# Return info about component instance belonging to given node."],
|
163
|
+
['edit',"edit","# Edit component module related to given component."],
|
164
|
+
# ['edit-dsl',"edit-dsl","# Edit component module dsl file related to given component."],
|
165
|
+
['link-components',"link-components ANTECEDENT-CMP-NAME [DEPENDENCY-NAME]","#Link components to satisfy component dependency relationship."],
|
166
|
+
['list-component-links',"list-component-links","# List component's links to other components."],
|
167
|
+
['unlink-components',"unlink-components SERVICE-TYPE","# Delete service link on component."]
|
168
|
+
],
|
169
|
+
:attribute => [
|
170
|
+
['info',"info","# Return info about attribute instance belonging to given component."]
|
171
|
+
]
|
172
|
+
}
|
173
|
+
}, [:utils])
|
174
|
+
end
|
175
|
+
|
176
|
+
desc "SERVICE-NAME/ID start [NODE-NAME]", "Starts all the service nodes. A single node can be selected."
|
177
|
+
def start(context_params)
|
178
|
+
start_aux(context_params)
|
179
|
+
end
|
180
|
+
|
181
|
+
desc "SERVICE-NAME/ID stop [NODE-NAME]", "Stops all the service nodes. A single node can be selected."
|
182
|
+
def stop(context_params)
|
183
|
+
stop_aux(context_params)
|
184
|
+
end
|
185
|
+
|
186
|
+
|
187
|
+
desc "SERVICE-NAME/ID cancel-task [TASK_ID]", "Cancels an executing task. If task id is omitted, this command cancels the most recent executing task."
|
188
|
+
def cancel_task(context_params)
|
189
|
+
cancel_task_aux(context_params)
|
190
|
+
end
|
191
|
+
|
192
|
+
desc "rename SERVICE-NAME NEW-SERVICE-NAME","Change service name."
|
193
|
+
def rename(context_params)
|
194
|
+
assembly_name, new_assembly_name = context_params.retrieve_arguments([:option_1!,:option_2!],method_argument_names)
|
195
|
+
|
196
|
+
if assembly_name.to_s =~ /^[0-9]+$/
|
197
|
+
assembly_id = assembly_name
|
198
|
+
else
|
199
|
+
assembly_id = get_assembly_id(assembly_name)
|
200
|
+
end
|
201
|
+
|
202
|
+
post_body = {
|
203
|
+
:assembly_id => assembly_id,
|
204
|
+
:assembly_name => assembly_name,
|
205
|
+
:new_assembly_name => new_assembly_name
|
206
|
+
}
|
207
|
+
|
208
|
+
response = post rest_url("assembly/rename"), post_body
|
209
|
+
return response unless response.ok?
|
210
|
+
|
211
|
+
@@invalidate_map << :service
|
212
|
+
response
|
213
|
+
end
|
214
|
+
|
215
|
+
#desc "ASSEMBLY-NAME/ID clear-tasks", "Clears the tasks that have been run already."
|
216
|
+
#def clear_tasks(context_params)
|
217
|
+
# clear_tasks_aux(context_params)
|
218
|
+
#end
|
219
|
+
|
220
|
+
desc "SERVICE-NAME/ID create-assembly SERVICE-MODULE-NAME ASSEMBLY-NAME", "Create a new assembly from this service instance in the designated service module."
|
221
|
+
def create_service(context_params)
|
222
|
+
assembly_id, service_module_name, assembly_template_name = context_params.retrieve_arguments([:service_id!,:option_1!,:option_2!],method_argument_names)
|
223
|
+
response = promote_assembly_aux(:create,assembly_id,service_module_name,assembly_template_name)
|
224
|
+
return response unless response.ok?
|
225
|
+
|
226
|
+
@@invalidate_map << :assembly
|
227
|
+
@@invalidate_map << :service_module
|
228
|
+
Response::Ok.new()
|
229
|
+
end
|
230
|
+
|
231
|
+
desc "SERVICE-NAME/ID converge [-m COMMIT-MSG]", "Converge service instance."
|
232
|
+
method_option "commit_msg",:aliases => "-m" ,
|
233
|
+
:type => :string,
|
234
|
+
:banner => "COMMIT-MSG",
|
235
|
+
:desc => "Commit message"
|
236
|
+
def converge(context_params)
|
237
|
+
converge_aux(context_params)
|
238
|
+
end
|
239
|
+
|
240
|
+
desc "SERVICE-NAME/ID push-assembly-updates [SERVICE-MODULE-NAME/ASSEMBLY-NAME]", "Push service instance to the designated assembly; default is parent assembly."
|
241
|
+
def push_service_updates(context_params)
|
242
|
+
assembly_id, qualified_assembly_name = context_params.retrieve_arguments([:service_id!,:option_1],method_argument_names)
|
243
|
+
service_module_name, assembly_template_name =
|
244
|
+
if qualified_assembly_name
|
245
|
+
if qualified_assembly_name =~ /(^[^\/]*)\/([^\/]*$)/
|
246
|
+
[$1,$2]
|
247
|
+
else
|
248
|
+
raise DtkError,"The term (#{qualified_assembly_name}) must have form SERVICE-MODULE-NAME/ASSEMBLY-NAME"
|
249
|
+
end
|
250
|
+
else
|
251
|
+
[nil,nil]
|
252
|
+
end
|
253
|
+
response = promote_assembly_aux(:update,assembly_id, service_module_name, assembly_template_name)
|
254
|
+
return response unless response.ok?
|
255
|
+
@@invalidate_map << :assembly
|
256
|
+
Response::Ok.new()
|
257
|
+
end
|
258
|
+
|
259
|
+
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."
|
260
|
+
method_option :force, :type => :boolean, :default => false, :aliases => '-f'
|
261
|
+
def push_component_module_updates(context_params)
|
262
|
+
push_module_updates_aux(context_params)
|
263
|
+
end
|
264
|
+
|
265
|
+
desc "SERVICE-NAME/ID edit-component-module COMPONENT-MODULE-NAME", "Edit a component module used in the service."
|
266
|
+
def edit_component_module(context_params)
|
267
|
+
edit_module_aux(context_params)
|
268
|
+
end
|
269
|
+
|
270
|
+
desc "SERVICE-NAME/ID edit-workflow", "Edit service's workflow."
|
271
|
+
def edit_workflow(context_params)
|
272
|
+
edit_workflow_aux(context_params)
|
273
|
+
end
|
274
|
+
|
275
|
+
=begin
|
276
|
+
desc "SERVICE-NAME/ID edit-attributes", "Edit service's attributes."
|
277
|
+
def edit_attributes(context_params)
|
278
|
+
edit_attributes_aux(context_params)
|
279
|
+
end
|
280
|
+
=end
|
281
|
+
|
282
|
+
# desc "ASSEMBLY-NAME/ID promote-module-updates COMPONENT-MODULE-NAME [--force]", "Promotes changes made to component module in assembly to base component module"
|
283
|
+
# method_option :force, :type => :boolean, :default => false, :aliases => '-f'
|
284
|
+
# def promote_module_updates(context_params)
|
285
|
+
# promote_module_updates_aux(context_params)
|
286
|
+
# end
|
287
|
+
|
288
|
+
=begin
|
289
|
+
TODO: will put in dot release and will rename to 'extend'
|
290
|
+
desc "ASSEMBLY-NAME/ID add EXTENSION-TYPE [-n COUNT]", "Adds a sub assembly template to the assembly"
|
291
|
+
method_option "count",:aliases => "-n" ,
|
292
|
+
:type => :string, #integer
|
293
|
+
:banner => "COUNT",
|
294
|
+
:desc => "Number of sub-assemblies to add"
|
295
|
+
def add_node(context_params)
|
296
|
+
assembly_id,service_add_on_name = context_params.retrieve_arguments([:assembly_id!,:option_1!],method_argument_names)
|
297
|
+
|
298
|
+
# create task
|
299
|
+
post_body = {
|
300
|
+
:assembly_id => assembly_id,
|
301
|
+
:service_add_on_name => service_add_on_name
|
302
|
+
}
|
303
|
+
|
304
|
+
post_body.merge!(:count => options.count) if options.count
|
305
|
+
|
306
|
+
response = post rest_url("assembly/add__service_add_on"), post_body
|
307
|
+
# when changing context send request for getting latest assemblies instead of getting from cache
|
308
|
+
@@invalidate_map << :assembly
|
309
|
+
|
310
|
+
return response
|
311
|
+
end
|
312
|
+
|
313
|
+
desc "ASSEMBLY-NAME/ID possible-extensions", "Lists the possible extensions to the assembly"
|
314
|
+
def possible_extensions(context_params)
|
315
|
+
assembly_id = context_params.retrieve_arguments([:assembly_id!],method_argument_names)
|
316
|
+
|
317
|
+
post_body = {
|
318
|
+
:assembly_id => assembly_id
|
319
|
+
}
|
320
|
+
response = post(rest_url("assembly/list_possible_add_ons"),post_body)
|
321
|
+
response.render_table(:service_add_on)
|
322
|
+
end
|
323
|
+
=end
|
324
|
+
|
325
|
+
desc "SERVICE-NAME/ID task-status [--wait]", "Get the task status of the running or last running service task."
|
326
|
+
method_option :wait, :type => :boolean, :default => false
|
327
|
+
def task_status(context_params)
|
328
|
+
task_status_aw_aux(context_params)
|
329
|
+
end
|
330
|
+
|
331
|
+
=begin
|
332
|
+
desc "ASSEMBLY-NAME/ID run-smoketests", "Run smoketests associated with assembly instance"
|
333
|
+
def run_smoketests(context_params)
|
334
|
+
assembly_id = context_params.retrieve_arguments([:assembly_id!],method_argument_names)
|
335
|
+
post_body = {
|
336
|
+
:assembly_id => assembly_id
|
337
|
+
}
|
338
|
+
# create smoke test
|
339
|
+
response = post rest_url("assembly/create_smoketests_task"), post_body
|
340
|
+
return response unless response.ok?
|
341
|
+
# execute
|
342
|
+
task_id = response.data(:task_id)
|
343
|
+
post rest_url("task/execute"), "task_id" => task_id
|
344
|
+
end
|
345
|
+
=end
|
346
|
+
|
347
|
+
desc "SERVICE-NAME/ID list-nodes","List nodes associated with service."
|
348
|
+
def list_nodes(context_params)
|
349
|
+
list_nodes_aux(context_params)
|
350
|
+
end
|
351
|
+
|
352
|
+
desc "SERVICE-NAME/ID list-component-links","List component links."
|
353
|
+
def list_component_links(context_params)
|
354
|
+
list_component_links_aux(context_params)
|
355
|
+
end
|
356
|
+
|
357
|
+
desc "SERVICE-NAME/ID list-components [--deps]","List components associated with service."
|
358
|
+
method_option :deps, :type => :boolean, :default => false, :aliases => '-l'
|
359
|
+
def list_components(context_params)
|
360
|
+
list_components_aux(context_params)
|
361
|
+
end
|
362
|
+
|
363
|
+
desc "SERVICE-NAME/ID list-attributes [-f FORMAT] [--links]","List attributes associated with service."
|
364
|
+
method_option :format,:aliases => '-f'
|
365
|
+
method_option :links, :type => :boolean, :default => false, :aliases => '-l'
|
366
|
+
def list_attributes(context_params)
|
367
|
+
list_attributes_aux(context_params)
|
368
|
+
end
|
369
|
+
|
370
|
+
desc "SERVICE-NAME/ID list-component-modules","List component modules associated with service."
|
371
|
+
def list_component_modules(context_params)
|
372
|
+
list_modules_aux(context_params)
|
373
|
+
end
|
374
|
+
|
375
|
+
desc "SERVICE-NAME/ID list-tasks","List tasks associated with service."
|
376
|
+
def list_tasks(context_params)
|
377
|
+
list_tasks_aux(context_params)
|
378
|
+
end
|
379
|
+
|
380
|
+
desc "SERVICE-NAME/ID list-violations", "Finds violations in the service that will prevent a converge operation."
|
381
|
+
def list_violations(context_params)
|
382
|
+
list_violations_aux(context_params)
|
383
|
+
end
|
384
|
+
|
385
|
+
desc "SERVICE-NAME/ID workflow-info", "Get the structure of the workflow associated with service."
|
386
|
+
def workflow_info(context_params)
|
387
|
+
workflow_info_aux(context_params)
|
388
|
+
end
|
389
|
+
|
390
|
+
desc "list","List services."
|
391
|
+
def list(context_params)
|
392
|
+
assembly_id, node_id, component_id, attribute_id, about = context_params.retrieve_arguments([:service_id,:node_id,:component_id,:attribute_id,:option_1],method_argument_names)
|
393
|
+
detail_to_include = nil
|
394
|
+
|
395
|
+
if about
|
396
|
+
case about
|
397
|
+
when "nodes"
|
398
|
+
data_type = :node
|
399
|
+
when "components"
|
400
|
+
data_type = :component
|
401
|
+
detail_to_include = [:component_dependencies]
|
402
|
+
when "attributes"
|
403
|
+
data_type = :attribute
|
404
|
+
detail_to_include = [:attribute_links]
|
405
|
+
when "tasks"
|
406
|
+
data_type = :task
|
407
|
+
else
|
408
|
+
raise_validation_error_method_usage('list')
|
409
|
+
end
|
410
|
+
end
|
411
|
+
|
412
|
+
post_body = {
|
413
|
+
:assembly_id => assembly_id,
|
414
|
+
:node_id => node_id,
|
415
|
+
:component_id => component_id,
|
416
|
+
:subtype => 'instance'
|
417
|
+
}
|
418
|
+
post_body.merge!(:detail_to_include => detail_to_include) if detail_to_include
|
419
|
+
rest_endpoint = "assembly/info_about"
|
420
|
+
|
421
|
+
if context_params.is_last_command_eql_to?(:attribute)
|
422
|
+
raise DTK::Client::DtkError, "Not supported command for current context level." if attribute_id
|
423
|
+
about, data_type = get_type_and_raise_error_if_invalid(about, "attributes", ["attributes"])
|
424
|
+
elsif context_params.is_last_command_eql_to?(:component)
|
425
|
+
if component_id
|
426
|
+
about, data_type = get_type_and_raise_error_if_invalid(about, "attributes", ["attributes"])
|
427
|
+
else
|
428
|
+
about, data_type = get_type_and_raise_error_if_invalid(about, "components", ["attributes", "components"])
|
429
|
+
end
|
430
|
+
elsif context_params.is_last_command_eql_to?(:node)
|
431
|
+
if node_id
|
432
|
+
about, data_type = get_type_and_raise_error_if_invalid(about, "components", ["attributes", "components"])
|
433
|
+
else
|
434
|
+
about, data_type = get_type_and_raise_error_if_invalid(about, "nodes", ["attributes", "components", "nodes"])
|
435
|
+
end
|
436
|
+
else
|
437
|
+
if assembly_id
|
438
|
+
about, data_type = get_type_and_raise_error_if_invalid(about, "nodes", ["attributes", "components", "nodes", "tasks"])
|
439
|
+
else
|
440
|
+
data_type = :assembly
|
441
|
+
post_body = { :subtype => 'instance', :detail_level => 'nodes' }
|
442
|
+
rest_endpoint = "assembly/list"
|
443
|
+
end
|
444
|
+
end
|
445
|
+
|
446
|
+
post_body[:about] = about
|
447
|
+
response = post rest_url(rest_endpoint), post_body
|
448
|
+
|
449
|
+
# set render view to be used
|
450
|
+
response.render_table(data_type)
|
451
|
+
|
452
|
+
return response
|
453
|
+
end
|
454
|
+
|
455
|
+
# desc "ASSEMBLY-NAME/ID list-attribute-mappings SERVICE-LINK-NAME/ID", "List attribute mappings associated with service link"
|
456
|
+
# def list_attribute_mappings(context_params)
|
457
|
+
# post_body = Helper(:service_link).post_body_with_id_keys(context_params,method_argument_names)
|
458
|
+
# post rest_url("assembly/list_attribute_mappings"), post_body
|
459
|
+
# end
|
460
|
+
|
461
|
+
#desc "ASSEMBLY-NAME/ID list-smoketests","List smoketests on asssembly"
|
462
|
+
#def list_smoketests(context_params)
|
463
|
+
# assembly_id = context_params.retrieve_arguments([:assembly_id!],method_argument_names)
|
464
|
+
#
|
465
|
+
# post_body = {
|
466
|
+
# :assembly_id => assembly_id
|
467
|
+
# }
|
468
|
+
# post rest_url("assembly/list_smoketests"), post_body
|
469
|
+
#end
|
470
|
+
|
471
|
+
desc "SERVICE-NAME/ID info", "Get info about content of the service."
|
472
|
+
def info(context_params)
|
473
|
+
info_aux(context_params)
|
474
|
+
end
|
475
|
+
|
476
|
+
desc "SERVICE-NAME/ID link-attributes TARGET-ATTR SOURCE-ATTR", "Link the value of the target attribute to the source attribute."
|
477
|
+
def link_attributes(context_params)
|
478
|
+
link_attributes_aux(context_params)
|
479
|
+
end
|
480
|
+
|
481
|
+
desc "delete-and-destroy NAME/ID [-y]", "Delete service instance, terminating any nodes that have been spun up."
|
482
|
+
method_option :force, :aliases => '-y', :type => :boolean, :default => false
|
483
|
+
def delete_and_destroy(context_params)
|
484
|
+
assembly_name = context_params.retrieve_arguments([:option_1!],method_argument_names)
|
485
|
+
|
486
|
+
if assembly_name.to_s =~ /^[0-9]+$/
|
487
|
+
assembly_id = assembly_name
|
488
|
+
else
|
489
|
+
assembly_id = get_assembly_id(assembly_name)
|
490
|
+
end
|
491
|
+
# assembly_name = get_assembly_name(assembly_id)
|
492
|
+
|
493
|
+
unless options.force?
|
494
|
+
# Ask user if really want to delete assembly, if not then return to dtk-shell without deleting
|
495
|
+
#used form "+'?' because ?" confused emacs ruby rendering
|
496
|
+
what = "service"
|
497
|
+
return unless Console.confirmation_prompt("Are you sure you want to delete and destroy #{what} '#{assembly_name}' and its nodes"+'?')
|
498
|
+
end
|
499
|
+
|
500
|
+
#purge local clone
|
501
|
+
response = purge_clone_aux(:all,:assembly_module => {:assembly_name => assembly_name})
|
502
|
+
return response unless response.ok?
|
503
|
+
|
504
|
+
post_body = {
|
505
|
+
:assembly_id => assembly_id,
|
506
|
+
:subtype => :instance
|
507
|
+
}
|
508
|
+
|
509
|
+
response = post rest_url("assembly/delete"), post_body
|
510
|
+
|
511
|
+
# when changing context send request for getting latest assemblies instead of getting from cache
|
512
|
+
@@invalidate_map << :service
|
513
|
+
@@invalidate_map << :assembly
|
514
|
+
response
|
515
|
+
end
|
516
|
+
|
517
|
+
desc "SERVICE-NAME/ID set-attribute ATTRIBUTE-NAME [VALUE] [-u]", "(Un)Set attribute value. The option -u will unset the attribute's value."
|
518
|
+
method_option :unset, :aliases => '-u', :type => :boolean, :default => false
|
519
|
+
def set_attribute(context_params)
|
520
|
+
set_attribute_aux(context_params)
|
521
|
+
end
|
522
|
+
|
523
|
+
desc "SERVICE-NAME/ID create-attribute ATTRIBUTE-NAME [VALUE] [--type DATATYPE] [--required] [--dynamic]", "Create a new attribute and optionally assign it a value."
|
524
|
+
method_option :required, :type => :boolean, :default => false
|
525
|
+
method_option :dynamic, :type => :boolean, :default => false
|
526
|
+
method_option "type",:aliases => "-t"
|
527
|
+
def create_attribute(context_params)
|
528
|
+
create_attribute_aux(context_params)
|
529
|
+
end
|
530
|
+
|
531
|
+
# desc "ASSEMBLY-NAME/ID add-assembly ASSEMBLY-TEMPLATE-NAME/ID", "Add (stage) an assembly template to become part of this assembly instance"
|
532
|
+
# method_option "auto-complete",:aliases => "-a" ,
|
533
|
+
# :type => :boolean,
|
534
|
+
# :default=> false,
|
535
|
+
# :desc => "Automatically add in connections"
|
536
|
+
# def add_assembly(context_params)
|
537
|
+
# assembly_id,assembly_template_id = context_params.retrieve_arguments([:assembly_id,:option_1!],method_argument_names)
|
538
|
+
# post_body = {
|
539
|
+
# :assembly_id => assembly_id,
|
540
|
+
# :assembly_template_id => assembly_template_id
|
541
|
+
# }
|
542
|
+
# post_body.merge!(:auto_add_connections => true) if options.auto_complete?
|
543
|
+
# post rest_url("assembly/add_assembly_template"), post_body
|
544
|
+
# end
|
545
|
+
|
546
|
+
# using ^^ before NODE-NAME to remove this command from assembly/assembly_id/node/node_id but show in assembly/assembly_id
|
547
|
+
desc "SERVICE-NAME/ID create-node ^^NODE-NAME NODE-TEMPLATE", "Add (stage) a new node in the service."
|
548
|
+
def create_node(context_params)
|
549
|
+
response = create_node_aux(context_params)
|
550
|
+
return response unless response.ok?
|
551
|
+
|
552
|
+
@@invalidate_map << :service_node
|
553
|
+
message = "Created node '#{response.data["display_name"]}'."
|
554
|
+
DTK::Client::OsUtil.print(message, :yellow)
|
555
|
+
end
|
556
|
+
|
557
|
+
desc "SERVICE-NAME/ID link-components TARGET-CMP-NAME SOURCE-CMP-NAME [DEPENDENCY-NAME]","Link the target component to the source component."
|
558
|
+
def link_components(context_params)
|
559
|
+
link_components_aux(context_params)
|
560
|
+
end
|
561
|
+
|
562
|
+
# only supported at node-level
|
563
|
+
# using HIDE_FROM_BASE to hide this command from base context (dtk:/assembly>)
|
564
|
+
desc "HIDE_FROM_BASE add-component NODE-NAME COMPONENT", "Add a component to the service."
|
565
|
+
def addcomponent(context_params)
|
566
|
+
response = create_component_aux(context_params)
|
567
|
+
|
568
|
+
@@invalidate_map << :service
|
569
|
+
@@invalidate_map << :service_node
|
570
|
+
|
571
|
+
response
|
572
|
+
end
|
573
|
+
|
574
|
+
# using ^^ before NODE-NAME to remove this command from assembly/assembly_id/node/node_id but show in assembly/assembly_id
|
575
|
+
desc "SERVICE-NAME/ID delete-node ^^NODE-NAME [-y]","Delete node, terminating it if the node has been spun up."
|
576
|
+
method_option :force, :aliases => '-y', :type => :boolean, :default => false
|
577
|
+
def delete_node(context_params)
|
578
|
+
response = delete_node_aux(context_params)
|
579
|
+
@@invalidate_map << :service_node
|
580
|
+
|
581
|
+
return response
|
582
|
+
end
|
583
|
+
|
584
|
+
desc "HIDE_FROM_BASE delete NAME/ID [-y]","Delete node, terminating it if the node has been spun up."
|
585
|
+
def delete(context_params)
|
586
|
+
if context_params.is_last_command_eql_to?(:node)
|
587
|
+
response = delete_node_aux(context_params)
|
588
|
+
return response unless response.ok?
|
589
|
+
@@invalidate_map << :service_node
|
590
|
+
|
591
|
+
response
|
592
|
+
elsif context_params.is_last_command_eql_to?(:component)
|
593
|
+
response = delete_component_aux(context_params)
|
594
|
+
return response unless response.ok?
|
595
|
+
@@invalidate_map << :assembly_node_component
|
596
|
+
|
597
|
+
response
|
598
|
+
end
|
599
|
+
end
|
600
|
+
|
601
|
+
desc "SERVICE-NAME/ID unlink-components TARGET-CMP-NAME SOURCE-CMP-NAME [DEPENDENCY-NAME]", "Remove a component link."
|
602
|
+
def unlink_components(context_params)
|
603
|
+
unlink_components_aux(context_params)
|
604
|
+
end
|
605
|
+
|
606
|
+
# using HIDE_FROM_BASE to hide this command from base context (dtk:/assembly>)
|
607
|
+
desc "HIDE_FROM_BASE delete-component COMPONENT-NAME [-y]","Delete component from the service."
|
608
|
+
method_option :force, :aliases => '-y', :type => :boolean, :default => false
|
609
|
+
def delete_component(context_params)
|
610
|
+
response = delete_component_aux(context_params)
|
611
|
+
return response unless response.ok?
|
612
|
+
|
613
|
+
@@invalidate_map << :service
|
614
|
+
@@invalidate_map << :service_node
|
615
|
+
@@invalidate_map << :service_node_component
|
616
|
+
|
617
|
+
response
|
618
|
+
end
|
619
|
+
|
620
|
+
# using HIDE_FROM_BASE to hide this command from base context (dtk:/assembly>)
|
621
|
+
desc "HIDE_FROM_BASE get-netstats", "Get netstats"
|
622
|
+
def get_netstats(context_params)
|
623
|
+
get_netstats_aux(context_params)
|
624
|
+
end
|
625
|
+
|
626
|
+
# using HIDE_FROM_BASE to hide this command from base context (dtk:/assembly>)
|
627
|
+
desc "HIDE_FROM_BASE get-ps [--filter PATTERN]", "Get ps"
|
628
|
+
method_option :filter, :type => :boolean, :default => false, :aliases => '-f'
|
629
|
+
def get_ps(context_params)
|
630
|
+
get_ps_aux(context_params)
|
631
|
+
end
|
632
|
+
|
633
|
+
desc "SERVICE-NAME/ID set-required-params", "Interactive dialog to set required params that are not currently set"
|
634
|
+
def set_required_params(context_params)
|
635
|
+
assembly_id = context_params.retrieve_arguments([:service_id!],method_argument_names)
|
636
|
+
set_required_params_aux(assembly_id,:assembly,:instance)
|
637
|
+
end
|
638
|
+
|
639
|
+
# using HIDE_FROM_BASE to hide this command from base context (dtk:/assembly>)
|
640
|
+
desc "HIDE_FROM_BASE tail NODES-IDENTIFIER LOG-PATH [REGEX-PATTERN] [--more]","Tail specified number of lines from log"
|
641
|
+
method_option :more, :type => :boolean, :default => false
|
642
|
+
def tail(context_params)
|
643
|
+
tail_aux(context_params)
|
644
|
+
end
|
645
|
+
|
646
|
+
# using HIDE_FROM_BASE to hide this command from base context (dtk:/assembly>)
|
647
|
+
desc "HIDE_FROM_BASE grep LOG-PATH NODES-ID-PATTERN GREP-PATTERN [--first]","Grep log from multiple nodes. --first option returns first match (latest log entry)."
|
648
|
+
method_option :first, :type => :boolean, :default => false
|
649
|
+
def grep(context_params)
|
650
|
+
grep_aux(context_params)
|
651
|
+
end
|
652
|
+
|
653
|
+
|
654
|
+
end
|
655
|
+
end
|
656
|
+
|