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,501 +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
|
-
dtk_require_common_commands('thor/module')
|
19
|
-
require 'fileutils'
|
20
|
-
|
21
|
-
module DTK::Client
|
22
|
-
class ComponentModule < CommandBaseThor
|
23
|
-
|
24
|
-
no_tasks do
|
25
|
-
include ModuleMixin
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.valid_children()
|
29
|
-
[:component, :remotes]
|
30
|
-
end
|
31
|
-
|
32
|
-
# this includes children of children - has to be sorted by n-level access
|
33
|
-
def self.all_children()
|
34
|
-
[:component]
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.multi_context_children()
|
38
|
-
[[:component], [:remotes], [:component, :remotes]]
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.valid_child?(name_of_sub_context)
|
42
|
-
return ComponentModule.valid_children().include?(name_of_sub_context.to_sym)
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.validation_list(context_params)
|
46
|
-
get_cached_response(:component_module, "component_module/list", {})
|
47
|
-
end
|
48
|
-
|
49
|
-
def self.override_allowed_methods()
|
50
|
-
return DTK::Shell::OverrideTasks.new(
|
51
|
-
{
|
52
|
-
:command_only => {
|
53
|
-
:self => [
|
54
|
-
["list"," list [--remote] [--diff] [-n NAMESPACE]","# List loaded or remote component modules. Use --diff to compare loaded and remote component modules."]
|
55
|
-
],
|
56
|
-
:component => [
|
57
|
-
["list","list","# List all component templates."],
|
58
|
-
["list-attributes","list-attributes", "# List all attributes for given component."]
|
59
|
-
],
|
60
|
-
:remotes => [
|
61
|
-
["push-remote", "push-remote [REMOTE-NAME] [--force]", "# Push local changes to remote git repository"],
|
62
|
-
["list-remotes", "list-remotes", "# List git remotes for given module"],
|
63
|
-
["add-remote", "add-remote REMOTE-NAME REMOTE-URL", "# Add git remote for given module"],
|
64
|
-
["remove-remote", "remove-remote REPO-NAME [-y]", "# Remove git remote for given module"]
|
65
|
-
]
|
66
|
-
},
|
67
|
-
:identifier_only => {
|
68
|
-
:component => [
|
69
|
-
["list-attributes","list-attributes", "# List all attributes for given component."]
|
70
|
-
]
|
71
|
-
}
|
72
|
-
|
73
|
-
})
|
74
|
-
end
|
75
|
-
|
76
|
-
def self.whoami()
|
77
|
-
return :component_module, "component_module/list", nil
|
78
|
-
end
|
79
|
-
|
80
|
-
desc "delete-version COMPONENT-MODULE-NAME [-y] [-p] [-v VERSION]", "Delete component module version and all items contained in it. Optional parameter [-p] is to delete local directory."
|
81
|
-
method_option :force, :aliases => '-y', :type => :boolean, :default => false
|
82
|
-
method_option :purge, :aliases => '-p', :type => :boolean, :default => false
|
83
|
-
version_method_option
|
84
|
-
def delete_version(context_params, method_opts = {})
|
85
|
-
response = delete_module_aux(context_params, method_opts)
|
86
|
-
@@invalidate_map << :component_module if response && response.ok?
|
87
|
-
|
88
|
-
response
|
89
|
-
end
|
90
|
-
|
91
|
-
desc "delete COMPONENT-MODULE-NAME [-y] [-p]", "Delete component module and all items contained in it. Optional parameter [-p] is to delete local directory."
|
92
|
-
method_option :force, :aliases => '-y', :type => :boolean, :default => false
|
93
|
-
method_option :purge, :aliases => '-p', :type => :boolean, :default => false
|
94
|
-
# version_method_option
|
95
|
-
def delete(context_params, method_opts = {})
|
96
|
-
response = delete_module_aux(context_params, method_opts.merge!(:delete_all => true))
|
97
|
-
@@invalidate_map << :component_module if response && response.ok?
|
98
|
-
|
99
|
-
response
|
100
|
-
end
|
101
|
-
|
102
|
-
desc "COMPONENT-MODULE-NAME/ID set-attribute ATTRIBUTE-ID VALUE", "Set value of component module attributes"
|
103
|
-
def set_attribute(context_params)
|
104
|
-
set_attribute_module_aux(context_params)
|
105
|
-
end
|
106
|
-
|
107
|
-
desc "list [--remote] [--diffs] [-n NAMESPACE]", "List loaded or remote component modules. Use --diff to compare loaded and remote component modules."
|
108
|
-
method_option :remote, :type => :boolean, :default => false
|
109
|
-
method_option :diffs, :type => :boolean, :default => false, :aliases => "--diff"
|
110
|
-
method_option :namespace, :aliases => "-n" ,
|
111
|
-
:type => :string,
|
112
|
-
:banner => "NAMESPACE",
|
113
|
-
:desc => "List modules only in specific namespace."
|
114
|
-
# method_option :with_versions, :type => :boolean, :default => false, :aliases => "with-versions"
|
115
|
-
def list(context_params)
|
116
|
-
return module_info_about(context_params, :components, :component) if context_params.is_there_command?(:"component")
|
117
|
-
|
118
|
-
forwarded_remote = context_params.get_forwarded_options()["remote"] if context_params.get_forwarded_options()
|
119
|
-
remote = options.remote? || forwarded_remote
|
120
|
-
action = (remote ? "list_remote" : "list")
|
121
|
-
|
122
|
-
post_body = (remote ? { :rsa_pub_key => SSHUtil.rsa_pub_key_content() } : {:detail_to_include => ["remotes"]})
|
123
|
-
post_body[:diff] = options.diffs? ? options.diffs : {}
|
124
|
-
|
125
|
-
if post_body[:detail_to_include]
|
126
|
-
post_body[:detail_to_include] << 'versions' # if options.with_versions?
|
127
|
-
else
|
128
|
-
post_body[:detail_to_include]
|
129
|
-
end
|
130
|
-
|
131
|
-
post_body.merge!(:module_namespace => options.namespace) if options.namespace
|
132
|
-
|
133
|
-
response = post rest_url("component_module/#{action}"), post_body
|
134
|
-
|
135
|
-
return response unless response.ok?
|
136
|
-
|
137
|
-
if options.with_versions?
|
138
|
-
response.render_table(:module_with_versions, true)
|
139
|
-
else
|
140
|
-
response.render_table()
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
desc "COMPONENT-MODULE-NAME/ID list-components", "List all components for given component module."
|
145
|
-
def list_components(context_params)
|
146
|
-
module_info_about(context_params, :components, :component)
|
147
|
-
end
|
148
|
-
|
149
|
-
desc "COMPONENT-MODULE-NAME/ID list-attributes", "List all attributes for given component module."
|
150
|
-
def list_attributes(context_params)
|
151
|
-
module_info_about(context_params, :attributes, :attribute_without_link)
|
152
|
-
end
|
153
|
-
|
154
|
-
desc "COMPONENT-MODULE-NAME/ID list-instances", "List all instances for given component module."
|
155
|
-
def list_instances(context_params)
|
156
|
-
module_info_about(context_params, :instances, :component_instances)
|
157
|
-
end
|
158
|
-
|
159
|
-
desc "COMPONENT-MODULE-NAME/ID list-versions","List all versions associated with this component module."
|
160
|
-
def list_versions(context_params)
|
161
|
-
response = list_versions_aux(context_params)
|
162
|
-
return response unless response.ok?
|
163
|
-
response.render_table(:list_versions, true)
|
164
|
-
end
|
165
|
-
|
166
|
-
desc "COMPONENT-MODULE-NAME/ID list-remote-versions","List all remote versions associated with this component module."
|
167
|
-
def list_remote_versions(context_params)
|
168
|
-
response = list_remote_versions_aux(context_params)
|
169
|
-
return response unless response.ok?
|
170
|
-
response.render_table(:list_versions, true)
|
171
|
-
end
|
172
|
-
|
173
|
-
desc "import [NAMESPACE:]COMPONENT-MODULE-NAME", "Create new component module from local clone"
|
174
|
-
def import(context_params)
|
175
|
-
response = import_module_aux(context_params)
|
176
|
-
@@invalidate_map << :component_module
|
177
|
-
response
|
178
|
-
end
|
179
|
-
|
180
|
-
desc "import-puppet-forge PUPPET-MODULE-NAME [[NAMESPACE:]COMPONENT-MODULE-NAME]", "Install puppet module from puppet forge"
|
181
|
-
def import_puppet_forge(context_params)
|
182
|
-
pf_module_name, full_module_name = context_params.retrieve_arguments([:option_1!, :option_2],method_argument_names)
|
183
|
-
namespace, module_name = get_namespace_and_name(full_module_name, ModuleUtil::NAMESPACE_SEPERATOR)
|
184
|
-
module_type = get_module_type(context_params)
|
185
|
-
|
186
|
-
OsUtil.print('Retrieving puppet module metadata, please wait ...')
|
187
|
-
response = puppet_forge_install_aux(context_params, pf_module_name, module_name, namespace, nil, module_type)
|
188
|
-
|
189
|
-
@@invalidate_map << :component_module
|
190
|
-
response
|
191
|
-
end
|
192
|
-
|
193
|
-
#
|
194
|
-
# Creates component module from input git repo, removing .git dir to rid of pointing to user github, and creates component module
|
195
|
-
#
|
196
|
-
method_option :branch, :aliases => '-b'
|
197
|
-
desc "import-git GIT-SSH-REPO-URL [NAMESPACE:]COMPONENT-MODULE-NAME [-b BRANCH/TAG]", "Create new local component module by importing from provided git repo URL"
|
198
|
-
def import_git(context_params)
|
199
|
-
response = import_git_module_aux(context_params)
|
200
|
-
@@invalidate_map << :component_module
|
201
|
-
response
|
202
|
-
end
|
203
|
-
|
204
|
-
=begin
|
205
|
-
# desc "COMPONENT-MODULE-NAME/ID validate-model [-v VERSION]", "Check the DSL model for errors"
|
206
|
-
# version_method_option
|
207
|
-
desc "COMPONENT-MODULE-NAME/ID validate-model", "Check the DSL model for errors"
|
208
|
-
def validate_model(context_params)
|
209
|
-
module_id, module_name = context_params.retrieve_arguments([:component_module_id!, :component_module_name],method_argument_names)
|
210
|
-
version = options["version"]
|
211
|
-
|
212
|
-
if module_name.to_s =~ /^[0-9]+$/
|
213
|
-
module_id = module_name
|
214
|
-
module_name = get_module_name(module_id)
|
215
|
-
end
|
216
|
-
|
217
|
-
modules_path = OsUtil.component_clone_location()
|
218
|
-
module_location = "#{modules_path}/#{module_name}#{version && "-#{version}"}"
|
219
|
-
|
220
|
-
raise DTK::Client::DtkValidationError, "Unable to parse module '#{module_name}#{version && "-#{version}"}' that doesn't exist on your local machine!" unless File.directory?(module_location)
|
221
|
-
|
222
|
-
reparse_aux(module_location)
|
223
|
-
end
|
224
|
-
=end
|
225
|
-
|
226
|
-
# TODO: put in back support for:desc "import REMOTE-MODULE[,...] [LIBRARY-NAME/ID]", "Import remote component module(s) into library"
|
227
|
-
# TODO: put in doc REMOTE-MODULE havs namespace and optionally version information; e.g. r8/hdp or r8/hdp/v1.1
|
228
|
-
# if multiple items and failire; stops on first failure
|
229
|
-
# desc "install [NAMESPACE/]REMOTE-COMPONENT-MODULE-NAME [-r DTK-REPO-MANAGER]","Install remote component module into local environment"
|
230
|
-
desc "install NAMESPACE/REMOTE-COMPONENT-MODULE-NAME [-v VERSION]","Install remote component module into local environment"
|
231
|
-
method_option "repo-manager",:aliases => "-r" ,
|
232
|
-
:type => :string,
|
233
|
-
:banner => "REPO-MANAGER",
|
234
|
-
:desc => "DTK Repo Manager from which to resolve requested module."
|
235
|
-
version_method_option
|
236
|
-
def install(context_params)
|
237
|
-
response = install_module_aux(context_params)
|
238
|
-
if response && response.ok?
|
239
|
-
@@invalidate_map << :component_module
|
240
|
-
# TODO: hack before clean up way to indicate to better format what is passed as hash; these lines print the created module,
|
241
|
-
# not the module_directory
|
242
|
-
if module_directory = response.data(:module_directory)
|
243
|
-
split = module_directory.split('/')
|
244
|
-
if split.size > 2
|
245
|
-
installed_module = split[split.size-2..split.size-1].join(':')
|
246
|
-
response = Response::Ok.new('installed_module' => installed_module)
|
247
|
-
end
|
248
|
-
end
|
249
|
-
end
|
250
|
-
response
|
251
|
-
end
|
252
|
-
|
253
|
-
|
254
|
-
=begin
|
255
|
-
=> DUE TO DEPENDENCY TO PUPPET GEM WE OMIT THIS <=
|
256
|
-
desc "import-puppet-forge PUPPET-FORGE-MODULE-NAME", "Imports puppet module from puppet forge via puppet gem"
|
257
|
-
def import_puppet_forge(context_params)
|
258
|
-
module_name = context_params.retrieve_arguments([:option_1!],method_argument_names)
|
259
|
-
# this call will throw exception if error occurs
|
260
|
-
module_dir_name = DtkPuppet.install_module(module_name)
|
261
|
-
|
262
|
-
# we change module name to be dir name
|
263
|
-
context_params.override_method_argument!(:option_1, module_dir_name)
|
264
|
-
|
265
|
-
# process will take some time adding friendly message
|
266
|
-
puts "Cloning to remote repo, please wait ..."
|
267
|
-
|
268
|
-
# rest of reponsabilty is given to import method
|
269
|
-
import(context_params)
|
270
|
-
end
|
271
|
-
=end
|
272
|
-
=begin
|
273
|
-
desc "COMPONENT-MODULE-NAME/ID import-version VERSION", "Import a specfic version from a linked component module"
|
274
|
-
def import_version(context_params)
|
275
|
-
component_module_id,version = context_params.retrieve_arguments([:component_module_id!,:option_1!],method_argument_names)
|
276
|
-
post_body = {
|
277
|
-
:component_module_id => component_module_id,
|
278
|
-
:version => version
|
279
|
-
}
|
280
|
-
response = post rest_url("component_module/import_version"), post_body
|
281
|
-
@@invalidate_map << :component_module
|
282
|
-
|
283
|
-
return response unless response.ok?
|
284
|
-
module_name,repo_url,branch,version = response.data(:module_name,:repo_url,:workspace_branch,:version)
|
285
|
-
|
286
|
-
if error = response.data(:dsl_parse_error)
|
287
|
-
dsl_parsed_message = ServiceImporter.error_message(module_name, error)
|
288
|
-
DTK::Client::OsUtil.print(dsl_parsed_message, :red)
|
289
|
-
end
|
290
|
-
|
291
|
-
#TODO: need to check if local clone directory exists
|
292
|
-
Helper(:git_repo).create_clone_with_branch(:component_module,module_name,repo_url,branch,version)
|
293
|
-
end
|
294
|
-
=end
|
295
|
-
|
296
|
-
desc "delete-from-catalog NAMESPACE/REMOTE-COMPONENT-MODULE-NAME [-y] [--force] [-v VERSION]", "Delete the component module from the DTK Network catalog"
|
297
|
-
method_option :confirmed, :aliases => '-y', :type => :boolean, :default => false
|
298
|
-
method_option :force, :type => :boolean, :default => false
|
299
|
-
version_method_option
|
300
|
-
def delete_from_catalog(context_params)
|
301
|
-
delete_from_catalog_aux(context_params)
|
302
|
-
end
|
303
|
-
|
304
|
-
# renamed to 'publish' but didn't delete this in case we run into issues with 'publish'
|
305
|
-
# desc "COMPONENT-MODULE-NAME/ID create-on-dtkn [[NAMESPACE/]REMOTE-COMPONENT-MODULE-NAME]", "Export component module to remote repository."
|
306
|
-
# def create_on_dtkn(context_params)
|
307
|
-
# component_module_id, input_remote_name = context_params.retrieve_arguments([:component_module_id!, :option_1],method_argument_names)
|
308
|
-
|
309
|
-
# post_body = {
|
310
|
-
# :component_module_id => component_module_id,
|
311
|
-
# :remote_component_name => input_remote_name,
|
312
|
-
# :rsa_pub_key => SSHUtil.rsa_pub_key_content()
|
313
|
-
# }
|
314
|
-
|
315
|
-
# response = post rest_url("component_module/export"), post_body
|
316
|
-
|
317
|
-
# return response
|
318
|
-
# end
|
319
|
-
|
320
|
-
desc "COMPONENT-MODULE-NAME/ID publish [[NAMESPACE/]REMOTE-COMPONENT-MODULE-NAME] -v VERSION [--force]", "Publish component module to remote repository."
|
321
|
-
version_method_option
|
322
|
-
method_option :force, :type => :boolean, :default => false, :aliases => '-f'
|
323
|
-
def publish(context_params)
|
324
|
-
publish_module_aux(context_params)
|
325
|
-
end
|
326
|
-
|
327
|
-
desc "COMPONENT-MODULE-NAME/ID pull-dtkn [-n NAMESPACE] [--force]", "Update local component module from remote repository."
|
328
|
-
method_option :namespace,:aliases => '-n',
|
329
|
-
:type => :string,
|
330
|
-
:banner => "NAMESPACE",
|
331
|
-
:desc => "Remote namespace"
|
332
|
-
method_option :force,:aliases => '-f',
|
333
|
-
:type => :boolean,
|
334
|
-
:desc => "Force pull",
|
335
|
-
:default => false
|
336
|
-
def pull_dtkn(context_params)
|
337
|
-
pull_dtkn_aux(context_params)
|
338
|
-
end
|
339
|
-
|
340
|
-
=begin
|
341
|
-
desc "COMPONENT-MODULE-NAME/ID chown REMOTE-USER", "Set remote module owner"
|
342
|
-
method_option "namespace", :aliases => "-n", :type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
|
343
|
-
def chown(context_params)
|
344
|
-
component_module_id, remote_user = context_params.retrieve_arguments([:component_module_id!,:option_1!],method_argument_names)
|
345
|
-
chown_aux(component_module_id, remote_user, options.namespace)
|
346
|
-
end
|
347
|
-
=end
|
348
|
-
|
349
|
-
desc "COMPONENT-MODULE-NAME/ID chmod PERMISSION-SELECTOR", "Update remote permissions e.g. ug+rw , user and group get RW permissions"
|
350
|
-
method_option "namespace", :aliases => "-n", :type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
|
351
|
-
def chmod(context_params)
|
352
|
-
chmod_module_aux(context_params)
|
353
|
-
end
|
354
|
-
|
355
|
-
desc "COMPONENT-MODULE-NAME/ID make-public", "Make this module public"
|
356
|
-
method_option "namespace", :aliases => "-n", :type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
|
357
|
-
def make_public(context_params)
|
358
|
-
make_public_module_aux(context_params)
|
359
|
-
end
|
360
|
-
|
361
|
-
desc "COMPONENT-MODULE-NAME/ID make-private", "Make this module private"
|
362
|
-
method_option "namespace", :aliases => "-n", :type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
|
363
|
-
def make_private(context_params)
|
364
|
-
make_private_module_aux(context_params)
|
365
|
-
end
|
366
|
-
|
367
|
-
desc "COMPONENT-MODULE-NAME/ID add-collaborators", "Add collabrators users or groups comma seperated (--users or --groups)"
|
368
|
-
method_option "namespace", :aliases => "-n", :type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
|
369
|
-
method_option "users", :aliases => "-u", :type => :string, :banner => "USERS", :desc => "User collabrators"
|
370
|
-
method_option "groups", :aliases => "-g", :type => :string, :banner => "GROUPS", :desc => "Group collabrators"
|
371
|
-
def add_collaborators(context_params)
|
372
|
-
add_collaborators_module_aux(context_params)
|
373
|
-
end
|
374
|
-
|
375
|
-
desc "COMPONENT-MODULE-NAME/ID remove-collaborators", "Remove collabrators users or groups comma seperated (--users or --groups)"
|
376
|
-
method_option "namespace",:aliases => "-n",:type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
|
377
|
-
method_option "users",:aliases => "-u", :type => :string, :banner => "USERS", :desc => "User collabrators"
|
378
|
-
method_option "groups",:aliases => "-g", :type => :string, :banner => "GROUPS", :desc => "Group collabrators"
|
379
|
-
def remove_collaborators(context_params)
|
380
|
-
remove_collaborators_module_aux(context_params)
|
381
|
-
end
|
382
|
-
|
383
|
-
desc "COMPONENT-MODULE-NAME/ID list-collaborators", "List collaborators for given module"
|
384
|
-
method_option "namespace",:aliases => "-n",:type => :string, :banner => "NAMESPACE", :desc => "Remote namespace"
|
385
|
-
def list_collaborators(context_params)
|
386
|
-
list_collaborators_module_aux(context_params)
|
387
|
-
end
|
388
|
-
|
389
|
-
##
|
390
|
-
#
|
391
|
-
# internal_trigger: this flag means that other method (internal) has trigger this.
|
392
|
-
# This will change behaviour of method in such way that edit will not be
|
393
|
-
# triggered after it.
|
394
|
-
#
|
395
|
-
desc "COMPONENT-MODULE-NAME/ID clone [-n] [-v VERSION]", "Locally clone component module and component files. Use -n to skip edit prompt"
|
396
|
-
method_option :skip_edit, :aliases => '-n', :type => :boolean, :default => false
|
397
|
-
version_method_option
|
398
|
-
def clone(context_params, internal_trigger=true)
|
399
|
-
clone_module_aux(context_params, internal_trigger)
|
400
|
-
end
|
401
|
-
|
402
|
-
# desc "COMPONENT-MODULE-NAME/ID edit [-v VERSION]","Switch to unix editing for given component module."
|
403
|
-
# version_method_option
|
404
|
-
desc "COMPONENT-MODULE-NAME/ID edit","Switch to unix editing for given component module."
|
405
|
-
def edit(context_params)
|
406
|
-
edit_module_aux(context_params)
|
407
|
-
end
|
408
|
-
|
409
|
-
desc "COMPONENT-MODULE-NAME/ID push [--force] [--docs]", "Push changes from local copy of component module to server"
|
410
|
-
method_option "message",:aliases => "-m" ,
|
411
|
-
:type => :string,
|
412
|
-
:banner => "COMMIT-MSG",
|
413
|
-
:desc => "Commit message"
|
414
|
-
# hidden option for dev
|
415
|
-
method_option :force, :type => :boolean, :default => false, :aliases => '-f'
|
416
|
-
method_option :docs, :type => :boolean, :default => false, :aliases => '-d'
|
417
|
-
def push(context_params, internal_trigger=false)
|
418
|
-
push_module_aux(context_params, internal_trigger)
|
419
|
-
end
|
420
|
-
|
421
|
-
# desc "COMPONENT-MODULE-NAME/ID push-dtkn [-n NAMESPACE] [-m COMMIT-MSG]", "Push changes from local copy of component module to remote repository (dtkn)."
|
422
|
-
desc "COMPONENT-MODULE-NAME/ID push-dtkn [-n NAMESPACE] [--force]", "Push changes from local copy of component module to remote repository (dtkn)."
|
423
|
-
method_option "message",:aliases => "-m" ,
|
424
|
-
:type => :string,
|
425
|
-
:banner => "COMMIT-MSG",
|
426
|
-
:desc => "Commit message"
|
427
|
-
method_option "namespace",:aliases => "-n",
|
428
|
-
:type => :string,
|
429
|
-
:banner => "NAMESPACE",
|
430
|
-
:desc => "Remote namespace"
|
431
|
-
#hidden option for dev
|
432
|
-
method_option :force, :type => :boolean, :default => false, :aliases => '-f'
|
433
|
-
def push_dtkn(context_params, internal_trigger=false)
|
434
|
-
push_dtkn_module_aux(context_params, internal_trigger)
|
435
|
-
end
|
436
|
-
PushCatalogs = ["origin", "dtkn"]
|
437
|
-
|
438
|
-
|
439
|
-
# desc "COMPONENT-MODULE-NAME/ID list-diffs [-v VERSION] [--remote]", "List diffs"
|
440
|
-
# version_method_option
|
441
|
-
desc "COMPONENT-MODULE-NAME/ID list-diffs", "List diffs between module on server and remote repo"
|
442
|
-
method_option :remote, :type => :boolean, :default => false
|
443
|
-
def list_diffs(context_params)
|
444
|
-
list_remote_module_diffs(context_params)
|
445
|
-
# list_diffs_module_aux(context_params)
|
446
|
-
end
|
447
|
-
|
448
|
-
# REMOTE INTERACTION
|
449
|
-
|
450
|
-
desc "HIDE_FROM_BASE push-remote [REMOTE-NAME] [--force]", "Push local changes to remote git repository"
|
451
|
-
method_option :force, :type => :boolean, :default => false
|
452
|
-
def push_remote(context_params)
|
453
|
-
push_remote_module_aux(context_params)
|
454
|
-
end
|
455
|
-
|
456
|
-
desc "HIDE_FROM_BASE list-remotes", "List git remotes for given module"
|
457
|
-
def list_remotes(context_params)
|
458
|
-
remote_list_aux(context_params)
|
459
|
-
end
|
460
|
-
|
461
|
-
desc "HIDE_FROM_BASE add-remote REMOTE-NAME REMOTE-URL", "Add git remote for given module"
|
462
|
-
def add_remote(context_params)
|
463
|
-
remote_add_aux(context_params)
|
464
|
-
end
|
465
|
-
|
466
|
-
desc "HIDE_FROM_BASE remove-remote REPO-NAME [-y]", "Remove git remote for given module"
|
467
|
-
method_option :force, :aliases => '-y', :type => :boolean, :default => false
|
468
|
-
def remove_remote(context_params)
|
469
|
-
remote_remove_aux(context_params)
|
470
|
-
end
|
471
|
-
|
472
|
-
desc "COMPONENT-MODULE-NAME/ID fork NAMESPACE", "Fork component module to new namespace"
|
473
|
-
def fork(context_params)
|
474
|
-
fork_aux(context_params)
|
475
|
-
end
|
476
|
-
|
477
|
-
desc "COMPONENT-MODULE-NAME/ID create-new-version VERSION", "Create new component module version"
|
478
|
-
def create_new_version(context_params)
|
479
|
-
create_new_version_aux(context_params)
|
480
|
-
end
|
481
|
-
|
482
|
-
#
|
483
|
-
# DEVELOPMENT MODE METHODS
|
484
|
-
#
|
485
|
-
if DTK::Configuration.get(:development_mode)
|
486
|
-
|
487
|
-
desc "delete-all","Delete all service modules"
|
488
|
-
def delete_all(context_params)
|
489
|
-
return unless Console.confirmation_prompt("This will DELETE ALL component modules, are you sure"+'?')
|
490
|
-
response = list(context_params)
|
491
|
-
|
492
|
-
response.data().each do |e|
|
493
|
-
run_shell_command("delete #{e['display_name']} -y -p")
|
494
|
-
end
|
495
|
-
end
|
496
|
-
|
497
|
-
end
|
498
|
-
|
499
|
-
#### end: commands related to cloning to and pushing from local clone
|
500
|
-
end
|
501
|
-
end
|
@@ -1,174 +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::Client
|
19
|
-
class ComponentTemplate < CommandBaseThor
|
20
|
-
|
21
|
-
def self.pretty_print_cols()
|
22
|
-
PPColumns.get(:component)
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.valid_children()
|
26
|
-
# Amar: attribute context commented out per Rich suggeston
|
27
|
-
#[:attribute]
|
28
|
-
[]
|
29
|
-
end
|
30
|
-
|
31
|
-
# this includes children of children
|
32
|
-
def self.all_children()
|
33
|
-
# Amar: attribute context commented out per Rich suggeston
|
34
|
-
#[:attribute]
|
35
|
-
[]
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.valid_child?(name_of_sub_context)
|
39
|
-
return ComponentTemplate.valid_children().include?(name_of_sub_context.to_sym)
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.validation_list(context_params)
|
43
|
-
if context_params.is_there_identifier?("component-module")
|
44
|
-
component_module_id = context_params.retrieve_arguments([:component_module_id!])
|
45
|
-
res = get_cached_response(:component_template, "component_module/info_about", { :component_module_id => component_module_id, :about => :components})
|
46
|
-
else
|
47
|
-
post_body = {:subtype => 'template', :ignore => 'test_module'}
|
48
|
-
if assembly_id = context_params.retrieve_arguments([[:service_id, :workspace_id]])
|
49
|
-
post_body.merge!(:assembly_id => assembly_id)
|
50
|
-
end
|
51
|
-
get_cached_response(:component_template, "component/list", post_body)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def self.override_allowed_methods()
|
56
|
-
return DTK::Shell::OverrideTasks.new({})
|
57
|
-
# Amar: attribute context commented out per Rich suggeston
|
58
|
-
#return DTK::Shell::OverrideTasks.new(
|
59
|
-
# {
|
60
|
-
# :command_only => {
|
61
|
-
# :attribute => [
|
62
|
-
# ['list',"list","List attributes for given component"]
|
63
|
-
# ]
|
64
|
-
# },
|
65
|
-
# :identifier_only => {
|
66
|
-
# :attribute => [
|
67
|
-
# ['list',"list","List attributes for given component"]
|
68
|
-
# ]
|
69
|
-
# }
|
70
|
-
#
|
71
|
-
#})
|
72
|
-
end
|
73
|
-
|
74
|
-
desc "COMPONENT-TEMPLATE-NAME/ID info", "Get information about given component template."
|
75
|
-
method_option :list, :type => :boolean, :default => false
|
76
|
-
def info(context_params)
|
77
|
-
component_id = context_params.retrieve_arguments([:component_template_id!],method_argument_names)
|
78
|
-
data_type = :component
|
79
|
-
|
80
|
-
post_body = {
|
81
|
-
:component_id => component_id,
|
82
|
-
:subtype => 'template'
|
83
|
-
}
|
84
|
-
response = post rest_url("component/info"), post_body
|
85
|
-
|
86
|
-
response.render_table(data_type) unless options.list?
|
87
|
-
|
88
|
-
return response
|
89
|
-
end
|
90
|
-
|
91
|
-
desc "COMPONENT-TEMPLATE-NAME/ID list-nodes [--module MODULE-NAME]", "List all nodes for given component template. Optional filter by modul name."
|
92
|
-
method_option :list, :type => :boolean, :default => false
|
93
|
-
method_option "module",:aliases => "-m" ,
|
94
|
-
:type => :string,
|
95
|
-
:banner => "MODULE-LIST-FILTER",
|
96
|
-
:desc => "Module list filter"
|
97
|
-
def list_nodes(context_params)
|
98
|
-
context_params.method_arguments = ["nodes"]
|
99
|
-
list(context_params)
|
100
|
-
end
|
101
|
-
|
102
|
-
desc "list [--module MODULE-NAME]", "List all component templates. Optional filter by module name."
|
103
|
-
method_option :list, :type => :boolean, :default => false
|
104
|
-
method_option "module",:aliases => "-m" ,
|
105
|
-
:type => :string,
|
106
|
-
:banner => "MODULE-LIST-FILTER",
|
107
|
-
:desc => "Module list filter"
|
108
|
-
def list(context_params)
|
109
|
-
component_id, about, module_filter = context_params.retrieve_arguments([:component_template_id,:option_1,:option_1],method_argument_names)
|
110
|
-
about ||= 'none'
|
111
|
-
data_type = :component
|
112
|
-
|
113
|
-
# Case when user provided '--module' / '-m' 'MODUL-NAME'
|
114
|
-
if options.module
|
115
|
-
# Special case when user sends --module; until now --OPTION didn't have value attached to it
|
116
|
-
if options.module.eql?("module")
|
117
|
-
module_id = module_filter
|
118
|
-
else
|
119
|
-
module_id = options.module
|
120
|
-
end
|
121
|
-
|
122
|
-
context_params_for_service = DTK::Shell::ContextParams.new
|
123
|
-
context_params_for_service.add_context_to_params("component_module", "component_module", module_id)
|
124
|
-
|
125
|
-
response = DTK::Client::ContextRouter.routeTask("component_module", "list_components", context_params_for_service, @conn)
|
126
|
-
|
127
|
-
else # Case without module filter
|
128
|
-
|
129
|
-
post_body = {
|
130
|
-
:component_id => component_id,
|
131
|
-
:subtype => 'template',
|
132
|
-
:about => about
|
133
|
-
}
|
134
|
-
|
135
|
-
case about
|
136
|
-
when 'none'
|
137
|
-
response = post rest_url("component/list")
|
138
|
-
when 'nodes'
|
139
|
-
response = post rest_url("component/list"), post_body
|
140
|
-
else
|
141
|
-
raise_validation_error_method_usage('list')
|
142
|
-
end
|
143
|
-
|
144
|
-
response.render_table(data_type) unless options.list?
|
145
|
-
end
|
146
|
-
|
147
|
-
return response
|
148
|
-
end
|
149
|
-
|
150
|
-
desc "COMPONENT-TEMPLATE-NAME/ID stage NODE-NAME/ID", "Stage indentified node for given component template."
|
151
|
-
method_option :list, :type => :boolean, :default => false
|
152
|
-
def stage(context_params)
|
153
|
-
component_id, node_id = context_params.retrieve_arguments([:component_template_id!,:option_1!],method_argument_names)
|
154
|
-
data_type = :component
|
155
|
-
|
156
|
-
post_body = {
|
157
|
-
:component_id => component_id
|
158
|
-
}
|
159
|
-
|
160
|
-
unless node_id.nil?
|
161
|
-
post_body.merge!({:node_id => node_id})
|
162
|
-
end
|
163
|
-
|
164
|
-
response = post rest_url("component/stage"), post_body
|
165
|
-
@@invalidate_map << :component_template
|
166
|
-
|
167
|
-
response.render_table(data_type) unless options.list?
|
168
|
-
response
|
169
|
-
end
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
end
|
174
|
-
end
|