pearl 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -2
- data/lib/pearl/cli.rb +31 -2
- data/lib/pearl/client/droplets.rb +6 -1
- data/lib/pearl/client/images.rb +6 -0
- data/lib/pearl/client/sshkeys.rb +8 -0
- data/lib/pearl/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d46e1fb5bffc38a2878437784aecf22aade76e9
|
4
|
+
data.tar.gz: de62586bc374afdd5104c49313057483d212acb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffb700fb93b64cfd5f9d8846dcabd686f98a494d26f307eb2c24b35fcee23a3a3c223dce9ef41a4b6385314ee02bbb5bef82b7315a890fc9d0debc2cb87af816
|
7
|
+
data.tar.gz: 1d375b32c9d59fe188bb488906cb5e132f381ce86eed82c8561b78ba5a59a4ea47c0f964cfecb946d77245a1c5ab908494435c6230a296287b4abccde8edc8de
|
data/README.md
CHANGED
@@ -81,6 +81,10 @@ Disable automatic backups
|
|
81
81
|
|
82
82
|
$ pearl droplet disable backups -d <droplet id>
|
83
83
|
|
84
|
+
Rename droplet
|
85
|
+
|
86
|
+
$ pearl droplet rename <name> -d <droplet id>
|
87
|
+
|
84
88
|
Destroy droplet
|
85
89
|
|
86
90
|
$ pearl droplet destroy -d <droplet id>
|
@@ -119,19 +123,27 @@ To destroy an image
|
|
119
123
|
|
120
124
|
$ pearl image destroy -i <image id>
|
121
125
|
|
126
|
+
To transfer an image
|
127
|
+
|
128
|
+
$ pearl image transfer -i <image id> -r <region id>
|
129
|
+
|
122
130
|
### SSH Keys
|
123
131
|
|
124
132
|
Display all ssh keys
|
125
133
|
|
126
134
|
$ pearl ssh_keys
|
127
135
|
|
136
|
+
Add a ssh key
|
137
|
+
|
138
|
+
$ pearl ssh_key add <name> -p <public ssh key>
|
139
|
+
|
128
140
|
To view a ssh key
|
129
141
|
|
130
|
-
$ pearl ssh_key -k <
|
142
|
+
$ pearl ssh_key -k <ssh key id>
|
131
143
|
|
132
144
|
To delete a ssh key
|
133
145
|
|
134
|
-
$
|
146
|
+
$ pearl ssh_key destroy -k <ssh key id>
|
135
147
|
|
136
148
|
## TODO
|
137
149
|
|
data/lib/pearl/cli.rb
CHANGED
@@ -11,7 +11,7 @@ module Pearl
|
|
11
11
|
region = nil
|
12
12
|
size = nil
|
13
13
|
ssh_key_ids = nil
|
14
|
-
|
14
|
+
public_ssh_key = nil
|
15
15
|
|
16
16
|
opts = OptionParser.new do |opts|
|
17
17
|
opts.banner = "Usage: pearl [resource] [options]"
|
@@ -37,10 +37,14 @@ module Pearl
|
|
37
37
|
size = s
|
38
38
|
end
|
39
39
|
|
40
|
-
opts.on('-k', '--ssh_key_ids [KEY ID]', 'SSH Keys
|
40
|
+
opts.on('-k', '--ssh_key_ids [KEY ID]', 'SSH Keys for the droplet') do |k|
|
41
41
|
ssh_key_ids = k
|
42
42
|
end
|
43
43
|
|
44
|
+
opts.on('-p', '--public_ssh_key [PUBLIC SSH KEY]', 'Public SSH Key to add to the droplet') do |k|
|
45
|
+
public_ssh_key = p
|
46
|
+
end
|
47
|
+
|
44
48
|
opts.on('-v', '--version', 'Display version') do
|
45
49
|
puts Pearl::VERSION
|
46
50
|
exit
|
@@ -177,6 +181,15 @@ module Pearl
|
|
177
181
|
|
178
182
|
Pearl.disable_backups(droplet_id)
|
179
183
|
exit
|
184
|
+
when /\Adroplet rename [\w\s]{3,}\z/i
|
185
|
+
droplet_id = droplet.to_i
|
186
|
+
raise 'Error: Invalid droplet id.' if droplet_id == 0 || !droplet_id.is_a?(Fixnum)
|
187
|
+
|
188
|
+
name = command.split(' ', 3)[2]
|
189
|
+
raise 'Error: Invalid droplet name.' if name.nil? || name.length <= 0
|
190
|
+
|
191
|
+
Pearl.rename(droplet_id, name)
|
192
|
+
exit
|
180
193
|
when /\Adroplet (destroy|delete)\z/i
|
181
194
|
droplet_id = droplet.to_i
|
182
195
|
raise 'Error: Invalid droplet id.' if droplet_id == 0 || !droplet_id.is_a?(Fixnum)
|
@@ -204,6 +217,15 @@ module Pearl
|
|
204
217
|
|
205
218
|
Pearl.destroy_image(image_id)
|
206
219
|
exit
|
220
|
+
when /\Aimage (transfer)\z/i
|
221
|
+
image_id = image.to_i
|
222
|
+
raise 'Error: Invalid image id.' if image_id == 0 || !image_id.is_a?(Fixnum)
|
223
|
+
|
224
|
+
region_id = region.to_i
|
225
|
+
raise 'Error: Invalid region id.' if region_id == 0 || !region_id.is_a?(Fixnum)
|
226
|
+
|
227
|
+
Pearl.transfer(image_id, region_id)
|
228
|
+
exit
|
207
229
|
when /\Aregions\z/i
|
208
230
|
Pearl.regions
|
209
231
|
exit
|
@@ -217,7 +239,14 @@ module Pearl
|
|
217
239
|
raise 'Error: Invalid SSH Key ID.' if ssh_key_ids == 0 || !ssh_key_ids.is_a?(Fixnum)
|
218
240
|
Pearl.ssh_key(ssh_key_ids)
|
219
241
|
exit
|
242
|
+
when /\sssh_key add [\w\-\.]{3,}\z/i
|
243
|
+
name = command.split(' ', 3)[2]
|
244
|
+
raise 'Error: Invalid ssh key name.' if name.nil? || name.length <= 0
|
220
245
|
|
246
|
+
raise 'Error: Invalid public ssh key id.' if public_ssh_key.nil? || public_ssh_key.nil?
|
247
|
+
|
248
|
+
Pearl.add_ssh_key(name, public_ssh_key)
|
249
|
+
exit
|
221
250
|
when /\Assh_key (destroy|delete)\z/i
|
222
251
|
ssh_key_ids = ssh_key_ids.to_i
|
223
252
|
raise 'Error: Invalid SSH Key ID.' if ssh_key_ids == 0 || !ssh_key_ids.is_a?(Fixnum)
|
@@ -60,7 +60,6 @@ module Pearl
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def snapshot(id, name)
|
63
|
-
puts name
|
64
63
|
params = { name: name }
|
65
64
|
response = request("droplets/#{id}/snapshot", params).body
|
66
65
|
pretty_event("Creating snapshot '#{name}' of droplet #{id}", response)
|
@@ -88,6 +87,12 @@ module Pearl
|
|
88
87
|
pretty_event("Disabling auto backups for droplet #{id}", response)
|
89
88
|
end
|
90
89
|
|
90
|
+
def rename(id, name)
|
91
|
+
params = { name: name }
|
92
|
+
response = request("droplets/#{id}/rename", params).body
|
93
|
+
pretty_event("Renaming droplet '#{id}' to #{name}", response)
|
94
|
+
end
|
95
|
+
|
91
96
|
def destroy_droplet(id)
|
92
97
|
response = request("droplets/#{id}/destroy").body
|
93
98
|
pretty_event("Destroying droplet #{id}", response)
|
data/lib/pearl/client/images.rb
CHANGED
@@ -23,6 +23,12 @@ module Pearl
|
|
23
23
|
response = request("images/#{id}/destroy").body
|
24
24
|
pretty_event("Destroying image #{id}", response)
|
25
25
|
end
|
26
|
+
|
27
|
+
def transfer(id, region)
|
28
|
+
params = { region_id: region }
|
29
|
+
response = request("images/#{id}/transfer", params).body
|
30
|
+
pretty_event("Transferring image '#{id}' to region #{region}", response)
|
31
|
+
end
|
26
32
|
end
|
27
33
|
end
|
28
34
|
end
|
data/lib/pearl/client/sshkeys.rb
CHANGED
@@ -13,6 +13,14 @@ module Pearl
|
|
13
13
|
pretty_table('SSH Key', response)
|
14
14
|
end
|
15
15
|
|
16
|
+
def add_ssh_key(name, public_ssh_key)
|
17
|
+
params = { name: name,
|
18
|
+
public_ssh_key: public_ssh_key
|
19
|
+
}
|
20
|
+
response = request("ssh_keys/new", params).body
|
21
|
+
pretty_table("SSH Key: #{name}", response)
|
22
|
+
end
|
23
|
+
|
16
24
|
def delete_ssh_key(id)
|
17
25
|
response = request("ssh_keys/#{id}/destroy").body
|
18
26
|
pretty_basic("Deleting ssh key #{id}", response)
|
data/lib/pearl/version.rb
CHANGED
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.7
|
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-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|