morpheus-cli 5.2.4.1 → 5.3.0

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: 37c9d87f1bfe67cebd9a25486613f11f221f5600a3fc888f58f073c97c12a656
4
- data.tar.gz: d1cbd8a33bea8749c042c3a3557760566102a24c8ddb54f7c4e5c0f833445504
3
+ metadata.gz: 4c04cf89b798df6d8dba342efe64eec23b5f97bbeef368072d56829c8b517707
4
+ data.tar.gz: 50a9448b2a167439efbd3f3bcd2f0ea91870681986108d975b058a40b5e14d69
5
5
  SHA512:
6
- metadata.gz: 2d47d04efd457d117b30d3909707924f3215e5d7196692a9b4f6e2d83f553d6b0a78b8a07b03e2350f8ff0750c64c9265a4c58c496eab71901c89ac9cfc0cc58
7
- data.tar.gz: fd8d5788f2288369735015854a5a6d469887d5624c8fe5fb212f077f54e15033397164f85c932883029f20f813296366fbe374855a7fd53461a58a022c384629
6
+ metadata.gz: 58613849cca0d5994cc866d6de770f0657b65ccbd3961e352ac934f21600f0888be755c70f54cc964a317fa12201a78800eb59447a664ec28df7eb00799cdc1f
7
+ data.tar.gz: 01307e6f8b6c91813a948d79b5dedc0914d5731b026d6152ddf1ea59d8ab9a830bca5305a28087623d088787464dc76ee3667673759467a2910723b06645a3b7
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.4
3
+ RUN gem install morpheus-cli -v 5.3.0
4
4
 
5
5
  ENTRYPOINT ["morpheus"]
@@ -22,6 +22,9 @@ class Morpheus::Cli::ActivityCommand
22
22
  params, options = {}, {}
23
23
  optparse = Morpheus::Cli::OptionParser.new do |opts|
24
24
  opts.banner = subcommand_usage()
25
+ opts.on('-a', '--details', "Display more details object id, full date and time, etc." ) do
26
+ options[:details] = true
27
+ end
25
28
  opts.on('-t','--type TYPE', "Activity Type eg. Provisioning, Admin") do |val|
26
29
  options[:type] ||= []
27
30
  options[:type] << val
@@ -115,20 +118,20 @@ EOT
115
118
  # {"SEVERITY" => lambda {|record| format_activity_severity(record['severity']) } },
116
119
  {"TYPE" => lambda {|record| record['activityType'] } },
117
120
  {"NAME" => lambda {|record| record['name'] } },
118
- {"RESOURCE" => lambda {|record| "#{record['objectType']} #{record['objectId']}" } },
121
+ options[:details] ? {"RESOURCE" => lambda {|record| "#{record['objectType']} #{record['objectId']}" } } : nil,
119
122
  {"MESSAGE" => lambda {|record| record['message'] || '' } },
120
123
  {"USER" => lambda {|record| record['user'] ? record['user']['username'] : record['userName'] } },
121
124
  #{"DATE" => lambda {|record| "#{format_duration_ago(record['ts'] || record['timestamp'])}" } },
122
125
  {"DATE" => lambda {|record|
123
- # show full time if searching for custom timerange, otherwise the default is to show relative time
124
- if params['start'] || params['end'] || params['timeframe']
126
+ # show full time if searching for custom timerange or --details, otherwise the default is to show relative time
127
+ if params['start'] || params['end'] || params['timeframe'] || options[:details]
125
128
  "#{format_local_dt(record['ts'] || record['timestamp'])}"
126
129
  else
127
130
  "#{format_duration_ago(record['ts'] || record['timestamp'])}"
128
131
  end
129
132
 
130
133
  } },
131
- ]
134
+ ].compact
132
135
  print as_pretty_table(activity, columns, options)
133
136
  print_results_pagination(json_response)
134
137
  end
@@ -272,20 +272,20 @@ This includes instance and backup counts, favorite instances, monitoring and rec
272
272
  # {"SEVERITY" => lambda {|record| format_activity_severity(record['severity']) } },
273
273
  {"TYPE" => lambda {|record| record['activityType'] } },
274
274
  {"NAME" => lambda {|record| record['name'] } },
275
- {"RESOURCE" => lambda {|record| "#{record['objectType']} #{record['objectId']}" } },
275
+ options[:details] ? {"RESOURCE" => lambda {|record| "#{record['objectType']} #{record['objectId']}" } } : nil,
276
276
  {"MESSAGE" => lambda {|record| record['message'] || '' } },
277
277
  {"USER" => lambda {|record| record['user'] ? record['user']['username'] : record['userName'] } },
278
278
  #{"DATE" => lambda {|record| "#{format_duration_ago(record['ts'] || record['timestamp'])}" } },
279
279
  {"DATE" => lambda {|record|
280
280
  # show full time if searching for custom timerange, otherwise the default is to show relative time
281
- if params['start'] || params['end'] || params['timeframe']
281
+ if params['start'] || params['end'] || params['timeframe'] || options[:details]
282
282
  "#{format_local_dt(record['ts'] || record['timestamp'])}"
283
283
  else
284
284
  "#{format_duration_ago(record['ts'] || record['timestamp'])}"
285
285
  end
286
286
 
287
287
  } },
288
- ]
288
+ ].compact
289
289
  print as_pretty_table(activity, columns, options)
290
290
  # print_results_pagination(json_response)
291
291
  # print reset,"\n"
@@ -31,6 +31,10 @@ class Morpheus::Cli::ExecutionRequestCommand
31
31
  handle_subcommand(args)
32
32
  end
33
33
 
34
+ def default_refresh_interval
35
+ 5
36
+ end
37
+
34
38
  def get(args)
35
39
  raw_args = args
36
40
  options = {}
@@ -134,7 +138,7 @@ class Morpheus::Cli::ExecutionRequestCommand
134
138
  options = {}
135
139
  params = {}
136
140
  script_content = nil
137
- do_refresh = true
141
+ options[:refresh_until_finished] = true
138
142
  optparse = Morpheus::Cli::OptionParser.new do|opts|
139
143
  opts.banner = subcommand_usage("[options]")
140
144
  opts.on('--server ID', String, "Server ID") do |val|
@@ -161,8 +165,14 @@ class Morpheus::Cli::ExecutionRequestCommand
161
165
  exit 1
162
166
  end
163
167
  end
164
- opts.on(nil, '--no-refresh', "Do not refresh until finished" ) do
165
- do_refresh = false
168
+ opts.on('--refresh [SECONDS]', String, "Refresh until execution is finished. Default interval is #{default_refresh_interval} seconds.") do |val|
169
+ options[:refresh_until_finished] = true
170
+ if !val.to_s.empty?
171
+ options[:refresh_interval] = val.to_f
172
+ end
173
+ end
174
+ opts.on(nil, '--no-refresh', "Do not refresh. The default behavior is to refresh until finished." ) do
175
+ options[:refresh_until_finished] = false
166
176
  end
167
177
  #build_option_type_options(opts, options, add_user_source_option_types())
168
178
  build_common_options(opts, options, [:options, :payload, :json, :dry_run, :quiet, :remote])
@@ -212,8 +222,8 @@ class Morpheus::Cli::ExecutionRequestCommand
212
222
  end
213
223
  execution_request = json_response['executionRequest']
214
224
  print_green_success "Executing request #{execution_request['uniqueId']}"
215
- if do_refresh
216
- get([execution_request['uniqueId'], "--refresh"] + (options[:remote] ? ["-r",options[:remote]] : []))
225
+ if options[:refresh_until_finished]
226
+ get([execution_request['uniqueId'], "--refresh", options[:refresh_interval] ? options[:refresh_interval].to_s : nil].compact + (options[:remote] ? ["-r",options[:remote]] : []))
217
227
  else
218
228
  get([execution_request['uniqueId']] + (options[:remote] ? ["-r",options[:remote]] : []))
219
229
  end
@@ -140,32 +140,32 @@ class Morpheus::Cli::InvoicesCommand
140
140
  # construct params
141
141
  params.merge!(parse_list_options(options))
142
142
  if options[:clouds]
143
- cloud_ids = parse_cloud_id_list(options[:clouds])
143
+ cloud_ids = parse_cloud_id_list(options[:clouds], {}, false, true)
144
144
  return 1, "clouds not found for #{options[:clouds]}" if cloud_ids.nil?
145
145
  params['zoneId'] = cloud_ids
146
146
  end
147
147
  if options[:groups]
148
- group_ids = parse_group_id_list(options[:groups])
148
+ group_ids = parse_group_id_list(options[:groups], {}, false, true)
149
149
  return 1, "groups not found for #{options[:groups]}" if group_ids.nil?
150
150
  params['siteId'] = group_ids
151
151
  end
152
152
  if options[:instances]
153
- instance_ids = parse_instance_id_list(options[:instances])
153
+ instance_ids = parse_instance_id_list(options[:instances], {}, false, true)
154
154
  return 1, "instances not found for #{options[:instances]}" if instance_ids.nil?
155
155
  params['instanceId'] = instance_ids
156
156
  end
157
157
  if options[:servers]
158
- server_ids = parse_server_id_list(options[:servers])
158
+ server_ids = parse_server_id_list(options[:servers], {}, false, true)
159
159
  return 1, "servers not found for #{options[:servers]}" if server_ids.nil?
160
160
  params['serverId'] = server_ids
161
161
  end
162
162
  if options[:users]
163
- user_ids = parse_user_id_list(options[:users])
163
+ user_ids = parse_user_id_list(options[:users], {}, false, true)
164
164
  return 1, "users not found for #{options[:users]}" if user_ids.nil?
165
165
  params['userId'] = user_ids
166
166
  end
167
167
  if options[:projects]
168
- project_ids = parse_project_id_list(options[:projects])
168
+ project_ids = parse_project_id_list(options[:projects], {}, false, true)
169
169
  return 1, "projects not found for #{options[:projects]}" if project_ids.nil?
170
170
  params['projectId'] = project_ids
171
171
  end
@@ -636,37 +636,20 @@ Update an invoice.
636
636
  params = {}
637
637
  payload = {}
638
638
  optparse = Morpheus::Cli::OptionParser.new do |opts|
639
- opts.banner = subcommand_usage("[--daily] [--costing] [--current] [-c CLOUD]")
640
- opts.on( '--daily', "Refresh Daily Invoices" ) do
641
- payload[:daily] = true
642
- end
643
- opts.on( '--costing', "Refresh Costing Data" ) do
644
- payload[:costing] = true
645
- end
646
- opts.on( '--current', "Collect the most up to date costing data." ) do
647
- payload[:current] = true
648
- end
649
- opts.on( '--date DATE', String, "Date to collect costing for. By default the cost data is collected for the end of the previous period." ) do |val|
650
- payload[:date] = val.to_s
651
- end
652
- opts.on( '-c', '--cloud CLOUD', "Specify cloud(s) to refresh costing for." ) do |val|
639
+ opts.banner = subcommand_usage("[-c CLOUD]")
640
+ opts.on( '-c', '--clouds CLOUD', "Specify clouds to refresh costing for." ) do |val|
653
641
  payload[:clouds] ||= []
654
642
  payload[:clouds] << val
655
643
  end
656
- opts.on( '--all', "Refresh costing for all clouds." ) do
644
+ opts.on( '--all', "Refresh costing for all clouds. This can be used instead of --clouds" ) do
657
645
  payload[:all] = true
658
646
  end
659
- # opts.on( '-f', '--force', "Force Refresh" ) do
660
- # query_params[:force] = 'true'
661
- # end
647
+ opts.on( '--date DATE', String, "Date to collect costing for. By default the cost data is collected for the end of the previous job interval (hour or day)." ) do |val|
648
+ payload[:date] = val.to_s
649
+ end
662
650
  build_standard_update_options(opts, options, [:query, :auto_confirm])
663
651
  opts.footer = <<-EOT
664
- Refresh invoices.
665
- By default, nothing is changed.
666
- Include --daily to regenerate invoice records.
667
- Include --costing to refresh actual costing data.
668
- Include --current to refresh costing data for the actual current time.
669
- To get the latest invoice costing data, include --daily --costing --current --all
652
+ Refresh invoice costing data for the specified clouds.
670
653
  EOT
671
654
  end
672
655
  optparse.parse!(args)
@@ -677,17 +660,11 @@ EOT
677
660
  payload = options[:payload]
678
661
  end
679
662
  payload.deep_merge!(parse_passed_options(options))
680
- # --clouds
663
+ # --clouds lookup ID for name
681
664
  if payload[:clouds]
682
- payload[:clouds] = parse_id_list(payload[:clouds]).collect {|cloud_id|
683
- if cloud_id.to_s =~ /\A\d{1,}\Z/
684
- cloud_id
685
- else
686
- cloud = find_cloud_option(cloud_id)
687
- return 1 if cloud.nil?
688
- cloud['id']
689
- end
690
- }
665
+ cloud_ids = parse_cloud_id_list(payload[:clouds], {}, false, true)
666
+ return 1, "clouds not found for #{payload[:clouds]}" if cloud_ids.nil?
667
+ payload[:clouds] = cloud_ids
691
668
  end
692
669
  # are you sure?
693
670
  unless options[:yes] || Morpheus::Cli::OptionTypes.confirm("Are you sure you want to refresh invoices?")
@@ -831,32 +808,32 @@ EOT
831
808
  # construct params
832
809
  params.merge!(parse_list_options(options))
833
810
  if options[:clouds]
834
- cloud_ids = parse_cloud_id_list(options[:clouds])
811
+ cloud_ids = parse_cloud_id_list(options[:clouds], {}, false, true)
835
812
  return 1, "clouds not found for #{options[:clouds]}" if cloud_ids.nil?
836
813
  params['zoneId'] = cloud_ids
837
814
  end
838
815
  if options[:groups]
839
- group_ids = parse_group_id_list(options[:groups])
816
+ group_ids = parse_group_id_list(options[:groups], {}, false, true)
840
817
  return 1, "groups not found for #{options[:groups]}" if group_ids.nil?
841
818
  params['siteId'] = group_ids
842
819
  end
843
820
  if options[:instances]
844
- instance_ids = parse_instance_id_list(options[:instances])
821
+ instance_ids = parse_instance_id_list(options[:instances], {}, false, true)
845
822
  return 1, "instances not found for #{options[:instances]}" if instance_ids.nil?
846
823
  params['instanceId'] = instance_ids
847
824
  end
848
825
  if options[:servers]
849
- server_ids = parse_server_id_list(options[:servers])
826
+ server_ids = parse_server_id_list(options[:servers], {}, false, true)
850
827
  return 1, "servers not found for #{options[:servers]}" if server_ids.nil?
851
828
  params['serverId'] = server_ids
852
829
  end
853
830
  if options[:users]
854
- user_ids = parse_user_id_list(options[:users])
831
+ user_ids = parse_user_id_list(options[:users], {}, false, true)
855
832
  return 1, "users not found for #{options[:users]}" if user_ids.nil?
856
833
  params['userId'] = user_ids
857
834
  end
858
835
  if options[:projects]
859
- project_ids = parse_project_id_list(options[:projects])
836
+ project_ids = parse_project_id_list(options[:projects], {}, false, true)
860
837
  return 1, "projects not found for #{options[:projects]}" if project_ids.nil?
861
838
  params['projectId'] = project_ids
862
839
  end
@@ -720,6 +720,7 @@ module Morpheus::Cli::PrintHelper
720
720
  columns.each do |column_def|
721
721
  # r << column_def.display_method.respond_to?(:call) ? column_def.display_method.call(row_data) : get_object_value(row_data, column_def.display_method)
722
722
  value = column_def.display_method.call(row_data)
723
+ value = JSON.fast_generate(value) if value.is_a?(Hash) || value.is_a?(Array)
723
724
  row << value
724
725
  end
725
726
  rows << row
@@ -802,6 +803,7 @@ module Morpheus::Cli::PrintHelper
802
803
  columns.each do |column_def|
803
804
  # r << column_def.display_method.respond_to?(:call) ? column_def.display_method.call(row_data) : get_object_value(row_data, column_def.display_method)
804
805
  value = column_def.display_method.call(row_data)
806
+ value = JSON.fast_generate(value) if value.is_a?(Hash) || value.is_a?(Array)
805
807
  row << value
806
808
  end
807
809
  rows << row
@@ -879,6 +881,7 @@ module Morpheus::Cli::PrintHelper
879
881
  label = label.upcase if ALL_LABELS_UPCASE
880
882
  # value = get_object_value(obj, column_def.display_method)
881
883
  value = column_def.display_method.call(obj)
884
+ value = JSON.fast_generate(value) if value.is_a?(Hash) || value.is_a?(Array)
882
885
  if label.size > max_label_width
883
886
  max_label_width = label.size
884
887
  end
@@ -1276,7 +1276,8 @@ EOT
1276
1276
 
1277
1277
  def format_remote_details(appliance, options={})
1278
1278
  columns = {
1279
- "Name" => :name,
1279
+ #"Name" => :name,
1280
+ "Name" => lambda {|it| it[:name].to_s },
1280
1281
  #"Name" => lambda {|it| it[:active] ? "#{it[:name]} #{bold}(current)#{reset}#{cyan}" : it[:name] },
1281
1282
  "URL" => lambda {|it| it[:url] || it[:host] },
1282
1283
  #"Status" => lambda {|it| format_appliance_status(it, cyan) },
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Morpheus
3
3
  module Cli
4
- VERSION = "5.2.4.1"
4
+ VERSION = "5.3.0"
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.4.1
4
+ version: 5.3.0
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: 2021-02-11 00:00:00.000000000 Z
14
+ date: 2021-02-25 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler