morpheus-cli 5.2.3 → 5.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d4e958144b7f0c3873aeef071a4596e5f6d2e4bde23a00e7cd40c812bd159afa
4
- data.tar.gz: 993097131d9693e90c6100da61d38d353efc656a0b426fcb8cf24a8d2e7d8360
3
+ metadata.gz: 3798eb711a94541135bbefd28bbf1b33db18460ab70d7caf4d6f1cde90dafed3
4
+ data.tar.gz: b24f15db530f004a00899a86d8c609ee5dc44e71ee7b69cc821e33f91070b4f1
5
5
  SHA512:
6
- metadata.gz: 585bb4e620fc552f48f1c3fd92e5c6e3e0782d52f14baa711c0afd3bbc563923f603f1c6a1f92ca7bf6189978d0d786737fc2781fc41d41f444d45f243efb386
7
- data.tar.gz: 3bce30c32854ba7be7f79b12acb6fdf041abc36db175aecbc268793a0262defd869ca9622d26c5277b42019f51777226b7b0149ddcc3e1eca14616dbcd15c4bc
6
+ metadata.gz: 165402498f461633ca18f4fd273e27cc5dcf7fddfd219722912563ea1c318a4412b9f6c6f5a014382e14bac1bfa060ffb4a794b72182739e57c1299ce685e7d2
7
+ data.tar.gz: 2305c2c67c28e206c9507abda3a95b2e62dadb0a6e73e44fd4b79a4feaa40f40fe713e47619f0383a30dfca22828ff439446063e5e7417746b658b08ced63804
data/Dockerfile CHANGED
@@ -1,5 +1,5 @@
1
1
  FROM ruby:2.5.1
2
2
 
3
- RUN gem install morpheus-cli -v 5.2.3
3
+ RUN gem install morpheus-cli -v 5.2.4
4
4
 
5
5
  ENTRYPOINT ["morpheus"]
@@ -190,6 +190,27 @@ class Morpheus::InstancesInterface < Morpheus::APIClient
190
190
  execute(opts)
191
191
  end
192
192
 
193
+ def clone_image(id, payload)
194
+ url = "#{@base_url}/api/instances/#{id}/clone-image"
195
+ headers = {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
196
+ opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
197
+ execute(opts)
198
+ end
199
+
200
+ def lock(id, payload)
201
+ url = "#{@base_url}/api/instances/#{id}/lock"
202
+ headers = {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
203
+ opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
204
+ execute(opts)
205
+ end
206
+
207
+ def unlock(id, payload)
208
+ url = "#{@base_url}/api/instances/#{id}/unlock"
209
+ headers = {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
210
+ opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
211
+ execute(opts)
212
+ end
213
+
193
214
  def firewall_disable(id)
194
215
  url = "#{@base_url}/api/instances/#{id}/security-groups/disable"
195
216
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
@@ -117,6 +117,12 @@ class Morpheus::Cli::Hosts
117
117
  opts.on( '--tenant TENANT', "Tenant Name or ID" ) do |val|
118
118
  options[:account] = val
119
119
  end
120
+ opts.on('--labels label',String, "Filter by labels (keywords).") do |val|
121
+ val.split(",").each do |k|
122
+ options[:labels] ||= []
123
+ options[:labels] << k.strip
124
+ end
125
+ end
120
126
  opts.on('--tags Name=Value',String, "Filter by tags.") do |val|
121
127
  val.split(",").each do |value_pair|
122
128
  k,v = value_pair.strip.split("=")
@@ -186,6 +192,7 @@ class Morpheus::Cli::Hosts
186
192
  params['clusterId'] = cluster['id']
187
193
  end
188
194
  end
195
+ params['labels'] = options[:labels] if options[:labels]
189
196
  if options[:tags] && !options[:tags].empty?
190
197
  options[:tags].each do |k,v|
191
198
  params['tags.' + k] = v
@@ -542,6 +549,7 @@ class Morpheus::Cli::Hosts
542
549
  "Name" => 'name',
543
550
  "Hostname" => 'hostname',
544
551
  "Description" => 'description',
552
+ "Labels" => lambda {|it| it['labels'] ? it['labels'].join(',') : '' },
545
553
  "Tags" => lambda {|it| tags ? format_metadata(tags) : '' },
546
554
  "Owner" => lambda {|it| it['owner'] ? it['owner']['username'] : '' },
547
555
  "Tenant" => lambda {|it| it['account'] ? it['account']['name'] : '' },
@@ -566,6 +574,7 @@ class Morpheus::Cli::Hosts
566
574
  # server_columns.delete("Tenant") if multi_tenant != true
567
575
  server_columns.delete("Cost") if server['hourlyCost'].to_f == 0
568
576
  server_columns.delete("Price") if server['hourlyPrice'].to_f == 0 || server['hourlyPrice'] == server['hourlyCost']
577
+ server_columns.delete("Labels") if server['labels'].nil? || server['labels'].empty?
569
578
  server_columns.delete("Tags") if tags.nil? || tags.empty?
570
579
 
571
580
  print_description_list(server_columns, server)
@@ -993,6 +1002,9 @@ class Morpheus::Cli::Hosts
993
1002
  opts.on('--power-schedule-type ID', String, "Power Schedule Type ID") do |val|
994
1003
  params['powerScheduleType'] = val == "null" ? nil : val
995
1004
  end
1005
+ opts.on('--labels [LIST]', String, "Labels (keywords) in the format 'foo, bar'") do |val|
1006
+ params['labels'] = val.to_s.split(',').collect {|it| it.to_s.strip }.compact.uniq.join(',')
1007
+ end
996
1008
  opts.on('--tags LIST', String, "Tags in the format 'name:value, name:value'. This will add and remove tags.") do |val|
997
1009
  options[:tags] = val
998
1010
  end
@@ -19,6 +19,7 @@ class Morpheus::Cli::Instances
19
19
  :history, {:'history-details' => :history_details}, {:'history-event' => :history_event_details},
20
20
  :stats, :stop, :start, :restart, :actions, :action, :suspend, :eject, :stop_service, :start_service, :restart_service,
21
21
  :backup, :backups, :resize, :clone, :envs, :setenv, :delenv,
22
+ :lock, :unlock, :clone_image,
22
23
  :security_groups, :apply_security_groups, :run_workflow, :import_snapshot, :snapshot, :snapshots,
23
24
  :console, :status_check, {:containers => :list_containers},
24
25
  :scaling, {:'scaling-update' => :scaling_update},
@@ -603,8 +604,8 @@ class Morpheus::Cli::Instances
603
604
  opts.on('--group GROUP', String, "Group Name or ID") do |val|
604
605
  options[:group] = val
605
606
  end
606
- opts.on('--labels LIST', String, "Labels (keywords) in the format 'foo, bar'") do |val|
607
- params['labels'] = val.split(',').collect {|it| it.to_s.strip }.compact.uniq.join(',')
607
+ opts.on('--labels [LIST]', String, "Labels (keywords) in the format 'foo, bar'") do |val|
608
+ params['labels'] = val.to_s.split(',').collect {|it| it.to_s.strip }.compact.uniq.join(',')
608
609
  end
609
610
  opts.on('--tags LIST', String, "Tags in the format 'name:value, name:value'. This will add and remove tags.") do |val|
610
611
  options[:tags] = val
@@ -1350,6 +1351,7 @@ class Morpheus::Cli::Instances
1350
1351
  "Shutdown Date" => lambda {|it| it['shutdownDate'] ? format_local_dt(it['shutdownDate']) : '' },
1351
1352
  "Nodes" => lambda {|it| it['containers'] ? it['containers'].count : 0 },
1352
1353
  "Connection" => lambda {|it| format_instance_connection_string(it) },
1354
+ "Locked" => lambda {|it| format_boolean(it['locked']) },
1353
1355
  "Status" => lambda {|it| format_instance_status(it) }
1354
1356
  }
1355
1357
  description_cols.delete("Labels") if labels.nil? || labels.empty?
@@ -1359,6 +1361,7 @@ class Morpheus::Cli::Instances
1359
1361
  description_cols.delete("Shutdown Date") if instance['shutdownDate'].nil?
1360
1362
  description_cols["Removal Date"] = lambda {|it| format_local_dt(it['removalDate'])} if instance['status'] == 'pendingRemoval'
1361
1363
  description_cols.delete("Last Deployment") if instance['lastDeploy'].nil?
1364
+ description_cols.delete("Locked") if instance['locked'] != true
1362
1365
  #description_cols.delete("Environment") if instance['instanceContext'].nil?
1363
1366
  print_description_list(description_cols, instance)
1364
1367
 
@@ -3888,6 +3891,117 @@ EOT
3888
3891
  return 0
3889
3892
  end
3890
3893
 
3894
+ def clone_image(args)
3895
+ options = {}
3896
+ optparse = Morpheus::Cli::OptionParser.new do |opts|
3897
+ opts.banner = subcommand_usage("[instance]")
3898
+ opts.on( '--name VALUE', String, "Image Name (Template Name). Default is server name + timestamp" ) do |val|
3899
+ options[:options]['templateName'] = val
3900
+ end
3901
+ build_standard_update_options(opts, options)
3902
+ opts.footer = <<-EOT
3903
+ Clone to image (template) for an instance
3904
+ [instance] is required. This is the name or id of an instance
3905
+ EOT
3906
+ end
3907
+ optparse.parse!(args)
3908
+ verify_args!(args:args, optparse:optparse, count:1)
3909
+ connect(options)
3910
+ instance = find_instance_by_name_or_id(args[0])
3911
+ return 1 if instance.nil?
3912
+ payload = {}
3913
+ if options[:payload]
3914
+ payload = options[:payload]
3915
+ payload.deep_merge!(parse_passed_options(options))
3916
+ else
3917
+ payload.deep_merge!(parse_passed_options(options))
3918
+ if payload['templateName'].nil?
3919
+ v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'templateName', 'type' => 'text', 'fieldLabel' => 'Image Name', 'description' => 'Choose a name for the new image template. Default is the server name + timestamp'}], options[:options])
3920
+ if v_prompt['templateName'].to_s != ''
3921
+ payload['templateName'] = v_prompt['templateName']
3922
+ end
3923
+ end
3924
+ end
3925
+ @instances_interface.setopts(options)
3926
+ if options[:dry_run]
3927
+ print_dry_run @instances_interface.dry.clone_image(instance['id'], payload)
3928
+ return
3929
+ end
3930
+ json_response = @instances_interface.clone_image(instance['id'], payload)
3931
+ render_response(json_response, options) do
3932
+ print_green_success "Clone Image initiated."
3933
+ end
3934
+ return 0, nil
3935
+ end
3936
+
3937
+ def lock(args)
3938
+ options = {}
3939
+ optparse = Morpheus::Cli::OptionParser.new do |opts|
3940
+ opts.banner = subcommand_usage("[instance]")
3941
+ build_standard_update_options(opts, options)
3942
+ opts.footer = <<-EOT
3943
+ Lock an instance
3944
+ [instance] is required. This is the name or id of an instance
3945
+ EOT
3946
+ end
3947
+ optparse.parse!(args)
3948
+ verify_args!(args:args, optparse:optparse, count:1)
3949
+ connect(options)
3950
+ instance = find_instance_by_name_or_id(args[0])
3951
+ return 1 if instance.nil?
3952
+ payload = {}
3953
+ if options[:payload]
3954
+ payload = options[:payload]
3955
+ payload.deep_merge!(parse_passed_options(options))
3956
+ else
3957
+ payload.deep_merge!(parse_passed_options(options))
3958
+ end
3959
+ @instances_interface.setopts(options)
3960
+ if options[:dry_run]
3961
+ print_dry_run @instances_interface.dry.lock(instance['id'], payload)
3962
+ return
3963
+ end
3964
+ json_response = @instances_interface.lock(instance['id'], payload)
3965
+ render_response(json_response, options) do
3966
+ print_green_success "Locked instance #{instance['name']}"
3967
+ end
3968
+ return 0, nil
3969
+ end
3970
+
3971
+ def unlock(args)
3972
+ options = {}
3973
+ optparse = Morpheus::Cli::OptionParser.new do |opts|
3974
+ opts.banner = subcommand_usage("[instance]")
3975
+ build_standard_update_options(opts, options)
3976
+ opts.footer = <<-EOT
3977
+ Unlock an instance
3978
+ [instance] is required. This is the name or id of an instance
3979
+ EOT
3980
+ end
3981
+ optparse.parse!(args)
3982
+ verify_args!(args:args, optparse:optparse, count:1)
3983
+ connect(options)
3984
+ instance = find_instance_by_name_or_id(args[0])
3985
+ return 1 if instance.nil?
3986
+ payload = {}
3987
+ if options[:payload]
3988
+ payload = options[:payload]
3989
+ payload.deep_merge!(parse_passed_options(options))
3990
+ else
3991
+ payload.deep_merge!(parse_passed_options(options))
3992
+ end
3993
+ @instances_interface.setopts(options)
3994
+ if options[:dry_run]
3995
+ print_dry_run @instances_interface.dry.unlock(instance['id'], payload)
3996
+ return
3997
+ end
3998
+ json_response = @instances_interface.unlock(instance['id'], payload)
3999
+ render_response(json_response, options) do
4000
+ print_green_success "Unlocked instance #{instance['name']}"
4001
+ end
4002
+ return 0, nil
4003
+ end
4004
+
3891
4005
  private
3892
4006
 
3893
4007
  def find_zone_by_name_or_id(group_id, val)
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Morpheus
3
3
  module Cli
4
- VERSION = "5.2.3"
4
+ VERSION = "5.2.4"
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: morpheus-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.3
4
+ version: 5.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Estes
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2020-12-16 00:00:00.000000000 Z
14
+ date: 2021-01-12 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler