dtk-client 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/dtk-client.gemspec +2 -2
- data/lib/auxiliary.rb +1 -1
- data/lib/client.rb +1 -1
- data/lib/command_helper.rb +1 -1
- data/lib/command_helpers/git_repo/merge.rb +1 -1
- data/lib/command_helpers/git_repo.rb +1 -1
- data/lib/command_helpers/jenkins_client/config_xml.rb +1 -1
- data/lib/command_helpers/jenkins_client.rb +1 -1
- data/lib/command_helpers/service_importer.rb +6 -2
- data/lib/command_helpers/service_link.rb +1 -1
- data/lib/command_helpers/test_module_creator.rb +1 -1
- data/lib/commands/common/thor/access_control.rb +1 -1
- data/lib/commands/common/thor/action_result_handler.rb +57 -57
- data/lib/commands/common/thor/assembly_template.rb +1 -1
- data/lib/commands/common/thor/assembly_workspace.rb +15 -5
- data/lib/commands/common/thor/base_command_helper.rb +1 -1
- data/lib/commands/common/thor/clone.rb +1 -1
- data/lib/commands/common/thor/common.rb +1 -1
- data/lib/commands/common/thor/common_base.rb +1 -1
- data/lib/commands/common/thor/create_target.rb +1 -1
- data/lib/commands/common/thor/edit.rb +1 -1
- data/lib/commands/common/thor/inventory_parser.rb +1 -1
- data/lib/commands/common/thor/list_diffs.rb +111 -111
- data/lib/commands/common/thor/module/import.rb +1 -1
- data/lib/commands/common/thor/module.rb +18 -5
- data/lib/commands/common/thor/node.rb +1 -1
- data/lib/commands/common/thor/poller.rb +1 -1
- data/lib/commands/common/thor/pull_clone_changes.rb +1 -1
- data/lib/commands/common/thor/pull_from_remote.rb +1 -1
- data/lib/commands/common/thor/puppet_forge.rb +1 -1
- data/lib/commands/common/thor/purge_clone.rb +1 -1
- data/lib/commands/common/thor/push_clone_changes.rb +1 -1
- data/lib/commands/common/thor/push_to_remote.rb +1 -1
- data/lib/commands/common/thor/remotes.rb +1 -1
- data/lib/commands/common/thor/reparse.rb +1 -1
- data/lib/commands/common/thor/set_required_attributes.rb +1 -1
- data/lib/commands/thor/account.rb +1 -1
- data/lib/commands/thor/assembly.rb +1 -1
- data/lib/commands/thor/attribute.rb +1 -1
- data/lib/commands/thor/component.rb +1 -1
- data/lib/commands/thor/component_module.rb +1 -1
- data/lib/commands/thor/component_template.rb +1 -1
- data/lib/commands/thor/dependency.rb +1 -1
- data/lib/commands/thor/developer.rb +127 -127
- data/lib/commands/thor/dtk.rb +1 -1
- data/lib/commands/thor/library.rb +1 -1
- data/lib/commands/thor/node.rb +1 -1
- data/lib/commands/thor/node_group.rb +1 -1
- data/lib/commands/thor/node_template.rb +1 -1
- data/lib/commands/thor/project.rb +17 -17
- data/lib/commands/thor/provider.rb +7 -5
- data/lib/commands/thor/remotes.rb +1 -1
- data/lib/commands/thor/service.rb +18 -3
- data/lib/commands/thor/service_module.rb +1 -1
- data/lib/commands/thor/target.rb +233 -231
- data/lib/commands/thor/task.rb +1 -1
- data/lib/commands/thor/test_module.rb +1 -1
- data/lib/commands/thor/workspace.rb +22 -3
- data/lib/commands.rb +40 -40
- data/lib/config/configuration.rb +1 -1
- data/lib/config/disk_cacher.rb +1 -1
- data/lib/configurator.rb +1 -1
- data/lib/context_router.rb +1 -1
- data/lib/core.rb +1 -1
- data/lib/domain/git_adapter.rb +395 -395
- data/lib/domain/git_error_handler.rb +47 -47
- data/lib/domain/response/error_handler.rb +13 -4
- data/lib/domain/response.rb +1 -1
- data/lib/dtk-client/version.rb +3 -3
- data/lib/dtk_client.rb +1 -1
- data/lib/dtk_constants.rb +1 -1
- data/lib/dtk_error.rb +1 -1
- data/lib/dtk_logger.rb +96 -96
- data/lib/error.rb +1 -1
- data/lib/execute/cli_pure/cli_rerouter.rb +1 -1
- data/lib/execute/command/api_call/map.rb +1 -1
- data/lib/execute/command/api_call/service.rb +1 -1
- data/lib/execute/command/api_call/translation_term.rb +1 -1
- data/lib/execute/command/api_call.rb +1 -1
- data/lib/execute/command/rest_call.rb +1 -1
- data/lib/execute/command.rb +1 -1
- data/lib/execute/command_processor/rest_call.rb +1 -1
- data/lib/execute/command_processor.rb +1 -1
- data/lib/execute/execute_context/result_store.rb +1 -1
- data/lib/execute/execute_context.rb +1 -1
- data/lib/execute/script/add_tenant.rb +1 -1
- data/lib/execute/script.rb +1 -1
- data/lib/execute.rb +1 -1
- data/lib/parser/adapters/option_parser.rb +1 -1
- data/lib/parser/adapters/thor/common_option_defs.rb +1 -1
- data/lib/parser/adapters/thor.rb +1 -1
- data/lib/require_first.rb +87 -87
- data/lib/search_hash.rb +1 -1
- data/lib/shell/context.rb +1 -1
- data/lib/shell/context_aux.rb +1 -1
- data/lib/shell/domain/active_context.rb +1 -1
- data/lib/shell/domain/context_entity.rb +1 -1
- data/lib/shell/domain/context_params.rb +1 -1
- data/lib/shell/domain/override_tasks.rb +1 -1
- data/lib/shell/domain/shadow_entity.rb +1 -1
- data/lib/shell/header_shell.rb +1 -1
- data/lib/shell/help_monkey_patch.rb +1 -1
- data/lib/shell/interactive_wizard.rb +1 -1
- data/lib/shell/message_queue.rb +1 -1
- data/lib/shell/parse_monkey_patch.rb +1 -1
- data/lib/shell/status_monitor.rb +107 -107
- data/lib/shell.rb +1 -1
- data/lib/task_status/refresh_mode.rb +1 -1
- data/lib/task_status/snapshot_mode.rb +1 -1
- data/lib/task_status/stream_mode/element/format.rb +1 -1
- data/lib/task_status/stream_mode/element/hierarchical_task/result/action.rb +1 -1
- data/lib/task_status/stream_mode/element/hierarchical_task/result.rb +1 -1
- data/lib/task_status/stream_mode/element/hierarchical_task/steps/action.rb +1 -1
- data/lib/task_status/stream_mode/element/hierarchical_task/steps/components.rb +1 -1
- data/lib/task_status/stream_mode/element/hierarchical_task/steps/node_level.rb +1 -1
- data/lib/task_status/stream_mode/element/hierarchical_task/steps.rb +1 -1
- data/lib/task_status/stream_mode/element/hierarchical_task.rb +1 -1
- data/lib/task_status/stream_mode/element/render.rb +1 -1
- data/lib/task_status/stream_mode/element/stage/render.rb +1 -1
- data/lib/task_status/stream_mode/element/stage.rb +1 -1
- data/lib/task_status/stream_mode/element/task_end.rb +1 -1
- data/lib/task_status/stream_mode/element/task_start.rb +1 -1
- data/lib/task_status/stream_mode/element.rb +1 -1
- data/lib/task_status/stream_mode.rb +1 -1
- data/lib/task_status.rb +1 -1
- data/lib/util/common_util.rb +1 -1
- data/lib/util/console.rb +1 -1
- data/lib/util/dtk_puppet.rb +1 -1
- data/lib/util/module_util.rb +1 -1
- data/lib/util/os_util.rb +6 -2
- data/lib/util/permission_util.rb +1 -1
- data/lib/util/remote_dependency_util.rb +1 -1
- data/lib/util/ssh_util.rb +77 -77
- data/lib/view_processor/augmented_simple_list.rb +1 -1
- data/lib/view_processor/hash_pretty_print.rb +1 -1
- data/lib/view_processor/simple_list.rb +1 -1
- data/lib/view_processor/table_print.rb +1 -1
- data/lib/view_processor.rb +1 -1
- data/spec/lib/spec_helper.rb +1 -1
- data/spec/lib/spec_thor.rb +1 -1
- data/spec/node_template_spec.rb +1 -1
- data/spec/table_print_spec.rb +1 -1
- data/spec/target_spec.rb +1 -1
- data/spec/task_spec.rb +1 -1
- metadata +20 -20
data/lib/commands/thor/target.rb
CHANGED
@@ -15,234 +15,236 @@
|
|
15
15
|
# See the License for the specific language governing permissions and
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
|
-
dtk_require_common_commands('thor/common_base')
|
19
|
-
dtk_require_common_commands('thor/inventory_parser')
|
20
|
-
dtk_require_common_commands('thor/create_target')
|
21
|
-
module DTK::Client
|
22
|
-
class Target < CommandBaseThor
|
23
|
-
include Commands
|
24
|
-
include InventoryParserMixin
|
25
|
-
|
26
|
-
def self.pretty_print_cols()
|
27
|
-
PPColumns.get(:target)
|
28
|
-
end
|
29
|
-
|
30
|
-
def self.alternate_identifiers()
|
31
|
-
return ['PROVIDER']
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.extended_context()
|
35
|
-
{
|
36
|
-
:context => {
|
37
|
-
# want auto complete for --provider option
|
38
|
-
"--provider" => "provider"
|
39
|
-
}
|
40
|
-
}
|
41
|
-
end
|
42
|
-
|
43
|
-
desc "TARGET-NAME/ID list-nodes","Lists node instances in given targets."
|
44
|
-
def list_nodes(context_params)
|
45
|
-
context_params.method_arguments = ["nodes"]
|
46
|
-
list(context_params)
|
47
|
-
end
|
48
|
-
|
49
|
-
desc "TARGET-NAME/ID info","Provides information about specified target"
|
50
|
-
def info(context_params)
|
51
|
-
target_id = context_params.retrieve_arguments([:target_id!],method_argument_names)
|
52
|
-
|
53
|
-
post_body = {:target_id => target_id}
|
54
|
-
post rest_url('target/info'), post_body
|
55
|
-
end
|
56
|
-
|
57
|
-
desc "TARGET-NAME/ID import-nodes --source SOURCE","Reads from inventory dsl and populates the node instance objects (SOURCE: file:/path/to/file.yaml)."
|
58
|
-
method_option :source, :type => :string
|
59
|
-
def import_nodes(context_params)
|
60
|
-
target_id = context_params.retrieve_arguments([:target_id!],method_argument_names)
|
61
|
-
source = context_params.retrieve_thor_options([:source!], options)
|
62
|
-
|
63
|
-
parsed_source = source.match(/^(\w+):(.+)/)
|
64
|
-
raise DtkValidationError, "Invalid source! Valid source should contain source_type:source_path (e.g. --source file:path/to/file.yaml)." unless parsed_source
|
65
|
-
|
66
|
-
import_type = parsed_source[1]
|
67
|
-
path = parsed_source[2]
|
68
|
-
|
69
|
-
raise DtkValidationError, "We do not support '#{import_type}' as import source at the moment. Valid sources: #{ValidImportTypes}" unless ValidImportTypes.include?(import_type)
|
70
|
-
|
71
|
-
post_body = {:target_id => target_id}
|
72
|
-
|
73
|
-
if import_type.eql?('file')
|
74
|
-
inventory_data = parse_inventory_file(path)
|
75
|
-
post_body.merge!(:inventory_data => inventory_data)
|
76
|
-
end
|
77
|
-
|
78
|
-
response = post rest_url("target/import_nodes"), post_body
|
79
|
-
return response unless response.ok?
|
80
|
-
|
81
|
-
if response.data.empty?
|
82
|
-
OsUtil.print("No new nodes to import!", :yellow)
|
83
|
-
else
|
84
|
-
OsUtil.print("Successfully imported nodes:", :yellow)
|
85
|
-
response.data.each do |node|
|
86
|
-
OsUtil.print("#{node}", :yellow)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
ValidImportTypes = ["file"]
|
91
|
-
|
92
|
-
desc "set-default-target TARGET-NAME","Sets the default target."
|
93
|
-
def set_default_target(context_params)
|
94
|
-
target_id = context_params.retrieve_arguments([:option_1!],method_argument_names)
|
95
|
-
post rest_url("target/set_default"), { :target_id => target_id }
|
96
|
-
end
|
97
|
-
|
98
|
-
desc "TARGET-NAME/ID install-agents","Install node agents on imported physical nodes."
|
99
|
-
def install_agents(context_params)
|
100
|
-
target_id = context_params.retrieve_arguments([:target_id!],method_argument_names)
|
101
|
-
|
102
|
-
post_body = {:target_id => target_id}
|
103
|
-
post rest_url("target/install_agents"), post_body
|
104
|
-
end
|
105
|
-
|
106
|
-
desc "create-target-ec2-classic [TARGET-NAME] --provider PROVIDER --region REGION [--keypair KEYPAIR] [--security-group SECURITY-GROUP(S)]", "Create target based on given provider"
|
107
|
-
method_option :provider, :type => :string
|
108
|
-
method_option :region, :type => :string
|
109
|
-
method_option :keypair, :type => :string
|
110
|
-
method_option :security_group, :type => :string, :aliases => '--security-groups'
|
111
|
-
def create_target_ec2_classic(context_params)
|
112
|
-
option_list = [:provider!, :region!, :keypair, :security_group]
|
113
|
-
response = Common::CreateTarget.new(self, context_params).execute(:ec2_classic,option_list)
|
114
|
-
@@invalidate_map << :target
|
115
|
-
response
|
116
|
-
end
|
117
|
-
|
118
|
-
desc "create-target-ec2-vpc [TARGET-NAME] --provider PROVIDER --region REGION --subnet SUBNET-ID [--keypair KEYPAIR] [--security-group SECURITY-GROUP(S)]", "Create target based on given provider"
|
119
|
-
method_option :provider, :type => :string
|
120
|
-
method_option :subnet, :type => :string
|
121
|
-
method_option :region, :type => :string
|
122
|
-
method_option :keypair, :type => :string
|
123
|
-
method_option :security_group, :type => :string, :aliases => '--security-groups'
|
124
|
-
def create_target_ec2_vpc(context_params)
|
125
|
-
option_list = [:provider!, :subnet!, :region!, :keypair, :security_group]
|
126
|
-
response = Common::CreateTarget.new(self, context_params).execute(:ec2_vpc,option_list)
|
127
|
-
@@invalidate_map << :target
|
128
|
-
response
|
129
|
-
end
|
130
|
-
|
131
|
-
|
132
|
-
desc "TARGET-NAME/ID list-services","Lists service instances in given targets."
|
133
|
-
def list_services(context_params)
|
134
|
-
context_params.method_arguments = ["assemblies"]
|
135
|
-
list(context_params)
|
136
|
-
end
|
137
|
-
|
138
|
-
def self.validation_list(context_params)
|
139
|
-
provider_id = context_params.retrieve_arguments([:provider_id])
|
140
|
-
|
141
|
-
if provider_id
|
142
|
-
# if assembly_id is present we're loading nodes filtered by assembly_id
|
143
|
-
post_body = {
|
144
|
-
:subtype => :instance,
|
145
|
-
:parent_id => provider_id
|
146
|
-
}
|
147
|
-
|
148
|
-
response = get_cached_response(:provider_target, "target/list", post_body)
|
149
|
-
else
|
150
|
-
# otherwise, load all nodes
|
151
|
-
response = get_cached_response(:target, "target/list", { :subtype => :instance })
|
152
|
-
end
|
153
|
-
|
154
|
-
response
|
155
|
-
end
|
156
|
-
|
157
|
-
desc "list","Lists available targets."
|
158
|
-
def list(context_params)
|
159
|
-
provider_id, target_id, about = context_params.retrieve_arguments([:provider_id, :target_id, :option_1],method_argument_names||="")
|
160
|
-
|
161
|
-
if target_id.nil?
|
162
|
-
post_body = {
|
163
|
-
:subtype => :instance,
|
164
|
-
:parent_id => provider_id
|
165
|
-
}
|
166
|
-
response = post rest_url("target/list"), post_body
|
167
|
-
|
168
|
-
response.render_table(:target)
|
169
|
-
else
|
170
|
-
post_body = {
|
171
|
-
:target_id => target_id,
|
172
|
-
:about => about
|
173
|
-
}
|
174
|
-
|
175
|
-
case about
|
176
|
-
when "nodes"
|
177
|
-
response = post rest_url("target/info_about"), post_body
|
178
|
-
data_type = :node
|
179
|
-
when "assemblies"
|
180
|
-
post_body.merge!(:detail_level => 'nodes', :include_workspace => true)
|
181
|
-
response = post rest_url("target/info_about"), post_body
|
182
|
-
data_type = :assembly
|
183
|
-
else
|
184
|
-
raise_validation_error_method_usage('list')
|
185
|
-
end
|
186
|
-
|
187
|
-
response.render_table(data_type)
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
desc "delete-and-destroy TARGET-NAME","Deletes target or provider"
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
if
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
iaas_properties.merge!(:
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
end
|
18
|
+
dtk_require_common_commands('thor/common_base')
|
19
|
+
dtk_require_common_commands('thor/inventory_parser')
|
20
|
+
dtk_require_common_commands('thor/create_target')
|
21
|
+
module DTK::Client
|
22
|
+
class Target < CommandBaseThor
|
23
|
+
include Commands
|
24
|
+
include InventoryParserMixin
|
25
|
+
|
26
|
+
def self.pretty_print_cols()
|
27
|
+
PPColumns.get(:target)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.alternate_identifiers()
|
31
|
+
return ['PROVIDER']
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.extended_context()
|
35
|
+
{
|
36
|
+
:context => {
|
37
|
+
# want auto complete for --provider option
|
38
|
+
"--provider" => "provider"
|
39
|
+
}
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "TARGET-NAME/ID list-nodes","Lists node instances in given targets."
|
44
|
+
def list_nodes(context_params)
|
45
|
+
context_params.method_arguments = ["nodes"]
|
46
|
+
list(context_params)
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "TARGET-NAME/ID info","Provides information about specified target"
|
50
|
+
def info(context_params)
|
51
|
+
target_id = context_params.retrieve_arguments([:target_id!],method_argument_names)
|
52
|
+
|
53
|
+
post_body = {:target_id => target_id}
|
54
|
+
post rest_url('target/info'), post_body
|
55
|
+
end
|
56
|
+
|
57
|
+
desc "TARGET-NAME/ID import-nodes --source SOURCE","Reads from inventory dsl and populates the node instance objects (SOURCE: file:/path/to/file.yaml)."
|
58
|
+
method_option :source, :type => :string
|
59
|
+
def import_nodes(context_params)
|
60
|
+
target_id = context_params.retrieve_arguments([:target_id!],method_argument_names)
|
61
|
+
source = context_params.retrieve_thor_options([:source!], options)
|
62
|
+
|
63
|
+
parsed_source = source.match(/^(\w+):(.+)/)
|
64
|
+
raise DtkValidationError, "Invalid source! Valid source should contain source_type:source_path (e.g. --source file:path/to/file.yaml)." unless parsed_source
|
65
|
+
|
66
|
+
import_type = parsed_source[1]
|
67
|
+
path = parsed_source[2]
|
68
|
+
|
69
|
+
raise DtkValidationError, "We do not support '#{import_type}' as import source at the moment. Valid sources: #{ValidImportTypes}" unless ValidImportTypes.include?(import_type)
|
70
|
+
|
71
|
+
post_body = {:target_id => target_id}
|
72
|
+
|
73
|
+
if import_type.eql?('file')
|
74
|
+
inventory_data = parse_inventory_file(path)
|
75
|
+
post_body.merge!(:inventory_data => inventory_data)
|
76
|
+
end
|
77
|
+
|
78
|
+
response = post rest_url("target/import_nodes"), post_body
|
79
|
+
return response unless response.ok?
|
80
|
+
|
81
|
+
if response.data.empty?
|
82
|
+
OsUtil.print("No new nodes to import!", :yellow)
|
83
|
+
else
|
84
|
+
OsUtil.print("Successfully imported nodes:", :yellow)
|
85
|
+
response.data.each do |node|
|
86
|
+
OsUtil.print("#{node}", :yellow)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
ValidImportTypes = ["file"]
|
91
|
+
|
92
|
+
desc "set-default-target TARGET-NAME","Sets the default target."
|
93
|
+
def set_default_target(context_params)
|
94
|
+
target_id = context_params.retrieve_arguments([:option_1!],method_argument_names)
|
95
|
+
post rest_url("target/set_default"), { :target_id => target_id }
|
96
|
+
end
|
97
|
+
|
98
|
+
desc "TARGET-NAME/ID install-agents","Install node agents on imported physical nodes."
|
99
|
+
def install_agents(context_params)
|
100
|
+
target_id = context_params.retrieve_arguments([:target_id!],method_argument_names)
|
101
|
+
|
102
|
+
post_body = {:target_id => target_id}
|
103
|
+
post rest_url("target/install_agents"), post_body
|
104
|
+
end
|
105
|
+
|
106
|
+
desc "create-target-ec2-classic [TARGET-NAME] --provider PROVIDER --region REGION [--keypair KEYPAIR] [--security-group SECURITY-GROUP(S)]", "Create target based on given provider"
|
107
|
+
method_option :provider, :type => :string
|
108
|
+
method_option :region, :type => :string
|
109
|
+
method_option :keypair, :type => :string
|
110
|
+
method_option :security_group, :type => :string, :aliases => '--security-groups'
|
111
|
+
def create_target_ec2_classic(context_params)
|
112
|
+
option_list = [:provider!, :region!, :keypair, :security_group]
|
113
|
+
response = Common::CreateTarget.new(self, context_params).execute(:ec2_classic,option_list)
|
114
|
+
@@invalidate_map << :target
|
115
|
+
response
|
116
|
+
end
|
117
|
+
|
118
|
+
desc "create-target-ec2-vpc [TARGET-NAME] --provider PROVIDER --region REGION --subnet SUBNET-ID [--keypair KEYPAIR] [--security-group SECURITY-GROUP(S)]", "Create target based on given provider"
|
119
|
+
method_option :provider, :type => :string
|
120
|
+
method_option :subnet, :type => :string
|
121
|
+
method_option :region, :type => :string
|
122
|
+
method_option :keypair, :type => :string
|
123
|
+
method_option :security_group, :type => :string, :aliases => '--security-groups'
|
124
|
+
def create_target_ec2_vpc(context_params)
|
125
|
+
option_list = [:provider!, :subnet!, :region!, :keypair, :security_group]
|
126
|
+
response = Common::CreateTarget.new(self, context_params).execute(:ec2_vpc,option_list)
|
127
|
+
@@invalidate_map << :target
|
128
|
+
response
|
129
|
+
end
|
130
|
+
|
131
|
+
|
132
|
+
desc "TARGET-NAME/ID list-services","Lists service instances in given targets."
|
133
|
+
def list_services(context_params)
|
134
|
+
context_params.method_arguments = ["assemblies"]
|
135
|
+
list(context_params)
|
136
|
+
end
|
137
|
+
|
138
|
+
def self.validation_list(context_params)
|
139
|
+
provider_id = context_params.retrieve_arguments([:provider_id])
|
140
|
+
|
141
|
+
if provider_id
|
142
|
+
# if assembly_id is present we're loading nodes filtered by assembly_id
|
143
|
+
post_body = {
|
144
|
+
:subtype => :instance,
|
145
|
+
:parent_id => provider_id
|
146
|
+
}
|
147
|
+
|
148
|
+
response = get_cached_response(:provider_target, "target/list", post_body)
|
149
|
+
else
|
150
|
+
# otherwise, load all nodes
|
151
|
+
response = get_cached_response(:target, "target/list", { :subtype => :instance })
|
152
|
+
end
|
153
|
+
|
154
|
+
response
|
155
|
+
end
|
156
|
+
|
157
|
+
desc "list","Lists available targets."
|
158
|
+
def list(context_params)
|
159
|
+
provider_id, target_id, about = context_params.retrieve_arguments([:provider_id, :target_id, :option_1],method_argument_names||="")
|
160
|
+
|
161
|
+
if target_id.nil?
|
162
|
+
post_body = {
|
163
|
+
:subtype => :instance,
|
164
|
+
:parent_id => provider_id
|
165
|
+
}
|
166
|
+
response = post rest_url("target/list"), post_body
|
167
|
+
|
168
|
+
response.render_table(:target)
|
169
|
+
else
|
170
|
+
post_body = {
|
171
|
+
:target_id => target_id,
|
172
|
+
:about => about
|
173
|
+
}
|
174
|
+
|
175
|
+
case about
|
176
|
+
when "nodes"
|
177
|
+
response = post rest_url("target/info_about"), post_body
|
178
|
+
data_type = :node
|
179
|
+
when "assemblies"
|
180
|
+
post_body.merge!(:detail_level => 'nodes', :include_workspace => true)
|
181
|
+
response = post rest_url("target/info_about"), post_body
|
182
|
+
data_type = :assembly
|
183
|
+
else
|
184
|
+
raise_validation_error_method_usage('list')
|
185
|
+
end
|
186
|
+
|
187
|
+
response.render_table(data_type)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
desc "delete-and-destroy TARGET-NAME [-y]","Deletes target or provider"
|
192
|
+
method_option :force, :aliases => '-y', :type => :boolean, :default => false
|
193
|
+
def delete_and_destroy(context_params)
|
194
|
+
target_id = context_params.retrieve_arguments([:option_1!],method_argument_names)
|
195
|
+
|
196
|
+
unless options.force?
|
197
|
+
return unless Console.confirmation_prompt("Are you sure you want to delete target '#{target_id}' (all services/nodes that belong to this target will be deleted as well)'"+'?')
|
198
|
+
end
|
199
|
+
|
200
|
+
post_body = {
|
201
|
+
:target_id => target_id,
|
202
|
+
:type => 'instance'
|
203
|
+
}
|
204
|
+
|
205
|
+
@@invalidate_map << :target
|
206
|
+
|
207
|
+
response = post(rest_url("target/delete_and_destroy"),post_body)
|
208
|
+
return response unless response.ok?
|
209
|
+
if info_array = response.data['info']
|
210
|
+
info_array.each{|info_msg|OsUtil.print(info_msg, :yellow)}
|
211
|
+
end
|
212
|
+
Response::Ok.new()
|
213
|
+
end
|
214
|
+
|
215
|
+
=begin
|
216
|
+
# TODO: DTK-2056: rewite
|
217
|
+
also put in list property
|
218
|
+
desc "TARGET-NAME/ID set-property PROPERTY VALUE
|
219
|
+
method_option :keypair, :type => :string
|
220
|
+
method_option :security_group, :type => :string, :aliases => '--security-groups'
|
221
|
+
def set_property(context_params)
|
222
|
+
raise "change so that param is seperated key value parts"
|
223
|
+
target_id = context_params.retrieve_arguments([:target_id!],method_argument_names)
|
224
|
+
keypair, security_group = context_params.retrieve_thor_options([:keypair, :security_group], options)
|
225
|
+
|
226
|
+
raise ::DTK::Client::DtkValidationError.new("You have to provide security-group or keypair to edit target!") unless keypair || security_group
|
227
|
+
|
228
|
+
security_groups, iaas_properties = [], {}
|
229
|
+
iaas_properties.merge!(:keypair => keypair) if keypair
|
230
|
+
|
231
|
+
if security_group
|
232
|
+
raise ::DTK::Client::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?(',')
|
233
|
+
security_groups = security_group.split(',')
|
234
|
+
if (security_groups.empty? || security_groups.size==1)
|
235
|
+
iaas_properties.merge!(:security_group => security_group)
|
236
|
+
else
|
237
|
+
iaas_properties.merge!(:security_group_set => security_groups)
|
238
|
+
end
|
239
|
+
end
|
240
|
+
@@invalidate_map << :target
|
241
|
+
|
242
|
+
post_body = {
|
243
|
+
:target_id => target_id,
|
244
|
+
:iaas_properties => iaas_properties
|
245
|
+
}
|
246
|
+
post rest_url("target/set_properties"), post_body
|
247
|
+
end
|
248
|
+
=end
|
249
|
+
end
|
250
|
+
end
|
data/lib/commands/thor/task.rb
CHANGED
@@ -462,7 +462,16 @@ module DTK::Client
|
|
462
462
|
method_option :component, :aliases => '-c'
|
463
463
|
method_option :attribute, :aliases => '-a'
|
464
464
|
def edit_attributes(context_params)
|
465
|
-
edit_attributes_aux(context_params)
|
465
|
+
response = edit_attributes_aux(context_params)
|
466
|
+
|
467
|
+
@@invalidate_map << :assembly
|
468
|
+
@@invalidate_map << :assembly_node
|
469
|
+
@@invalidate_map << :service
|
470
|
+
@@invalidate_map << :service_node
|
471
|
+
@@invalidate_map << :workspace
|
472
|
+
@@invalidate_map << :workspace_node
|
473
|
+
|
474
|
+
response
|
466
475
|
end
|
467
476
|
|
468
477
|
# using HIDE_FROM_BASE to hide this command from base context (dtk:/workspace>)
|
@@ -615,7 +624,17 @@ module DTK::Client
|
|
615
624
|
method_option :component_attribute, :aliases => '-c', :type => :boolean, :default => false
|
616
625
|
method_option :node_attribute, :aliases => '-n', :type => :boolean, :default => false
|
617
626
|
def set_attribute(context_params)
|
618
|
-
set_attribute_aux(context_params)
|
627
|
+
response = set_attribute_aux(context_params)
|
628
|
+
return response unless response.ok?
|
629
|
+
|
630
|
+
@@invalidate_map << :assembly
|
631
|
+
@@invalidate_map << :assembly_node
|
632
|
+
@@invalidate_map << :service
|
633
|
+
@@invalidate_map << :service_node
|
634
|
+
@@invalidate_map << :workspace
|
635
|
+
@@invalidate_map << :workspace_node
|
636
|
+
|
637
|
+
response
|
619
638
|
end
|
620
639
|
|
621
640
|
desc "WORKSPACE-NAME/ID set-required-attributes", "Interactive dialog to set required attributes that are not currently set"
|
@@ -675,4 +694,4 @@ module DTK::Client
|
|
675
694
|
end
|
676
695
|
|
677
696
|
end
|
678
|
-
end
|
697
|
+
end
|
data/lib/commands.rb
CHANGED
@@ -15,43 +15,43 @@
|
|
15
15
|
# See the License for the specific language governing permissions and
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
|
-
module DTK
|
19
|
-
module Client
|
20
|
-
module CommandBase
|
21
|
-
#TODO: temp workaround
|
22
|
-
def rotate_args(rotated_args)
|
23
|
-
[rotated_args.last] + rotated_args[0..rotated_args.size-2]
|
24
|
-
end
|
25
|
-
|
26
|
-
def get(url)
|
27
|
-
get_connection.get(self.class,url)
|
28
|
-
end
|
29
|
-
def post(url,body=nil)
|
30
|
-
get_connection.post(self.class,url,body)
|
31
|
-
end
|
32
|
-
|
33
|
-
def post_file(url,body=nil)
|
34
|
-
get_connection.post_file(self.class,url,body)
|
35
|
-
end
|
36
|
-
|
37
|
-
def rest_url(route)
|
38
|
-
get_connection.rest_url(route)
|
39
|
-
end
|
40
|
-
|
41
|
-
def get_connection
|
42
|
-
DTK::Client::Session.get_connection()
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.handle_argument_error(task, error)
|
46
|
-
super
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
def pretty_print_cols()
|
52
|
-
self.class.pretty_print_cols()
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
57
|
-
end
|
18
|
+
module DTK
|
19
|
+
module Client
|
20
|
+
module CommandBase
|
21
|
+
#TODO: temp workaround
|
22
|
+
def rotate_args(rotated_args)
|
23
|
+
[rotated_args.last] + rotated_args[0..rotated_args.size-2]
|
24
|
+
end
|
25
|
+
|
26
|
+
def get(url)
|
27
|
+
get_connection.get(self.class,url)
|
28
|
+
end
|
29
|
+
def post(url,body=nil)
|
30
|
+
get_connection.post(self.class,url,body)
|
31
|
+
end
|
32
|
+
|
33
|
+
def post_file(url,body=nil)
|
34
|
+
get_connection.post_file(self.class,url,body)
|
35
|
+
end
|
36
|
+
|
37
|
+
def rest_url(route)
|
38
|
+
get_connection.rest_url(route)
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_connection
|
42
|
+
DTK::Client::Session.get_connection()
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.handle_argument_error(task, error)
|
46
|
+
super
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def pretty_print_cols()
|
52
|
+
self.class.pretty_print_cols()
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
data/lib/config/configuration.rb
CHANGED
data/lib/config/disk_cacher.rb
CHANGED
data/lib/configurator.rb
CHANGED
data/lib/context_router.rb
CHANGED
data/lib/core.rb
CHANGED