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,20 +0,0 @@
|
|
1
|
-
development_mode=false
|
2
|
-
meta_table_ttl=7200000 # time to live (ms)
|
3
|
-
meta_constants_ttl=7200000 # time to live (ms)
|
4
|
-
meta_pretty_print_ttl=7200000 # time to live (ms)
|
5
|
-
task_check_frequency=60 # check frequency for task status threads (seconds)
|
6
|
-
tail_log_frequency=2 # assembly - frequency between requests (seconds)
|
7
|
-
debug_task_frequency=5 # assembly - frequency between requests (seconds)
|
8
|
-
auto_commit_changes=false # autocommit for modules
|
9
|
-
verbose_rest_calls=false # logging of REST calls
|
10
|
-
|
11
|
-
# if relative path is used we will use HOME + relative path, apsoluth path will override this
|
12
|
-
module_location=component_modules
|
13
|
-
service_location=service_modules
|
14
|
-
test_module_location=test_modules
|
15
|
-
backups_location=backups
|
16
|
-
|
17
|
-
# server connection details
|
18
|
-
server_port=80
|
19
|
-
secure_connection_server_port=443
|
20
|
-
secure_connection=true
|
data/lib/config/configuration.rb
DELETED
@@ -1,99 +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
|
-
# Singleton patern to hold configuration for dtk client.
|
20
|
-
#
|
21
|
-
# DEFAULT: Configuration
|
22
|
-
# DEVELOPMENT: Can add lib/config/local.conf, this is git ignored
|
23
|
-
#
|
24
|
-
# NOTE: Singleton here is not necessery since it will not persist in memory due
|
25
|
-
# to nature of DTK Client, but it is right approach for possible re-use
|
26
|
-
#
|
27
|
-
# Pririoty of load
|
28
|
-
# 1) LOCAL
|
29
|
-
# 2) EXTERNAL
|
30
|
-
# 3) DEFAULT
|
31
|
-
#
|
32
|
-
# NOTE: Default will be used if there some parameters missing in other configuration
|
33
|
-
#
|
34
|
-
require 'singleton'
|
35
|
-
|
36
|
-
dtk_require_from_base('util/os_util')
|
37
|
-
|
38
|
-
module DTK
|
39
|
-
class Configuration
|
40
|
-
include Singleton
|
41
|
-
|
42
|
-
EXTERNAL_APP_CONF = "client.conf"
|
43
|
-
DEVELOPMENT_CONF = 'local.conf'
|
44
|
-
DEFAULT_CONF = 'default.conf'
|
45
|
-
|
46
|
-
def self.get(name, default=nil)
|
47
|
-
Configuration.instance.get(name, default)
|
48
|
-
end
|
49
|
-
|
50
|
-
def self.[](k)
|
51
|
-
Configuration.instance.get(k)
|
52
|
-
end
|
53
|
-
|
54
|
-
def initialize
|
55
|
-
# default configuration
|
56
|
-
@cache = load_configuration_to_hash(File.expand_path("../#{DEFAULT_CONF}",__FILE__))
|
57
|
-
|
58
|
-
# we will not use local.conf from gemfile because client.conf is required so this is deprecated
|
59
|
-
if File.exist?(File.expand_path("../#{DEVELOPMENT_CONF}",__FILE__))
|
60
|
-
local_configuration = load_configuration_to_hash(File.expand_path("../#{DEVELOPMENT_CONF}",__FILE__))
|
61
|
-
# we override only values from local configuration
|
62
|
-
# that way developer does not have updates its local configuration all the time
|
63
|
-
@cache.merge!(local_configuration)
|
64
|
-
# if we have loaded local configuration we will not check external
|
65
|
-
return
|
66
|
-
end
|
67
|
-
|
68
|
-
# We load this if there is no local configuration
|
69
|
-
external_file_location = File.join(::DTK::Client::OsUtil.dtk_local_folder(), "#{EXTERNAL_APP_CONF}")
|
70
|
-
|
71
|
-
if File.exist?(external_file_location)
|
72
|
-
external_configuration = load_configuration_to_hash(external_file_location)
|
73
|
-
@cache.merge!(external_configuration)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def get(name, default=nil)
|
78
|
-
return @cache[name.to_s] || default
|
79
|
-
end
|
80
|
-
|
81
|
-
private
|
82
|
-
|
83
|
-
def load_configuration_to_hash(path_to_file)
|
84
|
-
configuration = Hash[*File.read(path_to_file).gsub(/#.+/,'').strip().gsub(/( |\t)+$/,'').split(/[=\n\r\r\n]+/)]
|
85
|
-
|
86
|
-
# check for types
|
87
|
-
return configuration.each do |k,v|
|
88
|
-
case v
|
89
|
-
when /^(true|false)$/
|
90
|
-
configuration[k] = v.eql?('true') ? true : false
|
91
|
-
when /^[0-9]+$/
|
92
|
-
configuration[k] = v.to_i
|
93
|
-
when /^[0-9\.]+$/
|
94
|
-
configuration[k] = v.to_f
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
data/lib/config/default.conf
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
development_mode=false
|
2
|
-
debug_grit=false
|
3
|
-
meta_table_ttl=7200000 # time to live (ms)
|
4
|
-
meta_constants_ttl=7200000 # time to live (ms)
|
5
|
-
meta_pretty_print_ttl=7200000 # time to live (ms)
|
6
|
-
task_check_frequency=60 # check frequency for task status threads (seconds)
|
7
|
-
tail_log_frequency=2 # assembly - frequency between requests (seconds)
|
8
|
-
debug_task_frequency=5 # assembly - frequency between requests (seconds)
|
9
|
-
auto_commit_changes=false # autocommit for modules
|
10
|
-
verbose_rest_calls=false # logging of REST calls
|
11
|
-
|
12
|
-
# if relative path is used we will use HOME + relative path, apsoluth path will override this
|
13
|
-
module_location=component_modules
|
14
|
-
service_location=service_modules
|
15
|
-
test_module_location=test_modules
|
16
|
-
backups_location=backups
|
data/lib/config/disk_cacher.rb
DELETED
@@ -1,80 +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 'net/http'
|
19
|
-
#require 'md5' => Ruby 1.8.7 specific
|
20
|
-
require File.expand_path('../util/os_util', File.dirname(__FILE__))
|
21
|
-
dtk_require("../commands")
|
22
|
-
|
23
|
-
|
24
|
-
#
|
25
|
-
# Class dedicated for caching data on local system as well as for cookie management
|
26
|
-
#
|
27
|
-
class DiskCacher
|
28
|
-
include DTK::Client::CommandBase
|
29
|
-
extend DTK::Client::CommandBase
|
30
|
-
|
31
|
-
# file name to hold cookies
|
32
|
-
COOKIE_HOLDER_NAME = 'tempdtkstore'
|
33
|
-
|
34
|
-
def initialize(cache_dir=DTK::Client::OsUtil.get_temp_location())
|
35
|
-
@cache_dir = cache_dir
|
36
|
-
@current_user = ::DTK::Client::Configurator.client_username
|
37
|
-
end
|
38
|
-
|
39
|
-
def fetch(file_name, max_age=0, use_mock_up=true)
|
40
|
-
file = Digest::MD5.hexdigest(file_name)
|
41
|
-
# current user is important so that there are no clashes in writting to temp file
|
42
|
-
# between multiple users on same machine
|
43
|
-
file_path = File.join(@cache_dir, "#{@current_user}::#{file}")
|
44
|
-
|
45
|
-
# we check if the file -- a MD5 hexdigest of the URL -- exists
|
46
|
-
# in the dir. If it does and the data is fresh, we just read
|
47
|
-
# data from the file and return
|
48
|
-
if File.exists? file_path
|
49
|
-
return File.new(file_path).read if Time.now-File.mtime(file_path)<max_age
|
50
|
-
end
|
51
|
-
|
52
|
-
# if the file does not exist (or if the data is not fresh), we
|
53
|
-
# make an get request and save it to a file
|
54
|
-
response_string = ""
|
55
|
-
@response = get rest_url("metadata/get_metadata/#{file_name}")
|
56
|
-
|
57
|
-
if (@response["status"] == "ok")
|
58
|
-
file = File.open(file_path, "w") do |data|
|
59
|
-
data << response_string = @response["data"]
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
return response_string
|
64
|
-
end
|
65
|
-
|
66
|
-
def save_cookie(cookie_content)
|
67
|
-
file_path = File.join(@cache_dir, COOKIE_HOLDER_NAME)
|
68
|
-
File.open(file_path, "w") do |file|
|
69
|
-
#data << cookie_content
|
70
|
-
Marshal.dump(cookie_content, file)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def load_cookie()
|
75
|
-
file_path = File.join(@cache_dir, COOKIE_HOLDER_NAME)
|
76
|
-
cookie_content = File.exists?(file_path) ? File.open(file_path) {|f| Marshal.load(f)} : nil
|
77
|
-
cookie_content
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|
data/lib/configurator.rb
DELETED
@@ -1,176 +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 'rubygems'
|
19
|
-
require 'fileutils'
|
20
|
-
dtk_require_from_base('util/os_util')
|
21
|
-
|
22
|
-
module DTK
|
23
|
-
module Client
|
24
|
-
class Configurator
|
25
|
-
|
26
|
-
CONFIG_FILE = File.join(OsUtil.dtk_local_folder, "client.conf")
|
27
|
-
CRED_FILE = File.join(OsUtil.dtk_local_folder, ".connection")
|
28
|
-
DIRECT_ACCESS = File.join(OsUtil.dtk_local_folder, ".add_direct_access")
|
29
|
-
NODE_SSH_CREDENTIALS = File.join(OsUtil.dtk_local_folder, "ssh_credentials.yaml")
|
30
|
-
|
31
|
-
FileUtils.mkdir(OsUtil.dtk_local_folder) unless File.directory?(OsUtil.dtk_local_folder)
|
32
|
-
|
33
|
-
def self.check_config_exists
|
34
|
-
exists = true
|
35
|
-
if !File.exists?(CONFIG_FILE)
|
36
|
-
puts "", "Please enter the DTK server address (example: instance.dtk.io)"
|
37
|
-
header = File.read(File.expand_path('../lib/config/client.conf.header', File.dirname(__FILE__)))
|
38
|
-
generate_conf_file(CONFIG_FILE, [['server_host', 'Server address']], header)
|
39
|
-
exists = false
|
40
|
-
end
|
41
|
-
if !File.exists?(CRED_FILE)
|
42
|
-
puts "", "Please enter your DTK login details"
|
43
|
-
generate_conf_file(CRED_FILE, [['username', 'Username'], ['password', 'Password']], '')
|
44
|
-
exists = false
|
45
|
-
end
|
46
|
-
|
47
|
-
exists
|
48
|
-
end
|
49
|
-
|
50
|
-
def self.check_git
|
51
|
-
if OsUtil.which('git') == nil
|
52
|
-
OsUtil.put_warning "[WARNING]", "Can't find the 'git' command in you path. Please make sure git is installed in order to use all features of DTK Client.", :yellow
|
53
|
-
else
|
54
|
-
OsUtil.put_warning "[WARNING]", 'Git username not set. This can cause issues while using DTK Client. To set it, run `git config --global user.name "User Name"`', :yellow if `git config --get user.name` == ""
|
55
|
-
OsUtil.put_warning "[WARNING]", 'Git email not set. This can cause issues while using DTK Client. To set it, run `git config --global user.email "me@here.com"`', :yellow if `git config --get user.email` == ""
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
# return true/false, .add_direct_access file location and ssk key file location
|
60
|
-
def self.check_direct_access
|
61
|
-
username_exists = check_for_username_entry(client_username())
|
62
|
-
ssh_key_path = SSHUtil.default_rsa_pub_key_path()
|
63
|
-
|
64
|
-
{:username_exists => username_exists, :file_path => DIRECT_ACCESS, :ssh_key_path => ssh_key_path}
|
65
|
-
end
|
66
|
-
|
67
|
-
def self.generate_conf_file(file_path, properties, header)
|
68
|
-
require 'highline/import'
|
69
|
-
property_template = []
|
70
|
-
|
71
|
-
properties.each do |p,d|
|
72
|
-
begin
|
73
|
-
trap("INT") {
|
74
|
-
puts "", "Exiting..."
|
75
|
-
abort
|
76
|
-
}
|
77
|
-
end
|
78
|
-
value = ask("#{d}: ") { |q| q.echo = false if p == 'password'}
|
79
|
-
property_template << [p,value]
|
80
|
-
end
|
81
|
-
|
82
|
-
File.open(file_path, 'w') do |f|
|
83
|
-
f.puts(header)
|
84
|
-
property_template.each do |prop|
|
85
|
-
f.puts("#{prop[0]}=#{prop[1]}")
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def self.regenerate_conf_file(file_path, properties, header)
|
91
|
-
File.open(file_path, 'w') do |f|
|
92
|
-
f.puts(header)
|
93
|
-
properties.each do |prop|
|
94
|
-
f.puts("#{prop[0]}=#{prop[1]}")
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
def self.create_missing_clone_dirs
|
100
|
-
FileUtils.mkdir(OsUtil.component_clone_location) unless File.directory?(OsUtil.component_clone_location)
|
101
|
-
FileUtils.mkdir(OsUtil.service_clone_location) unless File.directory?(OsUtil.service_clone_location)
|
102
|
-
FileUtils.mkdir(OsUtil.test_clone_location) unless File.directory?(OsUtil.test_clone_location)
|
103
|
-
FileUtils.mkdir(OsUtil.backups_location) unless File.directory?(OsUtil.backups_location)
|
104
|
-
end
|
105
|
-
|
106
|
-
|
107
|
-
def self.parse_key_value_file(file)
|
108
|
-
# adapted from mcollective config
|
109
|
-
ret = Hash.new
|
110
|
-
raise DTK::Client::DtkError,"Config file (#{file}) does not exists" unless File.exists?(file)
|
111
|
-
File.open(file).each do |line|
|
112
|
-
# strip blank spaces, tabs etc off the end of all lines
|
113
|
-
line.gsub!(/\s*$/, "")
|
114
|
-
unless line =~ /^#|^$/
|
115
|
-
if (line =~ /(.+?)\s*=\s*(.+)/)
|
116
|
-
key = $1
|
117
|
-
val = $2
|
118
|
-
ret[key.to_sym] = val
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
ret
|
123
|
-
end
|
124
|
-
def self.add_current_user_to_direct_access()
|
125
|
-
username = client_username()
|
126
|
-
|
127
|
-
File.open(DIRECT_ACCESS, 'a') do |file|
|
128
|
-
file.puts(username)
|
129
|
-
end
|
130
|
-
|
131
|
-
true
|
132
|
-
end
|
133
|
-
|
134
|
-
def self.client_username()
|
135
|
-
parse_key_value_file(CRED_FILE)[:username]
|
136
|
-
end
|
137
|
-
|
138
|
-
#
|
139
|
-
# Method will check if there is username entry in DIRECT_ACCESS file
|
140
|
-
#
|
141
|
-
def self.check_for_username_entry(username)
|
142
|
-
if File.exists?(DIRECT_ACCESS)
|
143
|
-
File.open(DIRECT_ACCESS).each do |line|
|
144
|
-
if line.strip.eql?(username)
|
145
|
-
return true
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
return false
|
151
|
-
end
|
152
|
-
|
153
|
-
def self.ask_catalog_credentials()
|
154
|
-
are_there_creds = Console.confirmation_prompt("Do you have DTK catalog credentials", true)
|
155
|
-
property_template = {}
|
156
|
-
if are_there_creds
|
157
|
-
property_template = self.enter_catalog_credentials()
|
158
|
-
end
|
159
|
-
|
160
|
-
property_template
|
161
|
-
end
|
162
|
-
|
163
|
-
def self.enter_catalog_credentials()
|
164
|
-
property_template = {}
|
165
|
-
# needed to preserve the order for ruby 1.8.7
|
166
|
-
# ruby 1.8 does not preserve order of insertation
|
167
|
-
wizard_values = { :username => 'Catalog Username', :password => 'Catalog Password' }
|
168
|
-
[:username, :password].each do |p|
|
169
|
-
value = ask("#{wizard_values[p]}: ") { |q| q.echo = false if p == :password }
|
170
|
-
property_template.store(p, value)
|
171
|
-
end
|
172
|
-
property_template
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
data/lib/context_router.rb
DELETED
@@ -1,44 +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
|
-
module DTK
|
19
|
-
module Client
|
20
|
-
|
21
|
-
#
|
22
|
-
# This class is used to reroute commands/tasks (Method invocations) from one context (Class) to another
|
23
|
-
#
|
24
|
-
class ContextRouter
|
25
|
-
|
26
|
-
extend DTK::Client::Auxiliary
|
27
|
-
|
28
|
-
# This method invokes target context task
|
29
|
-
def self.routeTask(target_context, target_method, target_context_params, conn)
|
30
|
-
target_context = target_context.to_s
|
31
|
-
target_method = target_method.to_s
|
32
|
-
|
33
|
-
# Initing required params and invoking target_context.target_method
|
34
|
-
load_command(target_context)
|
35
|
-
target_context_class = DTK::Client.const_get "#{cap_form(target_context)}"
|
36
|
-
|
37
|
-
ret = target_context_class.execute_from_cli(conn, target_method, target_context_params, [], false)
|
38
|
-
ret.kind_of?(Response::NoOp) ? Response::Ok.new() : ret
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|