morpheus-cli 2.10.0 → 2.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/morpheus +27 -32
- data/lib/morpheus/api/accounts_interface.rb +36 -47
- data/lib/morpheus/api/api_client.rb +141 -110
- data/lib/morpheus/api/app_templates_interface.rb +56 -72
- data/lib/morpheus/api/apps_interface.rb +111 -132
- data/lib/morpheus/api/auth_interface.rb +30 -0
- data/lib/morpheus/api/clouds_interface.rb +71 -76
- data/lib/morpheus/api/custom_instance_types_interface.rb +21 -46
- data/lib/morpheus/api/dashboard_interface.rb +10 -17
- data/lib/morpheus/api/deploy_interface.rb +60 -72
- data/lib/morpheus/api/deployments_interface.rb +53 -71
- data/lib/morpheus/api/groups_interface.rb +55 -45
- data/lib/morpheus/api/instance_types_interface.rb +19 -23
- data/lib/morpheus/api/instances_interface.rb +179 -177
- data/lib/morpheus/api/key_pairs_interface.rb +11 -17
- data/lib/morpheus/api/license_interface.rb +18 -23
- data/lib/morpheus/api/load_balancers_interface.rb +54 -69
- data/lib/morpheus/api/logs_interface.rb +25 -29
- data/lib/morpheus/api/options_interface.rb +13 -17
- data/lib/morpheus/api/provision_types_interface.rb +19 -22
- data/lib/morpheus/api/roles_interface.rb +75 -94
- data/lib/morpheus/api/security_group_rules_interface.rb +28 -37
- data/lib/morpheus/api/security_groups_interface.rb +39 -51
- data/lib/morpheus/api/servers_interface.rb +113 -115
- data/lib/morpheus/api/setup_interface.rb +31 -0
- data/lib/morpheus/api/task_sets_interface.rb +36 -38
- data/lib/morpheus/api/tasks_interface.rb +56 -69
- data/lib/morpheus/api/users_interface.rb +67 -76
- data/lib/morpheus/api/virtual_images_interface.rb +61 -61
- data/lib/morpheus/api/whoami_interface.rb +12 -15
- data/lib/morpheus/cli.rb +71 -60
- data/lib/morpheus/cli/accounts.rb +254 -315
- data/lib/morpheus/cli/alias_command.rb +219 -0
- data/lib/morpheus/cli/app_templates.rb +264 -272
- data/lib/morpheus/cli/apps.rb +608 -671
- data/lib/morpheus/cli/cli_command.rb +259 -21
- data/lib/morpheus/cli/cli_registry.rb +99 -14
- data/lib/morpheus/cli/clouds.rb +599 -372
- data/lib/morpheus/cli/config_file.rb +126 -0
- data/lib/morpheus/cli/credentials.rb +141 -117
- data/lib/morpheus/cli/dashboard_command.rb +48 -56
- data/lib/morpheus/cli/deployments.rb +254 -268
- data/lib/morpheus/cli/deploys.rb +150 -142
- data/lib/morpheus/cli/error_handler.rb +38 -0
- data/lib/morpheus/cli/groups.rb +551 -179
- data/lib/morpheus/cli/hosts.rb +862 -617
- data/lib/morpheus/cli/instance_types.rb +103 -95
- data/lib/morpheus/cli/instances.rb +1335 -1009
- data/lib/morpheus/cli/key_pairs.rb +82 -90
- data/lib/morpheus/cli/library.rb +498 -499
- data/lib/morpheus/cli/license.rb +83 -101
- data/lib/morpheus/cli/load_balancers.rb +314 -300
- data/lib/morpheus/cli/login.rb +66 -44
- data/lib/morpheus/cli/logout.rb +47 -46
- data/lib/morpheus/cli/mixins/accounts_helper.rb +69 -31
- data/lib/morpheus/cli/mixins/infrastructure_helper.rb +106 -0
- data/lib/morpheus/cli/mixins/print_helper.rb +181 -17
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +535 -458
- data/lib/morpheus/cli/mixins/whoami_helper.rb +2 -2
- data/lib/morpheus/cli/option_parser.rb +35 -0
- data/lib/morpheus/cli/option_types.rb +232 -192
- data/lib/morpheus/cli/recent_activity_command.rb +61 -65
- data/lib/morpheus/cli/remote.rb +446 -199
- data/lib/morpheus/cli/roles.rb +884 -906
- data/lib/morpheus/cli/security_group_rules.rb +213 -203
- data/lib/morpheus/cli/security_groups.rb +237 -192
- data/lib/morpheus/cli/shell.rb +338 -231
- data/lib/morpheus/cli/tasks.rb +326 -308
- data/lib/morpheus/cli/users.rb +457 -462
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli/version_command.rb +16 -18
- data/lib/morpheus/cli/virtual_images.rb +526 -345
- data/lib/morpheus/cli/whoami.rb +125 -111
- data/lib/morpheus/cli/workflows.rb +338 -185
- data/lib/morpheus/formatters.rb +8 -1
- data/lib/morpheus/logging.rb +1 -1
- data/lib/morpheus/rest_client.rb +17 -8
- metadata +9 -3
- data/lib/morpheus/api/custom_instance_types.rb +0 -55
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad4ff693efbb10952b74f63eafd3ceacfe382d5e
|
4
|
+
data.tar.gz: f5fc0c7184848496e5fdcfedb6f08c38d0353c81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7193e79c98e5a13b6e7f60a686167eae26872dc8d62410099aa58ded65f73ce2d77430389b822cc818504ef382c837b620ba20ffe34c46315214bc37d020070a
|
7
|
+
data.tar.gz: 5dd1cde1959ea0dbcc0f2ade4805b2a23959d0edf450069a558eb454f0ca48a70eac75a19695d257a457917db76f783d13098eab72bff2dbcfbe47ab66d0309d
|
data/bin/morpheus
CHANGED
@@ -1,59 +1,54 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
require 'term/ansicolor'
|
2
3
|
require 'optparse'
|
3
4
|
require 'morpheus/cli'
|
4
5
|
require 'morpheus/rest_client'
|
5
6
|
require 'morpheus/cli/cli_registry'
|
7
|
+
require 'morpheus/cli/config_file'
|
8
|
+
require 'morpheus/cli/error_handler'
|
9
|
+
|
10
|
+
# use colors by default
|
11
|
+
Term::ANSIColor::coloring = STDOUT.isatty
|
12
|
+
# include Term::ANSIColor # tempting
|
6
13
|
|
7
14
|
# short circuit version switch
|
8
|
-
if ARGV[0] == '-v'
|
15
|
+
if ARGV[0] == '-v'
|
9
16
|
version = Morpheus::Cli::VERSION
|
10
17
|
puts version
|
11
18
|
exit 0
|
12
19
|
end
|
13
20
|
|
14
|
-
|
15
|
-
|
16
|
-
#
|
17
|
-
if args.find {|
|
21
|
+
args = ARGV.dup
|
22
|
+
|
23
|
+
# raise log level right away
|
24
|
+
if args.find {|it| it == '-V' || it == '--debug'}
|
18
25
|
Morpheus::Logging.set_log_level(Morpheus::Logging::Logger::DEBUG)
|
19
26
|
end
|
20
|
-
args = args.find_all {|arg| arg != '-V' && arg != '--debug'}
|
21
27
|
|
22
|
-
#
|
23
|
-
|
24
|
-
Morpheus::RestClient.enable_ssl_verification = false
|
25
|
-
end
|
26
|
-
args = args.find_all {|arg| arg != '--insecure'}
|
28
|
+
# load config file(s)
|
29
|
+
Morpheus::Cli::ConfigFile.init(ENV['MORPHEUS_CLI_HOME'])
|
27
30
|
|
28
|
-
# all commands should be registered commands
|
29
|
-
if Morpheus::Cli::CliRegistry.has_command?(args[0])
|
31
|
+
# all commands should be registered commands or aliases
|
32
|
+
if Morpheus::Cli::CliRegistry.has_command?(args[0]) || Morpheus::Cli::CliRegistry.has_alias?(args[0])
|
30
33
|
begin
|
31
|
-
Morpheus::Cli::CliRegistry.exec(args[0], args[1..-1])
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
print "\n", "Try -h for help with this command.", "\n\n"
|
37
|
-
if Morpheus::Logging.print_stacktrace?
|
38
|
-
print Term::ANSIColor.red, "\n", "#{e.class}: #{e.message}", "\n", Term::ANSIColor.reset
|
39
|
-
print e.backtrace.join("\n"), "\n\n"
|
34
|
+
cmd_result = Morpheus::Cli::CliRegistry.exec(args[0], args[1..-1])
|
35
|
+
if cmd_result == false
|
36
|
+
exit 1
|
37
|
+
else
|
38
|
+
exit 0
|
40
39
|
end
|
41
|
-
exit 1
|
42
40
|
rescue => e
|
43
|
-
|
44
|
-
if Morpheus::Logging.print_stacktrace?
|
45
|
-
print Term::ANSIColor.red, "\n", "#{e.class}: #{e.message}", "\n", Term::ANSIColor.reset
|
46
|
-
print e.backtrace.join("\n"), "\n\n"
|
47
|
-
end
|
41
|
+
Morpheus::Cli::ErrorHandler.new.handle_error(e)
|
48
42
|
exit 1
|
49
43
|
end
|
50
|
-
exit 0
|
51
44
|
else
|
52
|
-
puts "
|
53
|
-
puts "\nCommands
|
54
|
-
Morpheus::Cli::CliRegistry.all.each {|cmd
|
45
|
+
puts "Usage: morpheus [command] [options]"
|
46
|
+
puts "\nCommands:"
|
47
|
+
Morpheus::Cli::CliRegistry.all.keys.sort.each {|cmd|
|
55
48
|
puts "\t#{cmd.to_s}"
|
56
49
|
}
|
57
50
|
puts ""
|
51
|
+
puts "For more information, see https://github.com/gomorpheus/morpheus-cli/wiki"
|
52
|
+
puts ""
|
58
53
|
exit 127
|
59
54
|
end
|
@@ -1,55 +1,44 @@
|
|
1
|
-
require '
|
2
|
-
require 'rest-client'
|
1
|
+
require 'morpheus/api/api_client'
|
3
2
|
|
4
3
|
class Morpheus::AccountsInterface < Morpheus::APIClient
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
JSON.parse(response.to_s)
|
19
|
-
end
|
11
|
+
def get(id)
|
12
|
+
raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
|
13
|
+
url = "#{@base_url}/api/accounts/#{id}"
|
14
|
+
headers = { params: {}, authorization: "Bearer #{@access_token}" }
|
15
|
+
execute(method: :get, url: url, headers: headers)
|
16
|
+
end
|
20
17
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
JSON.parse(response.to_s)
|
28
|
-
end
|
18
|
+
def list(options={})
|
19
|
+
url = "#{@base_url}/api/accounts"
|
20
|
+
headers = { params: {}, authorization: "Bearer #{@access_token}" }
|
21
|
+
headers[:params].merge!(options)
|
22
|
+
execute(method: :get, url: url, headers: headers)
|
23
|
+
end
|
29
24
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
JSON.parse(response.to_s)
|
37
|
-
end
|
25
|
+
def create(options)
|
26
|
+
url = "#{@base_url}/api/accounts"
|
27
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
28
|
+
payload = options
|
29
|
+
execute(method: :post, url: url, headers: headers, payload: payload.to_json)
|
30
|
+
end
|
38
31
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
JSON.parse(response.to_s)
|
46
|
-
end
|
32
|
+
def update(id, options)
|
33
|
+
url = "#{@base_url}/api/accounts/#{id}"
|
34
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
35
|
+
payload = options
|
36
|
+
execute(method: :put, url: url, headers: headers, payload: payload.to_json)
|
37
|
+
end
|
47
38
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
JSON.parse(response.to_s)
|
54
|
-
end
|
39
|
+
def destroy(id)
|
40
|
+
url = "#{@base_url}/api/accounts/#{id}"
|
41
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
42
|
+
execute(method: :delete, url: url, headers: headers)
|
43
|
+
end
|
55
44
|
end
|
@@ -1,118 +1,149 @@
|
|
1
1
|
require 'json'
|
2
|
+
require 'uri'
|
2
3
|
require 'rest-client'
|
3
4
|
|
4
5
|
class Morpheus::APIClient
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
6
|
+
def initialize(access_token, refresh_token=nil,expires_in = nil, base_url=nil)
|
7
|
+
@access_token = access_token
|
8
|
+
@refresh_token = refresh_token
|
9
|
+
@base_url = base_url
|
10
|
+
if expires_in != nil
|
11
|
+
@expires_at = DateTime.now + expires_in.seconds
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def dry_run(val=true)
|
16
|
+
@dry_run = !!val
|
17
|
+
self
|
18
|
+
end
|
19
|
+
|
20
|
+
def dry()
|
21
|
+
dry_run(true)
|
22
|
+
end
|
23
|
+
|
24
|
+
def execute(opts, parse_json=true)
|
25
|
+
if @dry_run
|
26
|
+
# JD: could return a Request object instead...
|
27
|
+
return opts
|
28
|
+
end
|
29
|
+
response = Morpheus::RestClient.execute(opts)
|
30
|
+
if parse_json
|
31
|
+
return JSON.parse(response.to_s)
|
32
|
+
else
|
33
|
+
return response
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def auth
|
38
|
+
Morpheus::AuthInterface.new(@base_url, @access_token)
|
39
|
+
end
|
40
|
+
|
41
|
+
def whoami
|
42
|
+
Morpheus::WhoamiInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
43
|
+
end
|
44
|
+
|
45
|
+
def options
|
46
|
+
Morpheus::OptionsInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
47
|
+
end
|
48
|
+
|
49
|
+
def groups
|
50
|
+
Morpheus::GroupsInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
51
|
+
end
|
52
|
+
|
53
|
+
def clouds
|
54
|
+
Morpheus::CloudsInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
55
|
+
end
|
56
|
+
|
57
|
+
def servers
|
58
|
+
Morpheus::ServersInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
59
|
+
end
|
60
|
+
|
61
|
+
def instances
|
62
|
+
Morpheus::InstancesInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
63
|
+
end
|
64
|
+
|
65
|
+
def instance_types
|
66
|
+
Morpheus::InstanceTypesInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
67
|
+
end
|
68
|
+
|
69
|
+
def provision_types
|
70
|
+
Morpheus::ProvisionTypesInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
71
|
+
end
|
72
|
+
|
73
|
+
def load_balancers
|
74
|
+
Morpheus::LoadBalancersInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
75
|
+
end
|
76
|
+
|
77
|
+
def tasks
|
78
|
+
Morpheus::TasksInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
79
|
+
end
|
80
|
+
|
81
|
+
def task_sets
|
82
|
+
Morpheus::TaskSetsInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
83
|
+
end
|
84
|
+
|
85
|
+
def virtual_images
|
86
|
+
Morpheus::VirtualImagesInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
87
|
+
end
|
88
|
+
|
89
|
+
def apps
|
90
|
+
Morpheus::AppsInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
91
|
+
end
|
92
|
+
|
93
|
+
def app_templates
|
94
|
+
Morpheus::AppTemplatesInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
95
|
+
end
|
96
|
+
|
97
|
+
def deploy
|
98
|
+
Morpheus::DeployInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
99
|
+
end
|
100
|
+
|
101
|
+
def deployments
|
102
|
+
Morpheus::DeploymentsInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
103
|
+
end
|
104
|
+
|
105
|
+
def security_groups
|
106
|
+
Morpheus::SecurityGroupsInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
107
|
+
end
|
108
|
+
|
109
|
+
def security_group_rules
|
110
|
+
Morpheus::SecurityGroupRulesInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
111
|
+
end
|
112
|
+
|
113
|
+
def accounts
|
114
|
+
Morpheus::AccountsInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
115
|
+
end
|
116
|
+
|
117
|
+
def users
|
118
|
+
Morpheus::UsersInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
119
|
+
end
|
120
|
+
|
121
|
+
def logs
|
122
|
+
Morpheus::LogsInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
123
|
+
end
|
124
|
+
|
125
|
+
def roles
|
126
|
+
Morpheus::RolesInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
127
|
+
end
|
128
|
+
|
129
|
+
def key_pairs
|
130
|
+
Morpheus::KeyPairsInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
131
|
+
end
|
132
|
+
|
133
|
+
def license
|
134
|
+
Morpheus::LicenseInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
135
|
+
end
|
109
136
|
|
110
|
-
|
111
|
-
|
112
|
-
|
137
|
+
def custom_instance_types
|
138
|
+
Morpheus::CustomInstanceTypesInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
139
|
+
end
|
113
140
|
|
114
|
-
|
115
|
-
|
116
|
-
|
141
|
+
def dashboard
|
142
|
+
Morpheus::DashboardInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
143
|
+
end
|
117
144
|
|
145
|
+
def setup
|
146
|
+
Morpheus::SetupInterface.new(@base_url)
|
147
|
+
end
|
148
|
+
|
118
149
|
end
|