Class: Morpheus::Cli::Projects

Inherits:
Object
  • Object
show all
Includes:
CliCommand, OptionSourceHelper, ProvisioningHelper
Defined in:
lib/morpheus/cli/projects_command.rb

Instance Attribute Summary

Attributes included from CliCommand

#no_prompt

Instance Method Summary collapse

Methods included from OptionSourceHelper

#find_available_user_option, #find_cloud_option, #find_group_option, #find_tenant_option, #get_available_user_options, #get_cloud_options, #get_group_options, #get_tenant_options, included, #load_option_source_data, #options_interface, #parse_cloud_id_list, #parse_group_id_list, #parse_option_source_id_list, #parse_project_id_list, #parse_tenant_id_list, #parse_user_id_list

Methods included from ProvisioningHelper

#accounts_interface, #add_perms_options, #api_client, #apps_interface, #cloud_datastores_interface, #clouds_interface, #datastores_interface, #find_app_by_id, #find_app_by_name, #find_app_by_name_or_id, #find_cloud_by_id_for_provisioning, #find_cloud_by_name_for_provisioning, #find_cloud_by_name_or_id_for_provisioning, #find_cloud_resource_pool_by_name_or_id, #find_group_by_id_for_provisioning, #find_group_by_name_for_provisioning, #find_group_by_name_or_id_for_provisioning, #find_host_by_id, #find_host_by_name, #find_host_by_name_or_id, #find_instance_by_id, #find_instance_by_name, #find_instance_by_name_or_id, #find_instance_type_by_code, #find_instance_type_by_id, #find_instance_type_by_name, #find_instance_type_by_name_or_id, #find_instance_type_layout_by_id, #find_server_by_id, #find_server_by_name, #find_server_by_name_or_id, #find_workflow_by_id, #find_workflow_by_name, #find_workflow_by_name_or_id, #format_blueprint_type, #format_metadata, #get_available_accounts, #get_available_clouds, #get_available_environments, #get_available_groups, #get_available_plans, #get_provision_type_for_zone_type, #get_static_environments, included, #instance_type_layouts_interface, #instance_types_interface, #instances_interface, #load_balance_protocols_dropdown, #options_interface, #parse_blueprint_type, #parse_host_id_list, #parse_instance_id_list, #parse_metadata, #parse_server_id_list, #print_permissions, #prompt_evars, #prompt_exposed_ports, #prompt_instance_load_balancer, #prompt_metadata, #prompt_network_interfaces, #prompt_new_instance, #prompt_permissions, #prompt_resize_volumes, #prompt_security_groups, #prompt_volumes, #provision_types_interface, #reject_service_plan_option_types, #servers_interface

Methods included from CliCommand

#apply_options, #build_common_options, #build_option_type_options, #build_standard_add_options, #build_standard_delete_options, #build_standard_get_options, #build_standard_list_options, #build_standard_post_options, #build_standard_put_options, #build_standard_remove_options, #build_standard_update_options, #command_name, #default_refresh_interval, #default_subcommand, #establish_remote_appliance_connection, #full_command_usage, #handle_subcommand, included, #interactive?, #my_help_command, #my_terminal, #my_terminal=, #parse_bytes_param, #parse_id_list, #parse_list_options, #parse_list_subtitles, #parse_passed_options, #parse_payload, #parse_query_options, #print, #print_error, #println, #puts, #puts_error, #raise_args_error, #raise_command_error, #render_response, #render_with_format, #run_command_for_each_arg, #subcommand_aliases, #subcommand_usage, #subcommands, #usage, #verify_args!, #visible_subcommands

Instance Method Details

#_get(id, options) ⇒ Object



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/morpheus/cli/projects_command.rb', line 120

def _get(id, options)
  @projects_interface.setopts(options)
  if options[:dry_run]
    if id.to_s =~ /\A\d{1,}\Z/
      print_dry_run @projects_interface.dry.get(id.to_i)
    else
      print_dry_run @projects_interface.dry.get({name: id})
    end
    return
  end
  project = find_project_by_name_or_id(id)
  exit 1 if project.nil?
  # refetch it by id
  json_response = {'project' => project}
  unless id.to_s =~ /\A\d{1,}\Z/
    json_response = @projects_interface.get(project['id'])
  end
  project = json_response['project']
  render_response(json_response, options, 'project') do
    print_h1 "Project Details"
    print cyan
    description_cols = {
      "ID" => 'id',
      "Name" => 'name',
      "Description" => 'description',
      "Tags" => lambda {|it| it['tags'] ? it['tags'].collect {|m| "#{m['name']}: #{m['value']}" }.join(', ') : '' },
      "Owner" => lambda {|it| it['owner'] ? it['owner']['username'] : '' },
      "Date Created" => lambda {|it| format_local_dt(it['dateCreated']) },
      "Last Updated" => lambda {|it| format_local_dt(it['lastUpdated']) }
    }
    print_description_list(description_cols, project)
    
    project_instances = project["instances"]
    if project_instances && project_instances.size > 0
      print_h2 "Instances"
      print cyan
      print as_pretty_table(project_instances, [:id, :name], options)
    end

    project_hosts = project["servers"] || project["hosts"]
    if project_hosts && project_hosts.size > 0
      print_h2 "Hosts"
      print cyan
      print as_pretty_table(project_hosts, [:id, :name], options)
    end

    project_clouds = project["clouds"] || project["zones"]
    if project_clouds && project_clouds.size > 0
      print_h2 "Clouds"
      print cyan
      print as_pretty_table(project_clouds, [:id, :name], options)
    end
    print reset,"\n"
  end
  return 0, nil
end

#add(args) ⇒ Object



177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/morpheus/cli/projects_command.rb', line 177

def add(args)
  exit_code, err = 0, nil
  params, options, payload = {}, {}, {}
  project_name, description, , instance_ids, server_ids, cloud_ids = nil, nil, nil, nil, nil, nil
  optparse = Morpheus::Cli::OptionParser.new do |opts|
    opts.banner = subcommand_usage("[name]")
    opts.on('--name NAME', String, "Project Name" ) do |val|
      project_name = val
    end
    opts.on('--description NAME', String, "Project Description" ) do |val|
      description = val
    end
    opts.on('--tags TAGS', String, "Tags in the format 'name:value, name:value'") do |val|
       = val
    end
    opts.on('--instances [LIST]', Array, "Instances, comma separated list of instance names or IDs.") do |list|
      instance_ids = list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq
    end
    opts.on('--servers [LIST]', Array, "Servers, comma separated list of server (host) names or IDs.") do |list|
      server_ids = list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq
    end
    opts.on('--clouds [LIST]', Array, "Clouds, comma separated list of cloud names or IDs.") do |list|
      cloud_ids = list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq
    end
    build_standard_add_options(opts, options)
    opts.footer = "Create a project.\n[name] is required. This is the name of the new project.\n"
  end
  optparse.parse!(args)
  verify_args!(args:args, optparse:optparse, max:1)
  if args[0]
    project_name = args[0]
  end
  connect(options)
  exit_code, err = 0, nil
  # construct payload
  if options[:payload]
    payload = options[:payload]
    payload.deep_merge!({'project' => parse_passed_options(options)})
  else
    payload['project'] = {}
    payload.deep_merge!({'project' => parse_passed_options(options)})
    payload['project']['name'] = project_name ? project_name : Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'name', 'fieldLabel' => 'Name', 'type' => 'text', 'required' => true, 'description' => 'Project Name'}], options[:options], @api_client)['name']
    payload['project']['description'] = description ? description : Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'description', 'fieldLabel' => 'Description', 'type' => 'text', 'required' => false, 'description' => 'Project Description'}], options[:options], @api_client)['description']
    # metadata tags
    if 
       = ()
      payload['project']['tags'] =  if 
    else
       = (options)
      payload['project']['tags'] =  if 
    end
    if instance_ids != nil
      payload['project']['instances'] = parse_instance_id_list(instance_ids).collect { |it| {'id': it.to_i} }
    else
      # could prompt
    end
    # --instances
    if instance_ids
      payload['project']['instances'] = parse_instance_id_list(instance_ids).collect { |it| {'id': it.to_i} }
    end
    # --servers
    if server_ids
      payload['project']['servers'] = parse_server_id_list(server_ids).collect { |it| {'id': it.to_i} }
    end
    # --clouds
    if cloud_ids
      payload['project']['clouds'] = parse_cloud_id_list(cloud_ids).collect { |it| {'id': it.to_i} }
    end
  end
  @projects_interface.setopts(options)
  if options[:dry_run]
    print_dry_run @projects_interface.dry.create(payload)
    return
  end
  json_response = @projects_interface.create(payload)
  project = json_response['project']
  render_response(json_response, options, 'project') do
    print_green_success "Project #{project['name']} created"
    exit_code, err = get([project['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
  end
  return exit_code, err
end

#add_tags(args) ⇒ Object



397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
# File 'lib/morpheus/cli/projects_command.rb', line 397

def add_tags(args)
  params = {}
  options = {}
  payload = {}
   = nil
  optparse = Morpheus::Cli::OptionParser.new do |opts|
    opts.banner = subcommand_usage("[project] [tag=value] [tag=value]")
    opts.on('--tags TAGS', String, "Project Tags in the format 'name:value, name:value'. This will add/update project tags.") do |val|
       = val
    end
    build_standard_update_options(opts, options)
    opts.footer = "Add metadata tags to a project.\n[project] is required. This is the name or id of a project.\n[tag=value] is required. This is a metadata tag in the format name=value, 1-N may be passed.\n"
  end
  optparse.parse!(args)
  verify_args!(args:args, optparse:optparse, min:1) # maybe min:2 instead ?
  connect(options)
  exit_code, err = 0, nil
  if args.count > 1
     = args[1..-1].join(" ")
  end
  project = find_project_by_name_or_id(args[0])
  return 1, "project not found by '#{args[0]}'" if project.nil?
  # construct payload

  if options[:payload]
    payload = options[:payload]
    payload.deep_merge!({'project' => parse_passed_options(options)})
  else
    payload['project'] = {}
    payload.deep_merge!({'project' => parse_passed_options(options)})
    if options[:metadata]
      payload['project']['addTags'] = ()
    end
  end
  @projects_interface.setopts(options)
  if options[:dry_run]
    print_dry_run @projects_interface.dry.update(project['id'], payload)
    return
  end
  json_response = @projects_interface.update(project['id'], payload)
  project = json_response['project']
  render_response(json_response, options, 'project') do
    print_green_success "Project #{project['name']} updated"
    exit_code, err = get([project['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
  end
  return exit_code, err
end

#get(args) ⇒ Object



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/morpheus/cli/projects_command.rb', line 98

def get(args)
  options = {}
  optparse = Morpheus::Cli::OptionParser.new do |opts|
    opts.banner = subcommand_usage("[workflow]")
    opts.on('--no-content', "Do not display script content." ) do
      options[:no_content] = true
    end
    build_common_options(opts, options, [:json, :yaml, :csv, :fields, :dry_run, :remote])
    opts.footer = "Get details about a project.\n[project] is required. This is the name or id of a project.\n"
  end
  optparse.parse!(args)
  verify_args!(args:args, optparse:optparse, min:1)
  connect(options)
  id_list = parse_id_list(args)
  return run_command_for_each_arg(id_list) do |arg|
    _get(arg, options)
  end
end

#handle(args) ⇒ Object



23
24
25
# File 'lib/morpheus/cli/projects_command.rb', line 23

def handle(args)
  handle_subcommand(args)
end

#list(args) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/morpheus/cli/projects_command.rb', line 27

def list(args)
  params = {}
  options = {}
  instance_ids, server_ids, cloud_ids = nil, nil, nil
  optparse = Morpheus::Cli::OptionParser.new do |opts|
    opts.banner = subcommand_usage()
    opts.on('--instances [LIST]', Array, "Filter by Instance, comma separated list of instance names or IDs.") do |list|
      instance_ids = list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq
    end
    opts.on('--servers [LIST]', Array, "Filter by Server, comma separated list of server (host) names or IDs.") do |list|
      server_ids = list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq
    end
    opts.on('--clouds [LIST]', Array, "Filter by Cloud, comma separated list of cloud (zone) names or IDs.") do |list|
      cloud_ids = list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq
    end
    # opts.on('--owner [LIST]', Array, "Owner, comma separated list of usernames or IDs.") do |list|
    #   params['ownerId'] = list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq
    # end
    build_standard_get_options(opts, options)
    opts.footer = "List projects.\n"
  end
  optparse.parse!(args)
  #verify_args!(args:args, optparse:optparse, count:0)
  connect(options)
  options[:phrase] = args.join(' ') if args.count > 0 && params[:phrase].nil? # pass args as phrase, every list command should do this
  params.merge!(parse_list_options(options))
  params['instanceId'] = parse_instance_id_list(instance_ids) if instance_ids
  # todo server and cloud, missing parse_server_id_list() too
  params['serverId'] = parse_server_id_list(server_ids) if server_ids
  params['cloudId'] = parse_cloud_id_list(cloud_ids) if cloud_ids
  @projects_interface.setopts(options)
  if options[:dry_run]
    print_dry_run @projects_interface.dry.list(params)
    return
  end
  json_response = @projects_interface.list(params)
  projects = json_response['projects']
  render_response(json_response, options, 'projects') do
    title = "Morpheus Projects"
    subtitles = []
    subtitles += parse_list_subtitles(options)
    print_h1 title, subtitles
    if projects.empty?
      print yellow,"No projects found.",reset,"\n"
    else
      print cyan
      columns = [
        {"ID" => lambda {|it| it['id'] } },
        {"NAME" => lambda {|it| it['name'] } },
        {"DESCRIPTION" => lambda {|it| it['description'] } },
        {"INSTANCES" => lambda {|it| it['instances'].size rescue '' } },
        {"SERVERS" => lambda {|it| it['servers'].size rescue '' } },
        {"CLOUDS" => lambda {|it| it['clouds'].size rescue '' } },
        {"OWNER" => lambda {|it| it['owner'] ? it['owner']['username'] : '' } },
        {"DATE CREATED" => lambda {|it| format_local_dt(it['dateCreated']) } },
        {"LAST UPDATED" => lambda {|it| format_local_dt(it['lastUpdated']) } },
      ]
      print as_pretty_table(projects, columns, options)
      print_results_pagination(json_response)
    end
    print reset,"\n"
  end
  if projects.empty?
    return 1, "No projects found"
  else
    return 0, nil
  end
end

#remove(args) ⇒ Object



501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
# File 'lib/morpheus/cli/projects_command.rb', line 501

def remove(args)
  params = {}
  options = {}
  optparse = Morpheus::Cli::OptionParser.new do |opts|
    opts.banner = subcommand_usage("[project]")
    build_common_options(opts, options, [:auto_confirm, :json, :dry_run, :quiet, :remote])
    # opts.on( '-f', '--force', "Force Delete" ) do
    #   params[:force] = true
    # end
    opts.footer = "Delete a project.\n[project] is required. This is the name or id of a project.\n"
  end
  optparse.parse!(args)
  verify_args!(args:args, optparse:optparse, count:1)
  connect(options)
  exit_code, err = 0, nil
  project = find_project_by_name_or_id(args[0])
  return 1, "project not found by '#{args[0]}'" if project.nil?
  unless options[:yes] || Morpheus::Cli::OptionTypes.confirm("Are you sure you want to delete the project #{project['name']}?")
    return 9, "aborted command"
  end
  @projects_interface.setopts(options)
  if options[:dry_run]
    print_dry_run @projects_interface.dry.destroy(project['id'], params)
    return
  end
  json_response = @projects_interface.destroy(project['id'], params)
  render_response(json_response, options) do
    print_green_success "Project #{project['name']} removed"
  end
  return exit_code, err
end

#remove_tags(args) ⇒ Object



449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
# File 'lib/morpheus/cli/projects_command.rb', line 449

def remove_tags(args)
  params = {}
  options = {}
  payload = {}
   = nil
  optparse = Morpheus::Cli::OptionParser.new do |opts|
    opts.banner = subcommand_usage("[project] [tags]")
    opts.on('--tags TAGS', String, "Project Tags in the format 'name=value, name=value'. This will add/update project tags.") do |val|
       = val
    end
    build_standard_update_options(opts, options)
    opts.footer = "Remove metadata tags from a project.\n[project] is required. This is the name or id of a project.\n[tags] is required. This is a metadata tag in the format tag=value, tag2, tag3, 1-N may be passed, value is optional and must match if passed.\n"
  end
  optparse.parse!(args)
  verify_args!(args:args, optparse:optparse, min:1) # maybe min:2 instead ?
  connect(options)
  exit_code, err = 0, nil
  if args.count > 1
     = args[1..-1].join(" ")
  end
  project = find_project_by_name_or_id(args[0])
  return 1, "project not found by '#{args[0]}'" if project.nil?
  # construct payload

  if options[:payload]
    payload = options[:payload]
    payload.deep_merge!({'project' => parse_passed_options(options)})
  else
    payload['project'] = {}
    payload.deep_merge!({'project' => parse_passed_options(options)})
    if 
      payload['project']['removeTags'] = ()
    end
  end
  @projects_interface.setopts(options)
  if options[:dry_run]
    print_dry_run @projects_interface.dry.update(project['id'], payload)
    return
  end
  json_response = @projects_interface.update(project['id'], payload)
  project = json_response['project']
  render_response(json_response, options, 'project') do
    print_green_success "Project #{project['name']} updated"
    exit_code, err = get([project['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
  end
  return exit_code, err
end

#update(args) ⇒ Object



263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
# File 'lib/morpheus/cli/projects_command.rb', line 263

def update(args)
  exit_code, err = 0, nil
  params, options, payload = {}, {}, {}
  project_name, description, , ,  = nil, nil, nil, nil, nil
  instance_ids, server_ids, cloud_ids = nil, nil, nil
  add_instance_ids, remove_instance_ids = nil, nil
  add_server_ids, remove_server_ids = nil, nil
  add_cloud_ids, remove_cloud_ids = nil, nil
  optparse = Morpheus::Cli::OptionParser.new do |opts|
    opts.banner = subcommand_usage("[project] [options]")
    opts.on('--name NAME', String, "Project Name" ) do |val|
      project_name = val
    end
    opts.on('--description NAME', String, "Project Description" ) do |val|
      description = val
    end
    opts.on('--tags [TAGS]', String, "Project Tags in the format 'name:value, name:value'. This replaces all project tags.") do |val|
       = val ? val : []
    end
    opts.on('--add-tags TAGS', String, "Add Project Tags in the format 'name:value, name:value'. This will add/update project tags.") do |val|
       = val
    end
    opts.on('--remove-tags TAGS', String, "Remove Project Tags in the format 'name, name:value'. This removes project tags, the :value component is optional and must match if passed.") do |val|
       = val
    end
    opts.on('--instances [LIST]', Array, "Instances, comma separated list of instance names or IDs.") do |list|
      instance_ids = list ? list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq : []
    end
    opts.on('--add-instances LIST', Array, "Add Instances, comma separated list of instance names or IDs to add.") do |list|
      add_instance_ids = list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq
    end
    opts.on('--remove-instances LIST', Array, "Remove Instances, comma separated list of instance names or IDs to remove.") do |list|
      remove_instance_ids = list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq
    end
    opts.on('--servers [LIST]', Array, "Servers, comma separated list of server (host) names or IDs.") do |list|
      server_ids = list ? list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq : []
    end
    opts.on('--add-servers LIST', Array, "Add Servers, comma separated list of server names or IDs to add.") do |list|
      add_server_ids = list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq
    end
    opts.on('--remove-servers LIST', Array, "Remove Servers, comma separated list of server names or IDs to remove.") do |list|
      remove_server_ids = list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq
    end
    opts.on('--clouds [LIST]', Array, "Clouds, comma separated list of cloud names or IDs.") do |list|
      cloud_ids = list ? list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq : []
    end
    opts.on('--add-clouds LIST', Array, "Add Clouds, comma separated list of cloud names or IDs to add.") do |list|
      add_cloud_ids = list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq
    end
    opts.on('--remove-clouds LIST', Array, "Remove Clouds, comma separated list of cloud names or IDs to remove.") do |list|
      remove_cloud_ids = list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq
    end
    build_standard_update_options(opts, options)
    opts.footer = "Update a project.\n[project] is required. This is the name or id of a project.\n"
  end
  optparse.parse!(args)
  verify_args!(args:args, optparse:optparse, count:1)
  connect(options)
  exit_code, err = 0, nil
  project = find_project_by_name_or_id(args[0])
  return 1, "project not found by '#{args[0]}'" if project.nil?
  # construct payload
  if options[:payload]
    payload = options[:payload]
    payload.deep_merge!({'project' => parse_passed_options(options)})
  else
    payload['project'] = {}
    payload.deep_merge!({'project' => parse_passed_options(options)})
    payload['project']['name'] = project_name if project_name
    payload['project']['description'] = description if description
    # metadata tags
    if 
      payload['project']['tags'] = ()
    end
    if 
      payload['project']['addTags'] = ()
    end
    if 
      payload['project']['removeTags'] = ()
    end
    # --instances
    if instance_ids
      payload['project']['instances'] = parse_instance_id_list(instance_ids).collect { |it| {'id': it.to_i} }
    end
    if add_instance_ids
      payload['project']['addInstances'] = parse_instance_id_list(add_instance_ids).collect { |it| {'id': it.to_i} }
    end
    if remove_instance_ids
      payload['project']['removeInstances'] = parse_instance_id_list(remove_instance_ids).collect { |it| {'id': it.to_i} }
    end
    # --servers
    if server_ids
      payload['project']['servers'] = parse_server_id_list(server_ids).collect { |it| {'id': it.to_i} }
    end
    if add_server_ids
      payload['project']['addServers'] = parse_server_id_list(add_server_ids).collect { |it| {'id': it.to_i} }
    end
    if remove_server_ids
      payload['project']['removeServers'] = parse_server_id_list(remove_server_ids).collect { |it| {'id': it.to_i} }
    end
    # --clouds
    if cloud_ids
      cloud_ids = parse_cloud_id_list(cloud_ids)
      return 1, "clouds not found" if cloud_ids.nil?
      payload['project']['clouds'] = cloud_ids.collect { |it| {'id': it.to_i} }
    end
    if add_cloud_ids
      add_cloud_ids = parse_cloud_id_list(add_cloud_ids)
      return 1, "clouds not found" if add_cloud_ids.nil?
      payload['project']['addClouds'] = add_cloud_ids.collect { |it| {'id': it.to_i} }
    end
    if remove_cloud_ids
      remove_cloud_ids = parse_cloud_id_list(remove_cloud_ids)
      return 1, "clouds not found" if remove_cloud_ids.nil?
      payload['project']['removeClouds'] = remove_cloud_ids.collect { |it| {'id': it.to_i} }
    end
  end
  @projects_interface.setopts(options)
  if options[:dry_run]
    print_dry_run @projects_interface.dry.update(project['id'], payload)
    return
  end
  json_response = @projects_interface.update(project['id'], payload)
  project = json_response['project']
  render_response(json_response, options, 'project') do
    print_green_success "Project #{project['name']} updated"
    exit_code, err = get([project['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
  end
  return exit_code, err
end