knife-digital_ocean 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/README.md +112 -20
- data/Rakefile +6 -0
- data/knife-digital_ocean.gemspec +4 -0
- data/lib/chef/knife/digital_ocean_base.rb +15 -0
- data/lib/chef/knife/digital_ocean_domain_create.rb +9 -10
- data/lib/chef/knife/digital_ocean_domain_destroy.rb +5 -5
- data/lib/chef/knife/digital_ocean_domain_list.rb +1 -2
- data/lib/chef/knife/digital_ocean_domain_record_create.rb +18 -18
- data/lib/chef/knife/digital_ocean_domain_record_destroy.rb +9 -10
- data/lib/chef/knife/digital_ocean_domain_record_edit.rb +21 -21
- data/lib/chef/knife/digital_ocean_domain_record_list.rb +4 -5
- data/lib/chef/knife/digital_ocean_droplet_create.rb +4 -5
- data/lib/chef/knife/digital_ocean_droplet_destroy.rb +3 -6
- data/lib/chef/knife/digital_ocean_droplet_power.rb +66 -0
- data/lib/chef/knife/digital_ocean_droplet_powercycle.rb +48 -0
- data/lib/chef/knife/digital_ocean_droplet_reboot.rb +48 -0
- data/lib/chef/knife/digital_ocean_droplet_rebuild.rb +58 -0
- data/lib/chef/knife/digital_ocean_droplet_rename.rb +58 -0
- data/lib/chef/knife/digital_ocean_droplet_resize.rb +58 -0
- data/lib/chef/knife/digital_ocean_droplet_snapshot.rb +58 -0
- data/lib/chef/knife/digital_ocean_image_destroy.rb +42 -0
- data/lib/chef/knife/digital_ocean_image_list.rb +1 -1
- data/lib/chef/knife/digital_ocean_image_transfer.rb +66 -0
- data/lib/chef/knife/digital_ocean_region_list.rb +1 -1
- data/lib/chef/knife/digital_ocean_sshkey_create.rb +11 -11
- data/lib/chef/knife/digital_ocean_sshkey_destroy.rb +6 -6
- data/lib/chef/knife/digital_ocean_sshkey_list.rb +1 -1
- data/lib/knife-digital_ocean/version.rb +1 -1
- data/spec/fixtures/keys/id_rsa.pub +1 -0
- data/spec/fixtures/vcr_cassettes/accountinfo.yml +7 -9
- data/spec/fixtures/vcr_cassettes/domain_create.yml +65 -0
- data/spec/fixtures/vcr_cassettes/{domainlist.yml → domain_list.yml} +15 -12
- data/spec/fixtures/vcr_cassettes/domain_record_create.yml +65 -0
- data/spec/fixtures/vcr_cassettes/domain_record_list.yml +63 -0
- data/spec/fixtures/vcr_cassettes/droplet.yml +12 -17
- data/spec/fixtures/vcr_cassettes/droplet_power.yml +65 -0
- data/spec/fixtures/vcr_cassettes/droplet_powercycle.yml +127 -0
- data/spec/fixtures/vcr_cassettes/droplet_reboot.yml +127 -0
- data/spec/fixtures/vcr_cassettes/droplet_rebuild.yml +65 -0
- data/spec/fixtures/vcr_cassettes/droplet_rename.yml +127 -0
- data/spec/fixtures/vcr_cassettes/droplet_resize.yml +65 -0
- data/spec/fixtures/vcr_cassettes/droplet_snapshot.yml +1057 -0
- data/spec/fixtures/vcr_cassettes/image.yml +55 -59
- data/spec/fixtures/vcr_cassettes/public_images.yml +54 -59
- data/spec/fixtures/vcr_cassettes/region.yml +8 -10
- data/spec/fixtures/vcr_cassettes/sizes.yml +8 -10
- data/spec/fixtures/vcr_cassettes/sshkey.yml +8 -10
- data/spec/fixtures/vcr_cassettes/sshkey_create.yml +68 -0
- data/spec/lib/chef/knife/digital_ocean_account_info_spec.rb +4 -4
- data/spec/lib/chef/knife/digital_ocean_domain_create_spec.rb +35 -1
- data/spec/lib/chef/knife/digital_ocean_domain_list_spec.rb +8 -9
- data/spec/lib/chef/knife/digital_ocean_domain_record_create_spec.rb +37 -1
- data/spec/lib/chef/knife/digital_ocean_domain_record_list_spec.rb +34 -1
- data/spec/lib/chef/knife/digital_ocean_droplet_create_spec.rb +5 -1
- data/spec/lib/chef/knife/digital_ocean_droplet_list_spec.rb +4 -4
- data/spec/lib/chef/knife/digital_ocean_droplet_power_spec.rb +39 -0
- data/spec/lib/chef/knife/digital_ocean_droplet_powercycle_spec.rb +38 -0
- data/spec/lib/chef/knife/digital_ocean_droplet_reboot_spec.rb +38 -0
- data/spec/lib/chef/knife/digital_ocean_droplet_rebuild_spec.rb +39 -0
- data/spec/lib/chef/knife/digital_ocean_droplet_rename_spec.rb +39 -0
- data/spec/lib/chef/knife/digital_ocean_droplet_resize_spec.rb +39 -0
- data/spec/lib/chef/knife/digital_ocean_droplet_snapshot_spec.rb +39 -0
- data/spec/lib/chef/knife/digital_ocean_image_list_spec.rb +8 -10
- data/spec/lib/chef/knife/digital_ocean_region_list_spec.rb +4 -4
- data/spec/lib/chef/knife/digital_ocean_size_list_spec.rb +4 -4
- data/spec/lib/chef/knife/digital_ocean_sshkey_create_spec.rb +35 -1
- data/spec/lib/chef/knife/digital_ocean_sshkey_list_spec.rb +4 -4
- data/spec/spec_helper.rb +29 -2
- metadata +93 -6
- data/spec/lib/chef/knife/digital_ocean_domain_record_edit_spec.rb +0 -5
@@ -21,14 +21,14 @@ class Chef
|
|
21
21
|
banner 'knife digital_ocean domain record destroy (options)'
|
22
22
|
|
23
23
|
option :domain,
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
short: '-D NAME',
|
25
|
+
long: '--domain-id NAME',
|
26
|
+
description: 'The domain name'
|
27
27
|
|
28
28
|
option :record,
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
short: '-R ID',
|
30
|
+
long: '--record-id ID',
|
31
|
+
description: 'The record id'
|
32
32
|
|
33
33
|
def run
|
34
34
|
$stdout.sync = true
|
@@ -36,19 +36,18 @@ class Chef
|
|
36
36
|
validate!
|
37
37
|
|
38
38
|
unless locate_config_value(:domain)
|
39
|
-
ui.error(
|
39
|
+
ui.error('Domain cannot be empty. => -D <domain-name>')
|
40
40
|
exit 1
|
41
41
|
end
|
42
42
|
|
43
43
|
unless locate_config_value(:record)
|
44
|
-
ui.error(
|
44
|
+
ui.error('Record cannot be empty. => -R <record-id>')
|
45
45
|
exit 1
|
46
46
|
end
|
47
47
|
|
48
48
|
result = client.domain_records.delete for_domain: locate_config_value(:domain), id: locate_config_value(:record)
|
49
|
-
ui.error JSON.parse(result)['message']
|
49
|
+
ui.info 'OK' if result == true or ui.error JSON.parse(result)['message']
|
50
50
|
end
|
51
|
-
|
52
51
|
end
|
53
52
|
end
|
54
53
|
end
|
@@ -21,29 +21,29 @@ class Chef
|
|
21
21
|
banner 'knife digital_ocean domain record edit (options)'
|
22
22
|
|
23
23
|
option :domain,
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
short: '-D NAME',
|
25
|
+
long: '--domain-id NAME',
|
26
|
+
description: 'The domain name'
|
27
27
|
|
28
28
|
option :record,
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
short: '-R ID',
|
30
|
+
long: '--record-id ID',
|
31
|
+
description: 'The record id'
|
32
32
|
|
33
33
|
option :type,
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
short: '-T RECORD TYPE',
|
35
|
+
long: '--type RECORD TYPE',
|
36
|
+
description: 'The type of record'
|
37
37
|
|
38
38
|
option :name,
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
short: '-N RECORD NAME',
|
40
|
+
long: '--name RECORD NAME',
|
41
|
+
description: 'The record name'
|
42
42
|
|
43
43
|
option :data,
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
short: '-a DATA',
|
45
|
+
long: '--data DATA',
|
46
|
+
description: 'The record data'
|
47
47
|
|
48
48
|
def run
|
49
49
|
$stdout.sync = true
|
@@ -51,27 +51,27 @@ class Chef
|
|
51
51
|
validate!
|
52
52
|
|
53
53
|
unless locate_config_value(:domain)
|
54
|
-
ui.error(
|
54
|
+
ui.error('Domain cannot be empty. => -D <domain-name>')
|
55
55
|
exit 1
|
56
56
|
end
|
57
57
|
|
58
58
|
unless locate_config_value(:record)
|
59
|
-
ui.error(
|
59
|
+
ui.error('Record cannot be empty. => -R <record-id>')
|
60
60
|
exit 1
|
61
61
|
end
|
62
62
|
|
63
63
|
unless locate_config_value(:type)
|
64
|
-
ui.error(
|
64
|
+
ui.error('Record type cannot be empty. => -T <record-type>')
|
65
65
|
exit 1
|
66
66
|
end
|
67
67
|
|
68
68
|
unless locate_config_value(:name)
|
69
|
-
ui.error(
|
69
|
+
ui.error('Record name cannot be empty. => -N <record-name>')
|
70
70
|
exit 1
|
71
71
|
end
|
72
72
|
|
73
73
|
unless locate_config_value(:data)
|
74
|
-
ui.error(
|
74
|
+
ui.error('Record data cannot be empty. => -d <data>')
|
75
75
|
exit 1
|
76
76
|
end
|
77
77
|
|
@@ -81,7 +81,7 @@ class Chef
|
|
81
81
|
data: locate_config_value(:data)
|
82
82
|
)
|
83
83
|
result = client.domain_records.update domain_record, for_domain: locate_config_value(:domain), id: locate_config_value(:record)
|
84
|
-
ui.error JSON.parse(result)['message']
|
84
|
+
ui.info 'OK' if result == true or ui.error JSON.parse(result)['message']
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|
@@ -19,9 +19,9 @@ class Chef
|
|
19
19
|
banner 'knife digital_ocean domain record list (options)'
|
20
20
|
|
21
21
|
option :name,
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
short: '-D NAME',
|
23
|
+
long: '--domain-name NAME',
|
24
|
+
description: 'The domain name'
|
25
25
|
|
26
26
|
def run
|
27
27
|
$stdout.sync = true
|
@@ -29,7 +29,7 @@ class Chef
|
|
29
29
|
validate!
|
30
30
|
|
31
31
|
unless locate_config_value(:name)
|
32
|
-
ui.error(
|
32
|
+
ui.error('Domain Name cannot be empty. => -D <domain-name>')
|
33
33
|
exit 1
|
34
34
|
end
|
35
35
|
|
@@ -48,7 +48,6 @@ class Chef
|
|
48
48
|
domains_list << domain.data.to_s
|
49
49
|
end
|
50
50
|
|
51
|
-
|
52
51
|
puts ui.list(domains_list, :uneven_columns_across, 4)
|
53
52
|
end
|
54
53
|
end
|
@@ -206,13 +206,12 @@ class Chef
|
|
206
206
|
ipv6: locate_config_value(:ipv6)
|
207
207
|
)
|
208
208
|
|
209
|
-
|
210
209
|
server = client.droplets.create(droplet)
|
211
210
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
211
|
+
if client.droplets.find(id: server.id).status != 'new'
|
212
|
+
ui.error("Droplet could not be started #{server.inspect}")
|
213
|
+
exit 1
|
214
|
+
end
|
216
215
|
|
217
216
|
puts "Droplet creation for #{locate_config_value(:server_name)} started. Droplet-ID is #{server.id}"
|
218
217
|
|
@@ -29,7 +29,6 @@ class Chef
|
|
29
29
|
long: '--all',
|
30
30
|
description: '!WARNING! UNRECOVERABLE Destroy all droplets.'
|
31
31
|
|
32
|
-
|
33
32
|
def run
|
34
33
|
$stdout.sync = true
|
35
34
|
|
@@ -52,15 +51,13 @@ class Chef
|
|
52
51
|
end
|
53
52
|
|
54
53
|
if locate_config_value(:all)
|
55
|
-
droplets_ids = client.droplets.all.map
|
56
|
-
droplet.id
|
57
|
-
end
|
54
|
+
droplets_ids = client.droplets.all.map(&:id)
|
58
55
|
end
|
59
56
|
|
60
57
|
droplets_ids.each do |id|
|
61
|
-
|
58
|
+
ui.info "Delete droplet with id: #{id}"
|
62
59
|
result = client.droplets.delete(id: id)
|
63
|
-
|
60
|
+
ui.info 'OK' if result == true or ui.error JSON.parse(result)['message']
|
64
61
|
end
|
65
62
|
end
|
66
63
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
2
|
+
# you may not use this file except in compliance with the License.
|
3
|
+
# You may obtain a copy of the License at
|
4
|
+
#
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
# See the License for the specific language governing permissions and
|
11
|
+
# limitations under the License.
|
12
|
+
#
|
13
|
+
require 'chef/knife/digital_ocean_base'
|
14
|
+
|
15
|
+
class Chef
|
16
|
+
class Knife
|
17
|
+
class DigitalOceanDropletPower < Knife
|
18
|
+
include Knife::DigitalOceanBase
|
19
|
+
|
20
|
+
banner 'knife digital_ocean droplet power (options)'
|
21
|
+
|
22
|
+
option :action,
|
23
|
+
short: '-a ACTION',
|
24
|
+
long: '--action ACTION',
|
25
|
+
description: 'Power Action On/Off'
|
26
|
+
|
27
|
+
option :id,
|
28
|
+
short: '-I ID',
|
29
|
+
long: '--droplet-id ID',
|
30
|
+
description: 'Droplet ID'
|
31
|
+
|
32
|
+
def run
|
33
|
+
$stdout.sync = true
|
34
|
+
|
35
|
+
validate!
|
36
|
+
|
37
|
+
unless locate_config_value(:action)
|
38
|
+
ui.error('Action cannot be empty. => -a <action>')
|
39
|
+
exit 1
|
40
|
+
end
|
41
|
+
|
42
|
+
unless locate_config_value(:id)
|
43
|
+
ui.error('ID cannot be empty. => -I <id>')
|
44
|
+
exit 1
|
45
|
+
end
|
46
|
+
|
47
|
+
case locate_config_value(:action)
|
48
|
+
when /(on)/i
|
49
|
+
result = client.droplet_actions.power_on(droplet_id: locate_config_value(:id))
|
50
|
+
when /(off)/i
|
51
|
+
result = client.droplet_actions.power_off(droplet_id: locate_config_value(:id))
|
52
|
+
else
|
53
|
+
ui.error 'Bad Action: Use on/off.'
|
54
|
+
exit 1
|
55
|
+
end
|
56
|
+
|
57
|
+
unless result.class == DropletKit::Action
|
58
|
+
ui.error JSON.parse(result)['message']
|
59
|
+
exit 1
|
60
|
+
end
|
61
|
+
|
62
|
+
wait_for_status(result)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
2
|
+
# you may not use this file except in compliance with the License.
|
3
|
+
# You may obtain a copy of the License at
|
4
|
+
#
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
# See the License for the specific language governing permissions and
|
11
|
+
# limitations under the License.
|
12
|
+
#
|
13
|
+
require 'chef/knife/digital_ocean_base'
|
14
|
+
|
15
|
+
class Chef
|
16
|
+
class Knife
|
17
|
+
class DigitalOceanDropletPowercycle < Knife
|
18
|
+
include Knife::DigitalOceanBase
|
19
|
+
|
20
|
+
banner 'knife digital_ocean droplet powercycle (options)'
|
21
|
+
|
22
|
+
option :id,
|
23
|
+
short: '-I ID',
|
24
|
+
long: '--droplet-id ID',
|
25
|
+
description: 'Droplet ID'
|
26
|
+
|
27
|
+
def run
|
28
|
+
$stdout.sync = true
|
29
|
+
|
30
|
+
validate!
|
31
|
+
|
32
|
+
unless locate_config_value(:id)
|
33
|
+
ui.error('ID cannot be empty. => -I <id>')
|
34
|
+
exit 1
|
35
|
+
end
|
36
|
+
|
37
|
+
result = client.droplet_actions.power_cycle(droplet_id: locate_config_value(:id))
|
38
|
+
|
39
|
+
unless result.class == DropletKit::Action
|
40
|
+
ui.error JSON.parse(result)['message']
|
41
|
+
exit 1
|
42
|
+
end
|
43
|
+
|
44
|
+
wait_for_status(result, status: 'active')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
2
|
+
# you may not use this file except in compliance with the License.
|
3
|
+
# You may obtain a copy of the License at
|
4
|
+
#
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
# See the License for the specific language governing permissions and
|
11
|
+
# limitations under the License.
|
12
|
+
#
|
13
|
+
require 'chef/knife/digital_ocean_base'
|
14
|
+
|
15
|
+
class Chef
|
16
|
+
class Knife
|
17
|
+
class DigitalOceanDropletReboot < Knife
|
18
|
+
include Knife::DigitalOceanBase
|
19
|
+
|
20
|
+
banner 'knife digital_ocean droplet reboot (options)'
|
21
|
+
|
22
|
+
option :id,
|
23
|
+
short: '-I ID',
|
24
|
+
long: '--droplet-id ID',
|
25
|
+
description: 'Droplet ID'
|
26
|
+
|
27
|
+
def run
|
28
|
+
$stdout.sync = true
|
29
|
+
|
30
|
+
validate!
|
31
|
+
|
32
|
+
unless locate_config_value(:id)
|
33
|
+
ui.error('ID cannot be empty. => -I <id>')
|
34
|
+
exit 1
|
35
|
+
end
|
36
|
+
|
37
|
+
result = client.droplet_actions.reboot(droplet_id: locate_config_value(:id))
|
38
|
+
|
39
|
+
unless result.class == DropletKit::Action
|
40
|
+
ui.error JSON.parse(result)['message']
|
41
|
+
exit 1
|
42
|
+
end
|
43
|
+
|
44
|
+
wait_for_status(result)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
2
|
+
# you may not use this file except in compliance with the License.
|
3
|
+
# You may obtain a copy of the License at
|
4
|
+
#
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
# See the License for the specific language governing permissions and
|
11
|
+
# limitations under the License.
|
12
|
+
#
|
13
|
+
require 'chef/knife/digital_ocean_base'
|
14
|
+
|
15
|
+
class Chef
|
16
|
+
class Knife
|
17
|
+
class DigitalOceanDropletRebuild < Knife
|
18
|
+
include Knife::DigitalOceanBase
|
19
|
+
|
20
|
+
banner 'knife digital_ocean droplet rebuild (options)'
|
21
|
+
|
22
|
+
option :image,
|
23
|
+
short: '-i IMAGE',
|
24
|
+
long: '--image-id IMAGE',
|
25
|
+
description: 'Image ID'
|
26
|
+
|
27
|
+
option :id,
|
28
|
+
short: '-I ID',
|
29
|
+
long: '--droplet-id ID',
|
30
|
+
description: 'Droplet ID'
|
31
|
+
|
32
|
+
def run
|
33
|
+
$stdout.sync = true
|
34
|
+
|
35
|
+
validate!
|
36
|
+
|
37
|
+
unless locate_config_value(:image)
|
38
|
+
ui.error('Image ID cannot be empty. => -i <image-id>')
|
39
|
+
exit 1
|
40
|
+
end
|
41
|
+
|
42
|
+
unless locate_config_value(:id)
|
43
|
+
ui.error('ID cannot be empty. => -I <id>')
|
44
|
+
exit 1
|
45
|
+
end
|
46
|
+
|
47
|
+
result = client.droplet_actions.rebuild(droplet_id: locate_config_value(:id), image: locate_config_value(:image))
|
48
|
+
|
49
|
+
unless result.class == DropletKit::Action
|
50
|
+
ui.error JSON.parse(result)['message']
|
51
|
+
exit 1
|
52
|
+
end
|
53
|
+
|
54
|
+
wait_for_status(result, status: 'active')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
2
|
+
# you may not use this file except in compliance with the License.
|
3
|
+
# You may obtain a copy of the License at
|
4
|
+
#
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
# See the License for the specific language governing permissions and
|
11
|
+
# limitations under the License.
|
12
|
+
#
|
13
|
+
require 'chef/knife/digital_ocean_base'
|
14
|
+
|
15
|
+
class Chef
|
16
|
+
class Knife
|
17
|
+
class DigitalOceanDropletRename < Knife
|
18
|
+
include Knife::DigitalOceanBase
|
19
|
+
|
20
|
+
banner 'knife digital_ocean droplet rename (options)'
|
21
|
+
|
22
|
+
option :name,
|
23
|
+
short: '-N NAME',
|
24
|
+
long: '--droplet-name NAME',
|
25
|
+
description: 'Name of droplet'
|
26
|
+
|
27
|
+
option :id,
|
28
|
+
short: '-I ID',
|
29
|
+
long: '--droplet-id ID',
|
30
|
+
description: 'Droplet ID'
|
31
|
+
|
32
|
+
def run
|
33
|
+
$stdout.sync = true
|
34
|
+
|
35
|
+
validate!
|
36
|
+
|
37
|
+
unless locate_config_value(:name)
|
38
|
+
ui.error('Name cannot be empty. => -N <name>')
|
39
|
+
exit 1
|
40
|
+
end
|
41
|
+
|
42
|
+
unless locate_config_value(:id)
|
43
|
+
ui.error('ID cannot be empty. => -I <id>')
|
44
|
+
exit 1
|
45
|
+
end
|
46
|
+
|
47
|
+
result = client.droplet_actions.rename(droplet_id: locate_config_value(:id), name: locate_config_value(:name))
|
48
|
+
|
49
|
+
unless result.class == DropletKit::Action
|
50
|
+
ui.error JSON.parse(result)['message']
|
51
|
+
exit 1
|
52
|
+
end
|
53
|
+
|
54
|
+
wait_for_status(result)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|