pearl 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +18 -5
- data/lib/pearl/cli.rb +35 -3
- data/lib/pearl/client/droplets.rb +3 -2
- data/lib/pearl/client/images.rb +2 -2
- data/lib/pearl/client/sshkeys.rb +22 -0
- data/lib/pearl/client.rb +2 -1
- data/lib/pearl/pretty_table.rb +11 -0
- data/lib/pearl/version.rb +1 -1
- data/pearl.gemspec +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af0e92ef3c79f8beabfb06a3cee20ee63301f5d1
|
4
|
+
data.tar.gz: 57e00452487c5877a3e4176cdbfd7388205b080d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f532cd6d58851a9f6d813d0a05db4ec4d0559feb4142d5bbd0c4e27f843d28cb37367e2af9a988796a6d0e67a48ef6241fc44cc375bb4d5657c3d9117f47d821
|
7
|
+
data.tar.gz: f2682056b712791515923daf7df86fa9c54909efdbc02d4da0cfbc6c6481ee5ee131fe5b6e5ecccba1c1138ed11cc931a981e2ab9d1b81b74ad301204bbd7e55
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -27,11 +27,11 @@ To view a droplet
|
|
27
27
|
|
28
28
|
To create a droplet
|
29
29
|
|
30
|
-
$ pearl droplet add <name> --size <size id> --image <image id> --region <region id>
|
30
|
+
$ pearl droplet add <name> --size <size id> --image <image id> --region <region id> --ssh_key_ids <ssh key ids>
|
31
31
|
|
32
32
|
or
|
33
33
|
|
34
|
-
$ pearl droplet add <name> -s <size id> -i <image id> -r <region id>
|
34
|
+
$ pearl droplet add <name> -s <size id> -i <image id> -r <region id> -k <ssh key ids>
|
35
35
|
|
36
36
|
Reboot a droplet
|
37
37
|
|
@@ -51,11 +51,11 @@ Power Off droplet
|
|
51
51
|
|
52
52
|
Power On droplet
|
53
53
|
|
54
|
-
$ pearl droplet
|
54
|
+
$ pearl droplet power on -d <droplet id>
|
55
55
|
|
56
56
|
Reset root password
|
57
57
|
|
58
|
-
$ pearl droplet
|
58
|
+
$ pearl droplet password reset -d <droplet id>
|
59
59
|
|
60
60
|
Resize droplet
|
61
61
|
|
@@ -119,10 +119,23 @@ To destroy an image
|
|
119
119
|
|
120
120
|
$ pearl image destroy -i <image id>
|
121
121
|
|
122
|
+
### SSH Keys
|
123
|
+
|
124
|
+
Display all ssh keys
|
125
|
+
|
126
|
+
$ pearl ssh_keys
|
127
|
+
|
128
|
+
To view a ssh key
|
129
|
+
|
130
|
+
$ pearl ssh_key -k <ssh_key_id>
|
131
|
+
|
132
|
+
To delete a ssh key
|
133
|
+
|
134
|
+
$ paerl ssh_key destroy -k <ssh_key_id>
|
135
|
+
|
122
136
|
## TODO
|
123
137
|
|
124
138
|
* ~~Format output instead of just printing the json response.~~
|
125
|
-
* Add SSH resource.
|
126
139
|
|
127
140
|
## Contributing
|
128
141
|
|
data/lib/pearl/cli.rb
CHANGED
@@ -10,6 +10,8 @@ module Pearl
|
|
10
10
|
image = nil
|
11
11
|
region = nil
|
12
12
|
size = nil
|
13
|
+
ssh_key_ids = nil
|
14
|
+
ssh_key_pub = nil
|
13
15
|
|
14
16
|
opts = OptionParser.new do |opts|
|
15
17
|
opts.banner = "Usage: pearl [resource] [options]"
|
@@ -31,10 +33,14 @@ module Pearl
|
|
31
33
|
region = r
|
32
34
|
end
|
33
35
|
|
34
|
-
opts.on('-s', '--size [SIZE ID]', 'Set the size
|
36
|
+
opts.on('-s', '--size [SIZE ID]', 'Set the size for the droplet') do |s|
|
35
37
|
size = s
|
36
38
|
end
|
37
39
|
|
40
|
+
opts.on('-k', '--ssh_key_ids [KEY ID]', 'SSH Keys to add to the droplet') do |k|
|
41
|
+
ssh_key_ids = k
|
42
|
+
end
|
43
|
+
|
38
44
|
opts.on('-v', '--version', 'Display version') do
|
39
45
|
puts Pearl::VERSION
|
40
46
|
exit
|
@@ -77,7 +83,13 @@ module Pearl
|
|
77
83
|
name = command.split(' ', 3)[2]
|
78
84
|
raise 'Error: Invalid droplet name.' if name.nil? || name.length <= 0
|
79
85
|
|
80
|
-
options = {
|
86
|
+
options = {
|
87
|
+
name: name,
|
88
|
+
image_id: image_id,
|
89
|
+
region_id: region_id,
|
90
|
+
size_id: size_id,
|
91
|
+
ssh_key_ids: ssh_key_ids
|
92
|
+
}
|
81
93
|
|
82
94
|
Pearl.create_droplet(options)
|
83
95
|
exit
|
@@ -195,9 +207,29 @@ module Pearl
|
|
195
207
|
when /\Aregions\z/i
|
196
208
|
Pearl.regions
|
197
209
|
exit
|
210
|
+
|
211
|
+
# SSH Keys
|
212
|
+
when /\Assh_keys\z/i
|
213
|
+
Pearl.ssh_keys
|
214
|
+
exit
|
215
|
+
when /\Assh_key\z/i
|
216
|
+
ssh_key_ids = ssh_key_ids.to_i
|
217
|
+
raise 'Error: Invalid SSH Key ID.' if ssh_key_ids == 0 || !ssh_key_ids.is_a?(Fixnum)
|
218
|
+
Pearl.ssh_key(ssh_key_ids)
|
219
|
+
exit
|
220
|
+
|
221
|
+
when /\Assh_key (destroy|delete)\z/i
|
222
|
+
ssh_key_ids = ssh_key_ids.to_i
|
223
|
+
raise 'Error: Invalid SSH Key ID.' if ssh_key_ids == 0 || !ssh_key_ids.is_a?(Fixnum)
|
224
|
+
Pearl.delete_ssh_key(ssh_key_ids)
|
225
|
+
exit
|
226
|
+
|
227
|
+
# Sizes
|
198
228
|
when /\Asizes\z/i
|
199
229
|
Pearl.sizes
|
200
230
|
exit
|
231
|
+
|
232
|
+
# Any other command
|
201
233
|
else
|
202
234
|
puts "Error: '#{command}' is an invalid command."
|
203
235
|
exit
|
@@ -212,4 +244,4 @@ module Pearl
|
|
212
244
|
end
|
213
245
|
end
|
214
246
|
end
|
215
|
-
end
|
247
|
+
end
|
@@ -16,7 +16,8 @@ module Pearl
|
|
16
16
|
params = { name: options[:name],
|
17
17
|
size_id: options[:size_id],
|
18
18
|
image_id: options[:image_id],
|
19
|
-
region_id: options[:region_id]
|
19
|
+
region_id: options[:region_id],
|
20
|
+
ssh_key_ids: options[:ssh_key_ids]
|
20
21
|
}
|
21
22
|
response = request("droplets/new", params).body
|
22
23
|
pretty_table("Droplet", response)
|
@@ -93,4 +94,4 @@ module Pearl
|
|
93
94
|
end
|
94
95
|
end
|
95
96
|
end
|
96
|
-
end
|
97
|
+
end
|
data/lib/pearl/client/images.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Pearl
|
2
|
+
class Client
|
3
|
+
|
4
|
+
module SshKeys
|
5
|
+
|
6
|
+
def ssh_keys
|
7
|
+
response = request("ssh_keys").body
|
8
|
+
pretty_table("SSH Keys", response)
|
9
|
+
end
|
10
|
+
|
11
|
+
def ssh_key(id)
|
12
|
+
response = request("ssh_keys/#{id}").body
|
13
|
+
pretty_table('SSH Key', response)
|
14
|
+
end
|
15
|
+
|
16
|
+
def delete_ssh_key(id)
|
17
|
+
response = request("ssh_keys/#{id}/destroy").body
|
18
|
+
pretty_basic("Deleting ssh key #{id}", response)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/pearl/client.rb
CHANGED
data/lib/pearl/pretty_table.rb
CHANGED
@@ -54,5 +54,16 @@ module Pearl
|
|
54
54
|
table = Terminal::Table.new title: heading, headings: ['Status', 'Event ID'], rows: rows
|
55
55
|
puts table
|
56
56
|
end
|
57
|
+
|
58
|
+
def pretty_basic(heading = '', data)
|
59
|
+
# Convert JSON response into a hash for easier parsing
|
60
|
+
tmp = MultiJson.load(data, symbolize_keys: true)
|
61
|
+
|
62
|
+
rows = []
|
63
|
+
rows << [tmp[:status]]
|
64
|
+
|
65
|
+
table = Terminal::Table.new title: heading, rows: rows
|
66
|
+
puts table
|
67
|
+
end
|
57
68
|
end
|
58
69
|
end
|
data/lib/pearl/version.rb
CHANGED
data/pearl.gemspec
CHANGED
@@ -23,5 +23,5 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.3"
|
24
24
|
spec.add_development_dependency "rake"
|
25
25
|
spec.add_dependency "multi_json", "~> 1.6.1"
|
26
|
-
spec.add_dependency "terminal-table"
|
26
|
+
spec.add_dependency "terminal-table", "~> 1.4.5"
|
27
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pearl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manish Valechha
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: terminal-table
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 1.4.5
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 1.4.5
|
69
69
|
description: Command line interface for DigitalOcean's API
|
70
70
|
email:
|
71
71
|
- manishval@hotmail.com
|
@@ -87,6 +87,7 @@ files:
|
|
87
87
|
- lib/pearl/client/images.rb
|
88
88
|
- lib/pearl/client/regions.rb
|
89
89
|
- lib/pearl/client/sizes.rb
|
90
|
+
- lib/pearl/client/sshkeys.rb
|
90
91
|
- lib/pearl/error.rb
|
91
92
|
- lib/pearl/http.rb
|
92
93
|
- lib/pearl/pretty_table.rb
|
@@ -120,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
121
|
version: '0'
|
121
122
|
requirements: []
|
122
123
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.0.
|
124
|
+
rubygems_version: 2.0.3
|
124
125
|
signing_key:
|
125
126
|
specification_version: 4
|
126
127
|
summary: Command line interface for DigitalOcean's API
|