morpheus-cli 4.2 → 4.2.1

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: 65ef554015f7c79d475689f9b09d7a91e235c7feb992580f588e11c4c2fe36a5
4
- data.tar.gz: 787e1ba5b1dbe066f8ab8e1fd47ec93372d9b68f5402ff4bcee3e1e7dbc62cfc
3
+ metadata.gz: 46d92f279d50a64ebeb6f5c08623f9e54573cbf4855f08f2bfbb6a201b706522
4
+ data.tar.gz: 19c96eb29f3afc1943d6e52667fac9be0364a8d8e87d9b2d04da13671d2b68c4
5
5
  SHA512:
6
- metadata.gz: f21d7fef551d46c5e2f9465fdebc59b8b3c801d8a44474a299a2285234672206da64a0e68ca7d3b3f36eb1ee80279477ea1a0fc3b13c7ade10e72cbdde4bb3e8
7
- data.tar.gz: 183b260af59171e6f0620864fc428245618506276cd350097396664a5f7609e866f4defcba7dd41f2f87a07ea292af42de57887b23736190c15ca46042977ea8
6
+ metadata.gz: d7267a3cfbc6052d7963dcda64401c289031b65b12779721361154dfdbf6344195779a8b44d8da5b45a0d52a1b06c5f53cd8a4cf07b300693e23ec71463adaf6
7
+ data.tar.gz: bca94b7c92c9c420224a5695d05f8f35f89c8211c61c74b3e106b2789439df2a46ab8f7adcee04654655cbff6275fddf5da68408f9691711c25152fcb9636c81
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
3
+ RUN gem install morpheus-cli -v 4.2.1
4
4
 
5
5
  ENTRYPOINT ["morpheus"]
@@ -10,21 +10,23 @@ class Morpheus::LibraryInstanceTypesInterface < Morpheus::APIClient
10
10
 
11
11
  def get(id, params={})
12
12
  raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
13
- url = "#{@base_url}/api/library/instance-types/#{id}"
13
+ # new URL is available in api 4.2 +
14
+ # url = "#{@base_url}/api/library/#{id}"
15
+ url = "#{@base_url}/api/library/#{id}"
14
16
  headers = { params: params, authorization: "Bearer #{@access_token}" }
15
17
  opts = {method: :get, url: url, headers: headers}
16
18
  execute(opts)
17
19
  end
18
20
 
19
21
  def list(params={})
20
- url = "#{@base_url}/api/library/instance-types"
22
+ url = "#{@base_url}/api/library"
21
23
  headers = { params: params, authorization: "Bearer #{@access_token}" }
22
24
  opts = {method: :get, url: url, headers: headers}
23
25
  execute(opts)
24
26
  end
25
27
 
26
28
  def create(options)
27
- url = "#{@base_url}/api/library/instance-types"
29
+ url = "#{@base_url}/api/library"
28
30
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
29
31
  payload = options
30
32
  opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
@@ -32,7 +34,7 @@ class Morpheus::LibraryInstanceTypesInterface < Morpheus::APIClient
32
34
  end
33
35
 
34
36
  def update(id, options)
35
- url = "#{@base_url}/api/library/instance-types/#{id}"
37
+ url = "#{@base_url}/api/library/#{id}"
36
38
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
37
39
  payload = options
38
40
  opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
@@ -40,14 +42,14 @@ class Morpheus::LibraryInstanceTypesInterface < Morpheus::APIClient
40
42
  end
41
43
 
42
44
  def toggle_featured(id, params={}, payload={})
43
- url = "#{@base_url}/api/library/instance-types/#{id}/toggle-featured"
45
+ url = "#{@base_url}/api/library/#{id}/toggle-featured"
44
46
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
45
47
  opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
46
48
  execute(opts)
47
49
  end
48
50
 
49
51
  def destroy(id, payload={})
50
- url = "#{@base_url}/api/library/instance-types/#{id}"
52
+ url = "#{@base_url}/api/library/#{id}"
51
53
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
52
54
  opts = {method: :delete, url: url, headers: headers, payload: payload.to_json}
53
55
  execute(opts)
@@ -55,7 +57,7 @@ class Morpheus::LibraryInstanceTypesInterface < Morpheus::APIClient
55
57
 
56
58
  # NOT json, multipart file upload
57
59
  def update_logo(id, logo_file)
58
- url = "#{@base_url}/api/library/instance-types/#{id}/update-logo"
60
+ url = "#{@base_url}/api/library/#{id}/update-logo"
59
61
  headers = { :params => {}, :authorization => "Bearer #{@access_token}"}
60
62
  payload = {}
61
63
  payload[:logo] = logo_file
@@ -51,7 +51,9 @@ class Morpheus::LibraryLayoutsInterface < Morpheus::APIClient
51
51
  def build_url(instance_type_id=nil, id=nil)
52
52
  url = "#{@base_url}/api"
53
53
  if instance_type_id
54
- url += "/library/instance-types/#{instance_type_id}/layouts"
54
+ # new URL is available in api 4.2 +
55
+ # url += "/library/instance-types/#{instance_type_id}/layouts"
56
+ url += "/library/#{instance_type_id}/layouts"
55
57
  else
56
58
  url += "/library/layouts"
57
59
  end
@@ -33,6 +33,12 @@ class Morpheus::ServicePlansInterface < Morpheus::APIClient
33
33
  execute(method: :put, url: url, headers: headers, payload: payload.to_json)
34
34
  end
35
35
 
36
+ def activate(id, params={})
37
+ url = "#{@api_url}/#{id}/activate"
38
+ headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
39
+ execute(method: :put, url: url, headers: headers)
40
+ end
41
+
36
42
  def deactivate(id, params={})
37
43
  url = "#{@api_url}/#{id}/deactivate"
38
44
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
@@ -599,13 +599,16 @@ module Morpheus::Cli::ProvisioningHelper
599
599
 
600
600
  # add selectable datastores for resource pool
601
601
  if options[:select_datastore]
602
- service_plan['datastores'] = {'cluster' => [], 'store' => []}
603
- selectable_datastores = cloud_datastores_interface.selectable(cloud_id, {'siteId' => group_id, 'resourcePoolId' => resource_pool['id']})
604
- ['cluster', 'store'].each do |type|
605
- service_plan['datastores'][type] ||= []
606
- selectable_datastores[type].reject { |ds| service_plan['datastores'][type].find {|it| it['id'] == ds['id']} }.each { |ds|
607
- service_plan['datastores'][type] << ds
608
- }
602
+ begin
603
+ service_plan['datastores'] = {'cluster' => [], 'store' => []}
604
+ selectable_datastores = cloud_datastores_interface.selectable(cloud_id, {'siteId' => group_id, 'resourcePoolId' => resource_pool['id']})
605
+ ['cluster', 'store'].each do |type|
606
+ service_plan['datastores'][type] ||= []
607
+ selectable_datastores[type].reject { |ds| service_plan['datastores'][type].find {|it| it['id'] == ds['id']} }.each { |ds|
608
+ service_plan['datastores'][type] << ds
609
+ }
610
+ end
611
+ rescue => error
609
612
  end
610
613
 
611
614
  if provision_type && provision_type['supportsAutoDatastore']
@@ -7,7 +7,7 @@ class Morpheus::Cli::ServicePlanCommand
7
7
 
8
8
  set_command_name :'service-plans'
9
9
 
10
- register_subcommands :list, :get, :add, :update, :deactivate
10
+ register_subcommands :list, :get, :add, :update, :activate, :deactivate
11
11
  set_default_subcommand :list
12
12
 
13
13
  def connect(opts)
@@ -637,6 +637,60 @@ class Morpheus::Cli::ServicePlanCommand
637
637
  exit 1
638
638
  end
639
639
  end
640
+
641
+ def activate(args)
642
+ options = {}
643
+ params = {}
644
+ optparse = Morpheus::Cli::OptionParser.new do |opts|
645
+ opts.banner = subcommand_usage( "[plan]")
646
+ build_common_options(opts, options, [:json, :dry_run, :remote, :auto_confirm])
647
+ opts.footer = "Activate service plan.\n" +
648
+ "[plan] is required. Service plan ID, name or code"
649
+ end
650
+ optparse.parse!(args)
651
+ connect(options)
652
+ if args.count != 1
653
+ raise_command_error "wrong number of arguments, expected 1 and got (#{args.count}) #{args}\n#{optparse}"
654
+ return 1
655
+ end
656
+
657
+ begin
658
+ plan = find_service_plan(args[0])
659
+
660
+ if !plan
661
+ print_red_alert "Service plan #{args[0]} not found"
662
+ exit 1
663
+ end
664
+
665
+ if plan['active'] == true
666
+ print_green_success "Service plan #{plan['name']} already actived."
667
+ return 0
668
+ end
669
+
670
+ unless options[:yes] || ::Morpheus::Cli::OptionTypes::confirm("Are you sure you would like to activate the service plan '#{plan['name']}'?", options)
671
+ return 9, "aborted command"
672
+ end
673
+
674
+ @service_plans_interface.setopts(options)
675
+ if options[:dry_run]
676
+ print_dry_run @service_plans_interface.dry.activate(plan['id'], params)
677
+ return
678
+ end
679
+
680
+ json_response = @service_plans_interface.activate(plan['id'], params)
681
+
682
+ if options[:json]
683
+ print JSON.pretty_generate(json_response)
684
+ print "\n"
685
+ elsif !options[:quiet]
686
+ print_green_success "Service plan #{plan['name']} activated"
687
+ end
688
+ return 0
689
+ rescue RestClient::Exception => e
690
+ print_rest_exception(e, options)
691
+ exit 1
692
+ end
693
+ end
640
694
 
641
695
  def deactivate(args)
642
696
  options = {}
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Morpheus
3
3
  module Cli
4
- VERSION = "4.2"
4
+ VERSION = "4.2.1"
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'
4
+ version: 4.2.1
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-03-06 00:00:00.000000000 Z
14
+ date: 2020-03-11 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler