morpheus-cli 3.2.0.1 → 3.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 840e751da65e4e0579b6156c4dd29bcb2621ce20
4
- data.tar.gz: d8914a6c16bc1a31186e1881dfdb4ee250aa91d0
3
+ metadata.gz: 9b8c741a2147562961cf875fa8395b16323e9c5c
4
+ data.tar.gz: 2ad98468d07e2981a0b5156c0ac21dce6669971d
5
5
  SHA512:
6
- metadata.gz: b0d6a8a5f02dfcbb6bdd2b9739348a7cc9a274a861d0649084d58f9a90893c8e2adb0de8550653bc97f0d179b6a8baffc0edc5c7c2c610410e6b76eee256409f
7
- data.tar.gz: e564ed304a60eefe51d0a1b341cfd3d50f95cf0a2f72dd4f9d3cfe5efc7fb7bb66b7d0fa6d10f6c0e2e88d0c509d43196805e159341a82dddfaad873f592004d
6
+ metadata.gz: 45bf78b5e848b756dc5ea5ff392b26dbaa89ae8c3b222c73c90c9619df47d916e9ed9b6d155fca5e79d4ec604c9f5f2d87607b7f40519b780b172db9abf8c55e
7
+ data.tar.gz: c838e7043db30e90aaa9fe114ed22167b921ef2f618fce9d6c11bec4d8f260e92c457742942970779070126fd12d3c1d0b557b146893e2c52ea3dbb2df39c9f9
@@ -177,6 +177,10 @@ class Morpheus::APIClient
177
177
  Morpheus::DashboardInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
178
178
  end
179
179
 
180
+ def power_scheduling
181
+ Morpheus::PowerSchedulingInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
182
+ end
183
+
180
184
  def setup
181
185
  Morpheus::SetupInterface.new(@base_url)
182
186
  end
@@ -68,37 +68,37 @@ class Morpheus::InstancesInterface < Morpheus::APIClient
68
68
  execute(opts)
69
69
  end
70
70
 
71
- def stop(id,server=true)
71
+ def stop(id, params={})
72
72
  url = "#{@base_url}/api/instances/#{id}/stop"
73
- headers = { :params => {:server => server}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
73
+ headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
74
74
  opts = {method: :put, url: url, headers: headers}
75
75
  execute(opts)
76
76
  end
77
77
 
78
- def start(id,server=true)
78
+ def start(id, params={})
79
79
  url = "#{@base_url}/api/instances/#{id}/start"
80
- headers = { :params => {:server => server}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
80
+ headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
81
81
  opts = {method: :put, url: url, headers: headers}
82
82
  execute(opts)
83
83
  end
84
84
 
85
- def restart(id,server=true)
85
+ def restart(id, params={})
86
86
  url = "#{@base_url}/api/instances/#{id}/restart"
87
- headers = { :params => {:server => server},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
87
+ headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
88
88
  opts = {method: :put, url: url, headers: headers}
89
89
  execute(opts)
90
90
  end
91
91
 
92
- def suspend(id,server=true)
92
+ def suspend(id, params={})
93
93
  url = "#{@base_url}/api/instances/#{id}/suspend"
94
- headers = { :params => {:server => server},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
94
+ headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
95
95
  opts = {method: :put, url: url, headers: headers}
96
96
  execute(opts)
97
97
  end
98
98
 
99
- def eject(id,server=true)
99
+ def eject(id, params={})
100
100
  url = "#{@base_url}/api/instances/#{id}/eject"
101
- headers = { :params => {:server => server},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
101
+ headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
102
102
  opts = {method: :put, url: url, headers: headers}
103
103
  execute(opts)
104
104
  end
@@ -0,0 +1,78 @@
1
+ require 'morpheus/api/api_client'
2
+
3
+ class Morpheus::PowerSchedulingInterface < Morpheus::APIClient
4
+ def initialize(access_token, refresh_token, expires_at = nil, base_url=nil)
5
+ @access_token = access_token
6
+ @refresh_token = refresh_token
7
+ @base_url = base_url
8
+ @expires_at = expires_at
9
+ end
10
+
11
+ def get(id)
12
+ raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
13
+ url = "#{@base_url}/api/power-scheduling/#{id}"
14
+ headers = { params: {}, authorization: "Bearer #{@access_token}" }
15
+ opts = {method: :get, url: url, timeout: 10, headers: headers}
16
+ execute(opts)
17
+ end
18
+
19
+ def list(options={})
20
+ url = "#{@base_url}/api/power-scheduling"
21
+ headers = { params: {}, authorization: "Bearer #{@access_token}" }
22
+ headers[:params].merge!(options)
23
+ opts = {method: :get, url: url, timeout: 10, headers: headers}
24
+ execute(opts)
25
+ end
26
+
27
+ def create(options)
28
+ url = "#{@base_url}/api/power-scheduling"
29
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
30
+ payload = options
31
+ opts = {method: :post, url: url, timeout: 10, headers: headers, payload: payload.to_json}
32
+ execute(opts)
33
+ end
34
+
35
+ def update(id, options)
36
+ url = "#{@base_url}/api/power-scheduling/#{id}"
37
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
38
+ payload = options
39
+ opts = {method: :put, url: url, timeout: 10, headers: headers, payload: payload.to_json}
40
+ execute(opts)
41
+ end
42
+
43
+ def destroy(id)
44
+ url = "#{@base_url}/api/power-scheduling/#{id}"
45
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
46
+ opts = {method: :delete, url: url, timeout: 10, headers: headers}
47
+ execute(opts)
48
+ end
49
+
50
+ def add_instances(id, payload)
51
+ url = "#{@base_url}/api/power-scheduling/#{id}/add-instances"
52
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
53
+ opts = {method: :put, url: url, timeout: 10, headers: headers, payload: payload.to_json}
54
+ execute(opts)
55
+ end
56
+
57
+ def remove_instances(id, payload)
58
+ url = "#{@base_url}/api/power-scheduling/#{id}/remove-instances"
59
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
60
+ opts = {method: :put, url: url, timeout: 10, headers: headers, payload: payload.to_json}
61
+ execute(opts)
62
+ end
63
+
64
+ def add_servers(id, payload)
65
+ url = "#{@base_url}/api/power-scheduling/#{id}/add-servers"
66
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
67
+ opts = {method: :put, url: url, timeout: 10, headers: headers, payload: payload.to_json}
68
+ execute(opts)
69
+ end
70
+
71
+ def remove_servers(id, payload)
72
+ url = "#{@base_url}/api/power-scheduling/#{id}/remove-servers"
73
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
74
+ opts = {method: :put, url: url, timeout: 10, headers: headers, payload: payload.to_json}
75
+ execute(opts)
76
+ end
77
+
78
+ end
data/lib/morpheus/cli.rb CHANGED
@@ -59,6 +59,7 @@ module Morpheus
59
59
  load 'morpheus/cli/logout.rb'
60
60
  load 'morpheus/cli/whoami.rb'
61
61
  load 'morpheus/cli/dashboard_command.rb'
62
+ load 'morpheus/cli/power_scheduling_command.rb'
62
63
  load 'morpheus/cli/recent_activity_command.rb'
63
64
  load 'morpheus/cli/groups.rb'
64
65
  load 'morpheus/cli/clouds.rb'
@@ -47,7 +47,7 @@ class Morpheus::Cli::AppTemplates
47
47
  options = {}
48
48
  optparse = Morpheus::Cli::OptionParser.new do |opts|
49
49
  opts.banner = subcommand_usage()
50
- build_common_options(opts, options, [:list, :json, :dry_run])
50
+ build_common_options(opts, options, [:list, :json, :yaml, :csv, :fields, :dry_run, :remote])
51
51
  opts.footer = "List app templates."
52
52
  end
53
53
  optparse.parse!(args)
@@ -61,26 +61,40 @@ class Morpheus::Cli::AppTemplates
61
61
  print_dry_run @app_templates_interface.dry.list(params)
62
62
  return
63
63
  end
64
+
64
65
  json_response = @app_templates_interface.list(params)
65
66
  app_templates = json_response['appTemplates']
67
+
68
+ if options[:include_fields]
69
+ json_response = {"appTemplates" => filter_data(json_response["appTemplates"], options[:include_fields]) }
70
+ end
66
71
  if options[:json]
67
- print JSON.pretty_generate(json_response)
68
- print "\n"
72
+ puts as_json(json_response, options)
73
+ return 0
74
+ elsif options[:csv]
75
+ puts records_as_csv(json_response['appTemplates'], options)
76
+ return 0
77
+ elsif options[:yaml]
78
+ puts as_yaml(json_response, options)
79
+ return 0
80
+ end
81
+
82
+
83
+ title = "Morpheus App Templates"
84
+ subtitles = []
85
+ if params[:phrase]
86
+ subtitles << "Search: #{params[:phrase]}".strip
87
+ end
88
+ print_h1 title, subtitles
89
+ if app_templates.empty?
90
+ print cyan,"No app templates found.",reset,"\n"
69
91
  else
70
- title = "Morpheus App Templates"
71
- subtitles = []
72
- if params[:phrase]
73
- subtitles << "Search: #{params[:phrase]}".strip
74
- end
75
- print_h1 title, subtitles
76
- if app_templates.empty?
77
- print cyan,"No app templates found.",reset,"\n"
78
- else
79
- print_app_templates_table(app_templates)
80
- print_results_pagination(json_response)
81
- end
82
- print reset,"\n"
92
+ print_app_templates_table(app_templates, options)
93
+ print_results_pagination(json_response)
83
94
  end
95
+ print reset,"\n"
96
+ return 0
97
+
84
98
  rescue RestClient::Exception => e
85
99
  print_rest_exception(e, options)
86
100
  exit 1
@@ -180,7 +194,7 @@ class Morpheus::Cli::AppTemplates
180
194
  options['configFile'] = val.to_s
181
195
  end
182
196
  build_option_type_options(opts, options, add_app_template_option_types(false))
183
- build_common_options(opts, options, [:options, :json, :dry_run])
197
+ build_common_options(opts, options, [:options, :json, :dry_run, :remote])
184
198
  opts.footer = "Create a new app template.\n" +
185
199
  "[name] is optional and can be passed as --name or inside the config instead."
186
200
  "[--config] or [--config-file] can be used to define the app template."
@@ -267,7 +281,7 @@ class Morpheus::Cli::AppTemplates
267
281
  options['configFile'] = val.to_s
268
282
  end
269
283
  build_option_type_options(opts, options, update_app_template_option_types(false))
270
- build_common_options(opts, options, [:options, :json, :dry_run, :quiet])
284
+ build_common_options(opts, options, [:options, :json, :dry_run, :quiet, :remote])
271
285
  opts.footer = "Update an app template.\n" +
272
286
  "[template] is required. This is the name or id of an app template.\n" +
273
287
  "[options] Available options include --name and --description. This will update only the specified values.\n" +
@@ -412,7 +426,7 @@ class Morpheus::Cli::AppTemplates
412
426
  options = {}
413
427
  optparse = Morpheus::Cli::OptionParser.new do |opts|
414
428
  opts.banner = subcommand_usage("[template] [new name]")
415
- build_common_options(opts, options, [:auto_confirm, :json, :dry_run])
429
+ build_common_options(opts, options, [:auto_confirm, :json, :dry_run, :remote])
416
430
  opts.footer = "Duplicate an app template." + "\n" +
417
431
  "[template] is required. This is the name or id of an app template." + "\n" +
418
432
  "[new name] is required. This is the name for the clone."
@@ -461,7 +475,7 @@ class Morpheus::Cli::AppTemplates
461
475
  options = {}
462
476
  optparse = Morpheus::Cli::OptionParser.new do |opts|
463
477
  opts.banner = subcommand_usage("[template]")
464
- build_common_options(opts, options, [:auto_confirm, :json, :dry_run])
478
+ build_common_options(opts, options, [:auto_confirm, :json, :dry_run, :remote])
465
479
  opts.footer = "Delete an app template." + "\n" +
466
480
  "[template] is required. This is the name or id of an app template."
467
481
  end
@@ -788,7 +802,7 @@ class Morpheus::Cli::AppTemplates
788
802
  # opts.on( nil, '--index NUMBER', "The index of the instance to remove, starting with 0." ) do |val|
789
803
  # instance_index = val.to_i
790
804
  # end
791
- build_common_options(opts, options, [:auto_confirm, :json, :dry_run])
805
+ build_common_options(opts, options, [:auto_confirm, :json, :dry_run, :remote])
792
806
  opts.footer = "Update an app template, removing a specified instance config." + "\n" +
793
807
  "[template] is required. This is the name or id of an app template." + "\n" +
794
808
  "[tier] is required. This is the name of the tier." + "\n" +
@@ -971,7 +985,7 @@ class Morpheus::Cli::AppTemplates
971
985
  # opts.on('--index NUMBER', Number, "Identify Instance by index within tier, starting with 0." ) do |val|
972
986
  # instance_index = val.to_i
973
987
  # end
974
- build_common_options(opts, options, [:auto_confirm, :json, :dry_run])
988
+ build_common_options(opts, options, [:auto_confirm, :json, :dry_run, :remote])
975
989
  end
976
990
  optparse.parse!(args)
977
991
 
@@ -1333,7 +1347,7 @@ class Morpheus::Cli::AppTemplates
1333
1347
  options = {}
1334
1348
  optparse = Morpheus::Cli::OptionParser.new do |opts|
1335
1349
  opts.banner = subcommand_usage("[template] [tier]")
1336
- build_common_options(opts, options, [:auto_confirm, :json, :dry_run])
1350
+ build_common_options(opts, options, [:auto_confirm, :json, :dry_run, :remote])
1337
1351
  end
1338
1352
  optparse.parse!(args)
1339
1353
 
@@ -1400,7 +1414,7 @@ class Morpheus::Cli::AppTemplates
1400
1414
  options = {}
1401
1415
  optparse = Morpheus::Cli::OptionParser.new do |opts|
1402
1416
  opts.banner = subcommand_usage("[template] [Tier1] [Tier2]")
1403
- build_common_options(opts, options, [:json, :dry_run])
1417
+ build_common_options(opts, options, [:json, :dry_run, :remote])
1404
1418
  end
1405
1419
  optparse.parse!(args)
1406
1420
 
@@ -1498,7 +1512,7 @@ class Morpheus::Cli::AppTemplates
1498
1512
  options = {}
1499
1513
  optparse = Morpheus::Cli::OptionParser.new do |opts|
1500
1514
  opts.banner = subcommand_usage("[template] [Tier1] [Tier2]")
1501
- build_common_options(opts, options, [:json, :dry_run])
1515
+ build_common_options(opts, options, [:json, :dry_run, :remote])
1502
1516
  end
1503
1517
  optparse.parse!(args)
1504
1518
 
@@ -1588,7 +1602,7 @@ class Morpheus::Cli::AppTemplates
1588
1602
  options = {}
1589
1603
  optparse = Morpheus::Cli::OptionParser.new do |opts|
1590
1604
  opts.banner = subcommand_usage()
1591
- build_common_options(opts, options, [:json, :dry_run])
1605
+ build_common_options(opts, options, [:json, :dry_run, :remote])
1592
1606
  end
1593
1607
  optparse.parse!(args)
1594
1608
  connect(options)
@@ -1735,10 +1749,9 @@ class Morpheus::Cli::AppTemplates
1735
1749
  :category,
1736
1750
  {:tiers_summary => {:display_name => "TIERS", :max_width => tiers_col_width} }
1737
1751
  ]
1738
- # # custom pretty table columns ...
1739
- # if options[:include_fields]
1740
- # columns = options[:include_fields]
1741
- # end
1752
+ if opts[:include_fields]
1753
+ columns = opts[:include_fields]
1754
+ end
1742
1755
  print table_color
1743
1756
  print as_pretty_table(rows, columns, opts)
1744
1757
  print reset
@@ -1751,6 +1764,7 @@ class Morpheus::Cli::AppTemplates
1751
1764
  end
1752
1765
 
1753
1766
  def format_app_template_tiers_summary(app_template)
1767
+ # don't use colors here, or cell truncation will not work
1754
1768
  str = ""
1755
1769
  if app_template["config"] && app_template["config"]["tiers"]
1756
1770
  tier_descriptions = app_template["config"]["tiers"].collect do |tier_name, tier_config|
@@ -1763,9 +1777,9 @@ class Morpheus::Cli::AppTemplates
1763
1777
  # instance_blurbs << instance_config["instance"]["type"]
1764
1778
  instance_name = instance_config["instance"]["name"] || ""
1765
1779
  instance_type_code = instance_config["instance"]["type"]
1766
- instances_str = "#{green}#{instance_type_code}#{cyan}"
1780
+ instances_str = "#{instance_type_code}"
1767
1781
  if instance_name.to_s != ""
1768
- instances_str << "#{green} - #{instance_name}#{cyan}"
1782
+ instances_str << " - #{instance_name}"
1769
1783
  end
1770
1784
  begin
1771
1785
  config_list = parse_scoped_instance_configs(instance_config)
@@ -1791,9 +1805,9 @@ class Morpheus::Cli::AppTemplates
1791
1805
  end
1792
1806
  end
1793
1807
  if instance_blurbs.size > 0
1794
- tier_name + ": #{instance_blurbs.join(', ')}" + cyan
1808
+ tier_name + ": #{instance_blurbs.join(', ')}"
1795
1809
  else
1796
- tier_name + ": (empty)" + cyan
1810
+ tier_name + ": (empty)"
1797
1811
  end
1798
1812
  end
1799
1813
  str += tier_descriptions.compact.join(", ")
@@ -1834,7 +1848,7 @@ class Morpheus::Cli::AppTemplates
1834
1848
  end
1835
1849
  instance_bullet = ""
1836
1850
  # instance_bullet += "#{green} - #{bold}#{instance_type_code}#{reset}"
1837
- instance_bullet += " #{green}#{bold}#{instance_type_code}#{reset}"
1851
+ instance_bullet += "#{green}#{bold}#{instance_type_code}#{reset}"
1838
1852
  if instance_name.to_s != ""
1839
1853
  instance_bullet += "#{green} - #{instance_name}#{reset}"
1840
1854
  end
@@ -1846,9 +1860,9 @@ class Morpheus::Cli::AppTemplates
1846
1860
  if config_list.size > 0
1847
1861
  print "\n"
1848
1862
  if config_list.size == 1
1849
- puts " Config:"
1863
+ puts " Config:"
1850
1864
  else
1851
- puts " Configs (#{config_list.size}):"
1865
+ puts " Configs (#{config_list.size}):"
1852
1866
  end
1853
1867
  config_list.each do |config_obj|
1854
1868
  # puts " = #{config_obj[:scope].inspect}"
@@ -1869,10 +1883,10 @@ class Morpheus::Cli::AppTemplates
1869
1883
  # config_items << {label: "Plan", value: scoped_instance_config['plan']['code']}
1870
1884
  # end
1871
1885
  config_description = config_items.collect {|item| "#{item[:label]}: #{item[:value]}"}.join(", ")
1872
- puts " * #{config_description}"
1886
+ puts " * #{config_description}"
1873
1887
  end
1874
1888
  else
1875
- print white," Instance has no configs, see `app-templates add-instance-config \"#{app_template['name']}\" \"#{tier_name}\" \"#{instance_type_code}\"`",reset,"\n"
1889
+ print white," Instance has no configs, see `app-templates add-instance-config \"#{app_template['name']}\" \"#{tier_name}\" \"#{instance_type_code}\"`",reset,"\n"
1876
1890
  end
1877
1891
  rescue => err
1878
1892
  #puts_error "Failed to parse instance scoped instance configs for app template #{app_template['id']} #{app_template['name']} Exception: #{err.class} #{err.message}"
@@ -1885,10 +1899,10 @@ class Morpheus::Cli::AppTemplates
1885
1899
 
1886
1900
  print cyan
1887
1901
  if tier_config['bootOrder']
1888
- puts " Boot Order: #{tier_config['bootOrder']}"
1902
+ puts "Boot Order: #{tier_config['bootOrder']}"
1889
1903
  end
1890
1904
  if tier_config['linkedTiers'] && !tier_config['linkedTiers'].empty?
1891
- puts " Connected Tiers: #{tier_config['linkedTiers'].join(', ')}"
1905
+ puts "Connected Tiers: #{tier_config['linkedTiers'].join(', ')}"
1892
1906
  end
1893
1907
 
1894
1908
  else
@@ -119,7 +119,14 @@ class Morpheus::Cli::Clouds
119
119
  end
120
120
  json_response = @clouds_interface.get(cloud['id'])
121
121
  cloud = json_response['zone']
122
- server_counts = json_response['serverCounts']
122
+ cloud_stats = cloud['stats']
123
+ # serverCounts moved to zone.stats.serverCounts
124
+ server_counts = nil
125
+ if cloud_stats
126
+ server_counts = cloud_stats['serverCounts']
127
+ else
128
+ server_counts = json_response['serverCounts'] # legacy
129
+ end
123
130
  if options[:json]
124
131
  print JSON.pretty_generate(json_response), "\n"
125
132
  return
@@ -212,7 +212,7 @@ class Morpheus::Cli::Instances
212
212
  opts.on("--expire-days NUMBER", Integer, "Automation: Expiration Days") do |val|
213
213
  options[:expire_days] = val.to_i
214
214
  end
215
- opts.on("--create-backup on|off", String, "Automation: Create Backups. Default is off") do |val|
215
+ opts.on("--create-backup on|off", String, "Automation: Create Backups. Default is off.") do |val|
216
216
  options[:create_backup] = ['on','true','1'].include?(val.to_s.downcase) ? 'on' : 'off'
217
217
  end
218
218
  build_common_options(opts, options, [:options, :payload, :json, :dry_run, :remote, :quiet])
@@ -256,6 +256,20 @@ class Morpheus::Cli::Instances
256
256
  lb_payload = prompt_instance_load_balancer(payload['instance'], nil, options)
257
257
  payload.deep_merge!(lb_payload)
258
258
  end
259
+ # clean payload of empty objects
260
+ # note: this is temporary and should be fixed upstream in OptionTypes.prompt()
261
+ if payload['instance'].is_a?(Hash)
262
+ payload['instance'].keys.each do |k|
263
+ v = payload['instance'][k]
264
+ payload['instance'].delete(k) if v.is_a?(Hash) && v.empty?
265
+ end
266
+ end
267
+ if payload['config'].is_a?(Hash)
268
+ payload['config'].keys.each do |k|
269
+ v = payload['config'][k]
270
+ payload['config'].delete(k) if v.is_a?(Hash) && v.empty?
271
+ end
272
+ end
259
273
  end
260
274
 
261
275
  if options[:dry_run]
@@ -1061,9 +1075,13 @@ class Morpheus::Cli::Instances
1061
1075
  end
1062
1076
 
1063
1077
  def stop(args)
1078
+ params = {'server' => true, 'muteMonitoring' => false}
1064
1079
  options = {}
1065
1080
  optparse = OptionParser.new do|opts|
1066
1081
  opts.banner = subcommand_usage("[name]")
1082
+ opts.on('--muteMonitoring [on|off]', String, "Mute monitoring. Default is off.") do |val|
1083
+ params['muteMonitoring'] = val.nil? || val.to_s == 'on' || val.to_s == 'true'
1084
+ end
1067
1085
  build_common_options(opts, options, [:auto_confirm, :quiet, :json, :dry_run, :remote])
1068
1086
  end
1069
1087
  optparse.parse!(args)
@@ -1078,10 +1096,10 @@ class Morpheus::Cli::Instances
1078
1096
  exit 1
1079
1097
  end
1080
1098
  if options[:dry_run]
1081
- print_dry_run @instances_interface.dry.stop(instance['id'])
1099
+ print_dry_run @instances_interface.dry.stop(instance['id'], params)
1082
1100
  return
1083
1101
  end
1084
- json_response = @instances_interface.stop(instance['id'])
1102
+ json_response = @instances_interface.stop(instance['id'], params)
1085
1103
  if options[:json]
1086
1104
  puts as_json(json_response, options)
1087
1105
  elsif !options[:quiet]
@@ -1095,6 +1113,7 @@ class Morpheus::Cli::Instances
1095
1113
  end
1096
1114
 
1097
1115
  def start(args)
1116
+ params = {'server' => true}
1098
1117
  options = {}
1099
1118
  optparse = OptionParser.new do|opts|
1100
1119
  opts.banner = subcommand_usage("[name]")
@@ -1109,10 +1128,10 @@ class Morpheus::Cli::Instances
1109
1128
  begin
1110
1129
  instance = find_instance_by_name_or_id(args[0])
1111
1130
  if options[:dry_run]
1112
- print_dry_run @instances_interface.dry.start(instance['id'])
1131
+ print_dry_run @instances_interface.dry.start(instance['id'], params)
1113
1132
  return 0
1114
1133
  end
1115
- json_response = @instances_interface.start(instance['id'])
1134
+ json_response = @instances_interface.start(instance['id'], params)
1116
1135
  if options[:json]
1117
1136
  puts as_json(json_response, options)
1118
1137
  return 0
@@ -1127,9 +1146,13 @@ class Morpheus::Cli::Instances
1127
1146
  end
1128
1147
 
1129
1148
  def restart(args)
1149
+ params = {'server' => true, 'muteMonitoring' => true}
1130
1150
  options = {}
1131
1151
  optparse = OptionParser.new do|opts|
1132
1152
  opts.banner = subcommand_usage("[name]")
1153
+ opts.on('--muteMonitoring [on|off]', String, "Mute monitoring. Default is on.") do |val|
1154
+ params['muteMonitoring'] = val.nil? || val.to_s == 'on' || val.to_s == 'true'
1155
+ end
1133
1156
  build_common_options(opts, options, [:auto_confirm, :quiet, :json, :dry_run, :remote])
1134
1157
  end
1135
1158
  optparse.parse!(args)
@@ -1144,14 +1167,14 @@ class Morpheus::Cli::Instances
1144
1167
  exit 1
1145
1168
  end
1146
1169
  if options[:dry_run]
1147
- print_dry_run @instances_interface.dry.restart(instance['id'])
1170
+ print_dry_run @instances_interface.dry.restart(instance['id'], params)
1148
1171
  return 0
1149
1172
  end
1150
- json_response = @instances_interface.restart(instance['id'])
1173
+ json_response = @instances_interface.restart(instance['id'], params)
1151
1174
  if options[:json]
1152
1175
  puts as_json(json_response, options)
1153
1176
  elsif !options[:quiet]
1154
- print green, "Stopping instance #{instance['name']}", reset, "\n"
1177
+ print green, "Restarting instance #{instance['name']}", reset, "\n"
1155
1178
  end
1156
1179
  return 0
1157
1180
  rescue RestClient::Exception => e
@@ -1161,9 +1184,13 @@ class Morpheus::Cli::Instances
1161
1184
  end
1162
1185
 
1163
1186
  def suspend(args)
1187
+ params = {'server' => true, 'muteMonitoring' => false}
1164
1188
  options = {}
1165
1189
  optparse = OptionParser.new do|opts|
1166
1190
  opts.banner = subcommand_usage("[name]")
1191
+ opts.on('--muteMonitoring [on|off]', String, "Mute monitoring. Default is off.") do |val|
1192
+ params['muteMonitoring'] = val.nil? || val.to_s == 'on' || val.to_s == 'true'
1193
+ end
1167
1194
  build_common_options(opts, options, [:auto_confirm, :quiet, :json, :dry_run, :remote])
1168
1195
  end
1169
1196
  optparse.parse!(args)
@@ -1178,10 +1205,10 @@ class Morpheus::Cli::Instances
1178
1205
  exit 1
1179
1206
  end
1180
1207
  if options[:dry_run]
1181
- print_dry_run @instances_interface.dry.suspend(instance['id'])
1208
+ print_dry_run @instances_interface.dry.suspend(instance['id'], params)
1182
1209
  return
1183
1210
  end
1184
- json_response = @instances_interface.suspend(instance['id'])
1211
+ json_response = @instances_interface.suspend(instance['id'], params)
1185
1212
  if options[:json]
1186
1213
  puts as_json(json_response, options)
1187
1214
  end
@@ -1193,6 +1220,7 @@ class Morpheus::Cli::Instances
1193
1220
  end
1194
1221
 
1195
1222
  def eject(args)
1223
+ params = {'server' => true}
1196
1224
  options = {}
1197
1225
  optparse = OptionParser.new do|opts|
1198
1226
  opts.banner = subcommand_usage("[name]")
@@ -1210,10 +1238,10 @@ class Morpheus::Cli::Instances
1210
1238
  # exit 1
1211
1239
  # end
1212
1240
  if options[:dry_run]
1213
- print_dry_run @instances_interface.dry.eject(instance['id'])
1241
+ print_dry_run @instances_interface.dry.eject(instance['id'], params)
1214
1242
  return
1215
1243
  end
1216
- json_response = @instances_interface.eject(instance['id'])
1244
+ json_response = @instances_interface.eject(instance['id'], params)
1217
1245
  if options[:json]
1218
1246
  puts as_json(json_response, options)
1219
1247
  end
@@ -1225,9 +1253,13 @@ class Morpheus::Cli::Instances
1225
1253
  end
1226
1254
 
1227
1255
  def stop_service(args)
1256
+ params = {'server' => false, 'muteMonitoring' => false}
1228
1257
  options = {}
1229
1258
  optparse = OptionParser.new do|opts|
1230
1259
  opts.banner = subcommand_usage("[name]")
1260
+ opts.on('--muteMonitoring [on|off]', String, "Mute monitoring. Default is off.") do |val|
1261
+ params['muteMonitoring'] = val.nil? || val.to_s == 'on' || val.to_s == 'true'
1262
+ end
1231
1263
  build_common_options(opts, options, [:auto_confirm, :quiet, :json, :dry_run, :remote])
1232
1264
  end
1233
1265
  optparse.parse!(args)
@@ -1242,10 +1274,10 @@ class Morpheus::Cli::Instances
1242
1274
  exit 1
1243
1275
  end
1244
1276
  if options[:dry_run]
1245
- print_dry_run @instances_interface.dry.stop(instance['id'],false)
1277
+ print_dry_run @instances_interface.dry.stop(instance['id'], params)
1246
1278
  return 0
1247
1279
  end
1248
- json_response = @instances_interface.stop(instance['id'],false)
1280
+ json_response = @instances_interface.stop(instance['id'], params)
1249
1281
  if options[:json]
1250
1282
  puts as_json(json_response, options)
1251
1283
  elsif !options[:quiet]
@@ -1259,6 +1291,7 @@ class Morpheus::Cli::Instances
1259
1291
  end
1260
1292
 
1261
1293
  def start_service(args)
1294
+ params = {'server' => true}
1262
1295
  options = {}
1263
1296
  optparse = OptionParser.new do|opts|
1264
1297
  opts.banner = subcommand_usage("[name]")
@@ -1273,10 +1306,10 @@ class Morpheus::Cli::Instances
1273
1306
  begin
1274
1307
  instance = find_instance_by_name_or_id(args[0])
1275
1308
  if options[:dry_run]
1276
- print_dry_run @instances_interface.dry.start(instance['id'], false)
1309
+ print_dry_run @instances_interface.dry.start(instance['id'], params)
1277
1310
  return 0
1278
1311
  end
1279
- json_response = @instances_interface.start(instance['id'],false)
1312
+ json_response = @instances_interface.start(instance['id'], params)
1280
1313
  if options[:json]
1281
1314
  puts as_json(json_response, options)
1282
1315
  elsif !options[:quiet]
@@ -1289,9 +1322,13 @@ class Morpheus::Cli::Instances
1289
1322
  end
1290
1323
 
1291
1324
  def restart_service(args)
1325
+ params = {'server' => false, 'muteMonitoring' => true}
1292
1326
  options = {}
1293
1327
  optparse = OptionParser.new do|opts|
1294
1328
  opts.banner = subcommand_usage("[name]")
1329
+ opts.on('--muteMonitoring [on|off]', String, "Mute monitoring. Default is on.") do |val|
1330
+ params['muteMonitoring'] = val.nil? || val.to_s == 'on' || val.to_s == 'true'
1331
+ end
1295
1332
  build_common_options(opts, options, [:auto_confirm, :quiet, :json, :dry_run, :remote])
1296
1333
  end
1297
1334
  optparse.parse!(args)
@@ -1306,10 +1343,10 @@ class Morpheus::Cli::Instances
1306
1343
  exit 1
1307
1344
  end
1308
1345
  if options[:dry_run]
1309
- print_dry_run @instances_interface.dry.restart(instance['id'],false)
1346
+ print_dry_run @instances_interface.dry.restart(instance['id'], params)
1310
1347
  return 0
1311
1348
  end
1312
- json_response = @instances_interface.restart(instance['id'],false)
1349
+ json_response = @instances_interface.restart(instance['id'], params)
1313
1350
  if options[:json]
1314
1351
  puts as_json(json_response, options)
1315
1352
  elsif !options[:quiet]