civo_cli 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/Gemfile.lock +1 -1
- data/README.md +2 -0
- data/lib/blueprint.rb +4 -4
- data/lib/civo_cli/version.rb +1 -1
- data/lib/instance.rb +14 -36
- data/lib/kubernetes.rb +6 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d861f11c17a9e24b51e0853bf40c4953f9a1aa45af1b7722f922d197bbeee969
|
4
|
+
data.tar.gz: 7edd364cba9bebb15b74dfffff2ca5e23008599486e0b1b7f2345220b052cc60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc8151061ee863bef860070924feef1c8b740cd15269510020f62cf7335ad5d6543d2624f056698cf9c2ca9b014808613c77285278d39dcdfc104636585c6e4d
|
7
|
+
data.tar.gz: f08fe71cfb4fe4d892ace4caff14337fc4f1af0090fa23321db7892715e60804235011a2974fc9d85a285fcda9cd4ddbc462727c16e74c70c94143690347885b
|
data/CHANGELOG.md
CHANGED
@@ -3,7 +3,11 @@ All notable changes to the Civo CLI will be documented in this file.
|
|
3
3
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
5
5
|
|
6
|
-
## [0.2.
|
6
|
+
## [0.2.6] - 2019-07-04
|
7
|
+
### Fixed
|
8
|
+
- Slightly badly named method caused confusion, clarified by renaming the method and correcting usage of it
|
9
|
+
|
10
|
+
## [0.2.5] - 2019-07-04
|
7
11
|
### Added
|
8
12
|
- Added support for using part of an ID instead of a whole ID
|
9
13
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
## Introduction
|
4
4
|
Civo CLI is a tool to manage your [Civo.com](https://www.civo.com) account from the terminal. The [Civo web control panel](https://www.civo.com/account/) has a user-friendly interface for managing your account, but in case you want to automate or run scripts on your account, or have multiple complex services, the command-line interface outlined here will be useful. This guide will cover the set-up and usage of the Civo CLI tool with examples.
|
5
5
|
|
6
|
+
**STATUS:** This project is currently under active development and maintainance.
|
7
|
+
|
6
8
|
## Table of contents
|
7
9
|
- [Introduction](#introduction)
|
8
10
|
- [Set-Up](#set-up)
|
data/lib/blueprint.rb
CHANGED
@@ -19,7 +19,7 @@ module CivoCLI
|
|
19
19
|
desc "show ID", "show the details for a single blueprint"
|
20
20
|
def show(id)
|
21
21
|
CivoCLI::Config.set_api_auth
|
22
|
-
blueprint =
|
22
|
+
blueprint = detect_blueprint(id)
|
23
23
|
puts " ID : #{blueprint.id}"
|
24
24
|
puts " Name : #{blueprint.name}"
|
25
25
|
puts " Template ID : #{blueprint.template_id}"
|
@@ -45,7 +45,7 @@ module CivoCLI
|
|
45
45
|
desc "update ID", "update the blueprint with ID"
|
46
46
|
def update(id)
|
47
47
|
CivoCLI::Config.set_api_auth
|
48
|
-
params = {id:
|
48
|
+
params = {id: detect_blueprint(id).id}
|
49
49
|
params[:dsl_content] = File.read(options["content-file"]) unless options["content-file"].nil?
|
50
50
|
params[:template_id] = options["template-id"] unless options["template-id"].nil?
|
51
51
|
params[:name] = options["name"] unless options["name"].nil?
|
@@ -86,7 +86,7 @@ module CivoCLI
|
|
86
86
|
desc "remove ID", "remove the blueprint with ID"
|
87
87
|
def remove(id)
|
88
88
|
CivoCLI::Config.set_api_auth
|
89
|
-
Civo::Blueprint.remove(
|
89
|
+
Civo::Blueprint.remove(detect_blueprint(id))
|
90
90
|
rescue Flexirest::HTTPForbiddenClientException => e
|
91
91
|
puts "Sorry, you don't have access to this feature".colorize(:red)
|
92
92
|
exit 1
|
@@ -100,7 +100,7 @@ module CivoCLI
|
|
100
100
|
|
101
101
|
private
|
102
102
|
|
103
|
-
def
|
103
|
+
def detect_blueprint(id)
|
104
104
|
result = []
|
105
105
|
Civo::Blueprint.all.items.each do |blueprint|
|
106
106
|
result << blueprint
|
data/lib/civo_cli/version.rb
CHANGED
data/lib/instance.rb
CHANGED
@@ -15,9 +15,8 @@ module CivoCLI
|
|
15
15
|
if CivoCLI::Config.get_meta("admin")
|
16
16
|
desc "high-cpu", "list high CPU using instances"
|
17
17
|
def high_cpu
|
18
|
-
# {ENV["CIVO_API_VERSION"] || "1"}/instances/high_cpu"
|
19
18
|
CivoCLI::Config.set_api_auth
|
20
|
-
instance =
|
19
|
+
instance = detect_instance(id)
|
21
20
|
|
22
21
|
Civo::Instance.high_cpu
|
23
22
|
end
|
@@ -25,10 +24,9 @@ module CivoCLI
|
|
25
24
|
|
26
25
|
desc "show ID/HOSTNAME", "show an instance by ID or hostname"
|
27
26
|
def show(id)
|
28
|
-
# {ENV["CIVO_API_VERSION"] || "1"}/instances/:id", requires: [:id]
|
29
27
|
CivoCLI::Config.set_api_auth
|
30
28
|
rows = []
|
31
|
-
instance =
|
29
|
+
instance = detect_instance(id)
|
32
30
|
|
33
31
|
sizes = Civo::Size.all(all: true).items
|
34
32
|
ssh_keys = Civo::SshKey.all.items
|
@@ -141,7 +139,7 @@ module CivoCLI
|
|
141
139
|
desc "tags ID/HOSTNAME 'tag1 tag2 tag3...'", "retag instance by ID (input no tags to clear all tags)"
|
142
140
|
def tags(id, newtags = nil)
|
143
141
|
CivoCLI::Config.set_api_auth
|
144
|
-
instance =
|
142
|
+
instance = detect_instance(id)
|
145
143
|
|
146
144
|
Civo::Instance.tags(id: instance.id, tags: newtags)
|
147
145
|
puts "Updated tags on #{instance.hostname.colorize(:green)}. Use 'civo instance show #{instance.hostname}' to see the current tags.'"
|
@@ -151,7 +149,6 @@ module CivoCLI
|
|
151
149
|
end
|
152
150
|
|
153
151
|
desc "update ID/HOSTNAME [--name] [--notes]", "update details of instance"
|
154
|
-
|
155
152
|
option :name
|
156
153
|
option :notes
|
157
154
|
long_desc <<-LONGDESC
|
@@ -159,7 +156,7 @@ module CivoCLI
|
|
159
156
|
LONGDESC
|
160
157
|
def update(id)
|
161
158
|
CivoCLI::Config.set_api_auth
|
162
|
-
instance =
|
159
|
+
instance = detect_instance(id)
|
163
160
|
|
164
161
|
if options[:name]
|
165
162
|
Civo::Instance.update(id: instance.id, hostname: options[:name])
|
@@ -176,9 +173,8 @@ module CivoCLI
|
|
176
173
|
|
177
174
|
desc "remove ID/HOSTNAME", "removes an instance with ID/hostname entered (use with caution!)"
|
178
175
|
def remove(id)
|
179
|
-
# {ENV["CIVO_API_VERSION"] || "1"}/instances/:id", requires: [:id], send_delete_body: true
|
180
176
|
CivoCLI::Config.set_api_auth
|
181
|
-
instance =
|
177
|
+
instance = detect_instance(id)
|
182
178
|
|
183
179
|
puts "Removing instance #{instance.hostname.colorize(:red)}"
|
184
180
|
instance.remove
|
@@ -190,10 +186,9 @@ module CivoCLI
|
|
190
186
|
|
191
187
|
desc "reboot ID/HOSTNAME", "reboots instance with ID/hostname entered"
|
192
188
|
def reboot(id)
|
193
|
-
# {ENV["CIVO_API_VERSION"] || "1"}/instances/:id/reboots", requires: [:id]
|
194
189
|
CivoCLI::Config.set_api_auth
|
195
190
|
|
196
|
-
instance =
|
191
|
+
instance = detect_instance(id)
|
197
192
|
puts "Rebooting #{instance.hostname.colorize(:red)}. Use 'civo instance show #{instance.hostname}' to see the current status."
|
198
193
|
instance.reboot
|
199
194
|
rescue Flexirest::HTTPException => e
|
@@ -204,10 +199,9 @@ module CivoCLI
|
|
204
199
|
|
205
200
|
desc "soft-reboot ID/HOSTNAME", "soft-reboots instance with ID entered"
|
206
201
|
def soft_reboot(id)
|
207
|
-
# {ENV["CIVO_API_VERSION"] || "1"}/instances/:id/soft_reboots", requires: [:id]
|
208
202
|
CivoCLI::Config.set_api_auth
|
209
203
|
|
210
|
-
instance =
|
204
|
+
instance = detect_instance(id)
|
211
205
|
puts "Soft-rebooting #{instance.hostname.colorize(:red)}. Use 'civo instance show #{instance.hostname}' to see the current status."
|
212
206
|
instance.soft_reboot
|
213
207
|
rescue Flexirest::HTTPException => e
|
@@ -217,9 +211,8 @@ module CivoCLI
|
|
217
211
|
|
218
212
|
desc "console ID/HOSTNAME", "outputs a URL for a web-based console for instance with ID provided"
|
219
213
|
def console(id)
|
220
|
-
# {ENV["CIVO_API_VERSION"] || "1"}/instances/:id/console", requires: [:id]
|
221
214
|
CivoCLI::Config.set_api_auth
|
222
|
-
instance =
|
215
|
+
instance = detect_instance(id)
|
223
216
|
puts "Access #{instance.hostname.colorize(:green)} at #{instance.console.url}"
|
224
217
|
rescue Flexirest::HTTPException => e
|
225
218
|
puts e.result.reason.colorize(:red)
|
@@ -228,9 +221,8 @@ module CivoCLI
|
|
228
221
|
|
229
222
|
desc "stop ID/HOSTNAME", "shuts down the instance with ID provided"
|
230
223
|
def stop(id)
|
231
|
-
# {ENV["CIVO_API_VERSION"] || "1"}/instances/:id/stop", requires: [:id]
|
232
224
|
CivoCLI::Config.set_api_auth
|
233
|
-
instance =
|
225
|
+
instance = detect_instance(id)
|
234
226
|
puts "Stopping #{instance.hostname.colorize(:red)}. Use 'civo instance show #{instance.hostname}' to see the current status."
|
235
227
|
Civo::Instance.stop(id: instance.id)
|
236
228
|
rescue Flexirest::HTTPException => e
|
@@ -240,10 +232,9 @@ module CivoCLI
|
|
240
232
|
|
241
233
|
desc "start ID/HOSTNAME", "starts a stopped instance with ID provided"
|
242
234
|
def start(id)
|
243
|
-
# {ENV["CIVO_API_VERSION"] || "1"}/instances/:id/start", requires: [:id]
|
244
235
|
CivoCLI::Config.set_api_auth
|
245
236
|
|
246
|
-
instance =
|
237
|
+
instance = detect_instance(id)
|
247
238
|
puts "Starting #{instance.hostname.colorize(:green)}. Use 'civo instance show #{instance.hostname}' to see the current status."
|
248
239
|
instance.start
|
249
240
|
rescue Flexirest::HTTPException => e
|
@@ -253,10 +244,9 @@ module CivoCLI
|
|
253
244
|
|
254
245
|
desc "upgrade ID/HOSTNAME new-size", "Upgrade instance with ID to size provided (see civo sizes for size names)"
|
255
246
|
def upgrade(id, new_size)
|
256
|
-
# {ENV["CIVO_API_VERSION"] || "1"}/instances/:id/resize", requires: [:size, :id]
|
257
247
|
CivoCLI::Config.set_api_auth
|
258
248
|
|
259
|
-
instance =
|
249
|
+
instance = detect_instance(id)
|
260
250
|
|
261
251
|
Civo::Instance.upgrade(id: instance.id, size: new_size)
|
262
252
|
puts "Resizing #{instance.hostname.colorize(:green)} to #{new_size.colorize(:red)}. Use 'civo instance show #{instance.hostname}' to see the current status."
|
@@ -267,10 +257,9 @@ module CivoCLI
|
|
267
257
|
|
268
258
|
desc "move-ip ID/HOSTNAME IP_Address", "move a public IP_Address to target instance"
|
269
259
|
def move_ip(id, ip_address)
|
270
|
-
# {ENV["CIVO_API_VERSION"] || "1"}/instances/:id/ip/:ip", requires: [:ip, :id]
|
271
260
|
CivoCLI::Config.set_api_auth
|
272
261
|
|
273
|
-
instance =
|
262
|
+
instance = detect_instance(id)
|
274
263
|
|
275
264
|
Civo::Instance.move_ip(id: instance.id, ip: ip_address)
|
276
265
|
puts "Moved public IP #{ip_address} to instance #{instance.hostname}"
|
@@ -279,22 +268,11 @@ module CivoCLI
|
|
279
268
|
exit 1
|
280
269
|
end
|
281
270
|
|
282
|
-
# desc "", ""
|
283
|
-
# def rescue
|
284
|
-
# # {ENV["CIVO_API_VERSION"] || "1"}/instances/:id/rescue", requires: [:id]
|
285
|
-
# end
|
286
|
-
|
287
|
-
# desc "", ""
|
288
|
-
# def unrescue
|
289
|
-
# # {ENV["CIVO_API_VERSION"] || "1"}/instances/:id/unrescue", requires: [:id]
|
290
|
-
# end
|
291
|
-
|
292
271
|
desc "firewall ID/HOSTNAME firewall_id", "set instance with ID/HOSTNAME to use firewall with firewall_id"
|
293
272
|
def firewall(id, firewall_id)
|
294
|
-
# {ENV["CIVO_API_VERSION"] || "1"}/instances/:id/firewall", requires: [:firewall_id, :id]
|
295
273
|
CivoCLI::Config.set_api_auth
|
296
274
|
|
297
|
-
instance =
|
275
|
+
instance = detect_instance(id)
|
298
276
|
|
299
277
|
Civo::Instance.firewall(id: instance.id, firewall_id: firewall_id)
|
300
278
|
puts "Set #{instance.hostname.colorize(:green)} to use firewall '#{firewall_id.colorize(:yellow)}'"
|
@@ -307,7 +285,7 @@ module CivoCLI
|
|
307
285
|
|
308
286
|
private
|
309
287
|
|
310
|
-
def
|
288
|
+
def detect_instance(id)
|
311
289
|
result = []
|
312
290
|
Civo::Instance.all.items.each do |instance|
|
313
291
|
result << instance
|
data/lib/kubernetes.rb
CHANGED
@@ -16,7 +16,7 @@ module CivoCLI
|
|
16
16
|
def show(id)
|
17
17
|
CivoCLI::Config.set_api_auth
|
18
18
|
rows = []
|
19
|
-
cluster =
|
19
|
+
cluster = detect_cluster(id)
|
20
20
|
|
21
21
|
puts " ID : #{cluster.id}"
|
22
22
|
puts " Name : #{cluster.name}"
|
@@ -48,7 +48,7 @@ module CivoCLI
|
|
48
48
|
def config(id)
|
49
49
|
CivoCLI::Config.set_api_auth
|
50
50
|
rows = []
|
51
|
-
cluster =
|
51
|
+
cluster = detect_cluster(id)
|
52
52
|
puts cluster.kubeconfig
|
53
53
|
rescue Flexirest::HTTPException => e
|
54
54
|
puts e.result.reason.colorize(:red)
|
@@ -98,7 +98,7 @@ module CivoCLI
|
|
98
98
|
LONGDESC
|
99
99
|
def rename(id)
|
100
100
|
CivoCLI::Config.set_api_auth
|
101
|
-
cluster =
|
101
|
+
cluster = detect_cluster(id)
|
102
102
|
|
103
103
|
if options[:name]
|
104
104
|
Civo::Kubernetes.update(id: cluster.id, name: options[:name])
|
@@ -116,7 +116,7 @@ module CivoCLI
|
|
116
116
|
LONGDESC
|
117
117
|
def scale(id)
|
118
118
|
CivoCLI::Config.set_api_auth
|
119
|
-
cluster =
|
119
|
+
cluster = detect_cluster(id)
|
120
120
|
|
121
121
|
if options[:nodes]
|
122
122
|
Civo::Kubernetes.update(id: cluster.id, num_target_nodes: options[:nodes])
|
@@ -131,7 +131,7 @@ module CivoCLI
|
|
131
131
|
desc "remove ID/NAME", "removes an entire Kubernetes cluster with ID/name entered (use with caution!)"
|
132
132
|
def remove(id)
|
133
133
|
CivoCLI::Config.set_api_auth
|
134
|
-
cluster =
|
134
|
+
cluster = detect_cluster(id)
|
135
135
|
|
136
136
|
puts "Removing Kubernetes cluster #{cluster.name.colorize(:red)}"
|
137
137
|
cluster.remove
|
@@ -145,7 +145,7 @@ module CivoCLI
|
|
145
145
|
|
146
146
|
private
|
147
147
|
|
148
|
-
def
|
148
|
+
def detect_cluster(id)
|
149
149
|
result = []
|
150
150
|
Civo::Kubernetes.all.items.each do |cluster|
|
151
151
|
result << cluster
|