dtk-client 0.7.7 → 0.7.8

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.
@@ -18,19 +18,21 @@ module DTK::Client
18
18
  response = post(rest_url("#{module_type}/get_remote_module_info"),post_body)
19
19
  return response unless response.ok?
20
20
 
21
- module_name,full_module_name = response.data(:module_name,:full_module_name)
21
+ module_name,full_module_name, frozen = response.data(:module_name, :full_module_name, :frozen)
22
+ raise DtkError, "You are not allowed to update frozen #{module_type} versions!" if frozen
23
+
22
24
  remote_params = response.data_hash_form(:remote_repo_url,:remote_repo,:remote_branch)
23
25
  remote_params.merge!(:version => version) if version
24
26
 
25
27
  # check and import component module dependencies before importing service itself
26
28
  unless opts[:skip_recursive_pull]
27
- import_module_component_dependencies(module_type, module_id,remote_namespace)
29
+ import_module_component_dependencies(module_type, module_id, remote_namespace)
28
30
  end
29
31
 
30
32
  # check whether a local module exists to determine whether pull from local clone or try to pull from server
31
33
  # TODO: probably remove OsUtil.print("Pulling changes from remote: #{remote_params[:remote_repo]} @ #{remote_params[:remote_repo_url]}")
32
34
 
33
- if Helper(:git_repo).local_clone_dir_exists?(module_type,module_name,:full_module_name=>full_module_name,:version=>version)
35
+ if Helper(:git_repo).local_clone_dir_exists?(module_type, module_name, :full_module_name => full_module_name, :version => version)
34
36
  unless rsa_pub_key
35
37
  raise DtkError,"No File found at (#{path_to_key}). Path is wrong or it is necessary to generate the public rsa key (e.g., run ssh-keygen -t rsa)"
36
38
  end
@@ -41,6 +41,7 @@ module DTK::Client
41
41
  post_body.merge!(:force => opts[:force]) if opts[:force]
42
42
  post_body.merge!(:task_action => opts[:task_action]) if opts[:task_action]
43
43
  post_body.merge!(:generate_docs => true) if opts[:generate_docs]
44
+ post_body.merge!(:use_impl_id => opts[:use_impl_id]) if opts[:use_impl_id]
44
45
 
45
46
  if opts[:set_parsed_false]
46
47
  post_body.merge!(:set_parsed_false => true)
@@ -60,9 +60,10 @@ module DTK::Client
60
60
  return :component_module, "component_module/list", nil
61
61
  end
62
62
 
63
- desc "delete COMPONENT-MODULE-NAME [-y] [-p]", "Delete component module and all items contained in it. Optional parameter [-p] is to delete local directory."
63
+ desc "delete COMPONENT-MODULE-NAME [-y] [-p] [-v VERSION]", "Delete component module and all items contained in it. Optional parameter [-p] is to delete local directory."
64
64
  method_option :force, :aliases => '-y', :type => :boolean, :default => false
65
65
  method_option :purge, :aliases => '-p', :type => :boolean, :default => false
66
+ version_method_option
66
67
  def delete(context_params,method_opts={})
67
68
  response = delete_module_aux(context_params, method_opts)
68
69
  @@invalidate_map << :component_module if response && response.ok?
@@ -75,13 +76,14 @@ module DTK::Client
75
76
  set_attribute_module_aux(context_params)
76
77
  end
77
78
 
78
- desc "list [--remote] [--diff] [-n NAMESPACE]", "List loaded or remote component modules. Use --diff to compare loaded and remote component modules."
79
+ desc "list [--remote] [--diffs] [-n NAMESPACE]", "List loaded or remote component modules. Use --diff to compare loaded and remote component modules."
79
80
  method_option :remote, :type => :boolean, :default => false
80
- method_option :diff, :type => :boolean, :default => false
81
+ method_option :diffs, :type => :boolean, :default => false, :aliases => "--diff"
81
82
  method_option :namespace, :aliases => "-n" ,
82
83
  :type => :string,
83
84
  :banner => "NAMESPACE",
84
85
  :desc => "List modules only in specific namespace."
86
+ # method_option :with_versions, :type => :boolean, :default => false, :aliases => "with-versions"
85
87
  def list(context_params)
86
88
  return module_info_about(context_params, :components, :component) if context_params.is_there_command?(:"component")
87
89
 
@@ -90,13 +92,25 @@ module DTK::Client
90
92
  action = (remote ? "list_remote" : "list")
91
93
 
92
94
  post_body = (remote ? { :rsa_pub_key => SSHUtil.rsa_pub_key_content() } : {:detail_to_include => ["remotes"]})
93
- post_body[:diff] = options.diff? ? options.diff : {}
95
+ post_body[:diff] = options.diffs? ? options.diffs : {}
96
+
97
+ if post_body[:detail_to_include]
98
+ post_body[:detail_to_include] << 'versions' # if options.with_versions?
99
+ else
100
+ post_body[:detail_to_include]
101
+ end
102
+
94
103
  post_body.merge!(:module_namespace => options.namespace) if options.namespace
95
104
 
96
105
  response = post rest_url("component_module/#{action}"), post_body
97
106
 
98
107
  return response unless response.ok?
99
- response.render_table()
108
+
109
+ if options.with_versions?
110
+ response.render_table(:module_with_versions, true)
111
+ else
112
+ response.render_table()
113
+ end
100
114
  end
101
115
 
102
116
  desc "COMPONENT-MODULE-NAME/ID list-components", "List all components for given component module."
@@ -114,6 +128,20 @@ module DTK::Client
114
128
  module_info_about(context_params, :instances, :component_instances)
115
129
  end
116
130
 
131
+ desc "COMPONENT-MODULE-NAME/ID list-versions","List all versions associated with this component module."
132
+ def list_versions(context_params)
133
+ response = list_versions_aux(context_params)
134
+ return response unless response.ok?
135
+ response.render_table(:list_versions, true)
136
+ end
137
+
138
+ desc "COMPONENT-MODULE-NAME/ID list-remote-versions","List all remote versions associated with this component module."
139
+ def list_remote_versions(context_params)
140
+ response = list_remote_versions_aux(context_params)
141
+ return response unless response.ok?
142
+ response.render_table(:list_versions, true)
143
+ end
144
+
117
145
  desc "import [NAMESPACE:]COMPONENT-MODULE-NAME", "Create new component module from local clone"
118
146
  def import(context_params)
119
147
  response = import_module_aux(context_params)
@@ -171,11 +199,12 @@ module DTK::Client
171
199
  # TODO: put in doc REMOTE-MODULE havs namespace and optionally version information; e.g. r8/hdp or r8/hdp/v1.1
172
200
  # if multiple items and failire; stops on first failure
173
201
  # desc "install [NAMESPACE/]REMOTE-COMPONENT-MODULE-NAME [-r DTK-REPO-MANAGER]","Install remote component module into local environment"
174
- desc "install NAMESPACE/REMOTE-COMPONENT-MODULE-NAME","Install remote component module into local environment"
202
+ desc "install NAMESPACE/REMOTE-COMPONENT-MODULE-NAME [-v VERSION]","Install remote component module into local environment"
175
203
  method_option "repo-manager",:aliases => "-r" ,
176
204
  :type => :string,
177
205
  :banner => "REPO-MANAGER",
178
206
  :desc => "DTK Repo Manager from which to resolve requested module."
207
+ version_method_option
179
208
  def install(context_params)
180
209
  response = install_module_aux(context_params)
181
210
  if response && response.ok?
@@ -236,9 +265,10 @@ module DTK::Client
236
265
  end
237
266
  =end
238
267
 
239
- desc "delete-from-catalog NAMESPACE/REMOTE-COMPONENT-MODULE-NAME [-y] [--force]", "Delete the component module from the DTK Network catalog"
268
+ desc "delete-from-catalog NAMESPACE/REMOTE-COMPONENT-MODULE-NAME [-y] [--force] [-v VERSION]", "Delete the component module from the DTK Network catalog"
240
269
  method_option :confirmed, :aliases => '-y', :type => :boolean, :default => false
241
270
  method_option :force, :type => :boolean, :default => false
271
+ version_method_option
242
272
  def delete_from_catalog(context_params)
243
273
  delete_from_catalog_aux(context_params)
244
274
  end
@@ -259,7 +289,9 @@ module DTK::Client
259
289
  # return response
260
290
  # end
261
291
 
262
- desc "COMPONENT-MODULE-NAME/ID publish [[NAMESPACE/]REMOTE-COMPONENT-MODULE-NAME]", "Publish component module to remote repository."
292
+ desc "COMPONENT-MODULE-NAME/ID publish [[NAMESPACE/]REMOTE-COMPONENT-MODULE-NAME] [-v VERSION] [--force]", "Publish component module to remote repository."
293
+ version_method_option
294
+ method_option :force, :type => :boolean, :default => false, :aliases => '-f'
263
295
  def publish(context_params)
264
296
  publish_module_aux(context_params)
265
297
  end
@@ -332,10 +364,9 @@ module DTK::Client
332
364
  # This will change behaviour of method in such way that edit will not be
333
365
  # triggered after it.
334
366
  #
335
- #desc "COMPONENT-MODULE-NAME/ID clone [-v VERSION] [-n]", "Locally clone component module and component files. Use -n to skip edit prompt"
336
- # version_method_option
337
- desc "COMPONENT-MODULE-NAME/ID clone [-n]", "Locally clone component module and component files. Use -n to skip edit prompt"
367
+ desc "COMPONENT-MODULE-NAME/ID clone [-n] [-v VERSION]", "Locally clone component module and component files. Use -n to skip edit prompt"
338
368
  method_option :skip_edit, :aliases => '-n', :type => :boolean, :default => false
369
+ version_method_option
339
370
  def clone(context_params, internal_trigger=true)
340
371
  clone_module_aux(context_params, internal_trigger)
341
372
  end
@@ -348,7 +379,6 @@ module DTK::Client
348
379
  end
349
380
 
350
381
  desc "COMPONENT-MODULE-NAME/ID push [--force] [--docs]", "Push changes from local copy of component module to server"
351
- version_method_option
352
382
  method_option "message",:aliases => "-m" ,
353
383
  :type => :string,
354
384
  :banner => "COMMIT-MSG",
@@ -360,7 +390,7 @@ module DTK::Client
360
390
  push_module_aux(context_params, internal_trigger)
361
391
  end
362
392
 
363
- # desc "COMPONENT-MODULE-NAME/ID push-dtkn [-n NAMESPACE] [-m COMMIT-MSG]", "Push changes from local copy of component module to remote repository (dtkn)."
393
+ # desc "COMPONENT-MODULE-NAME/ID push-dtkn [-n NAMESPACE] [-m COMMIT-MSG]", "Push changes from local copy of component module to remote repository (dtkn)."
364
394
  desc "COMPONENT-MODULE-NAME/ID push-dtkn [-n NAMESPACE] [--force]", "Push changes from local copy of component module to remote repository (dtkn)."
365
395
  method_option "message",:aliases => "-m" ,
366
396
  :type => :string,
@@ -416,6 +446,11 @@ module DTK::Client
416
446
  fork_aux(context_params)
417
447
  end
418
448
 
449
+ desc "COMPONENT-MODULE-NAME/ID create-new-version VERSION", "Create new component module version"
450
+ def create_new_version(context_params)
451
+ create_new_version_aux(context_params)
452
+ end
453
+
419
454
  #
420
455
  # DEVELOPMENT MODE METHODS
421
456
  #
@@ -44,15 +44,16 @@ module DTK::Client
44
44
  # run-agent haris1 dev_manager inject_agent "{ 'action_agent_branch': 'master', 'action_agent_url': 'git@github.com:rich-reactor8/dtk-action-agent.git' }"
45
45
  desc "run-agent SERVICE-NAME AGENT-NAME AGENT-METHOD PARAMS", "Updates DTK Action Agent to provided branch, example: dev_manager inject_agent \"{ 'action_agent_branch': 'master', 'action_agent_url': 'url' }\""
46
46
  def run_agent(context_params)
47
- service_name, agent_name, agent_method, action_params = context_params.retrieve_arguments([:option_1!, :option_2!, :option_3!, :option_4], method_argument_names)
47
+ service_name, agent_name, agent_method, action_params = context_params.retrieve_arguments([:option_1!, :option_2!, :option_3!, :option_4!], method_argument_names)
48
48
 
49
49
  action_params ||= "{}"
50
50
  action_params.gsub!("'",'"')
51
51
 
52
52
  response = post_file rest_url("developer/run_agent"), { :service_name => service_name, :agent_name => agent_name, :agent_method => agent_method, :agent_params => action_params }
53
+ return response unless response.ok?
53
54
 
54
55
  action_results_id = response.data(:action_results_id)
55
- print_action_results(action_results_id)
56
+ print_simple_results(action_results_id)
56
57
 
57
58
  nil
58
59
  end
@@ -68,12 +68,16 @@ module DTK::Client
68
68
  def self.extended_context()
69
69
  {
70
70
  :context => {
71
- :add_component => "component_template",
72
71
  :create_node => "node_template",
73
72
  :create_node_group => "node_template",
74
73
  :add_component_dependency => "component_template"
75
74
  },
76
75
  :command => {
76
+ :add_component => {
77
+ :endpoint => "component_template",
78
+ :url => "component/list",
79
+ :opts => {:subtype=>"template", :ignore => "test_module", :hide_assembly_cmps => "true"}
80
+ },
77
81
  :edit_component_module => {
78
82
  :endpoint => "assembly",
79
83
  :url => "assembly/info_about",
@@ -8,6 +8,7 @@ dtk_require_from_base('command_helpers/service_importer')
8
8
  dtk_require_common_commands('thor/common')
9
9
  dtk_require_common_commands('thor/module')
10
10
  dtk_require_common_commands('thor/poller')
11
+ dtk_require_common_commands('thor/assembly_template')
11
12
 
12
13
  module DTK::Client
13
14
  class ServiceModule < CommandBaseThor
@@ -19,6 +20,7 @@ module DTK::Client
19
20
  include ServiceImporter
20
21
  include ModuleMixin
21
22
  include Poller
23
+ include AssemblyTemplateMixin
22
24
 
23
25
  def get_service_module_name(service_module_id)
24
26
  get_name_from_id_helper(service_module_id)
@@ -76,7 +78,7 @@ module DTK::Client
76
78
  ],
77
79
  :assembly => [
78
80
  ["info","info","# Info for given assembly in current service module."],
79
- ["stage", "stage [INSTANCE-NAME] [-t TARGET-NAME/ID] [--node-size NODE-SIZE-SPEC] [--os-type OS-TYPE]", "# Stage assembly in target."],
81
+ # ["stage", "stage [INSTANCE-NAME] [-t TARGET-NAME/ID] [--node-size NODE-SIZE-SPEC] [--os-type OS-TYPE] [-v VERSION]", "# Stage assembly in target."],
80
82
  # ["deploy","deploy [-v VERSION] [INSTANCE-NAME] [-t TARGET-NAME/ID] [-m COMMIT-MSG]", "# Stage and deploy assembly in target."],
81
83
  # ["deploy","deploy [INSTANCE-NAME] [-t TARGET-NAME/ID] [-m COMMIT-MSG]", "# Stage and deploy assembly in target."],
82
84
  ["deploy","deploy [INSTANCE-NAME] [-m COMMIT-MSG]", "# Stage and deploy assembly in target."],
@@ -95,7 +97,8 @@ module DTK::Client
95
97
  module_info_aux(context_params)
96
98
  end
97
99
 
98
- desc "SERVICE-MODULE-NAME/ID list-assemblies","List assemblies associated with service module."
100
+ desc "SERVICE-MODULE-NAME/ID list-assemblies [-v VERSION]","List assemblies associated with service module."
101
+ version_method_option
99
102
  method_option :remote, :type => :boolean, :default => false
100
103
  def list_assemblies(context_params)
101
104
  context_params.method_arguments = ["assembly"]
@@ -109,13 +112,14 @@ module DTK::Client
109
112
  list(context_params)
110
113
  end
111
114
 
112
- desc "list [--remote] [--diff] [-n NAMESPACE]","List service modules (local/remote). Use --diff to compare loaded and remote modules."
115
+ desc "list [--remote] [--diffs] [-n NAMESPACE]","List service modules (local/remote). Use --diff to compare loaded and remote modules."
113
116
  method_option :remote, :type => :boolean, :default => false
114
- method_option :diff, :type => :boolean, :default => false
117
+ method_option :diffs, :type => :boolean, :default => false, :aliases => "--diff"
115
118
  method_option :namespace, :aliases => "-n" ,
116
119
  :type => :string,
117
120
  :banner => "NAMESPACE",
118
121
  :desc => "List modules only in specific namespace."
122
+ # method_option :with_versions, :type => :boolean, :default => false, :aliases => "with-versions"
119
123
  def list(context_params)
120
124
  service_module_id, about, service_module_name = context_params.retrieve_arguments([:service_module_id, :option_1, :option_2],method_argument_names)
121
125
  datatype = nil
@@ -132,21 +136,29 @@ module DTK::Client
132
136
  if (context_params.last_entity_name == :"service-module") and about.nil?
133
137
  action = options.remote? ? "list_remote" : "list"
134
138
  post_body = (options.remote? ? { :rsa_pub_key => SSHUtil.rsa_pub_key_content() } : {:detail_to_include => ["remotes"]})
135
- post_body[:diff] = options.diff? ? options.diff : {}
139
+ post_body[:diff] = options.diffs? ? options.diffs : {}
136
140
  post_body.merge!(:module_namespace => options.namespace) if options.namespace
137
141
 
142
+ if post_body[:detail_to_include]
143
+ post_body[:detail_to_include] << 'versions' # if options.with_versions?
144
+ else
145
+ post_body[:detail_to_include]
146
+ end
147
+
138
148
  response = post rest_url("service_module/#{action}"), post_body
139
149
  # If user is on service identifier level, list task can't have '--remote' option.
140
150
  else
141
151
  # TODO: this is temp; will shortly support this
142
152
  raise DTK::Client::DtkValidationError.new("Not supported '--remote' option when listing service module assemblies, component templates or modules", true) if options.remote?
143
153
  raise DTK::Client::DtkValidationError.new("Not supported type '#{about}' for list for current context level. Possible type options: 'assembly'", true) unless(about == "assembly" || about == "modules")
144
-
154
+ post_body = { :service_module_id => service_module_id }
145
155
  if about
146
156
  case about
147
157
  when "assembly"
148
- data_type = :assembly_template_description
149
- action = "list_assemblies"
158
+ version = options.version
159
+ data_type = :assembly_template_description
160
+ action = "list_assemblies"
161
+ post_body.merge!(:version => version) if version
150
162
  when "modules"
151
163
  data_type = options.remote? ? :component_remote : :component_module
152
164
  action = "list_component_modules"
@@ -154,10 +166,16 @@ module DTK::Client
154
166
  raise_validation_error_method_usage('list')
155
167
  end
156
168
  end
157
- response = post rest_url("service_module/#{action}"), { :service_module_id => service_module_id }
169
+ response = post rest_url("service_module/#{action}"), post_body
158
170
  end
159
171
 
160
- response.render_table(data_type) unless response.nil?
172
+ unless response.nil?
173
+ if options.with_versions?
174
+ response.render_table(:module_with_versions, true)
175
+ else
176
+ response.render_table(data_type)
177
+ end
178
+ end
161
179
 
162
180
  response
163
181
  end
@@ -167,24 +185,26 @@ module DTK::Client
167
185
  list_instances_aux(context_params)
168
186
  end
169
187
 
170
- # desc "SERVICE-MODULE-NAME/ID list-versions","List all versions associated with this service module."
171
- # def list_versions(context_params)
172
- # service_module_id = context_params.retrieve_arguments([:service_module_id!],method_argument_names)
173
- # post_body = {
174
- # :service_module_id => service_module_id,
175
- # :detail_to_include => ["remotes"],
176
- # :rsa_pub_key => SSHUtil.rsa_pub_key_content()
177
- # }
178
- # response = post rest_url("service_module/versions"), post_body
188
+ desc "SERVICE-MODULE-NAME/ID list-versions","List all versions associated with this service module."
189
+ def list_versions(context_params)
190
+ response = list_versions_aux(context_params)
191
+ return response unless response.ok?
192
+ response.render_table(:list_versions, true)
193
+ end
179
194
 
180
- # response.render_table(:module_version)
181
- # end
195
+ desc "SERVICE-MODULE-NAME/ID list-remote-versions","List all remote versions associated with this service module."
196
+ def list_remote_versions(context_params)
197
+ response = list_remote_versions_aux(context_params)
198
+ return response unless response.ok?
199
+ response.render_table(:list_versions, true)
200
+ end
182
201
 
183
202
  # version_method_option
184
- desc "install NAMESPACE/REMOTE-SERVICE-MODULE-NAME [-y]", "Install remote service module into local environment. -y will automatically clone component modules."
203
+ desc "install NAMESPACE/REMOTE-SERVICE-MODULE-NAME [-y] [-v VERSION]", "Install remote service module into local environment. -y will automatically clone component modules."
185
204
  method_option :force, :aliases => '-y', :type => :boolean, :default => false
186
205
  # method_option :ignore, :aliases => '-i', :type => :boolean, :default => false
187
206
  method_option :update_none, :type => :boolean, :default => false
207
+ version_method_option
188
208
  def install(context_params)
189
209
  response = install_module_aux(context_params)
190
210
  @@invalidate_map << :service_module if response && response.ok?
@@ -249,7 +269,9 @@ module DTK::Client
249
269
  # post rest_url("service_module/export"), post_body
250
270
  # end
251
271
 
252
- desc "SERVICE-MODULE-NAME/ID publish [[NAMESPACE/]REMOTE-SERVICE-MODULE-NAME]","Publish service module to remote repository"
272
+ desc "SERVICE-MODULE-NAME/ID publish [[NAMESPACE/]REMOTE-SERVICE-MODULE-NAME] [-v VERSION] [--force]","Publish service module to remote repository"
273
+ version_method_option
274
+ method_option :force, :type => :boolean, :default => false, :aliases => '-f'
253
275
  def publish(context_params)
254
276
  publish_module_aux(context_params)
255
277
  end
@@ -293,7 +315,6 @@ module DTK::Client
293
315
  # push_to_remote_aux(:service_module, service_module_id, service_module_name, options["namespace"], options["version"])
294
316
  # end
295
317
 
296
- # desc "SERVICE-MODULE-NAME/ID pull-from-dtkn [-n NAMESPACE] [-v VERSION]", "Update local service module from remote repository."
297
318
  desc "SERVICE-MODULE-NAME/ID pull-dtkn [-n NAMESPACE] [--force]", "Update local service module from remote repository."
298
319
  method_option :namespace,:aliases => '-n',
299
320
  :type => :string,
@@ -354,8 +375,9 @@ module DTK::Client
354
375
  #
355
376
  # desc "SERVICE-MODULE-NAME/ID clone [-v VERSION] [-n]", "Locally clone the service module files. Use -n to skip edit prompt"
356
377
  # version_method_option
357
- desc "SERVICE-MODULE-NAME/ID clone [-n]", "Locally clone the service module files. Use -n to skip edit prompt"
378
+ desc "SERVICE-MODULE-NAME/ID clone [-n] [-v VERSION]", "Locally clone the service module files. Use -n to skip edit prompt"
358
379
  method_option :skip_edit, :aliases => '-n', :type => :boolean, :default => false
380
+ version_method_option
359
381
  def clone(context_params, internal_trigger=false)
360
382
  clone_module_aux(context_params, internal_trigger)
361
383
  end
@@ -420,6 +442,68 @@ module DTK::Client
420
442
  response
421
443
  end
422
444
 
445
+ desc "SERVICE-MODULE-NAME/ID stage ASSEMBLY-NAME [INSTANCE-NAME] [-t TARGET-NAME/ID] [--node-size NODE-SIZE-SPEC] [--os-type OS-TYPE] [-v VERSION]", "Stage assembly in target."
446
+ method_option "in-target", :aliases => "-t", :type => :string, :banner => "TARGET-NAME/ID", :desc => "Target (id) to create assembly in"
447
+ method_option :settings, :type => :string, :aliases => '-s'
448
+ method_option :node_size, :type => :string, :aliases => "--node-size"
449
+ method_option :os_type, :type => :string, :aliases => "--os-type"
450
+ version_method_option
451
+ #hidden option
452
+ method_option "instance-bindings", :type => :string
453
+ def stage(context_params)
454
+ service_module_id, service_module_name, assembly_template_name, name = context_params.retrieve_arguments([:service_module_id!, :service_module_name!, :option_1!, :option_2], method_argument_names)
455
+ post_body = {
456
+ :assembly_id => assembly_template_name
457
+ }
458
+
459
+ # special case when we need service module id
460
+ context_params.pure_cli_mode = true
461
+ post_body[:service_module_id] = service_module_id if context_params.pure_cli_mode
462
+
463
+ # using this to make sure cache will be invalidated after new assembly is created from other commands e.g.
464
+ # 'assembly-create', 'install' etc.
465
+ @@invalidate_map << :assembly
466
+
467
+ if assembly_template_name.to_s =~ /^[0-9]+$/
468
+ assembly_template_name = get_assembly_name(assembly_template_id)
469
+ else
470
+ namespace, module_name = get_namespace_and_name(service_module_name, ':')
471
+ assembly_template_name = "#{module_name}/#{assembly_template_name}"
472
+ end
473
+ assembly_template_name.gsub!(/(::)|(\/)/,'-') if assembly_template_name
474
+
475
+ in_target = options["in-target"]
476
+ instance_bindings = options["instance-bindings"]
477
+ settings = parse_service_settings(options["settings"])
478
+ node_size = options.node_size
479
+ os_type = options.os_type
480
+ version = options.version
481
+ assembly_list = Assembly.assembly_list()
482
+
483
+ if name
484
+ raise DTK::Client::DtkValidationError, "Unable to stage service with name '#{name}'. Service with specified name exists already!" if assembly_list.include?(name)
485
+ else
486
+ name = get_assembly_stage_name(assembly_list, assembly_template_name)
487
+ end
488
+
489
+ post_body.merge!(:target_id => in_target) if in_target
490
+ post_body.merge!(:name => name) if name
491
+ post_body.merge!(:instance_bindings => instance_bindings) if instance_bindings
492
+ post_body.merge!(:settings_json_form => JSON.generate(settings)) if settings
493
+ post_body.merge!(:node_size => node_size) if node_size
494
+ post_body.merge!(:os_type => os_type) if os_type
495
+ post_body.merge!(:version => version) if version
496
+ post_body.merge!(:service_module_name => service_module_name) if service_module_name
497
+
498
+ response = post rest_url("assembly/stage"), post_body
499
+ return response unless response.ok?
500
+ # when changing context send request for getting latest assemblies instead of getting from cache
501
+ @@invalidate_map << :service
502
+ @@invalidate_map << :assembly
503
+
504
+ return response
505
+ end
506
+
423
507
 
424
508
  # desc "SERVICE-MODULE-NAME/ID push [-v VERSION] [-m COMMIT-MSG]", "Push changes from local copy of service module to server"
425
509
  # version_method_option
@@ -513,9 +597,10 @@ module DTK::Client
513
597
 
514
598
  # desc "delete SERVICE-MODULE-NAME [-v VERSION] [-y] [-p]", "Delete service module or service module version and all items contained in it. Optional parameter [-p] is to delete local directory."
515
599
  # version_method_option
516
- desc "delete SERVICE-MODULE-NAME [-y] [-p]", "Delete service module and all items contained in it. Optional parameter [-p] is to delete local directory."
600
+ desc "delete SERVICE-MODULE-NAME [-y] [-p] [-v VERSION]", "Delete service module and all items contained in it. Optional parameter [-p] is to delete local directory."
517
601
  method_option :force, :aliases => '-y', :type => :boolean, :default => false
518
602
  method_option :purge, :aliases => '-p', :type => :boolean, :default => false
603
+ version_method_option
519
604
  def delete(context_params)
520
605
  response = delete_module_aux(context_params)
521
606
  @@invalidate_map << :service_module if response && response.ok?
@@ -523,9 +608,10 @@ module DTK::Client
523
608
  response
524
609
  end
525
610
 
526
- desc "delete-from-catalog NAMESPACE/REMOTE-SERVICE-MODULE-NAME [-y] [--force]", "Delete the service module from the DTK Network catalog"
611
+ desc "delete-from-catalog NAMESPACE/REMOTE-SERVICE-MODULE-NAME [-y] [--force] [-v VERSION]", "Delete the service module from the DTK Network catalog"
527
612
  method_option :confirmed, :aliases => '-y', :type => :boolean, :default => false
528
613
  method_option :force, :type => :boolean, :default => false
614
+ version_method_option
529
615
  def delete_from_catalog(context_params)
530
616
  delete_from_catalog_aux(context_params)
531
617
  end
@@ -569,6 +655,11 @@ module DTK::Client
569
655
  fork_aux(context_params)
570
656
  end
571
657
 
658
+ desc "SERVICE-MODULE-NAME/ID create-new-version VERSION", "Create new service module version"
659
+ def create_new_version(context_params)
660
+ create_new_version_aux(context_params)
661
+ end
662
+
572
663
  #
573
664
  # DEVELOPMENT MODE METHODS
574
665
  #