morpheus-cli 2.10.0 → 2.10.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.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/bin/morpheus +27 -32
  3. data/lib/morpheus/api/accounts_interface.rb +36 -47
  4. data/lib/morpheus/api/api_client.rb +141 -110
  5. data/lib/morpheus/api/app_templates_interface.rb +56 -72
  6. data/lib/morpheus/api/apps_interface.rb +111 -132
  7. data/lib/morpheus/api/auth_interface.rb +30 -0
  8. data/lib/morpheus/api/clouds_interface.rb +71 -76
  9. data/lib/morpheus/api/custom_instance_types_interface.rb +21 -46
  10. data/lib/morpheus/api/dashboard_interface.rb +10 -17
  11. data/lib/morpheus/api/deploy_interface.rb +60 -72
  12. data/lib/morpheus/api/deployments_interface.rb +53 -71
  13. data/lib/morpheus/api/groups_interface.rb +55 -45
  14. data/lib/morpheus/api/instance_types_interface.rb +19 -23
  15. data/lib/morpheus/api/instances_interface.rb +179 -177
  16. data/lib/morpheus/api/key_pairs_interface.rb +11 -17
  17. data/lib/morpheus/api/license_interface.rb +18 -23
  18. data/lib/morpheus/api/load_balancers_interface.rb +54 -69
  19. data/lib/morpheus/api/logs_interface.rb +25 -29
  20. data/lib/morpheus/api/options_interface.rb +13 -17
  21. data/lib/morpheus/api/provision_types_interface.rb +19 -22
  22. data/lib/morpheus/api/roles_interface.rb +75 -94
  23. data/lib/morpheus/api/security_group_rules_interface.rb +28 -37
  24. data/lib/morpheus/api/security_groups_interface.rb +39 -51
  25. data/lib/morpheus/api/servers_interface.rb +113 -115
  26. data/lib/morpheus/api/setup_interface.rb +31 -0
  27. data/lib/morpheus/api/task_sets_interface.rb +36 -38
  28. data/lib/morpheus/api/tasks_interface.rb +56 -69
  29. data/lib/morpheus/api/users_interface.rb +67 -76
  30. data/lib/morpheus/api/virtual_images_interface.rb +61 -61
  31. data/lib/morpheus/api/whoami_interface.rb +12 -15
  32. data/lib/morpheus/cli.rb +71 -60
  33. data/lib/morpheus/cli/accounts.rb +254 -315
  34. data/lib/morpheus/cli/alias_command.rb +219 -0
  35. data/lib/morpheus/cli/app_templates.rb +264 -272
  36. data/lib/morpheus/cli/apps.rb +608 -671
  37. data/lib/morpheus/cli/cli_command.rb +259 -21
  38. data/lib/morpheus/cli/cli_registry.rb +99 -14
  39. data/lib/morpheus/cli/clouds.rb +599 -372
  40. data/lib/morpheus/cli/config_file.rb +126 -0
  41. data/lib/morpheus/cli/credentials.rb +141 -117
  42. data/lib/morpheus/cli/dashboard_command.rb +48 -56
  43. data/lib/morpheus/cli/deployments.rb +254 -268
  44. data/lib/morpheus/cli/deploys.rb +150 -142
  45. data/lib/morpheus/cli/error_handler.rb +38 -0
  46. data/lib/morpheus/cli/groups.rb +551 -179
  47. data/lib/morpheus/cli/hosts.rb +862 -617
  48. data/lib/morpheus/cli/instance_types.rb +103 -95
  49. data/lib/morpheus/cli/instances.rb +1335 -1009
  50. data/lib/morpheus/cli/key_pairs.rb +82 -90
  51. data/lib/morpheus/cli/library.rb +498 -499
  52. data/lib/morpheus/cli/license.rb +83 -101
  53. data/lib/morpheus/cli/load_balancers.rb +314 -300
  54. data/lib/morpheus/cli/login.rb +66 -44
  55. data/lib/morpheus/cli/logout.rb +47 -46
  56. data/lib/morpheus/cli/mixins/accounts_helper.rb +69 -31
  57. data/lib/morpheus/cli/mixins/infrastructure_helper.rb +106 -0
  58. data/lib/morpheus/cli/mixins/print_helper.rb +181 -17
  59. data/lib/morpheus/cli/mixins/provisioning_helper.rb +535 -458
  60. data/lib/morpheus/cli/mixins/whoami_helper.rb +2 -2
  61. data/lib/morpheus/cli/option_parser.rb +35 -0
  62. data/lib/morpheus/cli/option_types.rb +232 -192
  63. data/lib/morpheus/cli/recent_activity_command.rb +61 -65
  64. data/lib/morpheus/cli/remote.rb +446 -199
  65. data/lib/morpheus/cli/roles.rb +884 -906
  66. data/lib/morpheus/cli/security_group_rules.rb +213 -203
  67. data/lib/morpheus/cli/security_groups.rb +237 -192
  68. data/lib/morpheus/cli/shell.rb +338 -231
  69. data/lib/morpheus/cli/tasks.rb +326 -308
  70. data/lib/morpheus/cli/users.rb +457 -462
  71. data/lib/morpheus/cli/version.rb +1 -1
  72. data/lib/morpheus/cli/version_command.rb +16 -18
  73. data/lib/morpheus/cli/virtual_images.rb +526 -345
  74. data/lib/morpheus/cli/whoami.rb +125 -111
  75. data/lib/morpheus/cli/workflows.rb +338 -185
  76. data/lib/morpheus/formatters.rb +8 -1
  77. data/lib/morpheus/logging.rb +1 -1
  78. data/lib/morpheus/rest_client.rb +17 -8
  79. metadata +9 -3
  80. data/lib/morpheus/api/custom_instance_types.rb +0 -55
@@ -1,72 +1,59 @@
1
- require 'json'
2
- require 'rest-client'
1
+ require 'morpheus/api/api_client'
3
2
 
4
3
  class Morpheus::TasksInterface < Morpheus::APIClient
5
- def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
6
- @access_token = access_token
7
- @refresh_token = refresh_token
8
- @base_url = base_url
9
- @expires_at = expires_at
10
- end
11
-
12
- def task_types(options={})
13
- url = "#{@base_url}/api/task-types"
14
- headers = { params: {}, authorization: "Bearer #{@access_token}" }
15
-
16
- if options.is_a?(Hash)
17
- headers[:params].merge!(options)
18
- elsif options.is_a?(Numeric)
19
- url = "#{@base_url}/api/task-types/#{options}"
20
- elsif options.is_a?(String)
21
- headers[:params]['name'] = options
22
- end
23
- response = Morpheus::RestClient.execute(method: :get, url: url,
24
- timeout: 30, headers: headers, verify_ssl:false)
25
- JSON.parse(response.to_s)
26
- end
27
-
28
- def get(options=nil)
29
- url = "#{@base_url}/api/tasks"
30
- headers = { params: {}, authorization: "Bearer #{@access_token}" }
31
-
32
- if options.is_a?(Hash)
33
- headers[:params].merge!(options)
34
- elsif options.is_a?(Numeric)
35
- url = "#{@base_url}/api/tasks/#{options}"
36
- elsif options.is_a?(String)
37
- headers[:params]['name'] = options
38
- end
39
- response = Morpheus::RestClient.execute(method: :get, url: url,
40
- timeout: 30, headers: headers, verify_ssl:false)
41
- JSON.parse(response.to_s)
42
- end
43
-
44
- def update(id, options)
45
- url = "#{@base_url}/api/tasks/#{id}"
46
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
47
-
48
- payload = options
49
- response = Morpheus::RestClient.execute(method: :put, url: url,
50
- timeout: 10, headers: headers, payload: payload.to_json)
51
- JSON.parse(response.to_s)
52
- end
53
-
54
-
55
- def create(options)
56
- url = "#{@base_url}/api/tasks"
57
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
58
-
59
- payload = options
60
- response = Morpheus::RestClient.execute(method: :post, url: url,
61
- timeout: 30, headers: headers, verify_ssl:false, payload: payload.to_json)
62
- JSON.parse(response.to_s)
63
- end
64
-
65
- def destroy(id)
66
- url = "#{@base_url}/api/tasks/#{id}"
67
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
68
- response = Morpheus::RestClient.execute(method: :delete, url: url,
69
- timeout: 30, headers: headers, verify_ssl:false)
70
- JSON.parse(response.to_s)
71
- end
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 task_types(options={})
12
+ url = "#{@base_url}/api/task-types"
13
+ headers = { params: {}, authorization: "Bearer #{@access_token}" }
14
+
15
+ if options.is_a?(Hash)
16
+ headers[:params].merge!(options)
17
+ elsif options.is_a?(Numeric)
18
+ url = "#{@base_url}/api/task-types/#{options}"
19
+ elsif options.is_a?(String)
20
+ headers[:params]['name'] = options
21
+ end
22
+ execute(method: :get, url: url, headers: headers)
23
+ end
24
+
25
+ def get(options=nil)
26
+ url = "#{@base_url}/api/tasks"
27
+ headers = { params: {}, authorization: "Bearer #{@access_token}" }
28
+
29
+ if options.is_a?(Hash)
30
+ headers[:params].merge!(options)
31
+ elsif options.is_a?(Numeric)
32
+ url = "#{@base_url}/api/tasks/#{options}"
33
+ elsif options.is_a?(String)
34
+ headers[:params]['name'] = options
35
+ end
36
+ execute(method: :get, url: url, headers: headers)
37
+ end
38
+
39
+ def update(id, options)
40
+ url = "#{@base_url}/api/tasks/#{id}"
41
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
42
+ payload = options
43
+ execute(method: :put, url: url, headers: headers, payload: payload.to_json)
44
+ end
45
+
46
+
47
+ def create(options)
48
+ url = "#{@base_url}/api/tasks"
49
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
50
+ payload = options
51
+ execute(method: :post, url: url, headers: headers, payload: payload.to_json)
52
+ end
53
+
54
+ def destroy(id)
55
+ url = "#{@base_url}/api/tasks/#{id}"
56
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
57
+ execute(method: :delete, url: url, headers: headers)
58
+ end
72
59
  end
@@ -1,89 +1,80 @@
1
- require 'json'
2
- require 'rest-client'
1
+ require 'morpheus/api/api_client'
3
2
 
4
3
  class Morpheus::UsersInterface < Morpheus::APIClient
5
-
6
- def initialize(access_token, refresh_token, expires_at = nil, base_url=nil)
7
- @access_token = access_token
8
- @refresh_token = refresh_token
9
- @base_url = base_url
10
- @expires_at = expires_at
11
- end
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
12
10
 
13
- def get(account_id, id)
14
- raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
15
- url = build_url(account_id, id)
16
- headers = { params: {}, authorization: "Bearer #{@access_token}" }
17
- response = Morpheus::RestClient.execute(method: :get, url: url,
18
- timeout: 10, headers: headers)
19
- JSON.parse(response.to_s)
20
- end
11
+ def get(account_id, id)
12
+ raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
13
+ url = build_url(account_id, id)
14
+ headers = { params: {}, authorization: "Bearer #{@access_token}" }
15
+ opts = {method: :get, url: url, timeout: 10, headers: headers}
16
+ execute(opts)
17
+ end
21
18
 
22
- def list(account_id, options={})
23
- url = build_url(account_id)
24
- headers = { params: {}, authorization: "Bearer #{@access_token}" }
25
- headers[:params].merge!(options)
26
- response = Morpheus::RestClient.execute(method: :get, url: url,
27
- timeout: 10, headers: headers)
28
- JSON.parse(response.to_s)
29
- end
19
+ def list(account_id, options={})
20
+ url = build_url(account_id)
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
30
26
 
31
- def feature_permissions(account_id, id)
32
- url = build_url(account_id, id) + "/feature-permissions"
33
- headers = { params: {}, authorization: "Bearer #{@access_token}" }
34
- response = Morpheus::RestClient.execute(method: :get, url: url,
35
- timeout: 10, headers: headers)
36
- JSON.parse(response.to_s)
37
- end
27
+ def feature_permissions(account_id, id)
28
+ url = build_url(account_id, id) + "/feature-permissions"
29
+ headers = { params: {}, authorization: "Bearer #{@access_token}" }
30
+ opts = {method: :get, url: url, timeout: 10, headers: headers}
31
+ execute(opts)
32
+ end
38
33
 
39
- def available_roles(account_id, id=nil, options={})
40
- url = build_url(account_id, id) + "/available-roles"
41
- headers = { params: {}, authorization: "Bearer #{@access_token}" }
42
- headers[:params].merge!(options)
43
- response = Morpheus::RestClient.execute(method: :get, url: url,
44
- timeout: 10, headers: headers)
45
- JSON.parse(response.to_s)
46
- end
34
+ def available_roles(account_id, id=nil, options={})
35
+ url = build_url(account_id, id) + "/available-roles"
36
+ headers = { params: {}, authorization: "Bearer #{@access_token}" }
37
+ headers[:params].merge!(options)
38
+ opts = {method: :get, url: url, timeout: 10, headers: headers}
39
+ execute(opts)
40
+ end
47
41
 
48
- def create(account_id, options)
49
- url = build_url(account_id)
50
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
51
- payload = options
52
- response = Morpheus::RestClient.execute(method: :post, url: url,
53
- timeout: 10, headers: headers, payload: payload.to_json)
54
- JSON.parse(response.to_s)
55
- end
42
+ def create(account_id, options)
43
+ url = build_url(account_id)
44
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
45
+ payload = options
46
+ opts = {method: :post, url: url, timeout: 10, headers: headers, payload: payload.to_json}
47
+ execute(opts)
48
+ end
56
49
 
57
- def update(account_id, id, options)
58
- url = build_url(account_id, id)
59
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
60
- payload = options
61
- response = Morpheus::RestClient.execute(method: :put, url: url,
62
- timeout: 10, headers: headers, payload: payload.to_json)
63
- JSON.parse(response.to_s)
64
- end
50
+ def update(account_id, id, options)
51
+ url = build_url(account_id, id)
52
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
53
+ payload = options
54
+ opts = {method: :put, url: url, timeout: 10, headers: headers, payload: payload.to_json}
55
+ execute(opts)
56
+ end
65
57
 
66
- def destroy(account_id, id)
67
- url = build_url(account_id, id)
68
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
69
- response = Morpheus::RestClient.execute(method: :delete, url: url,
70
- timeout: 10, headers: headers)
71
- JSON.parse(response.to_s)
72
- end
58
+ def destroy(account_id, id)
59
+ url = build_url(account_id, id)
60
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
61
+ opts = {method: :delete, url: url, timeout: 10, headers: headers}
62
+ execute(opts)
63
+ end
73
64
 
74
- private
65
+ private
75
66
 
76
- def build_url(account_id=nil, user_id=nil)
77
- url = "#{@base_url}/api"
78
- if account_id
79
- url += "/accounts/#{account_id}/users"
80
- else
81
- url += "/users"
82
- end
83
- if user_id
84
- url += "/#{user_id}"
85
- end
86
- url
87
- end
67
+ def build_url(account_id=nil, user_id=nil)
68
+ url = "#{@base_url}/api"
69
+ if account_id
70
+ url += "/accounts/#{account_id}/users"
71
+ else
72
+ url += "/users"
73
+ end
74
+ if user_id
75
+ url += "/#{user_id}"
76
+ end
77
+ url
78
+ end
88
79
 
89
80
  end
@@ -1,72 +1,72 @@
1
- require 'json'
2
- require 'rest-client'
1
+ require 'morpheus/api/api_client'
3
2
 
4
3
  class Morpheus::VirtualImagesInterface < Morpheus::APIClient
5
- def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
6
- @access_token = access_token
7
- @refresh_token = refresh_token
8
- @base_url = base_url
9
- @expires_at = expires_at
10
- end
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
11
10
 
12
- def virtual_image_types(options={})
13
- url = "#{@base_url}/api/virtual-image-types"
14
- headers = { params: {}, authorization: "Bearer #{@access_token}" }
11
+ def virtual_image_types(options={})
12
+ url = "#{@base_url}/api/virtual-image-types"
13
+ headers = { params: {}, authorization: "Bearer #{@access_token}" }
14
+ if options.is_a?(Hash)
15
+ headers[:params].merge!(options)
16
+ end
17
+ execute(method: :get, url: url, headers: headers)
18
+ end
15
19
 
16
- if options.is_a?(Hash)
17
- headers[:params].merge!(options)
18
- elsif options.is_a?(Numeric)
19
- url = "#{@base_url}/api/virtual-image-types/#{options}"
20
- elsif options.is_a?(String)
21
- headers[:params]['name'] = options
22
- end
23
- response = Morpheus::RestClient.execute(method: :get, url: url,
24
- timeout: 30, headers: headers, verify_ssl:false)
25
- JSON.parse(response.to_s)
26
- end
20
+ def get(options=nil)
21
+ url = "#{@base_url}/api/virtual-images"
22
+ headers = { params: {}, authorization: "Bearer #{@access_token}" }
27
23
 
28
- def get(options=nil)
29
- url = "#{@base_url}/api/virtual-images"
30
- headers = { params: {}, authorization: "Bearer #{@access_token}" }
24
+ if options.is_a?(Hash)
25
+ headers[:params].merge!(options)
26
+ elsif options.is_a?(Numeric)
27
+ url = "#{@base_url}/api/virtual-images/#{options}"
28
+ elsif options.is_a?(String)
29
+ headers[:params]['name'] = options
30
+ end
31
+ execute(method: :get, url: url, headers: headers)
32
+ end
31
33
 
32
- if options.is_a?(Hash)
33
- headers[:params].merge!(options)
34
- elsif options.is_a?(Numeric)
35
- url = "#{@base_url}/api/virtual-images/#{options}"
36
- elsif options.is_a?(String)
37
- headers[:params]['name'] = options
38
- end
39
- response = Morpheus::RestClient.execute(method: :get, url: url,
40
- timeout: 30, headers: headers, verify_ssl:false)
41
- JSON.parse(response.to_s)
42
- end
34
+ def update(id, options)
35
+ url = "#{@base_url}/api/virtual-images/#{id}"
36
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
37
+ execute(method: :put, url: url, headers: headers, payload: payload.to_json)
38
+ end
43
39
 
44
- def update(id, options)
45
- url = "#{@base_url}/api/virtual-images/#{id}"
46
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
47
-
48
- payload = options
49
- response = Morpheus::RestClient.execute(method: :put, url: url,
50
- timeout: 10, headers: headers, payload: payload.to_json)
51
- JSON.parse(response.to_s)
52
- end
53
40
 
41
+ def create(options)
42
+ url = "#{@base_url}/api/virtual-images"
43
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
44
+ payload = options
45
+ execute(method: :post, url: url, headers: headers, payload: payload.to_json)
46
+ end
54
47
 
55
- def create(options)
56
- url = "#{@base_url}/api/virtual-images"
57
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
58
-
59
- payload = options
60
- response = Morpheus::RestClient.execute(method: :post, url: url,
61
- timeout: 30, headers: headers, verify_ssl:false, payload: payload.to_json)
62
- JSON.parse(response.to_s)
63
- end
48
+ def destroy(id)
49
+ url = "#{@base_url}/api/virtual-images/#{id}"
50
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
51
+ execute(method: :delete, url: url, headers: headers)
52
+ end
53
+
54
+ # NOT json, multipart file upload
55
+ def upload(id, image_file)
56
+ url = "#{@base_url}/api/virtual-images/#{id}/upload"
57
+ headers = { :params => {}, :authorization => "Bearer #{@access_token}"}
58
+ payload = {}
59
+ payload[:file] = image_file
60
+ payload[:multipart] = true
61
+ execute(method: :post, url: url, headers: headers, payload: payload)
62
+ end
63
+
64
+ def destroy_file(id, filename)
65
+ url = "#{@base_url}/api/virtual-images/#{id}/files"
66
+ #url = "#{@base_url}/api/virtual-images/#{id}/files/#{filename}"
67
+ headers = { params: {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
68
+ headers[:params][:filename] = filename
69
+ execute(method: :delete, url: url, headers: headers)
70
+ end
64
71
 
65
- def destroy(id)
66
- url = "#{@base_url}/api/virtual-images/#{id}"
67
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
68
- response = Morpheus::RestClient.execute(method: :delete, url: url,
69
- timeout: 30, headers: headers, verify_ssl:false)
70
- JSON.parse(response.to_s)
71
- end
72
72
  end
@@ -1,20 +1,17 @@
1
- require 'json'
2
- require 'rest-client'
1
+ require 'morpheus/api/api_client'
3
2
 
4
3
  class Morpheus::WhoamiInterface < Morpheus::APIClient
5
- def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
6
- @access_token = access_token
7
- @refresh_token = refresh_token
8
- @base_url = base_url
9
- @expires_at = expires_at
10
- end
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
11
10
 
12
- def get()
13
- url = "#{@base_url}/api/whoami"
14
- headers = { params: {}, authorization: "Bearer #{@access_token}" }
15
- response = Morpheus::RestClient.execute(method: :get, url: url,
16
- timeout: 30, headers: headers, verify_ssl: false)
17
- JSON.parse(response.to_s)
18
- end
11
+ def get()
12
+ url = "#{@base_url}/api/whoami"
13
+ headers = { params: {}, authorization: "Bearer #{@access_token}" }
14
+ execute(method: :get, url: url, headers: headers, timeout: 5)
15
+ end
19
16
 
20
17
  end