morpheus-cli 0.1.1 → 0.9.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 +4 -4
- data/lib/morpheus/api/accounts_interface.rb +55 -0
- data/lib/morpheus/api/api_client.rb +48 -3
- data/lib/morpheus/api/apps_interface.rb +13 -13
- data/lib/morpheus/api/{zones_interface.rb → clouds_interface.rb} +10 -10
- data/lib/morpheus/api/deploy_interface.rb +4 -4
- data/lib/morpheus/api/groups_interface.rb +3 -3
- data/lib/morpheus/api/instance_types_interface.rb +2 -2
- data/lib/morpheus/api/instances_interface.rb +35 -19
- data/lib/morpheus/api/key_pairs_interface.rb +60 -0
- data/lib/morpheus/api/license_interface.rb +29 -0
- data/lib/morpheus/api/load_balancers_interface.rb +72 -0
- data/lib/morpheus/api/logs_interface.rb +37 -0
- data/lib/morpheus/api/options_interface.rb +20 -0
- data/lib/morpheus/api/provision_types_interface.rb +27 -0
- data/lib/morpheus/api/roles_interface.rb +73 -0
- data/lib/morpheus/api/security_group_rules_interface.rb +3 -3
- data/lib/morpheus/api/security_groups_interface.rb +5 -5
- data/lib/morpheus/api/servers_interface.rb +67 -3
- data/lib/morpheus/api/task_sets_interface.rb +46 -0
- data/lib/morpheus/api/tasks_interface.rb +72 -0
- data/lib/morpheus/api/users_interface.rb +72 -0
- data/lib/morpheus/cli.rb +27 -4
- data/lib/morpheus/cli/accounts.rb +306 -0
- data/lib/morpheus/cli/apps.rb +58 -1
- data/lib/morpheus/cli/cli_command.rb +87 -0
- data/lib/morpheus/cli/cli_registry.rb +6 -1
- data/lib/morpheus/cli/{zones.rb → clouds.rb} +99 -70
- data/lib/morpheus/cli/credentials.rb +23 -11
- data/lib/morpheus/cli/error_handler.rb +31 -11
- data/lib/morpheus/cli/groups.rb +1 -0
- data/lib/morpheus/cli/hosts.rb +567 -0
- data/lib/morpheus/cli/instances.rb +588 -292
- data/lib/morpheus/cli/key_pairs.rb +393 -0
- data/lib/morpheus/cli/license.rb +118 -0
- data/lib/morpheus/cli/load_balancers.rb +366 -0
- data/lib/morpheus/cli/mixins/accounts_helper.rb +193 -0
- data/lib/morpheus/cli/option_types.rb +260 -0
- data/lib/morpheus/cli/roles.rb +164 -0
- data/lib/morpheus/cli/security_group_rules.rb +4 -9
- data/lib/morpheus/cli/shell.rb +108 -0
- data/lib/morpheus/cli/tasks.rb +370 -0
- data/lib/morpheus/cli/users.rb +325 -0
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli/workflows.rb +100 -0
- data/lib/morpheus/formatters.rb +43 -0
- data/morpheus-cli.gemspec +1 -1
- metadata +33 -10
- data/lib/morpheus/cli/servers.rb +0 -265
data/morpheus-cli.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.6"
|
23
23
|
spec.add_development_dependency "rake"
|
24
24
|
spec.add_dependency 'term-ansicolor', '~> 1.3.0'
|
25
|
-
spec.add_dependency "rest-client", "
|
25
|
+
spec.add_dependency "rest-client", "2.0.0"
|
26
26
|
spec.add_dependency 'multipart-post'
|
27
27
|
spec.add_dependency "filesize"
|
28
28
|
spec.add_dependency 'mime-types'
|
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: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Estes
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-08-31 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -58,16 +58,16 @@ dependencies:
|
|
58
58
|
name: rest-client
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- -
|
61
|
+
- - '='
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version:
|
63
|
+
version: 2.0.0
|
64
64
|
type: :runtime
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- -
|
68
|
+
- - '='
|
69
69
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
70
|
+
version: 2.0.0
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: multipart-post
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,32 +139,55 @@ files:
|
|
139
139
|
- README.md
|
140
140
|
- Rakefile
|
141
141
|
- bin/morpheus
|
142
|
+
- lib/morpheus/api/accounts_interface.rb
|
142
143
|
- lib/morpheus/api/api_client.rb
|
143
144
|
- lib/morpheus/api/apps_interface.rb
|
145
|
+
- lib/morpheus/api/clouds_interface.rb
|
144
146
|
- lib/morpheus/api/deploy_interface.rb
|
145
147
|
- lib/morpheus/api/groups_interface.rb
|
146
148
|
- lib/morpheus/api/instance_types_interface.rb
|
147
149
|
- lib/morpheus/api/instances_interface.rb
|
150
|
+
- lib/morpheus/api/key_pairs_interface.rb
|
151
|
+
- lib/morpheus/api/license_interface.rb
|
152
|
+
- lib/morpheus/api/load_balancers_interface.rb
|
153
|
+
- lib/morpheus/api/logs_interface.rb
|
154
|
+
- lib/morpheus/api/options_interface.rb
|
155
|
+
- lib/morpheus/api/provision_types_interface.rb
|
156
|
+
- lib/morpheus/api/roles_interface.rb
|
148
157
|
- lib/morpheus/api/security_group_rules_interface.rb
|
149
158
|
- lib/morpheus/api/security_groups_interface.rb
|
150
159
|
- lib/morpheus/api/servers_interface.rb
|
151
|
-
- lib/morpheus/api/
|
160
|
+
- lib/morpheus/api/task_sets_interface.rb
|
161
|
+
- lib/morpheus/api/tasks_interface.rb
|
162
|
+
- lib/morpheus/api/users_interface.rb
|
152
163
|
- lib/morpheus/cli.rb
|
164
|
+
- lib/morpheus/cli/accounts.rb
|
153
165
|
- lib/morpheus/cli/apps.rb
|
154
166
|
- lib/morpheus/cli/cli_command.rb
|
155
167
|
- lib/morpheus/cli/cli_registry.rb
|
168
|
+
- lib/morpheus/cli/clouds.rb
|
156
169
|
- lib/morpheus/cli/credentials.rb
|
157
170
|
- lib/morpheus/cli/deploys.rb
|
158
171
|
- lib/morpheus/cli/error_handler.rb
|
159
172
|
- lib/morpheus/cli/groups.rb
|
173
|
+
- lib/morpheus/cli/hosts.rb
|
160
174
|
- lib/morpheus/cli/instance_types.rb
|
161
175
|
- lib/morpheus/cli/instances.rb
|
176
|
+
- lib/morpheus/cli/key_pairs.rb
|
177
|
+
- lib/morpheus/cli/license.rb
|
178
|
+
- lib/morpheus/cli/load_balancers.rb
|
179
|
+
- lib/morpheus/cli/mixins/accounts_helper.rb
|
180
|
+
- lib/morpheus/cli/option_types.rb
|
162
181
|
- lib/morpheus/cli/remote.rb
|
182
|
+
- lib/morpheus/cli/roles.rb
|
163
183
|
- lib/morpheus/cli/security_group_rules.rb
|
164
184
|
- lib/morpheus/cli/security_groups.rb
|
165
|
-
- lib/morpheus/cli/
|
185
|
+
- lib/morpheus/cli/shell.rb
|
186
|
+
- lib/morpheus/cli/tasks.rb
|
187
|
+
- lib/morpheus/cli/users.rb
|
166
188
|
- lib/morpheus/cli/version.rb
|
167
|
-
- lib/morpheus/cli/
|
189
|
+
- lib/morpheus/cli/workflows.rb
|
190
|
+
- lib/morpheus/formatters.rb
|
168
191
|
- lib/morpheus/rest_client.rb
|
169
192
|
- morpheus-cli.gemspec
|
170
193
|
homepage: http://www.morpheusdata.com
|
@@ -187,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
210
|
version: '0'
|
188
211
|
requirements: []
|
189
212
|
rubyforge_project:
|
190
|
-
rubygems_version: 2.
|
213
|
+
rubygems_version: 2.5.1
|
191
214
|
signing_key:
|
192
215
|
specification_version: 4
|
193
216
|
summary: Provides CLI Interface to the Morpheus Public/Private Cloud Appliance
|
data/lib/morpheus/cli/servers.rb
DELETED
@@ -1,265 +0,0 @@
|
|
1
|
-
# require 'yaml'
|
2
|
-
require 'io/console'
|
3
|
-
require 'rest_client'
|
4
|
-
require 'term/ansicolor'
|
5
|
-
require 'optparse'
|
6
|
-
require 'morpheus/cli/cli_command'
|
7
|
-
|
8
|
-
|
9
|
-
class Morpheus::Cli::Servers
|
10
|
-
include Term::ANSIColor
|
11
|
-
include Morpheus::Cli::CliCommand
|
12
|
-
|
13
|
-
def initialize()
|
14
|
-
@appliance_name, @appliance_url = Morpheus::Cli::Remote.active_appliance
|
15
|
-
@access_token = Morpheus::Cli::Credentials.new(@appliance_name,@appliance_url).request_credentials()
|
16
|
-
@servers_interface = Morpheus::APIClient.new(@access_token,nil,nil, @appliance_url).servers
|
17
|
-
@groups_interface = Morpheus::APIClient.new(@access_token,nil,nil, @appliance_url).groups
|
18
|
-
@zones_interface = Morpheus::APIClient.new(@access_token,nil,nil, @appliance_url).zones
|
19
|
-
@zone_types = @zones_interface.zone_types['zoneTypes']
|
20
|
-
@active_groups = ::Morpheus::Cli::Groups.load_group_file
|
21
|
-
end
|
22
|
-
|
23
|
-
def handle(args)
|
24
|
-
if @access_token.empty?
|
25
|
-
print red,bold, "\nInvalid Credentials. Unable to acquire access token. Please verify your credentials and try again.\n\n",reset
|
26
|
-
return 1
|
27
|
-
end
|
28
|
-
if args.empty?
|
29
|
-
puts "\nUsage: morpheus servers [list,add,remove] [name]\n\n"
|
30
|
-
return
|
31
|
-
end
|
32
|
-
|
33
|
-
case args[0]
|
34
|
-
when 'list'
|
35
|
-
list(args[1..-1])
|
36
|
-
when 'add'
|
37
|
-
add(args[1..-1])
|
38
|
-
when 'remove'
|
39
|
-
remove(args[1..-1])
|
40
|
-
else
|
41
|
-
puts "\nUsage: morpheus servers [list,add,remove] [name]\n\n"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def add(args)
|
46
|
-
if args.count < 2
|
47
|
-
puts "\nUsage: morpheus servers add ZONE [name]\n\n"
|
48
|
-
return
|
49
|
-
end
|
50
|
-
options = {zone: args[0]}
|
51
|
-
|
52
|
-
zone=nil
|
53
|
-
if !options[:group].nil?
|
54
|
-
group = find_group_by_name(options[:group])
|
55
|
-
if !group.nil?
|
56
|
-
options['groupId'] = group['id']
|
57
|
-
end
|
58
|
-
else
|
59
|
-
options['groupId'] = @active_groups[@appliance_name.to_sym]
|
60
|
-
end
|
61
|
-
|
62
|
-
if !options['groupId'].nil?
|
63
|
-
if !options[:zone].nil?
|
64
|
-
zone = find_zone_by_name(options['groupId'], options[:zone])
|
65
|
-
if !zone.nil?
|
66
|
-
options['zoneId'] = zone['id']
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
if options['zoneId'].nil?
|
72
|
-
puts red,bold,"\nEither the zone was not specified or was not found. Please make sure a zone is specified with --zone\n\n", reset
|
73
|
-
return
|
74
|
-
end
|
75
|
-
|
76
|
-
zone_type = zone_type_for_id(zone['zoneTypeId'])
|
77
|
-
begin
|
78
|
-
case zone_type['code']
|
79
|
-
when 'standard'
|
80
|
-
add_standard(args[1],options[:description],zone, args[2..-1])
|
81
|
-
list([])
|
82
|
-
when 'openstack'
|
83
|
-
add_openstack(args[1],options[:description],zone, args[2..-1])
|
84
|
-
list([])
|
85
|
-
when 'amazon'
|
86
|
-
add_amazon(args[1],options[:description],zone, args[2..-1])
|
87
|
-
list([])
|
88
|
-
else
|
89
|
-
puts "Unsupported Zone Type: This version of the morpheus cli does not support the requested zone type"
|
90
|
-
end
|
91
|
-
rescue RestClient::Exception => e
|
92
|
-
if e.response.code == 400
|
93
|
-
error = JSON.parse(e.response.to_s)
|
94
|
-
::Morpheus::Cli::ErrorHandler.new.print_errors(error)
|
95
|
-
else
|
96
|
-
puts "Error Communicating with the Appliance. Please try again later. #{e}"
|
97
|
-
end
|
98
|
-
return nil
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
def remove(args)
|
103
|
-
if args.count < 1
|
104
|
-
puts "\nUsage: morpheus servers remove [name]\n\n"
|
105
|
-
return
|
106
|
-
end
|
107
|
-
begin
|
108
|
-
server_results = @servers_interface.get({name: args[0]})
|
109
|
-
if server_results['servers'].empty?
|
110
|
-
puts "Server not found by name #{args[0]}"
|
111
|
-
return
|
112
|
-
end
|
113
|
-
@servers_interface.destroy(server_results['servers'][0]['id'])
|
114
|
-
list([])
|
115
|
-
rescue RestClient::Exception => e
|
116
|
-
if e.response.code == 400
|
117
|
-
error = JSON.parse(e.response.to_s)
|
118
|
-
::Morpheus::Cli::ErrorHandler.new.print_errors(error)
|
119
|
-
else
|
120
|
-
puts "Error Communicating with the Appliance. Please try again later. #{e}"
|
121
|
-
end
|
122
|
-
return nil
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
def list(args)
|
127
|
-
options = {}
|
128
|
-
optparse = OptionParser.new do|opts|
|
129
|
-
opts.on( '-g', '--group GROUP', "Group Name" ) do |group|
|
130
|
-
options[:group] = group
|
131
|
-
end
|
132
|
-
end
|
133
|
-
optparse.parse(args)
|
134
|
-
begin
|
135
|
-
params = {}
|
136
|
-
if !options[:group].nil?
|
137
|
-
group = find_group_by_name(options[:group])
|
138
|
-
if !group.nil?
|
139
|
-
params['site'] = group['id']
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
json_response = @servers_interface.get(params)
|
144
|
-
servers = json_response['servers']
|
145
|
-
print "\n" ,red, bold, "Morpheus Servers\n","==================", reset, "\n\n"
|
146
|
-
if servers.empty?
|
147
|
-
puts yellow,"No servers currently configured.",reset
|
148
|
-
else
|
149
|
-
servers.each do |server|
|
150
|
-
print red, "= #{server['name']} - #{server['description']} (#{server['status']})\n"
|
151
|
-
end
|
152
|
-
end
|
153
|
-
print reset,"\n\n"
|
154
|
-
|
155
|
-
rescue => e
|
156
|
-
puts "Error Communicating with the Appliance. Please try again later. #{e}"
|
157
|
-
return nil
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
private
|
162
|
-
|
163
|
-
|
164
|
-
def add_openstack(name, description,zone, args)
|
165
|
-
options = {}
|
166
|
-
optparse = OptionParser.new do|opts|
|
167
|
-
|
168
|
-
opts.on( '-s', '--size SIZE', "Disk Size" ) do |size|
|
169
|
-
options[:diskSize] = size.to_l
|
170
|
-
end
|
171
|
-
opts.on('-i', '--image IMAGE', "Image Name") do |image|
|
172
|
-
options[:imageName] = image
|
173
|
-
end
|
174
|
-
|
175
|
-
opts.on('-f', '--flavor FLAVOR', "Flavor Name") do |flavor|
|
176
|
-
options[:flavorName] = flavor
|
177
|
-
end
|
178
|
-
end
|
179
|
-
optparse.parse(args)
|
180
|
-
|
181
|
-
server_payload = {server: {name: name, description: description}, zoneId: zone['id']}
|
182
|
-
response = @servers_interface.create(server_payload)
|
183
|
-
end
|
184
|
-
|
185
|
-
def add_standard(name,description,zone, args)
|
186
|
-
options = {}
|
187
|
-
networkOptions = {name: 'eth0'}
|
188
|
-
optparse = OptionParser.new do|opts|
|
189
|
-
opts.banner = "Usage: morpheus server add ZONE NAME [options]"
|
190
|
-
opts.on( '-u', '--ssh-user USER', "SSH Username" ) do |sshUser|
|
191
|
-
options['sshUsername'] = sshUser
|
192
|
-
end
|
193
|
-
opts.on('-p', '--password PASSWORD', "SSH Password (optional)") do |password|
|
194
|
-
options['sshPassword'] = password
|
195
|
-
end
|
196
|
-
|
197
|
-
opts.on('-h', '--host HOST', "HOST IP") do |host|
|
198
|
-
options['sshHost'] = host
|
199
|
-
end
|
200
|
-
|
201
|
-
options['dataDevice'] = '/dev/sdb'
|
202
|
-
opts.on('-m', '--data-device DATADEVICE', "Data device for LVM") do |device|
|
203
|
-
options['dataDevice'] = device
|
204
|
-
end
|
205
|
-
|
206
|
-
|
207
|
-
opts.on('-n', '--interface NETWORK', "Default Network Interface") do |net|
|
208
|
-
networkOptions[:name] = net
|
209
|
-
end
|
210
|
-
|
211
|
-
opts.on_tail(:NONE, "--help", "Show this message") do
|
212
|
-
puts opts
|
213
|
-
exit
|
214
|
-
end
|
215
|
-
end
|
216
|
-
optparse.parse(args)
|
217
|
-
|
218
|
-
server_payload = {server: {name: name, description: description, zone: {id: zone['id']}}.merge(options), network: networkOptions}
|
219
|
-
response = @servers_interface.create(server_payload)
|
220
|
-
|
221
|
-
end
|
222
|
-
|
223
|
-
def add_amazon(name,description,zone, args)
|
224
|
-
puts "NOT YET IMPLEMENTED"
|
225
|
-
end
|
226
|
-
|
227
|
-
def zone_type_for_id(id)
|
228
|
-
# puts "Zone Types #{@zone_types}"
|
229
|
-
if !@zone_types.empty?
|
230
|
-
zone_type = @zone_types.find { |z| z['id'].to_i == id.to_i}
|
231
|
-
if !zone_type.nil?
|
232
|
-
return zone_type
|
233
|
-
end
|
234
|
-
end
|
235
|
-
return nil
|
236
|
-
end
|
237
|
-
|
238
|
-
|
239
|
-
def find_group_by_name(name)
|
240
|
-
group_results = @groups_interface.get(name)
|
241
|
-
if group_results['groups'].empty?
|
242
|
-
puts "Group not found by name #{name}"
|
243
|
-
return nil
|
244
|
-
end
|
245
|
-
return group_results['groups'][0]
|
246
|
-
end
|
247
|
-
|
248
|
-
def find_zone_by_name(groupId, name)
|
249
|
-
zone_results = @zones_interface.get({groupId: groupId, name: name})
|
250
|
-
if zone_results['zones'].empty?
|
251
|
-
puts "Zone not found by name #{name}"
|
252
|
-
return nil
|
253
|
-
end
|
254
|
-
return zone_results['zones'][0]
|
255
|
-
end
|
256
|
-
|
257
|
-
def find_group_by_id(id)
|
258
|
-
group_results = @groups_interface.get(id)
|
259
|
-
if group_results['groups'].empty?
|
260
|
-
puts "Group not found by id #{id}"
|
261
|
-
return nil
|
262
|
-
end
|
263
|
-
return group_results['groups'][0]
|
264
|
-
end
|
265
|
-
end
|