dtk-shell 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +5 -0
- data/Gemfile_dev +13 -0
- data/README.md +121 -0
- data/bin/dtk-execute +32 -0
- data/bin/dtk-run +92 -0
- data/bin/dtk-shell +31 -0
- data/dtk-shell.gemspec +50 -0
- data/lib/auxiliary.rb +61 -0
- data/lib/bundler_monkey_patch.rb +26 -0
- data/lib/client.rb +58 -0
- data/lib/command_helper.rb +33 -0
- data/lib/command_helpers/git_repo.rb +589 -0
- data/lib/command_helpers/git_repo/merge.rb +153 -0
- data/lib/command_helpers/jenkins_client.rb +106 -0
- data/lib/command_helpers/jenkins_client/config_xml.rb +288 -0
- data/lib/command_helpers/service_importer.rb +251 -0
- data/lib/command_helpers/service_link.rb +33 -0
- data/lib/command_helpers/test_module_creator.rb +69 -0
- data/lib/command_helpers/test_module_templates/dtk.model.yaml.eruby +10 -0
- data/lib/command_helpers/test_module_templates/spec_helper.rb.eruby +10 -0
- data/lib/command_helpers/test_module_templates/temp_component_spec.rb.eruby +5 -0
- data/lib/commands.rb +57 -0
- data/lib/commands/common/thor/access_control.rb +133 -0
- data/lib/commands/common/thor/action_result_handler.rb +74 -0
- data/lib/commands/common/thor/assembly_template.rb +92 -0
- data/lib/commands/common/thor/assembly_workspace.rb +1801 -0
- data/lib/commands/common/thor/base_command_helper.rb +59 -0
- data/lib/commands/common/thor/clone.rb +82 -0
- data/lib/commands/common/thor/common.rb +88 -0
- data/lib/commands/common/thor/common_base.rb +49 -0
- data/lib/commands/common/thor/create_target.rb +70 -0
- data/lib/commands/common/thor/edit.rb +255 -0
- data/lib/commands/common/thor/inventory_parser.rb +98 -0
- data/lib/commands/common/thor/list_diffs.rb +128 -0
- data/lib/commands/common/thor/module.rb +1011 -0
- data/lib/commands/common/thor/module/import.rb +210 -0
- data/lib/commands/common/thor/node.rb +53 -0
- data/lib/commands/common/thor/poller.rb +65 -0
- data/lib/commands/common/thor/pull_clone_changes.rb +28 -0
- data/lib/commands/common/thor/pull_from_remote.rb +152 -0
- data/lib/commands/common/thor/puppet_forge.rb +72 -0
- data/lib/commands/common/thor/purge_clone.rb +101 -0
- data/lib/commands/common/thor/push_clone_changes.rb +162 -0
- data/lib/commands/common/thor/push_to_remote.rb +94 -0
- data/lib/commands/common/thor/remotes.rb +71 -0
- data/lib/commands/common/thor/reparse.rb +40 -0
- data/lib/commands/common/thor/set_required_attributes.rb +46 -0
- data/lib/commands/thor/account.rb +239 -0
- data/lib/commands/thor/assembly.rb +356 -0
- data/lib/commands/thor/attribute.rb +79 -0
- data/lib/commands/thor/component.rb +70 -0
- data/lib/commands/thor/component_module.rb +501 -0
- data/lib/commands/thor/component_template.rb +174 -0
- data/lib/commands/thor/dependency.rb +34 -0
- data/lib/commands/thor/developer.rb +144 -0
- data/lib/commands/thor/dtk.rb +152 -0
- data/lib/commands/thor/library.rb +125 -0
- data/lib/commands/thor/node.rb +504 -0
- data/lib/commands/thor/node_template.rb +94 -0
- data/lib/commands/thor/project.rb +34 -0
- data/lib/commands/thor/provider.rb +233 -0
- data/lib/commands/thor/remotes.rb +49 -0
- data/lib/commands/thor/service.rb +941 -0
- data/lib/commands/thor/service_module.rb +914 -0
- data/lib/commands/thor/state_change.rb +25 -0
- data/lib/commands/thor/target.rb +250 -0
- data/lib/commands/thor/task.rb +116 -0
- data/lib/commands/thor/test_module.rb +310 -0
- data/lib/commands/thor/utils.rb +21 -0
- data/lib/commands/thor/workspace.rb +685 -0
- data/lib/config/cacert.pem +3785 -0
- data/lib/config/client.conf.header +20 -0
- data/lib/config/configuration.rb +99 -0
- data/lib/config/default.conf +16 -0
- data/lib/config/disk_cacher.rb +80 -0
- data/lib/configurator.rb +176 -0
- data/lib/context_router.rb +44 -0
- data/lib/core.rb +497 -0
- data/lib/domain/git_adapter.rb +412 -0
- data/lib/domain/git_error_handler.rb +64 -0
- data/lib/domain/response.rb +285 -0
- data/lib/domain/response/error_handler.rb +86 -0
- data/lib/dtk-shell/version.rb +20 -0
- data/lib/dtk_constants.rb +40 -0
- data/lib/dtk_error.rb +114 -0
- data/lib/dtk_logger.rb +126 -0
- data/lib/dtk_shell.rb +31 -0
- data/lib/error.rb +85 -0
- data/lib/execute.rb +29 -0
- data/lib/execute/cli_pure/cli_rerouter.rb +102 -0
- data/lib/execute/command.rb +40 -0
- data/lib/execute/command/api_call.rb +60 -0
- data/lib/execute/command/api_call/map.rb +60 -0
- data/lib/execute/command/api_call/service.rb +91 -0
- data/lib/execute/command/api_call/translation_term.rb +119 -0
- data/lib/execute/command/rest_call.rb +37 -0
- data/lib/execute/command_processor.rb +30 -0
- data/lib/execute/command_processor/rest_call.rb +59 -0
- data/lib/execute/error_usage.rb +21 -0
- data/lib/execute/execute_context.rb +86 -0
- data/lib/execute/execute_context/result_store.rb +37 -0
- data/lib/execute/script.rb +64 -0
- data/lib/execute/script/add_tenant.rb +121 -0
- data/lib/git-logs/git.log +0 -0
- data/lib/parser/adapters/option_parser.rb +70 -0
- data/lib/parser/adapters/thor.rb +555 -0
- data/lib/parser/adapters/thor/common_option_defs.rb +40 -0
- data/lib/require_first.rb +104 -0
- data/lib/search_hash.rb +44 -0
- data/lib/shell.rb +261 -0
- data/lib/shell/context.rb +1065 -0
- data/lib/shell/context_aux.rb +46 -0
- data/lib/shell/domain/active_context.rb +186 -0
- data/lib/shell/domain/context_entity.rb +89 -0
- data/lib/shell/domain/context_params.rb +223 -0
- data/lib/shell/domain/override_tasks.rb +88 -0
- data/lib/shell/domain/shadow_entity.rb +76 -0
- data/lib/shell/header_shell.rb +44 -0
- data/lib/shell/help_monkey_patch.rb +283 -0
- data/lib/shell/interactive_wizard.rb +225 -0
- data/lib/shell/message_queue.rb +63 -0
- data/lib/shell/parse_monkey_patch.rb +39 -0
- data/lib/shell/status_monitor.rb +124 -0
- data/lib/task_status.rb +83 -0
- data/lib/task_status/refresh_mode.rb +77 -0
- data/lib/task_status/snapshot_mode.rb +28 -0
- data/lib/task_status/stream_mode.rb +48 -0
- data/lib/task_status/stream_mode/element.rb +101 -0
- data/lib/task_status/stream_mode/element/format.rb +101 -0
- data/lib/task_status/stream_mode/element/hierarchical_task.rb +100 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/result.rb +72 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/result/action.rb +93 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/result/components.rb +26 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/result/node_level.rb +26 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/steps.rb +34 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/steps/action.rb +53 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/steps/components.rb +53 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/steps/node_level.rb +42 -0
- data/lib/task_status/stream_mode/element/no_results.rb +26 -0
- data/lib/task_status/stream_mode/element/render.rb +59 -0
- data/lib/task_status/stream_mode/element/stage.rb +84 -0
- data/lib/task_status/stream_mode/element/stage/render.rb +76 -0
- data/lib/task_status/stream_mode/element/task_end.rb +35 -0
- data/lib/task_status/stream_mode/element/task_start.rb +37 -0
- data/lib/util/common_util.rb +37 -0
- data/lib/util/console.rb +235 -0
- data/lib/util/dtk_puppet.rb +65 -0
- data/lib/util/module_util.rb +66 -0
- data/lib/util/os_util.rb +385 -0
- data/lib/util/permission_util.rb +31 -0
- data/lib/util/remote_dependency_util.rb +84 -0
- data/lib/util/ssh_util.rb +94 -0
- data/lib/view_processor.rb +129 -0
- data/lib/view_processor/augmented_simple_list.rb +44 -0
- data/lib/view_processor/hash_pretty_print.rb +123 -0
- data/lib/view_processor/simple_list.rb +156 -0
- data/lib/view_processor/table_print.rb +309 -0
- data/lib/violation.rb +86 -0
- data/lib/violation/attribute.rb +76 -0
- data/lib/violation/fix.rb +26 -0
- data/lib/violation/fix/result.rb +73 -0
- data/lib/violation/fix/result/error.rb +34 -0
- data/lib/violation/fix/set_attribute.rb +41 -0
- data/lib/violation/sub_classes.rb +60 -0
- data/puppet/manifests/init.pp +72 -0
- data/puppet/manifests/params.pp +16 -0
- data/puppet/r8meta.puppet.yml +35 -0
- data/puppet/templates/bash_profile.erb +2 -0
- data/puppet/templates/client.conf.erb +1 -0
- data/puppet/templates/dtkclient.erb +2 -0
- data/spec/component_module_spec.rb +34 -0
- data/spec/dependency_spec.rb +6 -0
- data/spec/dtk_shell_spec.rb +13 -0
- data/spec/dtk_spec.rb +33 -0
- data/spec/lib/spec_helper.rb +10 -0
- data/spec/lib/spec_thor.rb +108 -0
- data/spec/node_template_spec.rb +24 -0
- data/spec/project_spec.rb +6 -0
- data/spec/repo_spec.rb +7 -0
- data/spec/response_spec.rb +52 -0
- data/spec/service_module_spec.rb +38 -0
- data/spec/service_spec.rb +50 -0
- data/spec/state_change_spec.rb +7 -0
- data/spec/table_print_spec.rb +48 -0
- data/spec/target_spec.rb +57 -0
- data/spec/task_spec.rb +28 -0
- data/views/assembly/augmented_simple_list.rb +12 -0
- data/views/assembly_template/augmented_simple_list.rb +12 -0
- data/views/list_task/augmented_simple_list.rb +12 -0
- metadata +421 -0
|
@@ -0,0 +1,94 @@
|
|
|
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 NodeTemplate < CommandBaseThor
|
|
20
|
+
|
|
21
|
+
def self.pretty_print_cols()
|
|
22
|
+
PPColumns.get(:node)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.extended_context()
|
|
26
|
+
{
|
|
27
|
+
:context => {
|
|
28
|
+
:add_component => "component_template"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.validation_list(context_params)
|
|
34
|
+
get_cached_response(:node_template, "node/list", {:subtype => 'template'})
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# desc "list --all -t [TARGET-NAME]", "List all node templates."
|
|
38
|
+
desc "list", "List all node templates."
|
|
39
|
+
method_option :all, :type => :boolean, :default => false
|
|
40
|
+
method_option "target_identifier",:aliases => "-t" ,
|
|
41
|
+
:type => :string,
|
|
42
|
+
:banner => "TARGET-IDENTIFIER",
|
|
43
|
+
:desc => "Name or ID of desired target"
|
|
44
|
+
def list(context_params)
|
|
45
|
+
post_body = {
|
|
46
|
+
:subtype => 'template',
|
|
47
|
+
:target_indentifier => options.target_identifier,
|
|
48
|
+
:is_list_all => options.all
|
|
49
|
+
}
|
|
50
|
+
response = post rest_url("node/list"), post_body
|
|
51
|
+
response.render_table(options.all ? :node_template_all : :node_template)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
#TODO: this may be moved to just be a utility fn
|
|
55
|
+
desc "image-upgrade OLD-IMAGE-ID NEW-IMAGE-ID", "Upgrade use of OLD-IMAGE-ID to NEW-IMAGE-ID"
|
|
56
|
+
def image_upgrade(context_params)
|
|
57
|
+
old_image_id, new_image_id = context_params.retrieve_arguments([:option_1!, :option_2!],method_argument_names)
|
|
58
|
+
post_body = {
|
|
59
|
+
:old_image_id => old_image_id,
|
|
60
|
+
:new_image_id => new_image_id
|
|
61
|
+
}
|
|
62
|
+
post rest_url("node/image_upgrade"), post_body
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
desc "add-node-template NODE-TEMPLATE-NAME [-t TARGET-NAME/ID] --os OS --image-id IMAGE-ID --size SIZE[,SIZE2,..]", "Add new node template"
|
|
66
|
+
method_option "target",:aliases => "-t"
|
|
67
|
+
method_option "os"
|
|
68
|
+
method_option "image-id",:aliases => "-i"
|
|
69
|
+
method_option "size",:aliases => "-s"
|
|
70
|
+
def add_node_template(context_params)
|
|
71
|
+
node_template_name = context_params.retrieve_arguments([:option_1!],method_argument_names)
|
|
72
|
+
size_array = options[:size] && options[:size].split(',')
|
|
73
|
+
|
|
74
|
+
post_body = post_body(
|
|
75
|
+
:node_template_name => node_template_name,
|
|
76
|
+
:target_id => options['target'],
|
|
77
|
+
:operating_system => required_option('os'),
|
|
78
|
+
:image_id => required_option('image-id'),
|
|
79
|
+
:size_array => size_array
|
|
80
|
+
)
|
|
81
|
+
post rest_url("node/add_node_template"), post_body
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
desc "delete-node-template NODE-TEMPLATE-NAME", "Delete node template"
|
|
85
|
+
def delete_node_template(context_params)
|
|
86
|
+
node_template_name = context_params.retrieve_arguments([:option_1!],method_argument_names)
|
|
87
|
+
post_body = post_body(
|
|
88
|
+
:node_template_name => node_template_name
|
|
89
|
+
)
|
|
90
|
+
post rest_url("node/delete_node_template"), post_body
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
end
|
|
94
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
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 Project < CommandBaseThor
|
|
20
|
+
|
|
21
|
+
def self.pretty_print_cols()
|
|
22
|
+
PPColumns.get(:project)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
desc "list","List projects"
|
|
26
|
+
def list(context_params)
|
|
27
|
+
search_hash = SearchHash.new()
|
|
28
|
+
search_hash.cols = pretty_print_cols()
|
|
29
|
+
post rest_url("project/list"), search_hash.post_body_hash()
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
@@ -0,0 +1,233 @@
|
|
|
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 Provider < CommandBaseThor
|
|
20
|
+
|
|
21
|
+
def self.valid_children()
|
|
22
|
+
[:target]
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.all_children()
|
|
26
|
+
[:target]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.validation_list(context_params)
|
|
30
|
+
get_cached_response(:provider, "target/list", {:subtype => :template })
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.override_allowed_methods()
|
|
34
|
+
return DTK::Shell::OverrideTasks.new({
|
|
35
|
+
:command_only => {
|
|
36
|
+
:target => [
|
|
37
|
+
['delete-and-destroy',"delete-and-destroy TARGET-NAME","# Deletes target"],
|
|
38
|
+
['list',"list","# Lists available targets."]
|
|
39
|
+
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
:identifier_only => {
|
|
43
|
+
:target => [
|
|
44
|
+
['list-nodes',"list-nodes","# Lists node instances in given targets."],
|
|
45
|
+
['list-services',"list-services","# Lists assembly instances in given targets."]
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def self.valid_child?(name_of_sub_context)
|
|
52
|
+
Provider.valid_children().include?(name_of_sub_context.to_sym)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
desc "create-provider-ec2 PROVIDER-NAME [--keypair KEYPAIR] [--security-group SECURITY-GROUP(S)]", "Create provider for ec2 vpc or classic. Multiple security groups separated with ',' (gr1,gr2,gr3,...)"
|
|
56
|
+
method_option :keypair, :type => :string
|
|
57
|
+
method_option :security_group, :type => :string, :aliases => '--security-groups'
|
|
58
|
+
# TODO: made this a hidden option; needs to be updated because now choice if vpc or classic
|
|
59
|
+
method_option :bootstrap, :type => :boolean, :default => false
|
|
60
|
+
def create_provider_ec2(context_params)
|
|
61
|
+
provider_name = context_params.retrieve_arguments([:option_1!],method_argument_names)
|
|
62
|
+
provider_type = 'ec2'
|
|
63
|
+
|
|
64
|
+
iaas_properties = Hash.new
|
|
65
|
+
|
|
66
|
+
keypair, security_group = context_params.retrieve_thor_options([:keypair, :security_group], options)
|
|
67
|
+
|
|
68
|
+
iaas_properties.merge!(:keypair => keypair) if keypair
|
|
69
|
+
if security_group
|
|
70
|
+
if security_group.end_with?(',')
|
|
71
|
+
raise DtkValidationError.new("Multiple security groups should be separated with ',' and without spaces between them (e.g. --security_groups gr1,gr2,gr3,...) ")
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
security_groups = security_group.split(',')
|
|
75
|
+
|
|
76
|
+
if (security_groups.empty? || security_groups.size==1)
|
|
77
|
+
iaas_properties.merge!(:security_group => security_group)
|
|
78
|
+
else
|
|
79
|
+
iaas_properties.merge!(:security_group_set => security_groups)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
result = Shell::InteractiveWizard::interactive_user_input(
|
|
84
|
+
{'IAAS Credentials' => { :type => :group, :options => [
|
|
85
|
+
{:key => {}},
|
|
86
|
+
{:secret => {}}
|
|
87
|
+
]}})
|
|
88
|
+
access_key, secret_key = result['IAAS Credentials'].values_at(:key, :secret)
|
|
89
|
+
iaas_properties.merge!(:key => access_key,:secret => secret_key)
|
|
90
|
+
|
|
91
|
+
# Remove sensitive readline history
|
|
92
|
+
OsUtil.pop_readline_history(2)
|
|
93
|
+
|
|
94
|
+
post_body = {
|
|
95
|
+
:iaas_properties => iaas_properties,
|
|
96
|
+
:provider_name => provider_name,
|
|
97
|
+
:iaas_type => 'ec2',
|
|
98
|
+
:no_bootstrap => ! options.bootstrap?
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
response = post rest_url("target/create_provider"), post_body
|
|
102
|
+
@@invalidate_map << :provider
|
|
103
|
+
|
|
104
|
+
response
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
desc "create-provider-physical PROVIDER-NAME", "Create provider to manage physical nodes."
|
|
108
|
+
def create_provider_physical(context_params)
|
|
109
|
+
provider_name = context_params.retrieve_arguments([:option_1!],method_argument_names)
|
|
110
|
+
|
|
111
|
+
# Remove sensitive readline history
|
|
112
|
+
OsUtil.pop_readline_history(2)
|
|
113
|
+
|
|
114
|
+
post_body = {
|
|
115
|
+
:provider_name => provider_name,
|
|
116
|
+
:iaas_type => 'physical'
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
response = post rest_url("target/create_provider"), post_body
|
|
120
|
+
@@invalidate_map << :provider
|
|
121
|
+
|
|
122
|
+
response
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
=begin
|
|
126
|
+
TODO: deprecated until this can be in sync with create-targets from target context where params depend on type
|
|
127
|
+
|
|
128
|
+
desc "PROVIDER-ID/NAME create-target [TARGET-NAME] --region REGION --keypair KEYPAIR --security-group SECURITY-GROUP(S)", "Create target based on given provider"
|
|
129
|
+
method_option :region, :type => :string
|
|
130
|
+
method_option :keypair, :type => :string
|
|
131
|
+
method_option :security_group, :type => :string, :aliases => '--security-groups'
|
|
132
|
+
def create_target(context_params)
|
|
133
|
+
# we use :target_id but that will retunr provider_id (another name for target template ID)
|
|
134
|
+
provider_id, target_name = context_params.retrieve_arguments([:provider_id!, :option_1],method_argument_names)
|
|
135
|
+
region, keypair, security_group = context_params.retrieve_thor_options([:region!, :keypair!, :security_group!], options)
|
|
136
|
+
|
|
137
|
+
#TODO: data-driven check if legal provider type and then what options needed depending on provider type
|
|
138
|
+
iaas_properties = Hash.new
|
|
139
|
+
Shell::InteractiveWizard.validate_region(region)
|
|
140
|
+
|
|
141
|
+
security_groups = []
|
|
142
|
+
raise DtkValidationError.new("Multiple security groups should be separated with ',' and without spaces between them (e.g. --security_groups gr1,gr2,gr3,...) ") if security_group.end_with?(',')
|
|
143
|
+
|
|
144
|
+
security_groups = security_group.split(',')
|
|
145
|
+
iaas_properties.merge!(:keypair => keypair)
|
|
146
|
+
|
|
147
|
+
if (security_groups.empty? || security_groups.size==1)
|
|
148
|
+
iaas_properties.merge!(:security_group => security_group)
|
|
149
|
+
else
|
|
150
|
+
iaas_properties.merge!(:security_group_set => security_groups)
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
post_body = {
|
|
154
|
+
:provider_id => provider_id,
|
|
155
|
+
:region => region,
|
|
156
|
+
:iaas_properties => iaas_properties
|
|
157
|
+
}
|
|
158
|
+
post_body.merge!(:target_name => target_name) if target_name
|
|
159
|
+
response = post rest_url("target/create"), post_body
|
|
160
|
+
@@invalidate_map << :target
|
|
161
|
+
|
|
162
|
+
response
|
|
163
|
+
end
|
|
164
|
+
=end
|
|
165
|
+
|
|
166
|
+
desc "list","Lists available providers."
|
|
167
|
+
def list(context_params)
|
|
168
|
+
if context_params.is_there_command?(:"target")
|
|
169
|
+
list_targets(context_params)
|
|
170
|
+
else
|
|
171
|
+
response = post rest_url("target/list"), { :subtype => :template }
|
|
172
|
+
response.render_table(:provider)
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
#TODO: Aldin; wanted to name this list_targets, but did not know how to do so w/o conflicting with desc "PROVIDER-ID/NAME list-targets
|
|
177
|
+
# Aldin: moved this to target base context (target>list)
|
|
178
|
+
#
|
|
179
|
+
# desc "list-all-targets","Lists all targets for all providers."
|
|
180
|
+
# def list_all_targets(context_params)
|
|
181
|
+
# response = post rest_url("target/list"), { :subtype => :instance }
|
|
182
|
+
# response.render_table(:target)
|
|
183
|
+
# end
|
|
184
|
+
|
|
185
|
+
desc "PROVIDER-ID/NAME list-targets", "List targets"
|
|
186
|
+
def list_targets(context_params)
|
|
187
|
+
provider_id = context_params.retrieve_arguments([:provider_id!],method_argument_names)
|
|
188
|
+
|
|
189
|
+
response = post rest_url("target/list"), { :subtype => :instance, :parent_id => provider_id }
|
|
190
|
+
response.render_table(:target)
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
desc "delete-and-destroy PROVIDER-NAME [-y]","Deletes target provider, its targets, and their assemblies"
|
|
194
|
+
method_option :force, :aliases => '-y', :type => :boolean, :default => false
|
|
195
|
+
def delete_and_destroy(context_params)
|
|
196
|
+
provider_id = context_params.retrieve_arguments([:option_1!],method_argument_names)
|
|
197
|
+
|
|
198
|
+
unless options.force?
|
|
199
|
+
return unless Console.confirmation_prompt("Are you sure you want to delete provider '#{provider_id}' and all target and service instances under it" +'?')
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
post_body = {
|
|
203
|
+
:target_id => provider_id,
|
|
204
|
+
:type => 'template'
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
@@invalidate_map << :provider
|
|
208
|
+
|
|
209
|
+
response = post(rest_url("target/delete_and_destroy"),post_body)
|
|
210
|
+
return response unless response.ok?
|
|
211
|
+
if info_array = response.data['info']
|
|
212
|
+
info_array.each{|info_msg|OsUtil.print(info_msg, :yellow)}
|
|
213
|
+
end
|
|
214
|
+
Response::Ok.new()
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
no_tasks do
|
|
218
|
+
|
|
219
|
+
def decompose_provider_type_and_name(composed_name)
|
|
220
|
+
provider_type, provider_name = composed_name.split(':')
|
|
221
|
+
|
|
222
|
+
if (provider_type.nil? || provider_name.nil? || provider_type.empty? || provider_name.empty?)
|
|
223
|
+
raise DtkValidationError.new("Provider name and type are required parameters and should be provided in format PROVIDER-TYPE:PROVIDER-NAME")
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
return [provider_type, provider_name]
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
end
|
|
233
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
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 Remotes < CommandBaseThor
|
|
20
|
+
|
|
21
|
+
def self.valid_children()
|
|
22
|
+
[]
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# REMOTE INTERACTION
|
|
26
|
+
desc "push-remote", "Push local changes to remote git repository"
|
|
27
|
+
method_option :force, :aliases => '--force', :type => :boolean, :default => false
|
|
28
|
+
def push_remote(context_params)
|
|
29
|
+
raise "NOT IMPLEMENTED"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
desc "list-remotes", "List git remotes for given module"
|
|
33
|
+
def list_remotes(context_params)
|
|
34
|
+
raise "NOT IMPLEMENTED"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
desc "add-remote", "Add git remote for given module"
|
|
38
|
+
def add_remote(context_params)
|
|
39
|
+
raise "NOT IMPLEMENTED"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
desc "remove-remote", "Remove git remote for given module"
|
|
43
|
+
method_option :force, :aliases => '-y', :type => :boolean, :default => false
|
|
44
|
+
def remove_remote(context_params)
|
|
45
|
+
raise "NOT IMPLEMENTED"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,941 @@
|
|
|
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 'rest_client'
|
|
19
|
+
require 'json'
|
|
20
|
+
require 'colorize'
|
|
21
|
+
require 'yaml'
|
|
22
|
+
|
|
23
|
+
dtk_require_from_base('dtk_logger')
|
|
24
|
+
dtk_require_from_base('util/os_util')
|
|
25
|
+
dtk_require_from_base('command_helper')
|
|
26
|
+
dtk_require_from_base('task_status')
|
|
27
|
+
dtk_require_common_commands('thor/set_required_attributes')
|
|
28
|
+
dtk_require_common_commands('thor/edit')
|
|
29
|
+
dtk_require_common_commands('thor/purge_clone')
|
|
30
|
+
dtk_require_common_commands('thor/assembly_workspace')
|
|
31
|
+
dtk_require_common_commands('thor/action_result_handler')
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
module DTK::Client
|
|
35
|
+
class Service < CommandBaseThor
|
|
36
|
+
no_tasks do
|
|
37
|
+
include TaskStatusMixin
|
|
38
|
+
include SetRequiredParamsMixin
|
|
39
|
+
include EditMixin
|
|
40
|
+
include PurgeCloneMixin
|
|
41
|
+
include AssemblyWorkspaceMixin
|
|
42
|
+
include ActionResultHandler
|
|
43
|
+
|
|
44
|
+
def get_assembly_name(assembly_id)
|
|
45
|
+
get_name_from_id_helper(assembly_id)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# def get_assembly_id(assembly_name)
|
|
49
|
+
# assembly_id = nil
|
|
50
|
+
# list = CommandBaseThor.get_cached_response(:service, "assembly/list", {})
|
|
51
|
+
|
|
52
|
+
# list.data.each do |item|
|
|
53
|
+
# if item["display_name"] == assembly_name
|
|
54
|
+
# assembly_id = item["id"]
|
|
55
|
+
# break
|
|
56
|
+
# end
|
|
57
|
+
# end
|
|
58
|
+
|
|
59
|
+
# raise DtkError,"[ERROR] Illegal name (#{assembly_name}) for service." unless assembly_id
|
|
60
|
+
# assembly_id
|
|
61
|
+
# end
|
|
62
|
+
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def self.whoami()
|
|
66
|
+
return :service, "assembly/list", {:subtype => 'instance'}
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def self.pretty_print_cols()
|
|
70
|
+
PPColumns.get(:assembly)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def self.valid_children()
|
|
74
|
+
[:utils]
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def self.invisible_context()
|
|
78
|
+
[:node]
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# using extended_context when we want to use autocomplete from other context
|
|
82
|
+
# e.g. we are in assembly/apache context and want to create-component we will use extended context to add
|
|
83
|
+
# component-templates to autocomplete
|
|
84
|
+
def self.extended_context()
|
|
85
|
+
{
|
|
86
|
+
:context => {
|
|
87
|
+
:create_node => "node_template",
|
|
88
|
+
:create_node_group => "node_template",
|
|
89
|
+
:add_component_dependency => "component_template"
|
|
90
|
+
},
|
|
91
|
+
:command => {
|
|
92
|
+
:add_component => {
|
|
93
|
+
:endpoint => "component_template",
|
|
94
|
+
:url => "component/list",
|
|
95
|
+
:opts => {:subtype=>"template", :ignore => "test_module", :hide_assembly_cmps => "true"}
|
|
96
|
+
},
|
|
97
|
+
:edit_component_module => {
|
|
98
|
+
:endpoint => "assembly",
|
|
99
|
+
:url => "assembly/info_about",
|
|
100
|
+
:opts => {:subtype=>"instance", :about=>"modules"}
|
|
101
|
+
},
|
|
102
|
+
:push_component_module_updates => {
|
|
103
|
+
:endpoint => "assembly",
|
|
104
|
+
:url => "assembly/info_about",
|
|
105
|
+
:opts => {:subtype=>"instance", :about=>"modules"}
|
|
106
|
+
},
|
|
107
|
+
:delete_node => {
|
|
108
|
+
:endpoint => "assembly",
|
|
109
|
+
:url => "assembly/get_nodes_without_node_groups"
|
|
110
|
+
},
|
|
111
|
+
:delete_node_group => {
|
|
112
|
+
:endpoint => "assembly",
|
|
113
|
+
:url => "assembly/get_node_groups"
|
|
114
|
+
},
|
|
115
|
+
:pull_base_component_module => {
|
|
116
|
+
:endpoint => "assembly",
|
|
117
|
+
:url => "assembly/info_about",
|
|
118
|
+
:opts => {:subtype=>"instance", :about=>"modules"}
|
|
119
|
+
},
|
|
120
|
+
:action_info => {
|
|
121
|
+
:endpoint => "assembly",
|
|
122
|
+
:url => "assembly/task_action_list"
|
|
123
|
+
},
|
|
124
|
+
:exec => {
|
|
125
|
+
:endpoint => "assembly",
|
|
126
|
+
:url => "assembly/list_actions"
|
|
127
|
+
},
|
|
128
|
+
:exec_sync => {
|
|
129
|
+
:endpoint => "assembly",
|
|
130
|
+
:url => "assembly/list_actions"
|
|
131
|
+
}
|
|
132
|
+
# TODO: DEPRECATE execute_workflow
|
|
133
|
+
# :execute_workflow => {
|
|
134
|
+
# :endpoint => "assembly",
|
|
135
|
+
# :url => "assembly/task_action_list"
|
|
136
|
+
# }
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# this includes children of children
|
|
142
|
+
def self.all_children()
|
|
143
|
+
# [:node, :component, :attribute]
|
|
144
|
+
[:node]
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def self.multi_context_children()
|
|
148
|
+
[[:utils],[:node, :utils]]
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def self.valid_child?(name_of_sub_context)
|
|
152
|
+
return Service.valid_children().include?(name_of_sub_context.to_sym)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def self.validation_list(context_params)
|
|
156
|
+
get_cached_response(:service, "assembly/list", {})
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# TODO: Hack which is necessery for the specific problem (DTK-541), something to reconsider down the line
|
|
160
|
+
# at this point not sure what would be clenear solution
|
|
161
|
+
|
|
162
|
+
# :all => include both for commands with command and identifier
|
|
163
|
+
# :command_only => only on command level
|
|
164
|
+
# :identifier_only => only on identifier level for given entity (command)
|
|
165
|
+
#
|
|
166
|
+
def self.override_allowed_methods()
|
|
167
|
+
override_methods = {
|
|
168
|
+
:all => {
|
|
169
|
+
# :node => [
|
|
170
|
+
# ['delete-component',"delete-component COMPONENT-ID","# Delete component from assembly's node"],
|
|
171
|
+
# ['list-components',"list-components","# List components associated with assembly's node."],
|
|
172
|
+
# ['list-attributes',"list-attributes","# List attributes associated with assembly's node."]
|
|
173
|
+
# ],
|
|
174
|
+
:component => [
|
|
175
|
+
['list-attributes',"list-attributes","# List attributes associated with given component."]
|
|
176
|
+
]
|
|
177
|
+
},
|
|
178
|
+
:command_only => {
|
|
179
|
+
:attribute => [
|
|
180
|
+
['list-attributes',"list-attributes","# List attributes."]
|
|
181
|
+
],
|
|
182
|
+
:node => [
|
|
183
|
+
['delete',"delete NODE-NAME/ID [-y] ","# Delete node, terminating it if the node has been spun up."],
|
|
184
|
+
['list',"list","# List nodes."]
|
|
185
|
+
],
|
|
186
|
+
:component => [
|
|
187
|
+
['delete',"delete COMPONENT-NAME/ID [-y] ","# Delete component from workspace."],
|
|
188
|
+
['list-components',"list-components","# List components."]
|
|
189
|
+
],
|
|
190
|
+
:utils => [
|
|
191
|
+
# TODO: DTK-2027 might subsume by the dtk actions; currently server changes does not support this command
|
|
192
|
+
# ['execute-tests',"execute-tests [--component COMPONENT-NAME] [--timeout TIMEOUT]","# Execute tests. --component filters execution per component, --timeout changes default execution timeout."],
|
|
193
|
+
['get-netstats',"get-netstats","# Get netstats."],
|
|
194
|
+
['get-ps',"get-ps [--filter PATTERN]","# Get ps."],
|
|
195
|
+
['grep',"grep LOG-PATH NODE-ID-PATTERN GREP-PATTERN [--first]","# Grep log from multiple nodes. --first option returns first match (latest log entry)."],
|
|
196
|
+
['tail',"tail LOG-PATH NODE-NAME [REGEX-PATTERN] [--more]","# Tail log from specified node. CTRL+C to quit."]
|
|
197
|
+
],
|
|
198
|
+
:node_utils => [
|
|
199
|
+
['get-netstats',"get-netstats","# Get netstats."],
|
|
200
|
+
['get-ps',"get-ps [--filter PATTERN]","# Get ps."],
|
|
201
|
+
['grep',"grep LOG-PATH GREP-PATTERN [--first]","# Grep log from node. --first option returns first match (latest log entry)."],
|
|
202
|
+
['tail',"tail LOG-PATH [REGEX-PATTERN] [--more]","# Tail log from node. CTRL+C to quit."]
|
|
203
|
+
]
|
|
204
|
+
},
|
|
205
|
+
:identifier_only => {
|
|
206
|
+
:node => [
|
|
207
|
+
['add-component',"add-component COMPONENT","# Add a component to the node."],
|
|
208
|
+
['delete-component',"delete-component COMPONENT-NAME [-y]","# Delete component from service's node"],
|
|
209
|
+
['info',"info","# Return info about node instance belonging to given workspace."],
|
|
210
|
+
['list-attributes',"list-attributes","# List attributes associated with service's node."],
|
|
211
|
+
['list-components',"list-components","# List components associated with service's node."],
|
|
212
|
+
['set-attribute',"set-attribute ATTRIBUTE-NAME [VALUE] [-u]","# (Un)Set attribute value. The option -u will unset the attribute's value."],
|
|
213
|
+
['start', "start", "# Start node instance."],
|
|
214
|
+
['stop', "stop", "# Stop node instance."],
|
|
215
|
+
['ssh', "ssh REMOTE-USER [-i PATH-TO-PEM]","# SSH into node, optional parameters are path to identity file."]
|
|
216
|
+
],
|
|
217
|
+
:node_group => [
|
|
218
|
+
['start', "start", "# 2Start node instance."],
|
|
219
|
+
['stop', "stop", "# 2Stop node instance."],
|
|
220
|
+
['ssh', "ssh REMOTE-USER [-i PATH-TO-PEM]","# 2SSH into node, optional parameters are path to identity file."]
|
|
221
|
+
],
|
|
222
|
+
:component => [
|
|
223
|
+
['info',"info","# Return info about component instance belonging to given node."],
|
|
224
|
+
['edit',"edit","# Edit component module related to given component."],
|
|
225
|
+
['link-components',"link-components ANTECEDENT-CMP-NAME [DEPENDENCY-NAME]","#Link components to satisfy component dependency relationship."],
|
|
226
|
+
['list-component-links',"list-component-links","# List component's links to other components."],
|
|
227
|
+
['unlink-components',"unlink-components SERVICE-TYPE","# Delete service link on component."]
|
|
228
|
+
],
|
|
229
|
+
:attribute => [
|
|
230
|
+
['info',"info","# Return info about attribute instance belonging to given component."]
|
|
231
|
+
]
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if DTK::Configuration.get(:development_mode)
|
|
236
|
+
override_methods[:identifier_only][:node] << ['test-action-agent', "test-action-agent BASH-COMMAND-LINE", "Run bash command on test action agent"]
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
return DTK::Shell::OverrideTasks.new(override_methods, [:utils])
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
desc "SERVICE-NAME/ID destroy-and-reset-nodes [-y]", "Terminates all nodes, but keeps config state so they can be spun up from scratch."
|
|
243
|
+
method_option :force, :aliases => '-y', :type => :boolean, :default => false
|
|
244
|
+
def destroy_and_reset_nodes(context_params)
|
|
245
|
+
destroy_and_reset_nodes_aux(context_params)
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
desc "SERVICE-NAME/ID start [NODE-NAME]", "Starts all the service nodes. A single node can be selected."
|
|
249
|
+
def start(context_params)
|
|
250
|
+
start_aux(context_params)
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
desc "SERVICE-NAME/ID stop [NODE-NAME]", "Stops all the service nodes. A single node can be selected."
|
|
254
|
+
method_option :legacy, :aliases => '--legacy', :type => :boolean, :default => false
|
|
255
|
+
def stop(context_params)
|
|
256
|
+
stop_aux(context_params)
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
desc "SERVICE-NAME/ID cancel-task [TASK_ID]", "Cancels an executing task. If task id is omitted, this command cancels the most recent executing task."
|
|
261
|
+
def cancel_task(context_params)
|
|
262
|
+
cancel_task_aux(context_params)
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
desc "SERVICE-NAME/ID create-assembly [NAMESPACE:]SERVICE-MODULE-NAME ASSEMBLY-NAME [-m DESCRIPTION]", "Create a new assembly from this service instance in the designated service module."
|
|
266
|
+
method_option "description",:aliases => "-m" ,
|
|
267
|
+
:type => :string,
|
|
268
|
+
:banner => "DESCRIPTION"
|
|
269
|
+
def create_assembly(context_params)
|
|
270
|
+
if options.description?
|
|
271
|
+
if context_params.method_arguments.length > 2
|
|
272
|
+
raise DtkError, "The number of arguments is invalid. If you are using -m with multiple words please put them under quotation marks"
|
|
273
|
+
end
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
assembly_id, service_module_name, assembly_template_name = context_params.retrieve_arguments([:service_id!,:option_1!,:option_2!],method_argument_names)
|
|
277
|
+
# need default_namespace for create-assembly because need to check if local service-module directory existst in promote_assembly_aux
|
|
278
|
+
resp = post rest_url("namespace/default_namespace_name")
|
|
279
|
+
return resp unless resp.ok?
|
|
280
|
+
default_namespace = resp.data
|
|
281
|
+
|
|
282
|
+
opts = {:default_namespace => default_namespace}
|
|
283
|
+
if description = options.description
|
|
284
|
+
description = "#{description}"
|
|
285
|
+
opts.merge!(:description => description)
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
response = promote_assembly_aux(:create,assembly_id,service_module_name,assembly_template_name,opts)
|
|
289
|
+
return response unless response.ok?
|
|
290
|
+
|
|
291
|
+
@@invalidate_map << :assembly
|
|
292
|
+
@@invalidate_map << :service
|
|
293
|
+
|
|
294
|
+
Response::Ok.new()
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
desc "SERVICE-NAME/ID exec [NODE/NODE-GROUP/]ACTION [ACTION-PARAMS]", "Execute action asynchronously"
|
|
298
|
+
def exec(context_params)
|
|
299
|
+
exec_aux(context_params)
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
desc "SERVICE-NAME/ID exec-sync [NODE/NODE-GROUP/]ACTION [ACTION-PARAMS]", "Execute action synchronously"
|
|
303
|
+
def exec_sync(context_params)
|
|
304
|
+
exec_sync_aux(context_params)
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
# desc "SERVICE-NAME/ID exec SERVICE-LEVEL-ACTION [PARAMS] [--stream-results]", "Execute a service level action", :hide => true
|
|
308
|
+
# method_option 'stream-results', :aliases => '-s', :type => :boolean, :default => false, :desc => "Stream results"
|
|
309
|
+
# def exec(context_params)
|
|
310
|
+
# opts = {}
|
|
311
|
+
# opts.merge!(:mode => :stream) if context_params.pure_cli_mode or options['stream-results']
|
|
312
|
+
# converge_aux(context_params, opts)
|
|
313
|
+
# end
|
|
314
|
+
|
|
315
|
+
# TODO: DEPRECATE: keeping around for backward compatibiity but will be deprecating execute-workflow
|
|
316
|
+
# desc "SERVICE-NAME/ID execute-workflow WORKFLOW-ACTION [WORKFLOW-PARAMS] [-m COMMIT-MSG]", "Execute workflow.", :hide => true
|
|
317
|
+
# method_option "commit_msg",:aliases => "-m" ,
|
|
318
|
+
# :type => :string,
|
|
319
|
+
# :banner => "COMMIT-MSG",
|
|
320
|
+
# :desc => "Commit message"
|
|
321
|
+
# def execute_workflow(context_params)
|
|
322
|
+
# OsUtil.print_deprecate_message("Command 'execute-workflow' will be deprecated; use 'exec' instead")
|
|
323
|
+
# converge(context_params)
|
|
324
|
+
# end
|
|
325
|
+
|
|
326
|
+
desc "SERVICE-NAME/ID converge [-m COMMIT-MSG] [--stream-results]", "Converge service instance."
|
|
327
|
+
method_option "commit_msg",:aliases => "-m" ,
|
|
328
|
+
:type => :string,
|
|
329
|
+
:banner => "COMMIT-MSG",
|
|
330
|
+
:desc => "Commit message"
|
|
331
|
+
method_option 'stream-results', :aliases => '-s', :type => :boolean, :default => false, :desc => "Stream results"
|
|
332
|
+
def converge(context_params)
|
|
333
|
+
opts = {}
|
|
334
|
+
opts.merge!(:mode => :stream) if context_params.pure_cli_mode or options['stream-results']
|
|
335
|
+
converge_aux(context_params, opts)
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
# desc "SERVICE-NAME/ID execute-action COMPONENT-INSTANCE [ACTION-NAME [ACTION-PARAMS]]", "Converge the component or execute tha action on the component.", :hide => true
|
|
339
|
+
# def execute_action(context_params)
|
|
340
|
+
# execute_ad_hoc_action_aux(context_params)
|
|
341
|
+
# end
|
|
342
|
+
|
|
343
|
+
desc "SERVICE-NAME/ID list-actions [--type TYPE]", "List the actions defined on components in the service instance."
|
|
344
|
+
method_option :type, :aliases => '-t'
|
|
345
|
+
def list_actions(context_params)
|
|
346
|
+
list_actions_aux(context_params)
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
desc "SERVICE-NAME/ID push-assembly-updates [NAMESPACE:SERVICE-MODULE-NAME/ASSEMBLY-NAME]", "Push changes made to this service instance to the designated assembly; default is parent assembly."
|
|
350
|
+
def push_assembly_updates(context_params)
|
|
351
|
+
assembly_id, qualified_assembly_name = context_params.retrieve_arguments([:service_id!, :option_1], method_argument_names)
|
|
352
|
+
service_module_name, assembly_template_name =
|
|
353
|
+
if qualified_assembly_name
|
|
354
|
+
if qualified_assembly_name =~ /(^[^\/]*)\/([^\/]*$)/
|
|
355
|
+
[$1,$2]
|
|
356
|
+
else
|
|
357
|
+
raise DtkError, "The term (#{qualified_assembly_name}) must have form SERVICE-MODULE-NAME/ASSEMBLY-NAME"
|
|
358
|
+
end
|
|
359
|
+
else
|
|
360
|
+
[nil, nil]
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
response = promote_assembly_aux(:update, assembly_id, service_module_name, assembly_template_name, :use_module_namespace => true)
|
|
364
|
+
return response unless response.ok?
|
|
365
|
+
@@invalidate_map << :assembly
|
|
366
|
+
Response::Ok.new()
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
desc "SERVICE-NAME/ID pull-base-component-module COMPONENT-MODULE-NAME [--force] [--revert]", "Pull base component module changes to component module in the service"
|
|
370
|
+
method_option :force, :type => :boolean, :default => false, :aliases => '-f'
|
|
371
|
+
method_option :revert, :type => :boolean, :default => false, :aliases => '-r'
|
|
372
|
+
def pull_base_component_module(context_params)
|
|
373
|
+
pull_base_component_module_aux(context_params)
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
desc "SERVICE-NAME/ID push-component-module-updates COMPONENT-MODULE-NAME [--force]", "Push changes made to a component module in the service to its base component module."
|
|
377
|
+
method_option :force, :type => :boolean, :default => false, :aliases => '-f'
|
|
378
|
+
def push_component_module_updates(context_params)
|
|
379
|
+
push_module_updates_aux(context_params)
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
desc "SERVICE-NAME/ID edit-component-module COMPONENT-MODULE-NAME", "Edit a component module used in the service."
|
|
383
|
+
def edit_component_module(context_params)
|
|
384
|
+
edit_module_aux(context_params)
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
# desc "SERVICE-NAME/ID create-workflow WORKFLOW-NAME [--from BASE-WORKFLOW-NAME]", "Create a new workflow in the service instance."
|
|
388
|
+
# method_option :from, :type => :string
|
|
389
|
+
# def create_workflow(context_params)
|
|
390
|
+
# edit_or_create_workflow_aux(context_params,:create => true,:create_from => options.from)
|
|
391
|
+
# end
|
|
392
|
+
|
|
393
|
+
desc "SERVICE-NAME/ID edit-action [SERVICE-LEVEL-ACTION]", "Edit action in the service instance."
|
|
394
|
+
def edit_action(context_params)
|
|
395
|
+
edit_or_create_workflow_aux(context_params)
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
desc "SERVICE-NAME/ID edit-attributes [-n NODE] [-c COMPONENT] [-a ATTRIBUTE]", "Edit service's attributes."
|
|
399
|
+
method_option :node, :aliases => '-n'
|
|
400
|
+
method_option :component, :aliases => '-c'
|
|
401
|
+
method_option :attribute, :aliases => '-a'
|
|
402
|
+
def edit_attributes(context_params)
|
|
403
|
+
response = edit_attributes_aux(context_params)
|
|
404
|
+
|
|
405
|
+
@@invalidate_map << :assembly
|
|
406
|
+
@@invalidate_map << :assembly_node
|
|
407
|
+
@@invalidate_map << :service
|
|
408
|
+
@@invalidate_map << :service_node
|
|
409
|
+
|
|
410
|
+
response
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
=begin
|
|
414
|
+
TODO: will put in dot release and will rename to 'extend'
|
|
415
|
+
desc "ASSEMBLY-NAME/ID add EXTENSION-TYPE [-n COUNT]", "Adds a sub assembly template to the assembly"
|
|
416
|
+
method_option "count",:aliases => "-n" ,
|
|
417
|
+
:type => :string, #integer
|
|
418
|
+
:banner => "COUNT",
|
|
419
|
+
:desc => "Number of sub-assemblies to add"
|
|
420
|
+
def add_node(context_params)
|
|
421
|
+
assembly_id,service_add_on_name = context_params.retrieve_arguments([:assembly_id!,:option_1!],method_argument_names)
|
|
422
|
+
|
|
423
|
+
# create task
|
|
424
|
+
post_body = {
|
|
425
|
+
:assembly_id => assembly_id,
|
|
426
|
+
:service_add_on_name => service_add_on_name
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
post_body.merge!(:count => options.count) if options.count
|
|
430
|
+
|
|
431
|
+
response = post rest_url("assembly/add__service_add_on"), post_body
|
|
432
|
+
# when changing context send request for getting latest assemblies instead of getting from cache
|
|
433
|
+
@@invalidate_map << :assembly
|
|
434
|
+
|
|
435
|
+
return response
|
|
436
|
+
end
|
|
437
|
+
|
|
438
|
+
=end
|
|
439
|
+
|
|
440
|
+
# TODO: deprecating --wait since subsubsumed by mode
|
|
441
|
+
# desc "SERVICE-NAME/ID task-status [--wait] [--summarize]", "Get the task status of the running or last running service task."
|
|
442
|
+
desc "SERVICE-NAME/ID task-status [--mode MODE] [--summarize]", "Get the task status of the running or last running service task."
|
|
443
|
+
method_option "mode",:aliases => "-m" ,
|
|
444
|
+
:type => :string,
|
|
445
|
+
:banner => "MODE",
|
|
446
|
+
:desc => "Mode in which task status display; one of [stream,snapshot,refresh]; default is 'snapshot'"
|
|
447
|
+
method_option :summarize, :type => :boolean, :default => false, :aliases => '-s'
|
|
448
|
+
# TODO: leaving --wait in for backwards compatability
|
|
449
|
+
method_option :wait, :type => :boolean, :default => false
|
|
450
|
+
def task_status(context_params)
|
|
451
|
+
response = task_status_aw_aux(context_params)
|
|
452
|
+
@@invalidate_map << :service
|
|
453
|
+
@@invalidate_map << :service_node
|
|
454
|
+
response
|
|
455
|
+
end
|
|
456
|
+
|
|
457
|
+
desc "SERVICE-NAME/ID task-action-detail", "Get the task info of the running or last running service task."
|
|
458
|
+
def task_action_detail(context_params)
|
|
459
|
+
task_action_detail_aw_aux(context_params)
|
|
460
|
+
end
|
|
461
|
+
|
|
462
|
+
desc "SERVICE-NAME/ID list-nodes","List nodes associated with service."
|
|
463
|
+
def list_nodes(context_params)
|
|
464
|
+
list_nodes_aux(context_params)
|
|
465
|
+
end
|
|
466
|
+
|
|
467
|
+
desc "SERVICE-NAME/ID list-component-links","List component links."
|
|
468
|
+
def list_component_links(context_params)
|
|
469
|
+
list_component_links_aux(context_params)
|
|
470
|
+
end
|
|
471
|
+
|
|
472
|
+
desc "SERVICE-NAME/ID list-components [--deps]","List components associated with service."
|
|
473
|
+
method_option :deps, :type => :boolean, :default => false, :aliases => '-l'
|
|
474
|
+
def list_components(context_params)
|
|
475
|
+
list_components_aux(context_params)
|
|
476
|
+
end
|
|
477
|
+
|
|
478
|
+
desc "SERVICE-NAME/ID list-attributes [-f FORMAT] [-t TAG,..] [--links] [-n NODE] [-c COMPONENT] [-a ATTRIBUTE]","List attributes associated with service."
|
|
479
|
+
method_option :format, :aliases => '-f'
|
|
480
|
+
method_option :tags, :aliases => '-t'
|
|
481
|
+
method_option :links, :type => :boolean, :default => false, :aliases => '-l'
|
|
482
|
+
method_option :node, :aliases => '-n'
|
|
483
|
+
method_option :component, :aliases => '-c'
|
|
484
|
+
method_option :attribute, :aliases => '-a'
|
|
485
|
+
def list_attributes(context_params)
|
|
486
|
+
list_attributes_aux(context_params)
|
|
487
|
+
end
|
|
488
|
+
|
|
489
|
+
desc "SERVICE-NAME/ID list-component-modules","List component modules associated with service."
|
|
490
|
+
def list_component_modules(context_params)
|
|
491
|
+
list_modules_aux(context_params)
|
|
492
|
+
end
|
|
493
|
+
|
|
494
|
+
desc "SERVICE-NAME/ID list-tasks","List tasks associated with service."
|
|
495
|
+
def list_tasks(context_params)
|
|
496
|
+
list_tasks_aux(context_params)
|
|
497
|
+
end
|
|
498
|
+
|
|
499
|
+
desc "SERVICE-NAME/ID list-violations [ACTION] [--fix]", "Finds violations that must be corrected before converging the service or running the specified action."
|
|
500
|
+
method_option :fix, :aliases => '-f', :type => :boolean, :default => false, :banner => 'Run wizard to fix violations found'
|
|
501
|
+
def list_violations(context_params)
|
|
502
|
+
list_violations_aux(context_params)
|
|
503
|
+
end
|
|
504
|
+
|
|
505
|
+
desc "SERVICE-NAME/ID print-includes", "Finds includes in the service."
|
|
506
|
+
def print_includes(context_params)
|
|
507
|
+
print_includes_aux(context_params)
|
|
508
|
+
end
|
|
509
|
+
|
|
510
|
+
desc "SERVICE-NAME/ID action-info [SERVICE-LEVEL-ACTION]", "Get the contents of action associated with the service."
|
|
511
|
+
def action_info(context_params)
|
|
512
|
+
action_info_aux(context_params)
|
|
513
|
+
end
|
|
514
|
+
|
|
515
|
+
# desc "SERVICE-NAME/ID list-workflows", "List the workflows associated with the service.", :hide => true
|
|
516
|
+
# def list_workflows(context_params)
|
|
517
|
+
# workflow_list_aux(context_params)
|
|
518
|
+
# end
|
|
519
|
+
|
|
520
|
+
desc "list","List services."
|
|
521
|
+
def list(context_params)
|
|
522
|
+
assembly_id, node_id, component_id, attribute_id, about = context_params.retrieve_arguments([:service_id,:node_id,:component_id,:attribute_id,:option_1],method_argument_names)
|
|
523
|
+
detail_to_include = nil
|
|
524
|
+
|
|
525
|
+
if about
|
|
526
|
+
case about
|
|
527
|
+
when "nodes"
|
|
528
|
+
data_type = :node
|
|
529
|
+
when "components"
|
|
530
|
+
data_type = :component
|
|
531
|
+
detail_to_include = [:component_dependencies]
|
|
532
|
+
when "attributes"
|
|
533
|
+
data_type = :attribute
|
|
534
|
+
detail_to_include = [:attribute_links]
|
|
535
|
+
when "tasks"
|
|
536
|
+
data_type = :task
|
|
537
|
+
else
|
|
538
|
+
raise_validation_error_method_usage('list')
|
|
539
|
+
end
|
|
540
|
+
end
|
|
541
|
+
|
|
542
|
+
post_body = {
|
|
543
|
+
:assembly_id => assembly_id,
|
|
544
|
+
:node_id => node_id,
|
|
545
|
+
:component_id => component_id,
|
|
546
|
+
:subtype => 'instance'
|
|
547
|
+
}
|
|
548
|
+
post_body.merge!(:detail_to_include => detail_to_include) if detail_to_include
|
|
549
|
+
rest_endpoint = "assembly/info_about"
|
|
550
|
+
|
|
551
|
+
if context_params.is_last_command_eql_to?(:attribute)
|
|
552
|
+
raise DtkError, "Not supported command for current context level." if attribute_id
|
|
553
|
+
about, data_type = get_type_and_raise_error_if_invalid(about, "attributes", ["attributes"])
|
|
554
|
+
elsif context_params.is_last_command_eql_to?(:component)
|
|
555
|
+
if component_id
|
|
556
|
+
about, data_type = get_type_and_raise_error_if_invalid(about, "attributes", ["attributes"])
|
|
557
|
+
else
|
|
558
|
+
about, data_type = get_type_and_raise_error_if_invalid(about, "components", ["attributes", "components"])
|
|
559
|
+
end
|
|
560
|
+
elsif context_params.is_last_command_eql_to?(:node)
|
|
561
|
+
if node_id
|
|
562
|
+
about, data_type = get_type_and_raise_error_if_invalid(about, "components", ["attributes", "components"])
|
|
563
|
+
else
|
|
564
|
+
about, data_type = get_type_and_raise_error_if_invalid(about, "nodes", ["attributes", "components", "nodes"])
|
|
565
|
+
end
|
|
566
|
+
else
|
|
567
|
+
if assembly_id
|
|
568
|
+
about, data_type = get_type_and_raise_error_if_invalid(about, "nodes", ["attributes", "components", "nodes", "tasks"])
|
|
569
|
+
else
|
|
570
|
+
data_type = :assembly
|
|
571
|
+
post_body = { :subtype => 'instance', :detail_level => 'nodes',:include_namespaces => true}
|
|
572
|
+
rest_endpoint = "assembly/list"
|
|
573
|
+
end
|
|
574
|
+
end
|
|
575
|
+
|
|
576
|
+
post_body[:about] = about
|
|
577
|
+
response = post rest_url(rest_endpoint), post_body
|
|
578
|
+
|
|
579
|
+
# set render view to be used
|
|
580
|
+
response.render_table(data_type)
|
|
581
|
+
|
|
582
|
+
return response
|
|
583
|
+
end
|
|
584
|
+
|
|
585
|
+
desc "SERVICE-NAME/ID list-diffs COMPONENT-MODULE-NAME", "List diffs between module in service instance and base module."
|
|
586
|
+
def list_diffs(context_params)
|
|
587
|
+
list_remote_module_diffs(context_params)
|
|
588
|
+
end
|
|
589
|
+
|
|
590
|
+
desc "SERVICE-NAME/ID grant-access USER-ACCOUNT PUB-KEY-NAME [PATH-TO-PUB-KEY] [--nodes NODE-NAMES]", "Grants ssh access to user account USER-ACCOUNT for nodes in service instance"
|
|
591
|
+
method_option :nodes, :type => :string, :default => nil
|
|
592
|
+
def grant_access(context_params)
|
|
593
|
+
grant_access_aux(context_params)
|
|
594
|
+
end
|
|
595
|
+
|
|
596
|
+
desc "SERVICE-NAME/ID revoke-access USER-ACCOUNT PUB-KEY-NAME [PATH-TO-PUB-KEY] [--nodes NODE-NAMES]", "Revokes ssh access to user account USER-ACCOUNT for nodes in service instance"
|
|
597
|
+
method_option :nodes, :type => :string, :default => nil
|
|
598
|
+
def revoke_access(context_params)
|
|
599
|
+
revoke_access_aux(context_params)
|
|
600
|
+
end
|
|
601
|
+
|
|
602
|
+
desc "SERVICE-NAME/ID list-ssh-access", "List SSH access for each of the nodes"
|
|
603
|
+
def list_ssh_access(context_params)
|
|
604
|
+
list_ssh_access_aux(context_params)
|
|
605
|
+
end
|
|
606
|
+
|
|
607
|
+
desc "SERVICE-NAME/ID info", "Get info about content of the service."
|
|
608
|
+
def info(context_params)
|
|
609
|
+
info_aux(context_params)
|
|
610
|
+
end
|
|
611
|
+
|
|
612
|
+
desc "SERVICE-NAME/ID link-attributes TARGET-ATTR SOURCE-ATTR", "Link the value of the target attribute to the source attribute."
|
|
613
|
+
def link_attributes(context_params)
|
|
614
|
+
link_attributes_aux(context_params)
|
|
615
|
+
end
|
|
616
|
+
|
|
617
|
+
desc "delete-and-destroy NAME/ID [-y] [--force] [-r]", "Delete service instance, terminating any nodes that have been spun up. Use -r with target to delete all service instances staged into specified target."
|
|
618
|
+
method_option :y, :aliases => '-y', :type => :boolean, :default => false
|
|
619
|
+
method_option :force, :aliases => '-f', :type => :boolean, :default => false
|
|
620
|
+
method_option :recursive, :aliases => '-r', :type => :boolean, :default => false
|
|
621
|
+
def delete_and_destroy(context_params)
|
|
622
|
+
response = delete_and_destroy_aux(context_params)
|
|
623
|
+
@@invalidate_map << :assembly
|
|
624
|
+
@@invalidate_map << :assembly_node
|
|
625
|
+
@@invalidate_map << :service
|
|
626
|
+
@@invalidate_map << :service_node
|
|
627
|
+
@@invalidate_map << :service_module
|
|
628
|
+
response
|
|
629
|
+
end
|
|
630
|
+
|
|
631
|
+
desc "SERVICE-NAME/ID set-attribute ATTRIBUTE-NAME [VALUE] [-u] [-c] [-n]", "(Un)Set attribute value. The option -u will unset the attribute's value, -c to set component-attribute, -n to set node-attribute."
|
|
632
|
+
method_option :unset, :aliases => '-u', :type => :boolean, :default => false
|
|
633
|
+
method_option :component_attribute, :aliases => '-c', :type => :boolean, :default => false
|
|
634
|
+
method_option :node_attribute, :aliases => '-n', :type => :boolean, :default => false
|
|
635
|
+
def set_attribute(context_params)
|
|
636
|
+
response = set_attribute_aux(context_params)
|
|
637
|
+
return response unless response.ok?
|
|
638
|
+
|
|
639
|
+
@@invalidate_map << :assembly
|
|
640
|
+
@@invalidate_map << :assembly_node
|
|
641
|
+
@@invalidate_map << :service
|
|
642
|
+
@@invalidate_map << :service_node
|
|
643
|
+
|
|
644
|
+
response
|
|
645
|
+
end
|
|
646
|
+
|
|
647
|
+
desc "SERVICE-NAME/ID create-attribute ATTRIBUTE-NAME [VALUE] [--type DATATYPE] [--required] [--dynamic]", "Create a new attribute and optionally assign it a value."
|
|
648
|
+
method_option :required, :type => :boolean, :default => false
|
|
649
|
+
method_option :dynamic, :type => :boolean, :default => false
|
|
650
|
+
method_option "type",:aliases => "-t"
|
|
651
|
+
def create_attribute(context_params)
|
|
652
|
+
create_attribute_aux(context_params)
|
|
653
|
+
end
|
|
654
|
+
|
|
655
|
+
# using ^^ before NODE-NAME to remove this command from assembly/assembly_id/node/node_id but show in assembly/assembly_id
|
|
656
|
+
desc "SERVICE-NAME/ID create-node ^^NODE-NAME [-i IMAGE] [-s SIZE]", "Add (stage) a new node in the service."
|
|
657
|
+
method_option :image, :aliases => '-i', :type => :string
|
|
658
|
+
method_option :instance_size, :aliases => '-s', :type => :string
|
|
659
|
+
def create_node(context_params)
|
|
660
|
+
response = create_node_aux(context_params)
|
|
661
|
+
|
|
662
|
+
@@invalidate_map << :assembly
|
|
663
|
+
@@invalidate_map << :assembly_node
|
|
664
|
+
@@invalidate_map << :service
|
|
665
|
+
@@invalidate_map << :service_node
|
|
666
|
+
@@invalidate_map << :workspace
|
|
667
|
+
@@invalidate_map << :workspace_node
|
|
668
|
+
|
|
669
|
+
return response unless response.ok?
|
|
670
|
+
|
|
671
|
+
message = "Created node '#{response.data["display_name"]}'."
|
|
672
|
+
OsUtil.print(message, :yellow)
|
|
673
|
+
end
|
|
674
|
+
|
|
675
|
+
desc "SERVICE-NAME/ID create-node-group ^^NODE-GROUP-NAME [-i IMAGE] [-s SIZE] [-n CARDINALITY]", "Add (stage) a new node group in the service."
|
|
676
|
+
method_option :image, :aliases => '-i', :type => :string
|
|
677
|
+
method_option :instance_size, :aliases => '-s', :type => :string
|
|
678
|
+
method_option :cardinality, :aliases => '-n', :type => :string, :default => 1
|
|
679
|
+
def create_node_group(context_params)
|
|
680
|
+
response = create_node_group_aux(context_params)
|
|
681
|
+
return response unless response.ok?
|
|
682
|
+
|
|
683
|
+
@@invalidate_map << :assembly
|
|
684
|
+
@@invalidate_map << :assembly_node
|
|
685
|
+
@@invalidate_map << :service
|
|
686
|
+
@@invalidate_map << :service_node
|
|
687
|
+
@@invalidate_map << :workspace
|
|
688
|
+
@@invalidate_map << :workspace_node
|
|
689
|
+
|
|
690
|
+
message = "Created node group '#{response.data["display_name"]}'."
|
|
691
|
+
OsUtil.print(message, :yellow)
|
|
692
|
+
end
|
|
693
|
+
|
|
694
|
+
desc "SERVICE-NAME/ID link-components TARGET-CMP-NAME SOURCE-CMP-NAME [DEPENDENCY-NAME]","Link the target component to the source component."
|
|
695
|
+
def link_components(context_params)
|
|
696
|
+
link_components_aux(context_params)
|
|
697
|
+
end
|
|
698
|
+
|
|
699
|
+
# only supported at node-level
|
|
700
|
+
# using HIDE_FROM_BASE to hide this command from base context (dtk:/assembly>)
|
|
701
|
+
desc "SERVICE-NAME/ID add-component COMPONENT [--auto-complete]", "Add a component to the service. Use --auto-complete to link components automatically"
|
|
702
|
+
method_option :auto_complete, :type => :boolean, :default => true
|
|
703
|
+
def add_component(context_params)
|
|
704
|
+
response = create_component_aux(context_params)
|
|
705
|
+
|
|
706
|
+
@@invalidate_map << :service
|
|
707
|
+
@@invalidate_map << :service_node
|
|
708
|
+
|
|
709
|
+
response
|
|
710
|
+
end
|
|
711
|
+
|
|
712
|
+
# using ^^ before NODE-NAME to remove this command from assembly/assembly_id/node/node_id but show in assembly/assembly_id
|
|
713
|
+
desc "SERVICE-NAME/ID delete-node ^^NODE-NAME [-y] [--force]","Delete node, terminating it if the node has been spun up."
|
|
714
|
+
method_option :y, :aliases => '-y', :type => :boolean, :default => false
|
|
715
|
+
method_option :force, :aliases => '-f', :type => :boolean, :default => false
|
|
716
|
+
def delete_node(context_params)
|
|
717
|
+
response = delete_node_aux(context_params)
|
|
718
|
+
|
|
719
|
+
@@invalidate_map << :assembly
|
|
720
|
+
@@invalidate_map << :assembly_node
|
|
721
|
+
@@invalidate_map << :service
|
|
722
|
+
@@invalidate_map << :service_node
|
|
723
|
+
@@invalidate_map << :workspace
|
|
724
|
+
@@invalidate_map << :workspace_node
|
|
725
|
+
|
|
726
|
+
return response
|
|
727
|
+
end
|
|
728
|
+
|
|
729
|
+
desc "SERVICE-NAME/ID delete-node-group ^^NODE-NAME [-y] [--force]","Delete node group and all nodes that are part of that group."
|
|
730
|
+
method_option :y, :aliases => '-y', :type => :boolean, :default => false
|
|
731
|
+
method_option :force, :aliases => '-f', :type => :boolean, :default => false
|
|
732
|
+
def delete_node_group(context_params)
|
|
733
|
+
response = delete_node_group_aux(context_params)
|
|
734
|
+
|
|
735
|
+
@@invalidate_map << :assembly
|
|
736
|
+
@@invalidate_map << :assembly_node
|
|
737
|
+
@@invalidate_map << :service
|
|
738
|
+
@@invalidate_map << :service_node
|
|
739
|
+
@@invalidate_map << :workspace
|
|
740
|
+
@@invalidate_map << :workspace_node
|
|
741
|
+
|
|
742
|
+
return response
|
|
743
|
+
end
|
|
744
|
+
|
|
745
|
+
desc "HIDE_FROM_BASE delete NAME/ID [-y]","Delete node, terminating it if the node has been spun up."
|
|
746
|
+
def delete(context_params)
|
|
747
|
+
if context_params.is_last_command_eql_to?(:node)
|
|
748
|
+
response = delete_node_aux(context_params)
|
|
749
|
+
return response unless response.ok?
|
|
750
|
+
@@invalidate_map << :service_node
|
|
751
|
+
|
|
752
|
+
response
|
|
753
|
+
elsif context_params.is_last_command_eql_to?(:component)
|
|
754
|
+
response = delete_component_aux(context_params)
|
|
755
|
+
return response unless response.ok?
|
|
756
|
+
@@invalidate_map << :assembly_node_component
|
|
757
|
+
|
|
758
|
+
response
|
|
759
|
+
end
|
|
760
|
+
end
|
|
761
|
+
|
|
762
|
+
desc "SERVICE-NAME/ID unlink-components TARGET-CMP-NAME SOURCE-CMP-NAME [DEPENDENCY-NAME]", "Remove a component link."
|
|
763
|
+
def unlink_components(context_params)
|
|
764
|
+
unlink_components_aux(context_params)
|
|
765
|
+
end
|
|
766
|
+
|
|
767
|
+
# using HIDE_FROM_BASE to hide this command from base context (dtk:/assembly>)
|
|
768
|
+
desc "SERVICE-NAME/ID delete-component COMPONENT-NAME [-y] [--force]","Delete component from the service."
|
|
769
|
+
method_option :y, :aliases => '-y', :type => :boolean, :default => false
|
|
770
|
+
method_option :force, :aliases => '-f', :type => :boolean, :default => false
|
|
771
|
+
def delete_component(context_params)
|
|
772
|
+
response = delete_component_aux(context_params)
|
|
773
|
+
|
|
774
|
+
@@invalidate_map << :service
|
|
775
|
+
@@invalidate_map << :service_node
|
|
776
|
+
@@invalidate_map << :service_node_component
|
|
777
|
+
|
|
778
|
+
response
|
|
779
|
+
end
|
|
780
|
+
|
|
781
|
+
# using HIDE_FROM_BASE to hide this command from base context (dtk:/assembly>)
|
|
782
|
+
desc "HIDE_FROM_BASE get-netstats", "Get netstats"
|
|
783
|
+
def get_netstats(context_params)
|
|
784
|
+
get_netstats_aux(context_params)
|
|
785
|
+
end
|
|
786
|
+
|
|
787
|
+
=begin
|
|
788
|
+
# TODO: DTK-2027 might subsume by the dtk actions; currently server changes does not support this command
|
|
789
|
+
# using HIDE_FROM_BASE to hide this command from base context (dtk:/assembly>)
|
|
790
|
+
desc "HIDE_FROM_BASE execute-tests [--component COMPONENT-NAME] [--timeout TIMEOUT]", "Execute tests. --component filters execution per component, --timeout changes default execution timeout"
|
|
791
|
+
method_option :component, :type => :string, :desc => "Component name"
|
|
792
|
+
method_option :timeout, :type => :string, :desc => "Timeout"
|
|
793
|
+
def execute_tests(context_params)
|
|
794
|
+
execute_tests_aux(context_params)
|
|
795
|
+
end
|
|
796
|
+
=end
|
|
797
|
+
|
|
798
|
+
# using HIDE_FROM_BASE to hide this command from base context (dtk:/assembly>)
|
|
799
|
+
desc "HIDE_FROM_BASE get-ps [--filter PATTERN]", "Get ps"
|
|
800
|
+
method_option :filter, :type => :boolean, :default => false, :aliases => '-f'
|
|
801
|
+
def get_ps(context_params)
|
|
802
|
+
get_ps_aux(context_params)
|
|
803
|
+
end
|
|
804
|
+
|
|
805
|
+
desc "SERVICE-NAME/ID set-required-attributes", "Interactive dialog to set required attributes that are not currently set"
|
|
806
|
+
def set_required_attributes(context_params)
|
|
807
|
+
assembly_id = context_params.retrieve_arguments([:service_id!],method_argument_names)
|
|
808
|
+
set_required_attributes_aux(assembly_id,:assembly,:instance)
|
|
809
|
+
end
|
|
810
|
+
|
|
811
|
+
# using HIDE_FROM_BASE to hide this command from base context (dtk:/assembly>)
|
|
812
|
+
desc "HIDE_FROM_BASE tail LOG-PATH NODE-NAME [REGEX-PATTERN] [--more]","Tail specified number of lines from log. CTRL+C to quit."
|
|
813
|
+
method_option :more, :type => :boolean, :default => false
|
|
814
|
+
def tail(context_params)
|
|
815
|
+
tail_aux(context_params)
|
|
816
|
+
end
|
|
817
|
+
|
|
818
|
+
# using HIDE_FROM_BASE to hide this command from base context (dtk:/assembly>)
|
|
819
|
+
desc "HIDE_FROM_BASE grep LOG-PATH NODES-ID-PATTERN GREP-PATTERN [--first]","Grep log from multiple nodes. --first option returns first match (latest log entry)."
|
|
820
|
+
method_option :first, :type => :boolean, :default => false
|
|
821
|
+
def grep(context_params)
|
|
822
|
+
grep_aux(context_params)
|
|
823
|
+
end
|
|
824
|
+
|
|
825
|
+
desc "stage ASSEMBLY-TEMPLATE [INSTANCE-NAME] [-t PARENT-SERVICE-INSTANCE-NAME/ID] [-v VERSION] [--no-auto-complete]", "Stage assembly in target."
|
|
826
|
+
method_option :no_auto_complete, :type => :boolean, :default => false, :aliases => '--no-ac'
|
|
827
|
+
method_option :parent_service, :type => :string, :aliases => '-t'
|
|
828
|
+
version_method_option
|
|
829
|
+
#hidden option
|
|
830
|
+
method_option "instance-bindings", :type => :string
|
|
831
|
+
def stage(context_params)
|
|
832
|
+
stage_aux(context_params)
|
|
833
|
+
end
|
|
834
|
+
|
|
835
|
+
desc "set-default-target INSTANCE-NAME/ID", "Set default target service instance."
|
|
836
|
+
def set_default_target(context_params)
|
|
837
|
+
set_default_target_aux(context_params)
|
|
838
|
+
end
|
|
839
|
+
|
|
840
|
+
desc "stage-target ASSEMBLY-TEMPLATE [INSTANCE-NAME] -t PARENT-SERVICE-INSTANCE-NAME/ID] [-v VERSION] [--no-auto-complete]", "Stage assembly as target instance."
|
|
841
|
+
method_option :settings, :type => :string, :aliases => '-s'
|
|
842
|
+
method_option :auto_complete, :type => :boolean, :default => true
|
|
843
|
+
method_option :no_auto_complete, :type => :boolean, :default => false, :aliases => '--no-ac'
|
|
844
|
+
method_option :parent_service, :type => :string, :aliases => '-t'
|
|
845
|
+
version_method_option
|
|
846
|
+
#hidden options
|
|
847
|
+
method_option "instance-bindings", :type => :string
|
|
848
|
+
method_option :is_target, :type => :boolean, :default => true
|
|
849
|
+
def stage_target(context_params)
|
|
850
|
+
response = stage_aux(context_params)
|
|
851
|
+
return response unless response.ok?
|
|
852
|
+
|
|
853
|
+
# when changing context send request for getting latest assemblies instead of getting from cache
|
|
854
|
+
@@invalidate_map << :service
|
|
855
|
+
@@invalidate_map << :assembly
|
|
856
|
+
|
|
857
|
+
return response
|
|
858
|
+
end
|
|
859
|
+
|
|
860
|
+
desc "deploy-target ASSEMBLY-TEMPLATE [INSTANCE-NAME] [-v VERSION] [--no-auto-complete] [--stream-results]", "Deploy assembly as target instance."
|
|
861
|
+
method_option 'stream-results', :aliases => '-s', :type => :boolean, :default => false, :desc => "Stream results"
|
|
862
|
+
method_option :no_auto_complete, :type => :boolean, :default => false, :aliases => '--no-ac'
|
|
863
|
+
version_method_option
|
|
864
|
+
#hidden options
|
|
865
|
+
method_option "instance-bindings", :type => :string
|
|
866
|
+
method_option :is_target, :type => :boolean, :default => true
|
|
867
|
+
# method_option :settings, :type => :string, :aliases => '-s'
|
|
868
|
+
def deploy_target(context_params)
|
|
869
|
+
response = deploy_aux(context_params)
|
|
870
|
+
return response unless response.ok?
|
|
871
|
+
|
|
872
|
+
@@invalidate_map << :service
|
|
873
|
+
@@invalidate_map << :assembly
|
|
874
|
+
|
|
875
|
+
response
|
|
876
|
+
end
|
|
877
|
+
|
|
878
|
+
desc "deploy ASSEMBLY-TEMPLATE [INSTANCE-NAME] [-t PARENT-SERVICE-INSTANCE-NAME/ID] [-v VERSION] [--no-auto-complete]", "Deploy assembly in target."
|
|
879
|
+
method_option 'stream-results', :aliases => '-s', :type => :boolean, :default => false, :desc => "Stream results"
|
|
880
|
+
method_option :no_auto_complete, :type => :boolean, :default => false, :aliases => '--no-ac'
|
|
881
|
+
method_option :parent_service, :type => :string, :aliases => '-t'
|
|
882
|
+
version_method_option
|
|
883
|
+
#hidden options
|
|
884
|
+
method_option "instance-bindings", :type => :string
|
|
885
|
+
# method_option :settings, :type => :string, :aliases => '-s'
|
|
886
|
+
def deploy(context_params)
|
|
887
|
+
response = deploy_aux(context_params)
|
|
888
|
+
return response unless response.ok?
|
|
889
|
+
|
|
890
|
+
@@invalidate_map << :service
|
|
891
|
+
@@invalidate_map << :assembly
|
|
892
|
+
|
|
893
|
+
response
|
|
894
|
+
end
|
|
895
|
+
|
|
896
|
+
desc "SERVICE-NAME/ID set-required-attributes-and-converge", "Interactive dialog to set required attributes that are not currently set", :hide => true
|
|
897
|
+
def set_required_attributes_and_converge(context_params)
|
|
898
|
+
begin
|
|
899
|
+
response = set_required_attributes_converge_aux(context_params)
|
|
900
|
+
rescue DtkError::InteractiveWizardError => e
|
|
901
|
+
@@invalidate_map << :service
|
|
902
|
+
@@invalidate_map << :assembly
|
|
903
|
+
|
|
904
|
+
# if skip correction wizzard still go to newly created service instance
|
|
905
|
+
if instance_name = (context_params.get_forwarded_options()||{})[:instance_name]
|
|
906
|
+
MainContext.get_context.change_context(["/service/#{instance_name}"])
|
|
907
|
+
end
|
|
908
|
+
|
|
909
|
+
raise e
|
|
910
|
+
end
|
|
911
|
+
|
|
912
|
+
@@invalidate_map << :service
|
|
913
|
+
@@invalidate_map << :assembly
|
|
914
|
+
|
|
915
|
+
# if instance_name = opts[:instance_name]
|
|
916
|
+
# MainContext.get_context.change_context([instance_name])
|
|
917
|
+
# end
|
|
918
|
+
|
|
919
|
+
response
|
|
920
|
+
end
|
|
921
|
+
|
|
922
|
+
desc "create-workspace [WORKSPACE-NAME] [-t PARENT-SERVICE-INSTANCE-NAME/ID]", "Create workspace"
|
|
923
|
+
method_option :parent_service, :type => :string, :aliases => '-t'
|
|
924
|
+
def create_workspace(context_params)
|
|
925
|
+
response = create_workspace_aux(context_params)
|
|
926
|
+
return response unless response.ok?
|
|
927
|
+
|
|
928
|
+
@@invalidate_map << :service
|
|
929
|
+
@@invalidate_map << :assembly
|
|
930
|
+
|
|
931
|
+
yaml_response = YAML.load(response.data)
|
|
932
|
+
if workspace_instance = yaml_response['new_workspace_instance']
|
|
933
|
+
MainContext.get_context.change_context(["/service/#{workspace_instance['name']}"])
|
|
934
|
+
else
|
|
935
|
+
fail DtkError.new('Workspace instance is not staged properly, please try again!')
|
|
936
|
+
end
|
|
937
|
+
|
|
938
|
+
response
|
|
939
|
+
end
|
|
940
|
+
end
|
|
941
|
+
end
|