dtk-client 0.9.1 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/Gemfile +1 -3
- data/README.md +2 -121
- data/Rakefile +44 -0
- data/bin/dtk +10 -88
- data/dtk-client.gemspec +21 -44
- data/examples/simple/dtk.module.yaml +32 -0
- data/{lib/git-logs/git.log → examples/simple/test/README.md} +0 -0
- data/examples/spark/dtk.module.yaml +120 -0
- data/examples/with_repo_content/deploy/puppet/manifests/hostname.pp +54 -0
- data/examples/with_repo_content/dtk.module.yaml +49 -0
- data/examples/with_repo_content/test/README.txt +0 -0
- data/features/dtk.feature +8 -0
- data/features/step_definitions/dtk_steps.rb +6 -0
- data/features/support/env.rb +15 -0
- data/lib/cli/command/mixin.rb +101 -0
- data/lib/cli/command/module/clone.rb +42 -0
- data/lib/cli/command/module/install.rb +52 -0
- data/lib/cli/command/module/list.rb +31 -0
- data/lib/cli/command/module/list_assemblies.rb +39 -0
- data/lib/cli/command/module/push.rb +34 -0
- data/lib/cli/command/module/uninstall.rb +46 -0
- data/lib/cli/command/module.rb +33 -0
- data/lib/cli/command/options.rb +33 -0
- data/lib/cli/command/service/cancel_task.rb +33 -0
- data/lib/cli/command/service/converge.rb +37 -0
- data/lib/{parser/adapters/thor/common_option_defs.rb → cli/command/service/create_workspace.rb} +13 -17
- data/lib/cli/command/service/destroy.rb +47 -0
- data/lib/cli/command/service/edit.rb +47 -0
- data/lib/cli/command/service/exec.rb +42 -0
- data/lib/cli/command/service/exec_sync.rb +53 -0
- data/lib/cli/command/service/list.rb +30 -0
- data/lib/cli/command/service/list_actions.rb +39 -0
- data/lib/cli/command/service/list_attributes.rb +44 -0
- data/lib/cli/command/service/list_component_links.rb +33 -0
- data/lib/cli/command/service/list_components.rb +39 -0
- data/lib/cli/command/service/list_dependent_modules.rb +33 -0
- data/lib/cli/command/service/list_nodes.rb +33 -0
- data/lib/cli/command/service/list_violations.rb +33 -0
- data/lib/cli/command/service/pull.rb +32 -0
- data/lib/cli/command/service/push.rb +37 -0
- data/lib/{shell/parse_monkey_patch.rb → cli/command/service/set_default_target.rb} +9 -17
- data/lib/cli/command/service/set_required_attributes.rb +32 -0
- data/lib/cli/command/service/ssh.rb +42 -0
- data/lib/cli/command/service/stage.rb +55 -0
- data/lib/cli/command/service/start.rb +33 -0
- data/lib/{shell/context_aux.rb → cli/command/service/stop.rb} +10 -23
- data/lib/cli/command/service/task_status.rb +39 -0
- data/lib/cli/command/service.rb +55 -0
- data/lib/{commands.rb → cli/command/subcommand.rb} +22 -25
- data/lib/{bundler_monkey_patch.rb → cli/command/token/arg.rb} +6 -6
- data/lib/cli/command/token/class_mixin.rb +96 -0
- data/lib/cli/command/token/flag.rb +42 -0
- data/lib/{execute/command/rest_call.rb → cli/command/token/mixin.rb} +23 -14
- data/lib/cli/command/token/switch.rb +35 -0
- data/lib/cli/command/token.rb +76 -0
- data/lib/cli/command.rb +46 -0
- data/lib/cli/context/attributes.rb +50 -0
- data/lib/cli/context/type/module.rb +34 -0
- data/lib/{commands/thor/state_change.rb → cli/context/type/service.rb} +11 -5
- data/lib/cli/context/type/top.rb +32 -0
- data/lib/cli/context/type.rb +42 -0
- data/lib/cli/context.rb +174 -0
- data/lib/cli/directory_parser/file_system.rb +105 -0
- data/lib/{execute/command.rb → cli/directory_parser.rb} +14 -17
- data/lib/{execute.rb → cli/file_obj.rb} +13 -9
- data/lib/cli/processor/plugin/gli.rb +70 -0
- data/lib/cli/processor.rb +60 -0
- data/lib/cli/runner/dtkn_access.rb +75 -0
- data/lib/cli/runner.rb +58 -0
- data/lib/cli/version.rb +8 -0
- data/lib/{config → client/config}/cacert.pem +0 -0
- data/lib/client/config/default.conf +20 -0
- data/lib/client/config.rb +106 -0
- data/lib/client/configurator.rb +182 -0
- data/lib/client/conn.rb +197 -0
- data/lib/client/content_generator.rb +127 -0
- data/lib/client/error/subclasses.rb +105 -0
- data/lib/client/error.rb +98 -0
- data/lib/client/git_repo/adapter/git_gem/error_handler.rb +70 -0
- data/lib/client/git_repo/adapter/git_gem.rb +179 -0
- data/lib/client/git_repo.rb +122 -0
- data/lib/client/logger.rb +136 -0
- data/lib/client/operation/account.rb +66 -0
- data/lib/client/operation/client_module_dir/git_repo.rb +286 -0
- data/lib/client/operation/client_module_dir.rb +138 -0
- data/lib/client/operation/module/clone_module.rb +52 -0
- data/lib/client/operation/module/install/common_module.rb +58 -0
- data/lib/client/operation/module/install/external_module.rb +122 -0
- data/lib/client/operation/module/install.rb +91 -0
- data/lib/client/operation/module/install_from_catalog.rb +76 -0
- data/lib/client/operation/module/list.rb +34 -0
- data/lib/client/operation/module/list_assemblies.rb +35 -0
- data/lib/client/operation/module/push.rb +62 -0
- data/lib/client/operation/module/uninstall.rb +44 -0
- data/lib/client/operation/module.rb +58 -0
- data/lib/{commands/common/thor/reparse.rb → client/operation/module_service_common.rb} +27 -16
- data/lib/client/operation/service/cancel_task.rb +29 -0
- data/lib/client/operation/service/commit_and_push.rb +128 -0
- data/lib/client/operation/service/converge.rb +50 -0
- data/lib/{util/common_util.rb → client/operation/service/create_workspace.rb} +13 -13
- data/lib/client/operation/service/destroy.rb +42 -0
- data/lib/client/operation/service/edit.rb +54 -0
- data/lib/client/operation/service/exec.rb +73 -0
- data/lib/client/operation/service/list.rb +32 -0
- data/lib/client/operation/service/list_actions.rb +34 -0
- data/lib/{commands/thor/dependency.rb → client/operation/service/list_attributes.rb} +16 -12
- data/lib/client/operation/service/list_component_links.rb +29 -0
- data/lib/{commands/common/thor/pull_clone_changes.rb → client/operation/service/list_components.rb} +13 -7
- data/lib/client/operation/service/list_dependent_modules.rb +29 -0
- data/lib/client/operation/service/list_nodes.rb +29 -0
- data/lib/{commands/thor/project.rb → client/operation/service/list_violations.rb} +8 -13
- data/lib/client/operation/service/pull.rb +37 -0
- data/lib/client/operation/service/set_default_target.rb +31 -0
- data/lib/client/operation/service/set_required_attributes.rb +41 -0
- data/lib/client/operation/service/ssh.rb +118 -0
- data/lib/client/operation/service/stage.rb +54 -0
- data/lib/client/operation/service/start.rb +29 -0
- data/lib/client/operation/service/stop.rb +30 -0
- data/lib/{task_status → client/operation/service/task_status}/refresh_mode.rb +15 -25
- data/lib/{task_status → client/operation/service/task_status}/snapshot_mode.rb +4 -5
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/format.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/result/action.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/result/components.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/result/node_level.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/result.rb +4 -4
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/steps/action.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/steps/components.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/steps/node_level.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/steps.rb +4 -4
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task.rb +3 -3
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/no_results.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/render.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/stage/render.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/stage.rb +3 -3
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/task_end.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/task_start.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element.rb +13 -13
- data/lib/{task_status → client/operation/service/task_status}/stream_mode.rb +5 -9
- data/lib/client/operation/service/task_status.rb +77 -0
- data/lib/client/operation/service.rb +54 -0
- data/lib/client/operation.rb +67 -0
- data/lib/client/operation_args.rb +40 -0
- data/lib/{execute/execute_context/result_store.rb → client/render/view/simple.rb} +15 -14
- data/lib/client/render/view/table/processor.rb +248 -0
- data/lib/client/render/view/table.rb +75 -0
- data/lib/client/render.rb +113 -0
- data/lib/client/response/error_handler.rb +97 -0
- data/lib/client/response/render_helper.rb +78 -0
- data/lib/client/response/subclasses.rb +62 -0
- data/lib/client/response.rb +83 -0
- data/lib/client/session.rb +62 -0
- data/lib/client/util/auxiliary.rb +34 -0
- data/lib/client/util/console.rb +81 -0
- data/lib/client/util/disk_cacher.rb +66 -0
- data/lib/client/util/dtk_path.rb +28 -0
- data/lib/{search_hash.rb → client/util/hash_with_optional_keys.rb} +29 -21
- data/lib/client/util/interactive_wizard.rb +84 -0
- data/lib/client/util/module_ref.rb +92 -0
- data/lib/client/util/os_util/print.rb +121 -0
- data/lib/client/util/os_util.rb +122 -0
- data/lib/{commands/thor/utils.rb → client/util/post_body.rb} +1 -1
- data/lib/{execute/error_usage.rb → client/util/query_string_hash.rb} +2 -2
- data/lib/client/util/remote_dependency.rb +67 -0
- data/lib/client/util/ssh_util.rb +89 -0
- data/lib/client/util/validation.rb +28 -0
- data/lib/client/util.rb +18 -0
- data/lib/{util/permission_util.rb → dtk_cli.rb} +10 -9
- data/lib/dtk_client.rb +18 -14
- data/test/default_test.rb +14 -0
- data/test/test_helper.rb +9 -0
- metadata +196 -307
- data/Gemfile_dev +0 -13
- data/bin/dtk-execute +0 -32
- data/bin/dtk-shell +0 -31
- data/lib/auxiliary.rb +0 -61
- data/lib/client.rb +0 -58
- data/lib/command_helper.rb +0 -33
- data/lib/command_helpers/git_repo/merge.rb +0 -153
- data/lib/command_helpers/git_repo.rb +0 -589
- data/lib/command_helpers/jenkins_client/config_xml.rb +0 -288
- data/lib/command_helpers/jenkins_client.rb +0 -106
- data/lib/command_helpers/service_importer.rb +0 -251
- data/lib/command_helpers/service_link.rb +0 -33
- data/lib/command_helpers/test_module_creator.rb +0 -69
- data/lib/command_helpers/test_module_templates/dtk.model.yaml.eruby +0 -10
- data/lib/command_helpers/test_module_templates/spec_helper.rb.eruby +0 -10
- data/lib/command_helpers/test_module_templates/temp_component_spec.rb.eruby +0 -5
- data/lib/commands/common/thor/access_control.rb +0 -133
- data/lib/commands/common/thor/action_result_handler.rb +0 -74
- data/lib/commands/common/thor/assembly_template.rb +0 -92
- data/lib/commands/common/thor/assembly_workspace.rb +0 -1638
- data/lib/commands/common/thor/base_command_helper.rb +0 -59
- data/lib/commands/common/thor/clone.rb +0 -82
- data/lib/commands/common/thor/common.rb +0 -88
- data/lib/commands/common/thor/common_base.rb +0 -49
- data/lib/commands/common/thor/create_target.rb +0 -70
- data/lib/commands/common/thor/edit.rb +0 -255
- data/lib/commands/common/thor/inventory_parser.rb +0 -98
- data/lib/commands/common/thor/list_diffs.rb +0 -128
- data/lib/commands/common/thor/module/import.rb +0 -215
- data/lib/commands/common/thor/module.rb +0 -1011
- data/lib/commands/common/thor/node.rb +0 -53
- data/lib/commands/common/thor/poller.rb +0 -65
- data/lib/commands/common/thor/pull_from_remote.rb +0 -152
- data/lib/commands/common/thor/puppet_forge.rb +0 -72
- data/lib/commands/common/thor/purge_clone.rb +0 -101
- data/lib/commands/common/thor/push_clone_changes.rb +0 -162
- data/lib/commands/common/thor/push_to_remote.rb +0 -94
- data/lib/commands/common/thor/remotes.rb +0 -71
- data/lib/commands/common/thor/set_required_attributes.rb +0 -46
- data/lib/commands/thor/account.rb +0 -239
- data/lib/commands/thor/assembly.rb +0 -361
- data/lib/commands/thor/attribute.rb +0 -79
- data/lib/commands/thor/component.rb +0 -70
- data/lib/commands/thor/component_module.rb +0 -501
- data/lib/commands/thor/component_template.rb +0 -174
- data/lib/commands/thor/developer.rb +0 -144
- data/lib/commands/thor/dtk.rb +0 -152
- data/lib/commands/thor/library.rb +0 -125
- data/lib/commands/thor/node.rb +0 -504
- data/lib/commands/thor/node_group.rb +0 -203
- data/lib/commands/thor/node_template.rb +0 -94
- data/lib/commands/thor/provider.rb +0 -233
- data/lib/commands/thor/remotes.rb +0 -49
- data/lib/commands/thor/service.rb +0 -932
- data/lib/commands/thor/service_module.rb +0 -900
- data/lib/commands/thor/target.rb +0 -250
- data/lib/commands/thor/task.rb +0 -116
- data/lib/commands/thor/test_module.rb +0 -310
- data/lib/commands/thor/workspace.rb +0 -698
- data/lib/config/client.conf.header +0 -20
- data/lib/config/configuration.rb +0 -99
- data/lib/config/default.conf +0 -16
- data/lib/config/disk_cacher.rb +0 -80
- data/lib/configurator.rb +0 -176
- data/lib/context_router.rb +0 -44
- data/lib/core.rb +0 -489
- data/lib/domain/git_adapter.rb +0 -412
- data/lib/domain/git_error_handler.rb +0 -64
- data/lib/domain/response/error_handler.rb +0 -86
- data/lib/domain/response.rb +0 -285
- data/lib/dtk-client/version.rb +0 -20
- data/lib/dtk_constants.rb +0 -40
- data/lib/dtk_error.rb +0 -114
- data/lib/dtk_logger.rb +0 -113
- data/lib/error.rb +0 -85
- data/lib/execute/cli_pure/cli_rerouter.rb +0 -102
- data/lib/execute/command/api_call/map.rb +0 -60
- data/lib/execute/command/api_call/service.rb +0 -91
- data/lib/execute/command/api_call/translation_term.rb +0 -119
- data/lib/execute/command/api_call.rb +0 -60
- data/lib/execute/command_processor/rest_call.rb +0 -59
- data/lib/execute/command_processor.rb +0 -30
- data/lib/execute/execute_context.rb +0 -86
- data/lib/execute/script/add_tenant.rb +0 -121
- data/lib/execute/script.rb +0 -64
- data/lib/parser/adapters/option_parser.rb +0 -70
- data/lib/parser/adapters/thor.rb +0 -555
- data/lib/require_first.rb +0 -104
- data/lib/shell/context.rb +0 -1064
- data/lib/shell/domain/active_context.rb +0 -186
- data/lib/shell/domain/context_entity.rb +0 -89
- data/lib/shell/domain/context_params.rb +0 -223
- data/lib/shell/domain/override_tasks.rb +0 -88
- data/lib/shell/domain/shadow_entity.rb +0 -76
- data/lib/shell/header_shell.rb +0 -44
- data/lib/shell/help_monkey_patch.rb +0 -283
- data/lib/shell/interactive_wizard.rb +0 -256
- data/lib/shell/message_queue.rb +0 -63
- data/lib/shell/status_monitor.rb +0 -124
- data/lib/shell.rb +0 -261
- data/lib/task_status.rb +0 -83
- data/lib/util/console.rb +0 -235
- data/lib/util/dtk_puppet.rb +0 -65
- data/lib/util/module_util.rb +0 -66
- data/lib/util/os_util.rb +0 -385
- data/lib/util/remote_dependency_util.rb +0 -84
- data/lib/util/ssh_util.rb +0 -94
- data/lib/view_processor/augmented_simple_list.rb +0 -44
- data/lib/view_processor/hash_pretty_print.rb +0 -123
- data/lib/view_processor/simple_list.rb +0 -156
- data/lib/view_processor/table_print.rb +0 -309
- data/lib/view_processor.rb +0 -129
- data/puppet/manifests/init.pp +0 -72
- data/puppet/manifests/params.pp +0 -16
- data/puppet/r8meta.puppet.yml +0 -35
- data/puppet/templates/bash_profile.erb +0 -2
- data/puppet/templates/client.conf.erb +0 -1
- data/puppet/templates/dtkclient.erb +0 -2
- data/spec/component_module_spec.rb +0 -34
- data/spec/dependency_spec.rb +0 -6
- data/spec/dtk_shell_spec.rb +0 -13
- data/spec/dtk_spec.rb +0 -33
- data/spec/lib/spec_helper.rb +0 -10
- data/spec/lib/spec_thor.rb +0 -108
- data/spec/node_template_spec.rb +0 -24
- data/spec/project_spec.rb +0 -6
- data/spec/repo_spec.rb +0 -7
- data/spec/response_spec.rb +0 -52
- data/spec/service_module_spec.rb +0 -38
- data/spec/service_spec.rb +0 -50
- data/spec/state_change_spec.rb +0 -7
- data/spec/table_print_spec.rb +0 -48
- data/spec/target_spec.rb +0 -57
- data/spec/task_spec.rb +0 -28
- data/views/assembly/augmented_simple_list.rb +0 -12
- data/views/assembly_template/augmented_simple_list.rb +0 -12
- data/views/list_task/augmented_simple_list.rb +0 -12
@@ -1,144 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (C) 2010-2016 dtk contributors
|
3
|
-
#
|
4
|
-
# This file is part of the dtk project.
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
require 'base64'
|
19
|
-
dtk_require_common_commands('thor/action_result_handler')
|
20
|
-
|
21
|
-
module DTK::Client
|
22
|
-
class Developer < CommandBaseThor
|
23
|
-
|
24
|
-
no_tasks do
|
25
|
-
include ActionResultHandler
|
26
|
-
end
|
27
|
-
|
28
|
-
MATCH_FILE_NAME = /[a-zA-Z0-9_]+\.[a-zA-Z]+$/
|
29
|
-
GIT_LOG_LOCATION = File.expand_path('../../../lib/git-logs/git.log', File.dirname(__FILE__))
|
30
|
-
PROJECT_ROOT = File.expand_path('../../../', File.dirname(__FILE__))
|
31
|
-
|
32
|
-
desc "upload-agent PATH-TO-AGENT[.rb,.dll] NODE-ID-PATTERN", "Uploads agent and ddl file to requested nodes, pattern is regexp for filtering node ids."
|
33
|
-
def upload_agent(context_params)
|
34
|
-
agent, node_pattern = context_params.retrieve_arguments([:option_1!, :option_2!], method_argument_names)
|
35
|
-
|
36
|
-
nodes = post rest_url("node/list"), { :is_list_all => true }
|
37
|
-
|
38
|
-
ids = []
|
39
|
-
# get all nodes which id starts with node_pattern
|
40
|
-
nodes["data"].collect{|a| ids<<a["id"].to_i if a["id"].to_s.match(Regexp.new(node_pattern.to_s)) }
|
41
|
-
raise DTK::Client::DtkValidationError, "Unable to find nodes to match this pattern: '#{node_pattern}'." if ids.empty?
|
42
|
-
|
43
|
-
# if it doesn't contain extension upload both *.rb and *.ddl
|
44
|
-
files = (agent.match(MATCH_FILE_NAME) ? [agent] : ["#{agent}.rb","#{agent}.ddl"])
|
45
|
-
|
46
|
-
# read require files and encode them
|
47
|
-
request_body = {}
|
48
|
-
files.each do |file_name|
|
49
|
-
raise DTK::Client::DtkError, "Unable to load file: #{file_name}" unless File.exists?(file_name)
|
50
|
-
# reason for this to file dues to previus match
|
51
|
-
agent_name = file_name.match(MATCH_FILE_NAME)[0]
|
52
|
-
File.open(file_name) { |file| request_body.store(agent_name,Base64.encode64(file.read)) }
|
53
|
-
end
|
54
|
-
|
55
|
-
# send as binary post request
|
56
|
-
response = post_file rest_url("developer/inject_agent"), { :agent_files => request_body, :node_pattern => node_pattern, :node_list => ids }
|
57
|
-
puts "Agent uploaded successfully!";return if response.ok?
|
58
|
-
return response
|
59
|
-
end
|
60
|
-
|
61
|
-
# run-agent haris1 dev_manager inject_agent "{ 'action_agent_branch': 'master', 'action_agent_url': 'git@github.com:rich-reactor8/dtk-action-agent.git' }"
|
62
|
-
desc "run-agent SERVICE-NAME AGENT-NAME AGENT-METHOD PARAMS", "Updates DTK Action Agent to provided branch, example: dev_manager inject_agent \"{ 'action_agent_branch': 'master', 'action_agent_url': 'url' }\""
|
63
|
-
def run_agent(context_params)
|
64
|
-
service_name, agent_name, agent_method, action_params = context_params.retrieve_arguments([:option_1!, :option_2!, :option_3!, :option_4!], method_argument_names)
|
65
|
-
|
66
|
-
action_params ||= "{}"
|
67
|
-
action_params.gsub!("'",'"')
|
68
|
-
|
69
|
-
response = post_file rest_url("developer/run_agent"), { :service_name => service_name, :agent_name => agent_name, :agent_method => agent_method, :agent_params => action_params }
|
70
|
-
return response unless response.ok?
|
71
|
-
|
72
|
-
action_results_id = response.data(:action_results_id)
|
73
|
-
print_simple_results(action_results_id)
|
74
|
-
|
75
|
-
nil
|
76
|
-
end
|
77
|
-
|
78
|
-
desc "remove-from-system SERVICE-NAME", "Removes objects associated with service, but does not destroy target isnatnces"
|
79
|
-
method_option :force, :aliases => '-y', :type => :boolean, :default => false
|
80
|
-
def remove_from_system(context_params)
|
81
|
-
assembly_id = context_params.retrieve_arguments([:option_1!],method_argument_names)
|
82
|
-
unless options.force?
|
83
|
-
# Ask user if really want to delete assembly, if not then return to dtk-shell without deleting
|
84
|
-
what = "service"
|
85
|
-
return unless Console.confirmation_prompt("Are you sure you want to remove #{what} '#{assembly_id}' and its nodes from the system"+'?')
|
86
|
-
end
|
87
|
-
|
88
|
-
response = post rest_url("assembly/remove_from_system"), {:assembly_id => assembly_id}
|
89
|
-
# when changing context send request for getting latest assemblies instead of getting from cache
|
90
|
-
@@invalidate_map << :service
|
91
|
-
return response
|
92
|
-
end
|
93
|
-
|
94
|
-
desc "apply-param-set SERVICE-NAME/ID PARAM-SET-PATH", "Uses the parametrs set in the file PARAM-SET-PATH and appleis to the service"
|
95
|
-
def apply_param_set(context_params)
|
96
|
-
assembly_id,path = context_params.retrieve_arguments([:option_1!,:option_2!],method_argument_names)
|
97
|
-
av_pairs = JSON.parse(File.open(path).read)
|
98
|
-
|
99
|
-
av_pairs.each do |a,v|
|
100
|
-
post_body = {
|
101
|
-
:assembly_id => assembly_id,
|
102
|
-
:pattern => a,
|
103
|
-
:value => v
|
104
|
-
}
|
105
|
-
response = post rest_url("assembly/set_attributes"), post_body
|
106
|
-
if response.ok?
|
107
|
-
pp response.data
|
108
|
-
else
|
109
|
-
return response
|
110
|
-
end
|
111
|
-
end
|
112
|
-
Response::Ok.new()
|
113
|
-
end
|
114
|
-
|
115
|
-
desc "commits", "View last commits that went into the gem"
|
116
|
-
def commits(context_params)
|
117
|
-
unless File.file?(GIT_LOG_LOCATION)
|
118
|
-
raise DTK::Client::DtkError, "Git log file not found, contact DTK support team."
|
119
|
-
end
|
120
|
-
|
121
|
-
File.readlines(GIT_LOG_LOCATION).reverse.each do |line|
|
122
|
-
puts line
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
desc "content FILE-NAME", "Get content of file name in DTK Client gem"
|
127
|
-
def content(context_params)
|
128
|
-
file_name = context_params.retrieve_arguments([:option_1!],method_argument_names)
|
129
|
-
found_files = Dir["#{PROJECT_ROOT}/**/*.*"].select { |fname| fname.end_with?(file_name) }
|
130
|
-
|
131
|
-
if found_files.empty?
|
132
|
-
raise DTK::Client::DtkValidationError, "No files found with name '#{file_name}'."
|
133
|
-
else
|
134
|
-
found_files.each do |fname|
|
135
|
-
header = "*********************** #{fname} ***********************"
|
136
|
-
DTK::Client::OsUtil.print(header, :yellow)
|
137
|
-
puts File.open(fname).readlines
|
138
|
-
DTK::Client::OsUtil.print("*"*header.size, :yellow)
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
data/lib/commands/thor/dtk.rb
DELETED
@@ -1,152 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (C) 2010-2016 dtk contributors
|
3
|
-
#
|
4
|
-
# This file is part of the dtk project.
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
module DTK::Client
|
20
|
-
|
21
|
-
# Following are descriptions of available commands
|
22
|
-
class Dtk < CommandBaseThor
|
23
|
-
|
24
|
-
# entities that are not available on root but later in n-context
|
25
|
-
def self.additional_entities()
|
26
|
-
['component','attribute','utils','node','task','component-template','assembly','remotes']
|
27
|
-
end
|
28
|
-
|
29
|
-
if ::DTK::Configuration.get(:development_mode)
|
30
|
-
desc "workspace","Sandbox for development and testing"
|
31
|
-
def workspace
|
32
|
-
# API descriptor, SYM_LINK!
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
if ::DTK::Configuration.get(:development_mode)
|
37
|
-
desc "target","Targets"
|
38
|
-
def target
|
39
|
-
# API descriptor, SYM_LINK!
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
|
44
|
-
# NOTE
|
45
|
-
# Following methods are just api descriptors, invocation happens at "bin/dtk" entry point
|
46
|
-
desc "account","Account management for accessing DTK server"
|
47
|
-
def account
|
48
|
-
# API descriptor
|
49
|
-
end
|
50
|
-
|
51
|
-
desc "service","Assembly instances that have been deployed via DTK."
|
52
|
-
def service
|
53
|
-
# API descriptor
|
54
|
-
end
|
55
|
-
|
56
|
-
# desc "assembly","Commands to stage or launch new assemblies and query assembly templates."
|
57
|
-
# def assembly
|
58
|
-
# # API descriptor
|
59
|
-
# end
|
60
|
-
|
61
|
-
#TODO: not exposed
|
62
|
-
#desc "dependency","DESCRIPTION TO BE ADDED."
|
63
|
-
#def dependency
|
64
|
-
# # API descriptor
|
65
|
-
#end
|
66
|
-
|
67
|
-
# desc "library", "Commands to list and query libraries."
|
68
|
-
# def library
|
69
|
-
# # API descriptor
|
70
|
-
# end
|
71
|
-
|
72
|
-
desc "component-module", "DTK definitions for modeling/defining individual configuration components."
|
73
|
-
def component_module
|
74
|
-
# API descriptor
|
75
|
-
end
|
76
|
-
|
77
|
-
if ::DTK::Configuration.get(:development_mode)
|
78
|
-
desc "test-module", "DTK definitions for modeling/defining individual test components."
|
79
|
-
def test_module
|
80
|
-
# API descriptor
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
# desc "node", "Commands to list, query, and delete/destroy node instances."
|
85
|
-
# def node
|
86
|
-
# # API descriptor
|
87
|
-
# end
|
88
|
-
|
89
|
-
# desc "node-group", "Add/Destroy/List available groups of nodes."
|
90
|
-
# def node_group
|
91
|
-
# # API descriptor
|
92
|
-
# end
|
93
|
-
|
94
|
-
if ::DTK::Configuration.get(:development_mode)
|
95
|
-
desc "node-template", "Node Templates that map to machine images and containers."
|
96
|
-
def node_template
|
97
|
-
# API descriptor
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
# desc "component-template","Commands to list and query component templates."
|
102
|
-
# def component_template
|
103
|
-
# # API descriptor
|
104
|
-
# end
|
105
|
-
|
106
|
-
#TODO: remove
|
107
|
-
#desc "repo", "Part of dtk client which enables us to sync, destroy, view available repos."
|
108
|
-
#def repo
|
109
|
-
# # API descriptor
|
110
|
-
#end
|
111
|
-
|
112
|
-
#TODO: not supported yet
|
113
|
-
#desc "project", "View available projects."
|
114
|
-
#def project
|
115
|
-
# # API descriptor
|
116
|
-
#end
|
117
|
-
|
118
|
-
desc "service-module", "DTK definitions for modeling/defining distributed applications and services."
|
119
|
-
def service_module
|
120
|
-
# API descriptor
|
121
|
-
end
|
122
|
-
|
123
|
-
# TODO: not supported yet
|
124
|
-
# desc "state-change", "Commands to query what has been changed."
|
125
|
-
# def state_change
|
126
|
-
# # API descriptor
|
127
|
-
# end
|
128
|
-
|
129
|
-
# desc "task", "Commands to list and view current and past tasks."
|
130
|
-
# def task
|
131
|
-
# # API descriptor
|
132
|
-
# end
|
133
|
-
|
134
|
-
if ::DTK::Configuration.get(:development_mode)
|
135
|
-
desc "developer", "DEV tools only available to developers."
|
136
|
-
def developer
|
137
|
-
# API descriptor
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
if ::DTK::Configuration.get(:development_mode)
|
142
|
-
desc "provider", "Manage infrastructure providers and deployment targets (ie: EC2 and us-east)"
|
143
|
-
def provider
|
144
|
-
# API descriptor
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
# we do not need help here
|
149
|
-
remove_task(:help,{:undefine => false})
|
150
|
-
|
151
|
-
end
|
152
|
-
end
|
@@ -1,125 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (C) 2010-2016 dtk contributors
|
3
|
-
#
|
4
|
-
# This file is part of the dtk project.
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
# TODO: Marked for removal [Haris]
|
19
|
-
module DTK::Client
|
20
|
-
|
21
|
-
class Library < CommandBaseThor
|
22
|
-
|
23
|
-
def self.pretty_print_cols()
|
24
|
-
PPColumns.get(:library)
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.whoami()
|
28
|
-
return :library, "library/list", nil
|
29
|
-
end
|
30
|
-
|
31
|
-
desc "[LIBRARY ID/NAME] info","Info for given library based on specified identifier."
|
32
|
-
def info(context_params)
|
33
|
-
library_id = context_params.retrieve_arguments([:library_id],method_argument_names)
|
34
|
-
not_implemented
|
35
|
-
end
|
36
|
-
|
37
|
-
desc "LIBRARY ID/NAME list-nodes","Show nodes associated with library"
|
38
|
-
def list_nodes(context_params)
|
39
|
-
context_params.method_arguments = ["nodes"]
|
40
|
-
list(context_params)
|
41
|
-
end
|
42
|
-
|
43
|
-
desc "LIBRARY ID/NAME list-components","Show components associated with library"
|
44
|
-
def list_components(context_params)
|
45
|
-
context_params.method_arguments = ["components"]
|
46
|
-
list(context_params)
|
47
|
-
end
|
48
|
-
|
49
|
-
desc "LIBRARY ID/NAME list-assemblies","Show assemblies associated with library"
|
50
|
-
def list_assemblies(context_params)
|
51
|
-
context_params.method_arguments = ["assemblies"]
|
52
|
-
list(context_params)
|
53
|
-
end
|
54
|
-
|
55
|
-
desc "list","Show nodes, components, or assemblies associated with library"
|
56
|
-
def list(context_params)
|
57
|
-
library_id, about = context_params.retrieve_arguments([:library_id, :option_1],method_argument_names||="")
|
58
|
-
if library_id.nil?
|
59
|
-
search_hash = SearchHash.new()
|
60
|
-
search_hash.cols = pretty_print_cols()
|
61
|
-
response = post rest_url("library/list"), search_hash.post_body_hash
|
62
|
-
response.render_table(:library)
|
63
|
-
else
|
64
|
-
# sets data type to be used when printing table
|
65
|
-
case about
|
66
|
-
when "assemblies"
|
67
|
-
data_type = :assembly_template
|
68
|
-
when "nodes"
|
69
|
-
data_type = :node_template
|
70
|
-
when "components"
|
71
|
-
data_type = :component
|
72
|
-
else
|
73
|
-
raise_validation_error_method_usage('list')
|
74
|
-
end
|
75
|
-
|
76
|
-
post_body = {
|
77
|
-
:library_id => library_id,
|
78
|
-
:about => about
|
79
|
-
}
|
80
|
-
response = post rest_url("library/info_about"), post_body
|
81
|
-
response.render_table(data_type)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
desc "[LIBRARY ID/NAME] import-service-module REMOTE-SERVICE-MODULE[,...]", "Import remote service module into library"
|
86
|
-
def import_service_module(context_params)
|
87
|
-
library_id, service_modules = context_params.retrieve_arguments([:library_id, :option_1!],method_argument_names)
|
88
|
-
post_body = {
|
89
|
-
:remote_module_name => service_modules,
|
90
|
-
:rsa_pub_key => SSHUtil.rsa_pub_key_content()
|
91
|
-
}
|
92
|
-
post_body.merge!(:library_id => library_id) if library_id
|
93
|
-
|
94
|
-
post rest_url("service_module/import"), post_body
|
95
|
-
end
|
96
|
-
|
97
|
-
desc "[LIBRARY ID/NAME] create-service-component SERVICE-MODULE-NAME", "Create an empty service module in library"
|
98
|
-
def create(context_params)
|
99
|
-
library_id, module_name = context_params.retrieve_arguments([:library_id, :option_1!],method_argument_names)
|
100
|
-
post_body = {
|
101
|
-
:module_name => module_name
|
102
|
-
}
|
103
|
-
post_body.merge!(:library_id => library_id) if library_id
|
104
|
-
response = post rest_url("service_module/create"), post_body
|
105
|
-
# when changing context send request for getting latest libraries instead of getting from cache
|
106
|
-
@@invalidate_map << :library
|
107
|
-
|
108
|
-
return response
|
109
|
-
end
|
110
|
-
|
111
|
-
desc "[LIBRARY ID/NAME] delete-service-component COMPONENT-MODULE-NAME","Delete component module and all items contained in it"
|
112
|
-
def delete(context_params)
|
113
|
-
library_id, component_module_id = context_params.retrieve_arguments([:library_id, :option_1!],method_argument_names)
|
114
|
-
post_body = {
|
115
|
-
:component_module_id => component_module_id
|
116
|
-
}
|
117
|
-
post_body.merge!(:library_id => library_id) if library_id
|
118
|
-
response = post rest_url("component_module/delete"), post_body
|
119
|
-
# when changing context send request for getting latest libraries instead of getting from cache
|
120
|
-
@@invalidate_map << :library
|
121
|
-
|
122
|
-
return response
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|