morpheus-cli 4.2.5 → 4.2.6

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: 7b6ccabcdbd7fef021565aa109c55832f6e1f67e4fff957849aa31bfff81b14b
4
- data.tar.gz: 4241cdcba0dfacfccfd15916340a5ffe1f876067e1565bac202e87c415603c09
3
+ metadata.gz: 7fa057d89b29003c127a3c53616a012aeb2c23368384b85f0bf03b10bfd5124e
4
+ data.tar.gz: bc219cef29503224870be7de21a626a2f98c8ed766470ee79e3001ca1c41015f
5
5
  SHA512:
6
- metadata.gz: 5bda2a86a83aa395736e0fd133d6aae6dd388f474e521252ef5c4bed9855b0e8a4325881c2daa0bdf6fe0ca52f650c853385b0974f1e7d399664e9dd997d4d6f
7
- data.tar.gz: 948e5582db73d74a27a270b61155a0ecb5844c0c5e6a58b5e0b6148ea6fbd5bfeb707e42592509ac4be2adab8c59978491caafef8c5e1f465b30cfad8d550529
6
+ metadata.gz: a93cb277435293503eddbd3abdb9f349b105298cf55820feeba7187d5c1f982b65c1cd5c2c1c4989b56f3e49c861acb8ce28e657fa4a797cd2589e193a858fd9
7
+ data.tar.gz: 2e11115d23a8d1d78eeb2214ca3aac06ef8ca92fd25d873c1ef02cb8350e2bfaeaeb25c7eb53c4311820c54266fb1fcd5c8a6fe1a2bacaf7d1e04308532c4821
data/Dockerfile CHANGED
@@ -1,5 +1,5 @@
1
1
  FROM ruby:2.5.1
2
2
 
3
- RUN gem install morpheus-cli -v 4.2.5
3
+ RUN gem install morpheus-cli -v 4.2.6
4
4
 
5
5
  ENTRYPOINT ["morpheus"]
@@ -153,8 +153,8 @@ class Morpheus::Cli::InvoicesCommand
153
153
  if invoices.empty?
154
154
  print cyan,"No invoices found.",reset,"\n"
155
155
  else
156
- current_date = Time.now
157
- current_period = "#{current_date.year}#{current_date.month.to_s.rjust(2, '0')}"
156
+ # current_date = Time.now
157
+ # current_period = "#{current_date.year}#{current_date.month.to_s.rjust(2, '0')}"
158
158
  columns = [
159
159
  {"INVOICE ID" => lambda {|it| it['id'] } },
160
160
  {"TYPE" => lambda {|it| format_invoice_ref_type(it) } },
@@ -170,7 +170,8 @@ class Morpheus::Cli::InvoicesCommand
170
170
  {"END" => lambda {|it| it['endDate'] ? format_date(it['endDate']) : '' } },
171
171
  {"MTD" => lambda {|it| format_money(it['runningCost']) } },
172
172
  {"TOTAL" => lambda {|it|
173
- if it['period'] == current_period && it['totalCost'].to_f > 0
173
+
174
+ if it['runningMultiplier'] && it['runningMultiplier'].to_i != 1 && it['totalCost'].to_f > 0
174
175
  format_money(it['totalCost']) + " (Projected)"
175
176
  else
176
177
  format_money(it['totalCost'])
@@ -178,7 +179,7 @@ class Morpheus::Cli::InvoicesCommand
178
179
  } },
179
180
  {"ACTUAL MTD" => lambda {|it| format_money(it['actualRunningCost']) } },
180
181
  {"ACTUAL TOTAL" => lambda {|it|
181
- if it['period'] == current_period && it['actualTotalCost'].to_f > 0
182
+ if it['runningMultiplier'] && it['runningMultiplier'].to_i != 1 && it['actualTotalCost'].to_f > 0
182
183
  format_money(it['actualTotalCost']) + " (Projected)"
183
184
  else
184
185
  format_money(it['actualTotalCost'])
@@ -196,19 +197,11 @@ class Morpheus::Cli::InvoicesCommand
196
197
  end
197
198
  if options[:show_actual_costs]
198
199
  columns += [
199
- {"ACTUAL COMPUTE" => lambda {|it| format_money(it['actualComputePrice']) } },
200
- # {"ACTUAL MEMORY" => lambda {|it| format_money(it['actualMemoryPrice']) } },
201
- {"ACTUAL STORAGE" => lambda {|it| format_money(it['actualStoragePrice']) } },
202
- {"ACTUAL NETWORK" => lambda {|it| format_money(it['actualNetworkPrice']) } },
203
- {"ACTUAL OTHER" => lambda {|it| format_money(it['actualExtraPrice']) } },
204
- # {"ACTUAL MTD" => lambda {|it| format_money(it['actualRunningPrice']) } },
205
- # {"ACTUAL TOTAL" => lambda {|it|
206
- # if it['period'] == current_period && it['actualTotalPrice'].to_f > 0
207
- # format_money(it['actualTotalPrice']) + " (Projected)"
208
- # else
209
- # format_money(it['actualTotalPrice'])
210
- # end
211
- # } }
200
+ {"ACTUAL COMPUTE" => lambda {|it| format_money(it['actualComputeCost']) } },
201
+ # {"ACTUAL MEMORY" => lambda {|it| format_money(it['actualMemoryCost']) } },
202
+ {"ACTUAL STORAGE" => lambda {|it| format_money(it['actualStorageCost']) } },
203
+ {"ACTUAL NETWORK" => lambda {|it| format_money(it['actualNetworkCost']) } },
204
+ {"ACTUAL OTHER" => lambda {|it| format_money(it['actualExtraCost']) } },
212
205
  ]
213
206
  end
214
207
 
@@ -221,7 +214,7 @@ class Morpheus::Cli::InvoicesCommand
221
214
  {"OTHER PRICE" => lambda {|it| format_money(it['extraPrice']) } },
222
215
  {"MTD PRICE" => lambda {|it| format_money(it['runningPrice']) } },
223
216
  {"TOTAL PRICE" => lambda {|it|
224
- if it['period'] == current_period && it['totalPrice'].to_f > 0
217
+ if it['runningMultiplier'] && it['runningMultiplier'].to_i != 1 && it['totalPrice'].to_f > 0
225
218
  format_money(it['totalPrice']) + " (Projected)"
226
219
  else
227
220
  format_money(it['totalPrice'])
@@ -291,6 +284,7 @@ class Morpheus::Cli::InvoicesCommand
291
284
  "Ref ID" => lambda {|it| it['refId'] },
292
285
  "Ref Name" => lambda {|it| it['refName'] },
293
286
  "Plan" => lambda {|it| it['plan'] ? it['plan']['name'] : '' },
287
+ "Power State" => lambda {|it| format_server_power_state(it) },
294
288
  "Account" => lambda {|it| it['account'] ? it['account']['name'] : '' },
295
289
  "Active" => lambda {|it| format_boolean(it['active']) },
296
290
  "Period" => lambda {|it| format_invoice_period(it) },
@@ -301,6 +295,13 @@ class Morpheus::Cli::InvoicesCommand
301
295
  "Created" => lambda {|it| format_local_dt(it['dateCreated']) },
302
296
  "Updated" => lambda {|it| format_local_dt(it['lastUpdated']) }
303
297
  }
298
+ # remove columns that do not apply
299
+ if !invoice['plan']
300
+ description_cols.delete("Plan")
301
+ end
302
+ if !['ComputeServer','Instance','Container'].include?(invoice['refType'])
303
+ description_cols.delete("Power State")
304
+ end
304
305
  print_description_list(description_cols, invoice)
305
306
  =begin
306
307
  print_h2 "Costs"
@@ -330,8 +331,8 @@ class Morpheus::Cli::InvoicesCommand
330
331
  print as_pretty_table([invoice], price_columns, options)
331
332
  =end
332
333
 
333
- current_date = Time.now
334
- current_period = "#{current_date.year}#{current_date.month.to_s.rjust(2, '0')}"
334
+ # current_date = Time.now
335
+ # current_period = "#{current_date.year}#{current_date.month.to_s.rjust(2, '0')}"
335
336
 
336
337
  print "\n"
337
338
  # print_h2 "Costs"
@@ -350,7 +351,7 @@ class Morpheus::Cli::InvoicesCommand
350
351
  "Other".upcase => lambda {|it| format_money(it[:extra]) },
351
352
  "MTD" => lambda {|it| format_money(it[:running]) },
352
353
  "Total".upcase => lambda {|it|
353
- if invoice['period'] == current_period && it[:total].to_f > 0
354
+ if invoice['runningMultiplier'] && invoice['runningMultiplier'].to_i != 1 && it[:total].to_f.to_f > 0
354
355
  format_money(it[:total]) + " (Projected)"
355
356
  else
356
357
  format_money(it[:total])
@@ -483,5 +484,17 @@ class Morpheus::Cli::InvoicesCommand
483
484
  return nil
484
485
  end
485
486
  end
487
+
488
+ def format_server_power_state(server, return_color=cyan)
489
+ out = ""
490
+ if server['powerState'] == 'on'
491
+ out << "#{green}ON#{return_color}"
492
+ elsif server['powerState'] == 'off'
493
+ out << "#{red}OFF#{return_color}"
494
+ else
495
+ out << "#{white}#{server['powerState'].to_s.upcase}#{return_color}"
496
+ end
497
+ out
498
+ end
486
499
 
487
500
  end
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Morpheus
3
3
  module Cli
4
- VERSION = "4.2.5"
4
+ VERSION = "4.2.6"
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: 4.2.5
4
+ version: 4.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Estes