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.
Files changed (146) hide show
  1. checksums.yaml +13 -5
  2. data/dtk-client.gemspec +2 -2
  3. data/lib/auxiliary.rb +1 -1
  4. data/lib/client.rb +1 -1
  5. data/lib/command_helper.rb +1 -1
  6. data/lib/command_helpers/git_repo/merge.rb +1 -1
  7. data/lib/command_helpers/git_repo.rb +1 -1
  8. data/lib/command_helpers/jenkins_client/config_xml.rb +1 -1
  9. data/lib/command_helpers/jenkins_client.rb +1 -1
  10. data/lib/command_helpers/service_importer.rb +6 -2
  11. data/lib/command_helpers/service_link.rb +1 -1
  12. data/lib/command_helpers/test_module_creator.rb +1 -1
  13. data/lib/commands/common/thor/access_control.rb +1 -1
  14. data/lib/commands/common/thor/action_result_handler.rb +57 -57
  15. data/lib/commands/common/thor/assembly_template.rb +1 -1
  16. data/lib/commands/common/thor/assembly_workspace.rb +15 -5
  17. data/lib/commands/common/thor/base_command_helper.rb +1 -1
  18. data/lib/commands/common/thor/clone.rb +1 -1
  19. data/lib/commands/common/thor/common.rb +1 -1
  20. data/lib/commands/common/thor/common_base.rb +1 -1
  21. data/lib/commands/common/thor/create_target.rb +1 -1
  22. data/lib/commands/common/thor/edit.rb +1 -1
  23. data/lib/commands/common/thor/inventory_parser.rb +1 -1
  24. data/lib/commands/common/thor/list_diffs.rb +111 -111
  25. data/lib/commands/common/thor/module/import.rb +1 -1
  26. data/lib/commands/common/thor/module.rb +18 -5
  27. data/lib/commands/common/thor/node.rb +1 -1
  28. data/lib/commands/common/thor/poller.rb +1 -1
  29. data/lib/commands/common/thor/pull_clone_changes.rb +1 -1
  30. data/lib/commands/common/thor/pull_from_remote.rb +1 -1
  31. data/lib/commands/common/thor/puppet_forge.rb +1 -1
  32. data/lib/commands/common/thor/purge_clone.rb +1 -1
  33. data/lib/commands/common/thor/push_clone_changes.rb +1 -1
  34. data/lib/commands/common/thor/push_to_remote.rb +1 -1
  35. data/lib/commands/common/thor/remotes.rb +1 -1
  36. data/lib/commands/common/thor/reparse.rb +1 -1
  37. data/lib/commands/common/thor/set_required_attributes.rb +1 -1
  38. data/lib/commands/thor/account.rb +1 -1
  39. data/lib/commands/thor/assembly.rb +1 -1
  40. data/lib/commands/thor/attribute.rb +1 -1
  41. data/lib/commands/thor/component.rb +1 -1
  42. data/lib/commands/thor/component_module.rb +1 -1
  43. data/lib/commands/thor/component_template.rb +1 -1
  44. data/lib/commands/thor/dependency.rb +1 -1
  45. data/lib/commands/thor/developer.rb +127 -127
  46. data/lib/commands/thor/dtk.rb +1 -1
  47. data/lib/commands/thor/library.rb +1 -1
  48. data/lib/commands/thor/node.rb +1 -1
  49. data/lib/commands/thor/node_group.rb +1 -1
  50. data/lib/commands/thor/node_template.rb +1 -1
  51. data/lib/commands/thor/project.rb +17 -17
  52. data/lib/commands/thor/provider.rb +7 -5
  53. data/lib/commands/thor/remotes.rb +1 -1
  54. data/lib/commands/thor/service.rb +18 -3
  55. data/lib/commands/thor/service_module.rb +1 -1
  56. data/lib/commands/thor/target.rb +233 -231
  57. data/lib/commands/thor/task.rb +1 -1
  58. data/lib/commands/thor/test_module.rb +1 -1
  59. data/lib/commands/thor/workspace.rb +22 -3
  60. data/lib/commands.rb +40 -40
  61. data/lib/config/configuration.rb +1 -1
  62. data/lib/config/disk_cacher.rb +1 -1
  63. data/lib/configurator.rb +1 -1
  64. data/lib/context_router.rb +1 -1
  65. data/lib/core.rb +1 -1
  66. data/lib/domain/git_adapter.rb +395 -395
  67. data/lib/domain/git_error_handler.rb +47 -47
  68. data/lib/domain/response/error_handler.rb +13 -4
  69. data/lib/domain/response.rb +1 -1
  70. data/lib/dtk-client/version.rb +3 -3
  71. data/lib/dtk_client.rb +1 -1
  72. data/lib/dtk_constants.rb +1 -1
  73. data/lib/dtk_error.rb +1 -1
  74. data/lib/dtk_logger.rb +96 -96
  75. data/lib/error.rb +1 -1
  76. data/lib/execute/cli_pure/cli_rerouter.rb +1 -1
  77. data/lib/execute/command/api_call/map.rb +1 -1
  78. data/lib/execute/command/api_call/service.rb +1 -1
  79. data/lib/execute/command/api_call/translation_term.rb +1 -1
  80. data/lib/execute/command/api_call.rb +1 -1
  81. data/lib/execute/command/rest_call.rb +1 -1
  82. data/lib/execute/command.rb +1 -1
  83. data/lib/execute/command_processor/rest_call.rb +1 -1
  84. data/lib/execute/command_processor.rb +1 -1
  85. data/lib/execute/execute_context/result_store.rb +1 -1
  86. data/lib/execute/execute_context.rb +1 -1
  87. data/lib/execute/script/add_tenant.rb +1 -1
  88. data/lib/execute/script.rb +1 -1
  89. data/lib/execute.rb +1 -1
  90. data/lib/parser/adapters/option_parser.rb +1 -1
  91. data/lib/parser/adapters/thor/common_option_defs.rb +1 -1
  92. data/lib/parser/adapters/thor.rb +1 -1
  93. data/lib/require_first.rb +87 -87
  94. data/lib/search_hash.rb +1 -1
  95. data/lib/shell/context.rb +1 -1
  96. data/lib/shell/context_aux.rb +1 -1
  97. data/lib/shell/domain/active_context.rb +1 -1
  98. data/lib/shell/domain/context_entity.rb +1 -1
  99. data/lib/shell/domain/context_params.rb +1 -1
  100. data/lib/shell/domain/override_tasks.rb +1 -1
  101. data/lib/shell/domain/shadow_entity.rb +1 -1
  102. data/lib/shell/header_shell.rb +1 -1
  103. data/lib/shell/help_monkey_patch.rb +1 -1
  104. data/lib/shell/interactive_wizard.rb +1 -1
  105. data/lib/shell/message_queue.rb +1 -1
  106. data/lib/shell/parse_monkey_patch.rb +1 -1
  107. data/lib/shell/status_monitor.rb +107 -107
  108. data/lib/shell.rb +1 -1
  109. data/lib/task_status/refresh_mode.rb +1 -1
  110. data/lib/task_status/snapshot_mode.rb +1 -1
  111. data/lib/task_status/stream_mode/element/format.rb +1 -1
  112. data/lib/task_status/stream_mode/element/hierarchical_task/result/action.rb +1 -1
  113. data/lib/task_status/stream_mode/element/hierarchical_task/result.rb +1 -1
  114. data/lib/task_status/stream_mode/element/hierarchical_task/steps/action.rb +1 -1
  115. data/lib/task_status/stream_mode/element/hierarchical_task/steps/components.rb +1 -1
  116. data/lib/task_status/stream_mode/element/hierarchical_task/steps/node_level.rb +1 -1
  117. data/lib/task_status/stream_mode/element/hierarchical_task/steps.rb +1 -1
  118. data/lib/task_status/stream_mode/element/hierarchical_task.rb +1 -1
  119. data/lib/task_status/stream_mode/element/render.rb +1 -1
  120. data/lib/task_status/stream_mode/element/stage/render.rb +1 -1
  121. data/lib/task_status/stream_mode/element/stage.rb +1 -1
  122. data/lib/task_status/stream_mode/element/task_end.rb +1 -1
  123. data/lib/task_status/stream_mode/element/task_start.rb +1 -1
  124. data/lib/task_status/stream_mode/element.rb +1 -1
  125. data/lib/task_status/stream_mode.rb +1 -1
  126. data/lib/task_status.rb +1 -1
  127. data/lib/util/common_util.rb +1 -1
  128. data/lib/util/console.rb +1 -1
  129. data/lib/util/dtk_puppet.rb +1 -1
  130. data/lib/util/module_util.rb +1 -1
  131. data/lib/util/os_util.rb +6 -2
  132. data/lib/util/permission_util.rb +1 -1
  133. data/lib/util/remote_dependency_util.rb +1 -1
  134. data/lib/util/ssh_util.rb +77 -77
  135. data/lib/view_processor/augmented_simple_list.rb +1 -1
  136. data/lib/view_processor/hash_pretty_print.rb +1 -1
  137. data/lib/view_processor/simple_list.rb +1 -1
  138. data/lib/view_processor/table_print.rb +1 -1
  139. data/lib/view_processor.rb +1 -1
  140. data/spec/lib/spec_helper.rb +1 -1
  141. data/spec/lib/spec_thor.rb +1 -1
  142. data/spec/node_template_spec.rb +1 -1
  143. data/spec/table_print_spec.rb +1 -1
  144. data/spec/target_spec.rb +1 -1
  145. data/spec/task_spec.rb +1 -1
  146. metadata +20 -20
@@ -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
- def delete_and_destroy(context_params)
193
- target_id = context_params.retrieve_arguments([:option_1!],method_argument_names)
194
-
195
- # No -y options since risk is too great
196
- 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)'"+'?')
197
-
198
- post_body = {
199
- :target_id => target_id,
200
- :type => 'instance'
201
- }
202
-
203
- @@invalidate_map << :target
204
-
205
- response = post(rest_url("target/delete_and_destroy"),post_body)
206
- return response unless response.ok?
207
- if info_array = response.data['info']
208
- info_array.each{|info_msg|OsUtil.print(info_msg, :yellow)}
209
- end
210
- Response::Ok.new()
211
- end
212
-
213
- =begin
214
- # TODO: DTK-2056: rewite
215
- also put in list property
216
- desc "TARGET-NAME/ID set-property PROPERTY VALUE
217
- method_option :keypair, :type => :string
218
- method_option :security_group, :type => :string, :aliases => '--security-groups'
219
- def set_property(context_params)
220
- raise "change so that param is seperated key value parts"
221
- target_id = context_params.retrieve_arguments([:target_id!],method_argument_names)
222
- keypair, security_group = context_params.retrieve_thor_options([:keypair, :security_group], options)
223
-
224
- raise ::DTK::Client::DtkValidationError.new("You have to provide security-group or keypair to edit target!") unless keypair || security_group
225
-
226
- security_groups, iaas_properties = [], {}
227
- iaas_properties.merge!(:keypair => keypair) if keypair
228
-
229
- if security_group
230
- 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?(',')
231
- security_groups = security_group.split(',')
232
- if (security_groups.empty? || security_groups.size==1)
233
- iaas_properties.merge!(:security_group => security_group)
234
- else
235
- iaas_properties.merge!(:security_group_set => security_groups)
236
- end
237
- end
238
- @@invalidate_map << :target
239
-
240
- post_body = {
241
- :target_id => target_id,
242
- :iaas_properties => iaas_properties
243
- }
244
- post rest_url("target/set_properties"), post_body
245
- end
246
- =end
247
- end
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
@@ -113,4 +113,4 @@ module DTK::Client
113
113
  end
114
114
 
115
115
  end
116
- end
116
+ end
@@ -307,4 +307,4 @@ module DTK::Client
307
307
  end
308
308
  end
309
309
  end
310
- end
310
+ end
@@ -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
@@ -96,4 +96,4 @@ module DTK
96
96
  end
97
97
  end
98
98
  end
99
- end
99
+ end
@@ -77,4 +77,4 @@ class DiskCacher
77
77
  cookie_content
78
78
  end
79
79
 
80
- end
80
+ end
data/lib/configurator.rb CHANGED
@@ -173,4 +173,4 @@ module DTK
173
173
  end
174
174
  end
175
175
  end
176
- end
176
+ end
@@ -41,4 +41,4 @@ module DTK
41
41
  end
42
42
 
43
43
  end
44
- end
44
+ end
data/lib/core.rb CHANGED
@@ -486,4 +486,4 @@ module DTK
486
486
  end
487
487
  end
488
488
  end
489
- end
489
+ end