civo 0.1.7 → 0.1.8
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/app/models/civo/instance.rb +3 -1
- data/lib/civo/cli/commands/instances.rb +65 -4
- data/lib/civo/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b9396f4d7e27b9f72e0888c45a71d5bccd243b9
|
4
|
+
data.tar.gz: 42a82ab43291563c8cb29e11fa3f37a8e45ee6ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4a57142ba1e19cfe1861e57f8e3e6e5f6a98e94cfbc0da68726cc7e22d7415ce871b2b2b9b44d5b2da1476bb490096e92903fce247d4a4346fd25ed2e32c3e1
|
7
|
+
data.tar.gz: c9576d95517c31b8f1876ae20bcfdb6959e727875e682c9c5ef1b717e3546492ac742115fce67503c1b8bb7057279be468706eeae19c4bb69b64b5a71e4e8efc
|
data/app/models/civo/instance.rb
CHANGED
@@ -3,7 +3,9 @@ module Civo
|
|
3
3
|
get :all, "/v1/instances"
|
4
4
|
post :create, "/v1/instances", requires: [:hostname, :size, :region, :ssh_key],
|
5
5
|
defaults: {public_ip: true, template: "ubuntu-14.04", initial_user: "civo"}
|
6
|
-
delete :remove, "/v1/instances/:id"
|
6
|
+
delete :remove, "/v1/instances/:id", requires: [:id]
|
7
|
+
post :reboot, "/v1/instances/:id/reboots", requires: [:id]
|
8
|
+
put :upgrade, "/v1/instances/:id", requires: [:size, :id]
|
7
9
|
|
8
10
|
def ip_addresses
|
9
11
|
self._attributes[:ip_addresses].items rescue ""
|
@@ -59,11 +59,11 @@ command "instances:remove" do |c|
|
|
59
59
|
instance = Civo::Instance.all.detect {|i| i.hostname == args.first}
|
60
60
|
id = instance.id
|
61
61
|
end
|
62
|
-
|
63
|
-
if
|
64
|
-
puts "
|
62
|
+
instance = Civo::Instance.remove(id: id)
|
63
|
+
if instance.result == "ok"
|
64
|
+
puts "Instance '#{args.first}' has been removed."
|
65
65
|
else
|
66
|
-
puts "Failed to delete that
|
66
|
+
puts "Failed to delete that instance: #{instance.inspect}"
|
67
67
|
end
|
68
68
|
rescue Flexirest::HTTPUnauthorisedClientException, Flexirest::HTTPForbiddenClientException
|
69
69
|
puts "Access denied to your default token, ensure it's set correctly with 'civo tokens'"
|
@@ -77,3 +77,64 @@ end
|
|
77
77
|
alias_command "instance:remove", "instances:remove"
|
78
78
|
alias_command "instances:delete", "instances:remove"
|
79
79
|
alias_command "instance:delete", "instances:remove"
|
80
|
+
|
81
|
+
command "instances:upgrade" do |c|
|
82
|
+
c.description = "Upgrade an instance by hostname or id"
|
83
|
+
c.option "--size STRING", String, "The size from 'civo sizes', must be larger than the current size"
|
84
|
+
c.example "Upgrades an instance called 'test.example.com' to `g1.large` size", 'civo instances:upgrade test.example.com --size g1.large'
|
85
|
+
c.action do |args, options|
|
86
|
+
begin
|
87
|
+
if args.first[/(\w{8}(-\w{4}){3}-\w{12}?)/]
|
88
|
+
id = args.first
|
89
|
+
else
|
90
|
+
instance = Civo::Instance.all.detect {|i| i.hostname == args.first}
|
91
|
+
id = instance.id
|
92
|
+
end
|
93
|
+
instance = Civo::Instance.upgrade(id: id, size: options.size)
|
94
|
+
if instance.result == "ok"
|
95
|
+
puts "Instance '#{args.first}' is being upgraded to #{options.size}."
|
96
|
+
else
|
97
|
+
puts "Failed to upgrade that instance: #{instance.inspect}"
|
98
|
+
end
|
99
|
+
rescue Flexirest::HTTPUnauthorisedClientException, Flexirest::HTTPForbiddenClientException
|
100
|
+
puts "Access denied to your default token, ensure it's set correctly with 'civo tokens'"
|
101
|
+
rescue Flexirest::HTTPNotFoundClientException => e
|
102
|
+
puts "Couldn't find that account to remove, maybe it's already been removed?"
|
103
|
+
rescue Flexirest::HTTPServerException => e
|
104
|
+
puts "Unable to remove #{e.result.reason}"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
alias_command "instance:upgrade", "instances:upgrade"
|
109
|
+
alias_command "instances:resize", "instances:upgrade"
|
110
|
+
alias_command "instance:resize", "instances:upgrade"
|
111
|
+
|
112
|
+
command "instances:reboot" do |c|
|
113
|
+
c.description = "Reboot an instance by hostname or id"
|
114
|
+
c.example "Reboot an instance called 'test.example.com'", 'civo instances:reboot test.example.com'
|
115
|
+
c.action do |args, options|
|
116
|
+
begin
|
117
|
+
if args.first[/(\w{8}(-\w{4}){3}-\w{12}?)/]
|
118
|
+
id = args.first
|
119
|
+
else
|
120
|
+
instance = Civo::Instance.all.detect {|i| i.hostname == args.first}
|
121
|
+
id = instance.id
|
122
|
+
end
|
123
|
+
instance = Civo::Instance.reboot(id: id)
|
124
|
+
if instance.result == "ok"
|
125
|
+
puts "Instance '#{args.first}' is being rebooted."
|
126
|
+
else
|
127
|
+
puts "Failed to reboot that instance: #{instance.inspect}"
|
128
|
+
end
|
129
|
+
rescue Flexirest::HTTPUnauthorisedClientException, Flexirest::HTTPForbiddenClientException
|
130
|
+
puts "Access denied to your default token, ensure it's set correctly with 'civo tokens'"
|
131
|
+
rescue Flexirest::HTTPNotFoundClientException => e
|
132
|
+
puts "Couldn't find that account to remove, maybe it's already been removed?"
|
133
|
+
rescue Flexirest::HTTPServerException => e
|
134
|
+
puts "Unable to remove #{e.result.reason}"
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
alias_command "instance:reboot", "instances:reboot"
|
139
|
+
alias_command "instances:restart", "instances:reboot"
|
140
|
+
alias_command "instance:restart", "instances:reboot"
|
data/lib/civo/version.rb
CHANGED