civo_cli 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f889f67630dde4f1c1a12f95dbeb7a907bdd076c6a2bfa188cbe16ee6239aad
4
- data.tar.gz: d14bf6d4b0f78ab145a59a5410d789b5f17a0ea2880426ce41dd44b86ec08914
3
+ metadata.gz: dc18131d19cedfa2820c3e95fe1d4ac11ef445fc7ff7d135e66c36b44a99642d
4
+ data.tar.gz: d5f5db7e0f7b09be339f35cbfa455be3e6cd0cc87cced3879aefb74847c3f2b2
5
5
  SHA512:
6
- metadata.gz: f1aa979054fb618830f244f2f8bda5bfcc8ec4344d202a2a31d4b0fba8689bc75075c4c2941763515d706b4d74eee9ca8c95215c9d02f7a94239bfe33ab2ce1f
7
- data.tar.gz: 94761e3c35048cd897f3ea6bd1a1d49a5f1fed3bf8b4fa33940715fea1cf7e4a6a38d49ded4f03053a36377d89a387fbdadbacce9693d941fad5ebb20b1c1788
6
+ metadata.gz: 79a321b15fc1ad58970324a440621f9ff035cfeec8429a152bc79a6fee82554423d2b6b523b118908ea43b3e74c4511fcad682768c0500f1be9169b8c33c3e26
7
+ data.tar.gz: d08124c5e75a90fc7c0401e62968f6da4683b4522134dcf50296ac7510b585bd25630eb8951a299dfc066fb56bace00dacdb29bc1d09650d14f3307c45a12b47
data/CHANGELOG.md CHANGED
@@ -3,10 +3,18 @@ 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.2] - 2019-06.19
6
+ ## [0.2.3] - 2019-06-21
7
+ ### Added
8
+ - Instance name generator
9
+ - Ability to start instances with default options and generated name
10
+
11
+ ### Changed
12
+ - README.md to reflect new scope of commands and abilities
13
+ - Help texts in instance methods to display long descriptions where appropriate
14
+
15
+ ## [0.2.2] - 2019-06-19
7
16
  ### Fixes
8
- - Fixes .json file check and removes file check at runtime ("if __FILE__ == $0
9
- ").
17
+ - Fixes .json file check and removes file check at runtime ("if __FILE__ == $0").
10
18
 
11
19
  ## [0.2.1] - 2019-06-19
12
20
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- civo_cli (0.2.2)
4
+ civo_cli (0.2.3)
5
5
  civo (>= 1.1.14)
6
6
  colorize
7
7
  json
@@ -33,7 +33,7 @@ GEM
33
33
  faraday (0.15.4)
34
34
  multipart-post (>= 1.2, < 3)
35
35
  ffi (1.10.0)
36
- flexirest (1.7.7)
36
+ flexirest (1.7.8)
37
37
  activesupport
38
38
  crack
39
39
  faraday
@@ -105,7 +105,7 @@ GEM
105
105
  parslet (~> 1.8.0)
106
106
  tzinfo (1.2.5)
107
107
  thread_safe (~> 0.1)
108
- unicode-display_width (1.4.1)
108
+ unicode-display_width (1.6.0)
109
109
  webmock (3.5.1)
110
110
  addressable (>= 2.3.6)
111
111
  crack (>= 0.3.2)
data/README.md CHANGED
@@ -1,201 +1,620 @@
1
1
  # Civo Command-Line Client
2
2
 
3
- This utility is for interacting with the Civo Cloud API provided on Civo.com. In order to use the API you need an API key, which is available when you're logged in to Civo.com at https://www.civo.com/api.
3
+ ## Introduction
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
+
6
+ ## Table of contents
7
+ - [Introduction](#introduction)
8
+ - [Set-Up](#set-up)
9
+ - [API Keys](#api-keys)
10
+ - [Instances](#instances)
11
+ - [Domains and Domain Records](#domains-and-domain-records)
12
+ - [Firewalls](#firewalls)
13
+ - [Networks](#networks)
14
+ - [Quota](#quota)
15
+ - [Sizes](#sizes)
16
+ - [Snapshots](#snapshots)
17
+ - [SSH Keys](#ssh-keys)
18
+ - [Templates](#templates)
19
+ - [Volumes](#volumes)
20
+ - [Development](#development)
21
+ - [Contributing](#contributing)
22
+ - [License](#license)
4
23
 
5
- ## Installation/overview
24
+ ## Set-up
25
+ Civo CLI is built with Ruby and distributed as a Gem. If you have Ruby (2.0.0 or later) installed, you can simply run `gem install civo_cli` in your terminal to get the gem and its dependencies.
6
26
 
7
- The first step should be to download the client. This is simply done using:
27
+ If you need to install Ruby, follow the installation instructions appropriate for your operating system, and return to this guide after you have successfully installed the gem.
8
28
 
9
- ```
10
- gem install civo_cli
11
- ```
29
+ - [Microsoft Windows](https://rubyinstaller.org/)
30
+ - [Mac OS](https://www.ruby-lang.org/en/documentation/installation/#homebrew)
31
+ - [UNIX/Linux](https://www.ruby-lang.org/en/documentation/installation/#package-management-systems)
12
32
 
13
- You'll then need to run a command in a Terminal to register your API key with the client. Let's take the example that your company is called "Acme Widgets" and your API key is "123456789012345678901234567890". You need to give the API key a short reference when saving it, such as `acme` (because you can register multiple API keys for different accounts in the same client):
14
-
15
- ```
16
- civo apikeys save -n acme -k 123456789012345678901234567890
17
- ```
18
33
 
19
- You will then need to set this as your default apikey to be used in all future requests with:
34
+ You will also, of course, need a Civo account, for which you can [register here](https://www.civo.com/signup).
20
35
 
21
- ```
22
- civo apikeys default -n acme
23
- ```
36
+ To run the tool, simply run `civo` with your chosen options. You can find context-sensitive help for commands and their options by invoking the `help` command:
37
+ `civo help`,
38
+ `civo instance help`,
39
+ `civo instance help create`
40
+ and so on. The main components of Civo CLI are outlined in the following sections.
24
41
 
25
- Now you are free to use the remaining commands in the system. We'll work through the most common ones below, the rest are normally used by Civo administrators (and the permission levels associated with your apikey in CIvo won't allow you to make them).
42
+ ## API Keys
43
+ #### Introduction
44
+ In order to use the command-line tool, you will need to authenticate yourself to the Civo API using a special key. You can find an automatically-generated API key or regenerate a new key at [https://www.civo.com/api](https://www.civo.com/api).
26
45
 
27
- In order to discover the available commands you can use `civo -h` to list the available commands, then use `civo [command] -h` to list sub commands and so on further down the line. For example:
46
+ #### Adding a current API Key to your account
47
+ You can add the API Key to the CLI tool through the API Keys command.
48
+ `civo apikey add apikey_name apikey` such as:
28
49
 
29
50
  ```
30
- civo -h
31
- civo instances -h
32
- civo instances create -h
51
+ $ civo apikey add Demo_Test_Key DAb75oyqVeaE7BI6Aa74FaRSP0E2tMZXkDWLC9wNQdcpGfH51r
52
+ Saved the API Key DAb75oyqVeaE7BI6Aa74FaRSP0E2tMZXkDWLC9wNQdcpGfH51r as Demo_Test_Key
53
+ ```
54
+ As you can have multiple API keys stored to handle multiple accounts, you will need to tell which key the tool is to authenticate with `civo apikey current [apikey_name]`. This sets your chosen API key as the default key to use for any subsequent commands:
33
55
  ```
56
+ $ civo apikey current Demo_Test_Key
57
+ The current API Key is now Demo_Test_Key
58
+ ```
59
+ #### Managing and listing API keys
60
+ You can list all stored API keys in your configuration by invoking `civo apikey list` or remove one by name by using `civo apikey remove apikey_name`.
61
+
62
+ ## Instances
63
+ #### Introduction
64
+ An instance is a virtual server running on the Civo cloud platform. They can be of variable size and you can run any number of them up to your quota on your account.
34
65
 
35
- In this way all the possible things you can do with the client are discoverable.
66
+ #### Creating an instance
67
+ You can create an instance by running `civo instance create` with a hostname parameter, as well as any options you provide:
36
68
 
69
+ * `hostname` is a fully qualified domain name that should be set as the instance's hostname. The client will generate a random name if not provided.
70
+ * `size` - The size of instance to create, from the current list of sizes (e.g. g2.small) available at [`civo sizes`](#sizes). Defaults to `g2.small`.
71
+ * `template` - The OS template UUID to use, from the available list at [`civo templates`](#templates) Defaults to Ubuntu 18.04 if no `template` value or `snapshot` provided.
72
+ * `snapshot` - The snapshot UUID to use, from snapshots you have saved on your account. Only required if `template` ID not provided.
73
+ * `region` - The region code identifier to have your instance built in. Optional; will be assigned randomly if not provided.
74
+ * `public_ip` - this should be either `none`, `create` or `from`. If `from` is specified then the `move_ip_from`parameter should also be specified (and contain the ID of the instance that will be releasing its IP). As aliases, `true` will be treated the same as `create` and `false` will be treated the same as `none`. If `create` or `true` is specified it will automatically allocate an initial public IP address, rather than having to add the first one later. Optional; default is `create`.
75
+ * `initial_user` - The name of the initial user created on the server. If not provided, will default to the template's `default_username` and fallback to `civo`.
76
+ * `ssh_key_id` - The ID of an already [uploaded SSH public key](#ssh-keys) to use for login to the default user. Optional; if one isn't provided a random password will be set and returned in the `initial_password` field.
77
+ * `tags` - A space-separated list of tags in `'quotation marks'` to be used freely as required. Optional.
37
78
 
38
- ## SSH keys
79
+ Example usage:
80
+ ```
81
+ $ civo instance create api-demo.test --size g2.small --template=811a8dfb-8202-49ad-b1ef-1e6320b20497 --initial_user=demo-user
82
+ Created instance api-demo.test
39
83
 
40
- One of the first things you'll likely want to do is upload your SSH public key, so that you can SSH in to new instances - you can't create a new instance without this step.
84
+ $ civo instance show api-demo.test
85
+ ID : 715f95d1-3cee-4a3c-8759-f9b49eec34c4
86
+ Hostname : api-demo.test
87
+ Tags :
88
+ Size : Small - 2GB RAM, 1 CPU Core, 25GB SSD Disk
89
+ Status : ACTIVE
90
+ Private IP : 10.250.199.4
91
+ Public IP : 172.31.2.164 => 91.211.152.100
92
+ Network : Default (10.250.199.0/24)
93
+ Firewall : (rules: )
94
+ Region : lon1
95
+ Initial User : api-demouser
96
+ Initial Password : [randomly-assigned-password-here]
97
+ OpenStack ID : 7c89f7de-2b29-4178-a2e5-55bdaa5c4c21
98
+ Template ID : 811a8dfb-8202-49ad-b1ef-1e6320b20497
99
+ Snapshot ID :
100
+
101
+ ----------------------------- NOTES -----------------------------
102
+
103
+
104
+ ```
41
105
 
42
- Assuming your public key is in `~/.ssh/id_rsa.pub` (if it isn't, you'll probably know why and where it is) you can upload this with:
106
+ You will be able to see the instance's details by running `civo instance show api-demo.test` as above.
43
107
 
108
+ #### Setting Firewalls
109
+ Instances can make use of separately-configured firewalls. By default, an instance is created with no firewall rules set, so you will need to configure some rules (see [Firewalls](#firewalls) for more information).
110
+
111
+ To associate a firewall with an instance, use the command `civo instance firewall ID/hostname firewall_id`. For example:
44
112
  ```
45
- civo sshkey upload --name default --public-key ~/.ssh/id_rsa.pub
113
+ $ civo instance firewall api-demo.test firewall_1
114
+ Set api-demo.test to use firewall firewall_1
46
115
  ```
47
116
 
48
- If you want to remove a public key (say you are replacing it with a new one), you can do this with:
117
+ #### Listing Instances
118
+ You can list all instances associated with a particular API key by running `civo instance list`.
49
119
 
120
+ #### Moving a Public IP Between Instances
121
+ Given two instances, one with a public IP and one without, you can move the public IP by `civo instance move_ip instance ip_address`:
122
+ ```
123
+ $ civo instance move_ip cli-private-ip-demo.test 123.234.123.255`
124
+ Moved public IP 123.234.123.255 to instance cli-private-ip-demo.test
50
125
  ```
51
- civo sshkey delete --name default
126
+ #### Rebooting/Restarting Instances
127
+ A user can reboot an instance at any time, for example to fix a crashed piece of software. Simply run `civo instance reboot instanceID/hostname`. You will see a confirmation message:
128
+ ```
129
+ $ civo instance reboot api-demo.test
130
+ Rebooting api-demo.test. Use 'civo instance show api-demo.test' to see the current status.
52
131
  ```
53
132
 
54
- **Note:** This won't remove it from your currently running instances, it will only affect new instances created.
133
+ If you prefer a soft reboot, you can run `civo instance soft_reboot instanceID/hostname` instead.
134
+
135
+ #### Removing Instances
136
+ You can use a command to remove an instance from your account. This is immediate, so use with caution! Any snapshots taken of the instance, as well as any mapped storage, will remain.
137
+ Usage: `civo instance remove instanceID/hostname`. For example:
138
+ ```
139
+ $ civo instance remove api-demo.test
140
+ Removing instance api-demo.test
141
+ ```
142
+ #### Stopping (Shutting Down) and Starting Instances
143
+ You can shut down an instance at any time by running `civo instance stop instanceID/hostname`:
55
144
 
145
+ ```
146
+ $ civo instance stop api-demo.test
147
+ Stopping api-demo.test. Use 'civo instance show api-demo.test' to see the current status.
148
+ ```
149
+ Any shut-down instance on your account can be powered back up with `civo instance start instanceID/hostname`:
150
+ ```
151
+ $ civo instance start api-demo.test
152
+ Starting api-demo.test. Use 'civo instance show api-demo.test' to see the current status.
153
+ ```
154
+ #### (Re)Tagging an Instance
155
+ Tags can be useful in distinguishing and managing your instances. You can retag an instance using `civo instance tags instanceID/hostname 'tag1 tag2 tag3...'` as follows:
156
+ ```
157
+ $ civo instance tags api-demo.test 'ubuntu demo web'
158
+ Updated tags on api-demo.test. Use 'civo instance show api-demo.test' to see the current tags.'
159
+ $ civo instance show api-demo.test
160
+ ID : 715f95d1-3cee-4a3c-8759-f9b49eec34c4
161
+ Hostname : api-demo.test
162
+ Tags : ubuntu, demo, web
163
+ Size : Small - 2GB RAM, 1 CPU Core, 25GB SSD Disk
164
+ Status : ACTIVE
165
+ Private IP : 10.250.199.4
166
+ Public IP : 172.31.2.164 => 91.211.152.100
167
+ Network : Default (10.250.199.0/24)
168
+ Firewall : (rules: )
169
+ Region : lon1
170
+ Initial User : api-demouser
171
+ Initial Password : [randomly-assigned-password-here]
172
+ OpenStack ID : 7c89f7de-2b29-4178-a2e5-55bdaa5c4c21
173
+ Template ID : 811a8dfb-8202-49ad-b1ef-1e6320b20497
174
+ Snapshot ID :
56
175
 
57
- ## Choosing the specification of an instance
58
- When creating an instance, you'll need to specify items such as the size of instance, which region to create it in (if your provider supports multiple regions) and the template to use (from the available operating systems, versions and layered applications).
176
+ ----------------------------- NOTES -----------------------------
177
+ ```
178
+ #### Updating Instance Information
179
+ In case you need to rename an instance or add notes, you can do so with the `instance update` command as follows:
180
+ ```
181
+ $ civo instance update api-demo.test --name api-demo-renamed.test --notes 'Hello, world!'
182
+ Instance 715f95d1-3cee-4a3c-8759-f9b49eec34c4 now named api-demo-renamed.test
183
+ Instance 715f95d1-3cee-4a3c-8759-f9b49eec34c4 notes are now: Hello, world!
184
+ $ civo instance show api-demo-renamed.test
185
+ ID : 715f95d1-3cee-4a3c-8759-f9b49eec34c4
186
+ Hostname : api-demo-renamed.test
187
+ Tags : ubuntu, demo, web
188
+ Size : Small - 2GB RAM, 1 CPU Core, 25GB SSD Disk
189
+ Status : ACTIVE
190
+ Private IP : 10.250.199.4
191
+ Public IP : 172.31.2.164 => 91.211.152.100
192
+ Network : Default (10.250.199.0/24)
193
+ Firewall : (rules: )
194
+ Region : lon1
195
+ Initial User : api-demouser
196
+ Initial Password : [randomly-assigned-password-here]
197
+ OpenStack ID : 7c89f7de-2b29-4178-a2e5-55bdaa5c4c21
198
+ Template ID : 811a8dfb-8202-49ad-b1ef-1e6320b20497
199
+ Snapshot ID :
59
200
 
60
- The information on all of these are available by running `civo size`, `civo region` and `civo template`. The output of the command will give you the key to use when creating the instance. For example (and these are subject to change):
201
+ ----------------------------- NOTES -----------------------------
61
202
 
203
+ Hello, world!
62
204
  ```
63
- $ civo size
64
- +-----------+----------------------------------------------------+
65
- | Name | Specification |
66
- +-----------+----------------------------------------------------+
67
- | g1.xsmall | Extra Small - 512MB RAM, 1 CPU Core, 20GB SSD Disk |
68
- | g1.small | Small - 1GB RAM, 2 CPU Cores, 50GB SSD Disk |
69
- | g1.medium | Medium - 2GB RAM, 4 CPU Cores, 100GB SSD Disk |
70
- | g1.large | Large - 4GB RAM, 6 CPU Cores, 150GB SSD Disk |
71
- | g1.xlarge | Extra Large - 8GB RAM, 8 CPU Cores, 200GB SSD Disk |
72
- +-----------+----------------------------------------------------+
205
+ You can leave out either the ``--name`` or `--notes` switch if you only want to update one of the fields.
73
206
 
74
- $ civo template
75
- +--------------------+------------------------------------------------------------------------+
76
- | ID | Description |
77
- +--------------------+------------------------------------------------------------------------+
78
- | centos-7 | CentOS version 7 (RHEL open source clone) |
79
- | ubuntu-14.04-vesta | Canonical's Ubuntu 14.04 with the Vesta Control Panel |
80
- | ubuntu-14.04 | Canonical's Ubuntu 14.04 installed in a minimal configuration |
81
- +--------------------+------------------------------------------------------------------------+
207
+ #### Upgrading (Resizing) an Instance
208
+ Provided you have room in your Civo quota, you can upgrade any instance up in size. You can upgrade an instance by using `civo instance upgrade instanceID/hostname new_size` where `new_size` is from the list of sizes at `civo sizes`:
209
+ ```
210
+ $ civo instance upgrade api-demo-renamed.test g2.medium
211
+ Resizing api-demo-renamed.test to g2.medium. Use 'civo instance show api-demo-renamed.test' to see the current status.
212
+
213
+ $ civo instance show api-demo-renamed.test
214
+ ID : 715f95d1-3cee-4a3c-8759-f9b49eec34c4
215
+ Hostname : api-demo-renamed.test
216
+ Tags : ubuntu, demo, web
217
+ Size : Medium - 4GB RAM, 2 CPU Cores, 50GB SSD Disk
218
+ Status : ACTIVE
219
+ Private IP : 10.250.199.4
220
+ Public IP : 172.31.2.164 => 91.211.152.100
221
+ Network : Default (10.250.199.0/24)
222
+ Firewall : (rules: )
223
+ Region : lon1
224
+ Initial User : api-demouser
225
+ Initial Password : [randomly-assigned-password-here]
226
+ OpenStack ID : 7c89f7de-2b29-4178-a2e5-55bdaa5c4c21
227
+ Template ID : 811a8dfb-8202-49ad-b1ef-1e6320b20497
228
+ Snapshot ID :
229
+
230
+ ----------------------------- NOTES -----------------------------
231
+
232
+ Hello, world!
233
+ ```
234
+ Please note that resizing can take a few minutes.
235
+
236
+ ## Domains and Domain Records
237
+ #### Introduction
238
+ We host reverse DNS for all instances automatically. If you'd like to manage forward (normal) DNS for your domains, you can do that for free within your account.
239
+
240
+ This section is effectively split in to two parts: 1) Managing domain names themselves, and 2) Managing records within those domain names.
241
+
242
+ We don't offer registration of domains names, this is purely for hosting the DNS. If you're looking to buy a domain name, we recommend [LCN.com](https://www.lcn.com/) for their excellent friendly support and very competitive prices.
243
+ #### Set Up a New Domain
244
+ Any user can add a domain name (that has been registered elsewhere) to be managed by Civo.com. You should adjust the nameservers of your domain (through your registrar) to point to `ns0.civo.com` and `ns1.civo.com`.
245
+
246
+ The command to set up a new domain is `civo domain create domainname`:
247
+ ```
248
+ $ civo domain create civoclidemo.xyz
249
+ Created a domain called civoclidemo.xyz with ID 418181b2-fcd2-46a2-ba7f-c843c331e79b
250
+ ```
251
+ You can then proceed to add DNS records to this domain.
252
+
253
+ #### List Domain Namess
254
+ To see your created domains, simply call `civo domain list`:
255
+ ```
256
+ $ civo domain list
257
+ +--------------------------------------+-----------------+
258
+ | ID | Name |
259
+ +--------------------------------------+-----------------+
260
+ | 418181b2-fcd2-46a2-ba7f-c843c331e79b | civoclidemo.xyz |
261
+ +--------------------------------------+-----------------+
262
+ ```
263
+ #### Deleting a Domain
264
+ If you choose to delete a domain, you can call `civo domain remove domain_id` and have the system immediately remove the domain and any associated DNS records. This removal is immediate, so use with caution.
265
+
266
+ #### Creating a DNS Record
267
+ A DNS record creation command takes a number of options in the format `civo domainrecord create record_name type value` with optional `-p` (priority for MX records) and `-t` (time-to-live of record cache, in seconds).
268
+
269
+ `type` is one of the following:
270
+ `a` -> Alias a hostname to an IP address
271
+ `cname` or `canonical` -> Point a hostname to another hostname
272
+ `mx` -> The hostname of a mail server
273
+ `txt` or `text` -> Generic text record
274
+
275
+ Usage is as follows:
276
+ ```
277
+ $ civo domainrecord create civoclidemo.xyz mx 10.0.0.1 -p=10 -t=1000
278
+
279
+ #<Civo::DnsRecord id: "2079e6e1-0633-4cd0-b883-e82a8991a91a", created_at: "2019-06-17 12:38:02", updated_at: "2019-06-17 12:38:02", account_id: nil, domain_id: "418181b2-fcd2-46a2-ba7f-c843c331e79b", name: "@", value: "10.0.0.1", type: "mx", priority: 10, ttl: 1000, ETag: "187cf7e849ce53336a889b2bde7ed061", Status: 200>
280
+ Created MX record civoclidemo.xyz for civoclidemo.xyz with a TTL of 1000 seconds and with a priority of 10 with ID 2079e6e1-0633-4cd0-b883-e82a8991a91a
281
+ ```
282
+ #### Listing DNS Records
283
+ You can get an overview of all records you have created for a particular domain by requesting `civo domainrecord list domain.name`:
284
+ ```
285
+ civo domainrecord list civoclidemo.xyz
286
+ +--------------------------------------+------+-------------------+----------+------+----------+
287
+ | ID | Type | Name | Value | TTL | Priority |
288
+ +--------------------------------------+------+-------------------+----------+------+----------+
289
+ | 2079e6e1-0633-4cd0-b883-e82a8991a91a | MX | @.civoclidemo.xyz | 10.0.0.1 | 1000 | 10 |
290
+ +--------------------------------------+------+-------------------+----------+------+----------+
291
+ ```
292
+ #### Deleting a DNS Record
293
+ You can remove a particular DNS record from a domain you own by requesting `civo domainrecord remove record_id`. This immediately removes the associated record, so use with caution:
294
+ ```
295
+ $ civo domainrecord remove 2079e6e1-0633-4cd0-b883-e82a8991a91a
296
+ Removed the record @ record with ID 2079e6e1-0633-4cd0-b883-e82a8991a91a
82
297
  ```
83
298
 
299
+ ## Firewalls
300
+ #### Introduction
301
+ You can configure custom firewall rules for your instances using the Firewall component of Civo CLI. These are freely configurable, however customers should be careful to not lock out their own access to their instances. By default, all ports are closed for custom firewalls.
84
302
 
85
- ## Managing instances
86
-
87
- To view the list of your currently running instances you can simply run:
303
+ Firewalls can be configured with rules, and they can be made to apply to your chosen instance(s) with subsequent commands.
88
304
 
305
+ #### Configuring a New Firewall
306
+ To create a new Firewall, use `civo firewall create new_firewall_name`:
89
307
  ```
90
- civo instance
308
+ $ civo firewall create civocli_demo
309
+ Created firewall civocli_demo
91
310
  ```
311
+ You will then be able to **configure rules** that allow connections to and from your instance by adding a new rule using `civo firewall new_rule firewall_id` with the required and your choice of optional parameters, listed here and used in an example below:
312
+ * `firewall_id` - The UUID of the firewall you are adding a rule to. Required.
313
+ * `start_port` - The starting port that the rule applies to. Required.
314
+ * `end_port` - The end of the port range that the rule applies to. Optional; if not specified, the rule will only apply to `start_port` specified.
315
+ * `protocol` - The protocol for the rule (`TCP, UDP, ICMP`). If not provided, defaults to `TCP`.
316
+ * `cidr` - The IP address of the other end (i.e. not your instance) to affect, or a valid network CIDR. Defaults to being globally applied, i.e. `0.0.0.0/0`.
317
+ * `direction` - Will this rule affect `inbound` or `outbound` traffic? Defaults to `inbound`.
318
+ * `label` - A label for your own reference for this rule. Optional.
92
319
 
93
- This will output a table listing the instances currently in your account:
320
+ Example usage:
321
+ ```
322
+ $ civo firewall new_rule --firewall_id=09f8d85b-0cf1-4dcf-a472-ba247fb4be21 --start_port=22 --direction=inbound --label='SSH access for CLI demo'
323
+ New rule SSH access for CLI demo created
324
+
325
+ $ civo firewall list_rules 09f8d85b-0cf1-4dcf-a472-ba247fb4be21
326
+ +--------------------------------------+----------+------------+----------+-----------+-------------------------+
327
+ | Firewall rules for 09f8d85b-0cf1-4dcf-a472-ba247fb4be21 |
328
+ +--------------------------------------+----------+------------+----------+-----------+-------------------------+
329
+ | ID | Protocol | Start Port | End Port | CIDR | Label |
330
+ +--------------------------------------+----------+------------+----------+-----------+-------------------------+
331
+ | 4070f87b-e6c6-4208-91c5-fc4bc72c1587 | tcp | 22 | 22 | 0.0.0.0/0 | SSH access for CLI demo |
332
+ +--------------------------------------+----------+------------+----------+-----------+-------------------------+
333
+ ```
334
+ You can see all active rules for a particular firewall by calling `civo firewall list_rules firewall_id`, where `firewall_id` is the UUID of your particular firewall.
94
335
 
336
+ #### Managing Firewalls
337
+ You can see an overview of your firewalls using `civo firewall list` showing you which firewalls have been configured with rules, and whether any of your instances are using a given firewall, such as in this case where the firewall we have just configured has the one rule, but no instances using it.
95
338
  ```
96
- +----------+-------------------+----------+-------------------------------+--------+------+--------------+
97
- | ID | Name | Size | IP Addresses | Status | User | Password |
98
- +----------+-------------------+----------+-------------------------------+--------+------+--------------+
99
- | 8043d0e7 | test1.example.com | g1.small | 10.0.0.2=>31.28.88.103 | ACTIVE | civo | jioAQfSDffFS |
100
- +----------+-------------------+----------+-------------------------------+--------+------+--------------+
339
+ $ civo firewall list
340
+ +--------------------------------------+--------------+--------------+-----------------+
341
+ | ID | Name | No. of Rules | instances using |
342
+ +--------------------------------------+--------------+--------------+-----------------+
343
+ | 09f8d85b-0cf1-4dcf-a472-ba247fb4be21 | civocli_demo | 1 | 0 |
344
+ +--------------------------------------+--------------+--------------+-----------------+
101
345
  ```
346
+ To configure an instance to use a particular firewall, see [Instances/Setting firewalls elsewhere in this guide](#setting-firewalls).
102
347
 
103
- Creating an instance is a simple command away (remember, if you can't remember the parameters `civo instance create -h` is there to help you) using something like:
348
+ To get more detail about the specific rule(s) of a particular firewall, you can use `civo firewall list_rules firewall_id`.
104
349
 
350
+ #### Deleting Firewall Rules and Firewalls
351
+ You can remove a firewall rule simply by calling `civo firewall delete_rule firewall_id rule_id` - confirming the Firewall ID to delete a particular rule from - as follows:
105
352
  ```
106
- civo instance create --name test2.example.com --size g1.small \
107
- --region svg1 --ssh-key-id default --template ubuntu-14.04 --public-ip
353
+ $ civo firewall delete_rule 09f8d85b-0cf1-4dcf-a472-ba247fb4be21 4070f87b-e6c6-4208-91c5-fc4bc72c1587
354
+ Removed Firewall rule 4070f87b-e6c6-4208-91c5-fc4bc72c1587
355
+
356
+ $ civo firewall list_rules 09f8d85b-0cf1-4dcf-a472-ba247fb4be21
357
+ +-------+----------+------------+----------+------+-------+
358
+ | Firewall rules for 09f8d85b-0cf1-4dcf-a472-ba247fb4be21 |
359
+ +-------+----------+------------+----------+------+-------+
360
+ | ID | Protocol | Start Port | End Port | CIDR | Label |
361
+ +-------+----------+------------+----------+------+-------+
362
+ +-------+----------+------------+----------+------+-------+
108
363
  ```
364
+ Similarly, you can delete a firewall itself by calling `civo firewall remove firewall_id`:
365
+ ```
366
+ $ civo firewall remove 09f8d85b-0cf1-4dcf-a472-ba247fb4be21
367
+ Removed firewall 09f8d85b-0cf1-4dcf-a472-ba247fb4be21
109
368
 
110
- If you don't specify a name, a random one will be created for you.
369
+ $ civo firewall list
370
+ +----+------+--------------+-----------------+
371
+ | ID | Name | No. of Rules | instances using |
372
+ +----+------+--------------+-----------------+
373
+ +----+------+--------------+-----------------+
374
+ ```
111
375
 
112
- **Note:** Specifying the name will set the hostname on the machine but won't affect DNS resolution, currently that's up to you to provide separately.
376
+ ## Networks
377
+ #### Introduction
378
+ Civo allows for true private networking if you want to isolate instances from each other. For example, you could set up three instances, keeping one as a [
379
+ ](https://en.wikipedia.org/wiki/Bastion_host) and load balancer, with instances acting as e.g. a database server and a separate application server, both with private IPs only.
113
380
 
114
- If you decide you don't need an instance any more you can remove it by simply calling `civo instance destroy` passing in either the ID or the name, using the details above as an example:
381
+ #### Viewing Networks
382
+ You can list your currently-configured networks by calling `civo network list`. This will show the network ID, name label and its CIDR range.
115
383
 
384
+ #### Creating Networks
385
+ You can create a new private network using `civo network create network_label`:
386
+ ```
387
+ $ civo network create cli-demo
388
+ Create a private network called cli-demo with ID 74b69006-ea59-46a0-96c4-63f5bfa290e1
389
+ ```
390
+ #### Removing Networks
391
+ Removal of a network, provided you do not need it and your applications do not depend on routing through it, is simple - simply call `civo network remove network_ID`:
116
392
  ```
117
- civo instance destroy -i8043d0e7
118
- civo instance destroy --id=test1.example.com
393
+ $ civo network remove 74b69006-ea59-46a0-96c4-63f5bfa290e1
394
+ Removed the network cli-demo with ID 74b69006-ea59-46a0-96c4-63f5bfa290e1
119
395
  ```
120
396
 
121
- **Note:** The machine will be forever destroyed at this point, you can't get the data back from the hard drive afterwards.
397
+ ## Quota
398
+ All customers joining Civo will have a default quota applied to their account. The quota has nothing to do with charges or payments, but with the limits on the amount of simultaneous resources you can use. You can view the state of your quota at any time by running `civo quota`. Here is my current quota usage at the time of writing:
399
+ ```
400
+ $ civo quota
401
+ +------------------+-------+-------+
402
+ | Item | Usage | Limit |
403
+ +------------------+-------+-------+
404
+ | Instances | 4 | 16 |
405
+ | CPU cores | 5 | 16 |
406
+ | RAM MB | 7168 | 32768 |
407
+ | Disk GB | 150 | 400 |
408
+ | Volumes | 4 | 16 |
409
+ | Snapshots | 1 | 48 |
410
+ | Public IPs | 4 | 16 |
411
+ | Subnets | 1 | 10 |
412
+ | Private networks | 1 | 10 |
413
+ | Firewalls | 1 | 16 |
414
+ | Firewall rules | 1 | 160 |
415
+ +------------------+-------+-------+
416
+ Any items in red are at least 80% of your limit
417
+ ```
418
+ If you have a legitimate need for a quota increase, visit the [
419
+ ](https://www.civo.com/account/quota) to place your request - we won't unreasonably withhold any increase, it's just in place so we can control the rate of growth of our platform and so that erran scripts using our API don't suddenly exhaust our available resources.
420
+
421
+ ## Regions
422
+ As Civo grows, more regions for hosting your instances will become available. You can run `civo region` to list the regions available. Block storage (Volumes) is region-specific, so if you configure an instance in one region, any volumes you wish to attach to that instance would have to be in the same region.
423
+
424
+ ## Sizes
425
+ Civo instances come in a variety of sizes depending on your need and budget. You can get details of the sizes of instances available by calling `civo sizes` or `civo sizes list`. You will get something along the lines of the following:
426
+ ```
427
+ $ civo sizes
428
+ +------------+----------------------------------------------------+-----+----------+-----------+
429
+ | Name | Description | CPU | RAM (MB) | Disk (GB) |
430
+ +------------+----------------------------------------------------+-----+----------+-----------+
431
+ | g2.xsmall | Extra Small - 1GB RAM, 1 CPU Core, 25GB SSD Disk | 1 | 1024 | 25 |
432
+ | g2.small | Small - 2GB RAM, 1 CPU Core, 25GB SSD Disk | 1 | 2048 | 25 |
433
+ | g2.medium | Medium - 4GB RAM, 2 CPU Cores, 50GB SSD Disk | 2 | 4096 | 50 |
434
+ | g2.large | Large - 8GB RAM, 4 CPU Cores, 100GB SSD Disk | 4 | 8192 | 100 |
435
+ | g2.xlarge | Extra Large - 16GB RAM, 6 CPU Core, 150GB SSD Disk | 6 | 16386 | 150 |
436
+ | g2.2xlarge | 2X Large - 32GB RAM, 8 CPU Core, 200GB SSD Disk | 8 | 32768 | 200 |
437
+ +------------+----------------------------------------------------+-----+----------+-----------+
438
+ ```
439
+ This command is useful for getting the name of the instance type if you do not remember it - you will need to specify the instance size name when creating an instance using the CLI tool.
440
+
441
+ ## Snapshots
442
+ #### Introduction
443
+ Snapshots are a clever way to back up your instances. A snapshot is an exact copy of the instance's virtual hard drive at the moment of creation. At any point, you can restore an instance to the state it was at snapshot creation, or use snapshots to build new instances that are configured exactly the same as other servers you host.
444
+
445
+ As snapshot storage is chargeable (see [
446
+ Quota](#quota)), at any time these can be deleted by you. They can also be scheduled rather than immediately created, and if desired repeated at the same schedule each week (although the repeated snapshot will overwrite itself each week, not keep multiple weekly snapshots).
447
+
448
+ #### Creating Snapshots
449
+ You can create a snapshot from an existing instance on the command line by using `civo snapshot create snapshot_name instance_id`
450
+ For a one-off snapshot that's all you will need:
451
+ ```
452
+ civo snapshot create CLI-demo-snapshot 715f95d1-3cee-4a3c-8759-f9b49eec34c4
453
+ Created snapshot CLI-demo-snapshot with ID d6d7704b-3402-44d0-aeb1-09875f71d168
454
+ ```
455
+ For scheduled snapshots, include the `-c '0 * * * *'` switch, where the `'0 * * * *'` string is in `cron` format.
122
456
 
123
- If your machine gets stuck you can restart it with (again using either the ID or the name):
457
+ Creating snapshots is not instant, and will take a while depending on the size of the instance being backed up. You will be able to monitor the status of your snapshot by listing your snapshots as described below.
124
458
 
459
+ #### Listing Snapshots
460
+ You can view all your currently-stored snapshots and a bit of information about them by running `civo snapshot list`:
125
461
  ```
126
- civo instance reboot --id=8043d0e7
462
+ $ ./exe/civo snapshot list
463
+ +--------------------------------------+-------------------+----------------+-----------+---------+
464
+ | ID | Name | State | Size (GB) | Cron |
465
+ +--------------------------------------+-------------------+----------------+-----------+---------+
466
+ | 3506a013-85a5-4628-bf51-3e25a3bb3dbd | hello_world | complete | 25 | One-off |
467
+ | d6d7704b-3402-44d0-aeb1-09875f71d168 | CLI-demo-snapshot | ready_to_start | | One-off |
468
+ +--------------------------------------+-------------------+----------------+-----------+---------+
127
469
  ```
470
+ (The 'ready_to_start' status in the above is indicative of the `CLI-demo-snapshot` being in the process of being created.)
128
471
 
129
- If it's *really* stuck (i.e. hard kernel lock) then you can do the cloud equivalent of unplugging it and plugging it back in with the addition of the hard switch:
130
-
472
+ #### Removing Snapshots
473
+ Snapshots that are not associated with an instance can be removed using `civo snapshot remove snapshot_id` as follows:
131
474
  ```
132
- civo instance reboot --hard --id=8043d0e7
475
+ $ civo snapshot remove d6d7704b-3402-44d0-aeb1-09875f71d168
476
+ Removed snapshot CLI-demo-snapshot with ID d6d7704b-3402-44d0-aeb1-09875f71d168
133
477
  ```
478
+ If an instance was created from a snapshot, you will not be able to remove the snapshot itself.
134
479
 
135
- ## Snapshots (backups)
480
+ ## SSH Keys
481
+ #### Introduction
482
+ To manage the SSH keys for an account that are used to log in to cloud instances, the Civo CLI tool provides the following commands. You would need to [
483
+ generate a new key](https://www.civo.com/learn/ssh-key-basics) according to your particular circumstances, if you do not have a suitable SSH key yet.
136
484
 
137
- If you want to take a snapshot of an instance, you can do this using a single command line like this:
485
+ #### Uploading a New SSH Key
486
+ You will need the path to your public SSH Key to upload a new key to Civo. The usage is as follows: `civo sshkey upload NAME /path/to/FILENAME`
138
487
 
488
+ #### Listing Your SSH Keys
489
+ You will be able to list the SSH keys known for the current account holder by invoking `civo sshkey list`:
490
+ ```
491
+ $ civo sshkeys
492
+ +--------------------------------------+------------------+----------------------------------------------------+
493
+ | ID | Name | Fingerprint |
494
+ +--------------------------------------+------------------+----------------------------------------------------+
495
+ | 8aa45fea-a395-471c-93a6-27485a8429f3 | civo_cli_demo | SHA256:[Unique SSH Fingerprint] |
496
+ +--------------------------------------+------------------+----------------------------------------------------+
497
+ ```
498
+ #### Removing a SSH Key
499
+ You can delete a SSH key by calling `remove` for it by ID:
139
500
  ```
140
- civo snapshot create --name my-backup --instance 8043d0e7 --safe
501
+ $ civo sshkeys remove 531d0998-4152-410a-af20-0cccb1c7c73b
502
+ Removed SSH key cli-demo with ID 531d0998-4152-410a-af20-0cccb1c7c73b
141
503
  ```
142
504
 
143
- The name can be anything you choose, it won't conflict if you create two snapshots with the same name (but it will make it harder for you to remember which is which). The instance has to be part of the ID or a unique part of the hostname. The `--safe` is optional - without this switch it will snapshot your instance while it runs, with the flag it will shut the instance down first, take a snapshot then start it back up. The reason it's referred to as `safe` is that if you snapshot a running instance, any database server may be the middle of rewriting files for example, leaving them in a half-rewritten and hence corrupted state. If you know your machine is in a good state (say it's an application server), then you can snapshot while it's running.
505
+ ## Templates
506
+ #### Introduction
507
+ Civo instances are built from a template that specifies a disk image. Templates can contain the bare-bones OS install such as Ubuntu or Debian, or custom pre-configured operating systems that you can create yourself from a bootable volume. This allows you to speedily deploy pre-configured instances.
144
508
 
145
- ## Firewalls
509
+ #### Listing Available Template Images
510
+ A simple list of available templates, both globally-defined ones and user-configured account-specific templates, can be seen by running `civo template list`:
511
+ ```
512
+ $ civo template list
513
+ +--------------------------------------+----------------------+--------------------------------------+--------------------------------------+------------------+
514
+ | ID | Name | Image ID | Volume ID | Default Username |
515
+ +--------------------------------------+----------------------+--------------------------------------+--------------------------------------+------------------+
516
+ | 62f9c8a5-c3aa-4873-afad-44e1ee01ed43 | Ubuntu 14.04 | 637b163e-ca9c-42a8-bc02-d60e3025e9b2 | 65288478-50d0-4ab7-837e-18ddcf71ea5f | ubuntu |
517
+ | 458ae900-30e0-4ade-bd68-d137d57d4e47 | CentOS 7 | e17ec38a-1e77-4c45-bef3-569567c9b169 | cf3368dd-ccb3-4f6d-adf5-bad9a8ae9177 | centos |
518
+ | 67c4df28-8db8-48e5-84b3-d79b9d59920b | CentOS 6 | 04d66ce1-f20e-4d84-a6d4-cdde5a07ff7e | d69c297b-a18d-4388-b4ce-9f11e04fc45f | centos |
519
+ | c2124658-0f9f-4d40-bb52-6288819fdc39 | Debian Jessie | 38686161-ba25-4899-ac0a-54eaf35239c0 | 5c37a01d-342e-4732-9a59-79fcbc4c91f4 | admin |
520
+ | 1427e49f-d159-4421-b6cc-34c43775764b | CoreOS | e5a2be4a-fb83-48e8-875d-5e5ff565c9e5 | | core |
521
+ | 5d61621a-f9c1-4261-b863-2a205792b12f | Ubuntu 17.04 | a478ab7f-1ac0-4d86-9a57-e607b2bbbcf0 | | ubuntu |
522
+ | 033c35a0-a8c3-4518-8114-d156a4d4c512 | Debian Stretch | 2ffff07e-6953-4864-8ce9-1f754d70de31 | 1b117fe1-a237-43b2-8cab-d47086ce3d30 | admin |
523
+ | 359494e6-2439-471e-a528-f8866dade6ba | FreeBSD 11.1-RELEASE | 8d3886df-c5c1-4efe-aa5a-659217b466a5 | | freebsd |
524
+ | b0d30599-898a-4072-86a1-6ed2965320d9 | Ubuntu 16.04 | 8b4d81e0-6283-4ea3-bbc4-478df568024e | ea411e3f-479a-4767-9273-b8cc758ca619 | ubuntu |
525
+ | 811a8dfb-8202-49ad-b1ef-1e6320b20497 | Ubuntu 18.04 | e4838e89-f086-41a1-86b2-60bc4b0a259e | 7c9f99a5-909a-4d4f-91a2-e0174fe4d2a9 | ubuntu |
526
+ +--------------------------------------+----------------------+--------------------------------------+--------------------------------------+------------------+
527
+ ```
146
528
 
147
- By default all ports and protocols are open on your instance. We would recommend either using something like [iptables](http://netfilter.org/projects/iptables/) or [Ucomplicated Fire Wall](https://help.ubuntu.com/community/UFW) on the instance, or using the Civo firewall functionality which sits outside your instance (and hence can't be turned off if the machine is compromised).
529
+ #### Viewing Details of a Template
530
+ Detailed information about a template can be obtained via the CLI using `civo template show template_ID`.
148
531
 
149
- The first step is to create a new firewall with:
150
532
 
533
+ #### Creating a Template
534
+ You can convert a **bootable** Volume (virtual disk) of an instance, or alternatively use an existing image ID, to create a template. The options for the `civo template create` command are:
151
535
  ```
152
- civo firewall create --name my-firewall
536
+ Options:
537
+ -c, [--cloud-init-file=CLOUD_INIT_FILENAME] # The filename of a file to be used as user-data/cloud-init
538
+ -d, [--description=DESCRIPTION] # A full/long multiline description (optional)
539
+ -i, [--image-id=IMAGE_ID] # The glance ID of the base filesystem image
540
+ -v, [--volume-id=VOLUME_ID] # The volume ID of the base filesystem volume
541
+ -n, [--name=NICE_NAME] # A nice name to be used for the template
542
+ -s, [--short-description=SUMMARY] # A one line short summary of the template
153
543
  ```
154
544
 
155
- For confirmation that this has worked you can run `civo firewall` to list the firewalls. Then you can add rules to it with commands like (to allow incoming SSH and pings):
156
-
157
545
  ```
158
- civo firewall rules create my-firewall -p tcp -s 22
159
- civo firewall rules create my-firewall -p icmp
546
+ $ civo template create -n="cli-demo" -v=1427e49f-d159-4421-b6cc-34c43775764b --description="This is a demo template made from a CoreOS image" --short-description="CoreOS CLI demo"
547
+ Created template cli-demo
160
548
  ```
161
549
 
162
- You can check that it's configured correctly by running `civo firewall rules my-firewall`. Now that you're sure your firewall is configured, you can assign it to one or more instances with:
550
+ #### Updating Template Information
551
+ Once you have created a custom template, you can update information that allows for the easy identification and management of the template. Usage is `civo template update template_id [options]`:
163
552
 
164
553
  ```
165
- civo instances firewall --id=8043d0e7 --firewall my-firewall
554
+ Options:
555
+ -c, [--cloud-init-file=CLOUD_INIT_FILENAME] # The filename of a file to be used as user-data/cloud-init
556
+ -d, [--description=DESCRIPTION] # A full/long multiline description
557
+ -i, [--image-id=IMAGE_ID] # The glance ID of the base filesystem image
558
+ -v, [--volume-id=VOLUME_ID] # The volume ID of the base filesystem volume
559
+ -n, [--name=NICE_NAME] # A nice name to be used for the template
560
+ -s, [--short-description=SUMMARY] # A one line short summary of the template
561
+ ```
562
+ #### Removing a Template
563
+ Removing an account-specific template is done using the `template remove template_id` command:
166
564
  ```
565
+ $ civo template remove 1427e22f-d149-4421-b6ab-34c43754224c
566
+ ```
567
+ Please note that template removal is immediate! Use with caution.
568
+
569
+ ## Volumes
570
+ #### Introduction
571
+ Volumes are flexible-size additional storage for instances. By creating and associating a Volume with an instance, an additional virtual disk will be made available for backups or database files that can then moved to another instance.
167
572
 
168
- If you make a mistake at any point, you can revert to the default firewall by simply running the same command without `--firewall ...`, for example:
573
+ Volumes take disk space on your account's quota, and can only be created up to this quota limit. For more information about the quota system, see [Quota](#quota).
169
574
 
575
+ #### Creating a Volume
576
+ You can create a new volume by calling `civo volume create NAME SIZE(GB)`:
170
577
  ```
171
- civo instances firewall --id=8043d0e7
578
+ $ civo volume create CLI-demo-volume 25
579
+ Created a new 25GB volume called CLI-demo-volume with ID 9b232ffa-7e05-45a4-85d8-d3643e68952e
172
580
  ```
581
+ #### Attaching a Volume to an Instance
582
+ Mounting (Attaching) a volume onto an instance will allow that instance to use the volume as a drive:
583
+ ```
584
+ $ civo volume attach 9b232ffa-7e05-45a4-85d8-d3643e68952e 715f95d1-3cee-4a3c-8759-f9b49eec34c4
585
+ Attached volume CLI-demo-volume with ID 9b232ffa-7e05-45a4-85d8-d3643e68952e to api-demo.test
586
+ ```
587
+ If this is a newly-created volume, you would need to partition, format and mount the volume. For more information, [see the Learn guide here](https://www.civo.com/learn/configuring-block-storage-on-civo).
588
+ Note: You can only attach a volume to one instance at a time.
173
589
 
174
- ## Quota
590
+ #### Detaching a Volume From an Instance
591
+ If you want to detach a volume to move it to another instance, or are just finished with it, you can detach it once it's been [unmounted](https://www.civo.com/learn/configuring-block-storage-on-civo) using `civo volume detach volume_id`:
592
+ ```
593
+ $ civo volume detach 9b232ffa-7e05-45a4-85d8-d3643e68952e
594
+ Detached volume CLI-demo-volume with ID 9b232ffa-7e05-45a4-85d8-d3643e68952e
595
+ ```
596
+ #### Listing Volumes
597
+ You can get an overall view of your volumes, their sizes and status by using `civo volume list`.
598
+
599
+ #### Resizing Volumes
600
+ An un-attached volume can be resized if you need extra space. This is done by calling `civo volume resize volume_id new_size` where `new-size` is in gigabytes:
601
+ ```
602
+ $ civo volume resize 9b232ffa-7e05-45a4-85d8-d3643e68952e 30
603
+ Resized volume CLI-demo-volume with ID 9b232ffa-7e05-45a4-85d8-d3643e68952e to be 30GB
604
+ ```
175
605
 
176
- All Civo users have a limited quota applied to their account (to stop errant scripts from filling up the cloud with a million instances). You can view your current quota using a command like this:
606
+ #### Deleting Volumes
177
607
 
608
+ To free up quota and therefore the amount to be billed to your account, you can delete a volume through `civo volume delete volume_id`. This deletion is immediate:
609
+ ```
610
+ $ civo volume delete 9b232ffa-7e05-45a4-85d8-d3643e68952e
611
+ Removed volume CLI-demo-volume with ID 9b232ffa-7e05-45a4-85d8-d3643e68952e (was 30GB)
612
+ $ civo volume list
613
+ +----+------+---------+-----------+
614
+ | ID | Name | Mounted | Size (GB) |
615
+ +----+------+---------+-----------+
616
+ +----+------+---------+-----------+
178
617
  ```
179
- $ civo quota
180
- +---------------------------------------+------+-------+
181
- | Title | Used | Limit |
182
- +---------------------------------------+------+-------+
183
- | Number of instances | 0 | 10 |
184
- | Total CPU cores | 0 | 20 |
185
- | Total RAM (MB) | 0 | 5120 |
186
- | Total disk space (GB) | 0 | 250 |
187
- | Disk volumes | 0 | 10 |
188
- | Disk snapshots | 0 | 30 |
189
- | Public IP addresses | 0 | 10 |
190
- | Private subnets | 0 | 1 |
191
- | Private networks | 0 | 1 |
192
- | Security groups | 0 | 10 |
193
- | Security group rules | 0 | 100 |
194
- | Number of ports (network connections) | 0 | 20 |
195
- +---------------------------------------+------+-------+
196
- ```
197
-
198
- If you want to increase them, contact us via Civo.com.
199
618
 
200
619
  ## Development
201
620
 
@@ -216,5 +635,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/civo/c
216
635
 
217
636
  ## License
218
637
 
219
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
220
-
638
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -1,3 +1,3 @@
1
1
  module CivoCLI
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
data/lib/instance.rb CHANGED
@@ -80,17 +80,29 @@ module CivoCLI
80
80
  exit 1
81
81
  end
82
82
 
83
- desc "create --hostname=host_name --size=instance_size [--template=template_id ] [--snapshot=snapshot_id]", "create a new instance with specified hostname, instance size, template/snapshot ID. Optional: region, public_ip (true or false), initial user"
84
- option :hostname, required: true
85
- option :size, required: true
86
- option :region, default: 'lon1'
87
- option :public_ip, default: 'create'
88
- option :initial_user, default: "civo"
89
- option :template
90
- option :snapshot
91
- option :ssh_key_id
92
- option :tags
93
- def create(*args)
83
+ desc "create [HOSTNAME] [...]", "create a new instance with specified hostname and provided options"
84
+ option :size, default: 'g2.small', banner: 'instance_size_code'
85
+ option :region, default: 'lon1', banner: 'civo_region'
86
+ option :public_ip, default: 'true', banner: 'true | false | from [instance_id]'
87
+ option :initial_user, default: 'civo', banner: 'username', aliases: '--user'
88
+ option :template, lazy_default: '811a8dfb-8202-49ad-b1ef-1e6320b20497', banner: 'template_id'
89
+ option :snapshot, banner: 'snapshot_id'
90
+ option :ssh_key, banner: 'ssh_key_id'
91
+ option :tags, banner: "'tag1 tag2 tag3...'"
92
+ long_desc <<-LONGDESC
93
+ Create a new instance with hostname (randomly assigned if blank), instance size (default: g2.small),
94
+ \x5template or snapshot ID (default: Ubuntu 18.04 template).
95
+ \x5\x5Optional parameters are as follows:
96
+ \x5 --size=<instance_size> - 'g2.small' if blank. List of sizes and codes to use can be found through `civo sizes`
97
+ \x5 --template=<template_id> - Ubuntu 18.04 if blank. Template_id is from a list of templates at `civo templates`
98
+ \x5 --snapshot=<snapshot_id> - Snapshot ID of a previously-made snapshot. Leave blank if using a template.
99
+ \x5 --public_ip=<true | false | from=instance_id> - 'true' if blank. 'from' requires an existing instance ID configured with a public IP address to move to this new instance.
100
+ \x5 --initial_user=<yourusername> - 'civo' if blank
101
+ \x5 --ssh_key=<ssh_key_id> - for specifying a SSH login key for the default user. Random password assigned if blank, visible by calling `civo instance show hostname`
102
+ \x5 --region=<regioncode> from available Civo regions. Randomly assigned if blank
103
+ \x5 --tags=<'tag1 tag2 tag3...'> - space-separated tag(s)
104
+ LONGDESC
105
+ def create(hostname = CivoCLI::NameGenerator.create, *args)
94
106
  # {ENV["CIVO_API_VERSION"] || "1"}/instances", requires: [:hostname, :size, :region],
95
107
  # defaults: {public_ip: true, initial_user: "civo"}
96
108
  CivoCLI::Config.set_api_auth
@@ -99,19 +111,19 @@ module CivoCLI
99
111
  exit 1
100
112
  end
101
113
  if options[:template]
102
- Civo::Instance.create(hostname: options[:hostname], size: options[:size], template: options[:template], initial_user: options[:initial_user], region: options[:region], ssh_key_id: options[:ssh_key_id], tags: options[:tags])
114
+ Civo::Instance.create(hostname: hostname, size: options[:size], template: options[:template], initial_user: options[:initial_user], region: options[:region], ssh_key_id: options[:ssh_key], tags: options[:tags])
103
115
  end
104
116
 
105
117
  if options[:snapshot]
106
- Civo::Instance.create(hostname: options[:hostname], size: options[:size], snapshot_id: options[:snapshot], initial_user: options[:initial_user], region: options[:region], ssh_key_id: options[:ssh_key_id], tags: options[:tags])
118
+ Civo::Instance.create(hostname: hostname, size: options[:size], snapshot_id: options[:snapshot], initial_user: options[:initial_user], region: options[:region], ssh_key_id: options[:ssh_key], tags: options[:tags])
107
119
  end
108
- puts "Created instance #{options[:hostname].colorize(:green)}"
120
+ puts "Created instance #{hostname.colorize(:green)}"
109
121
  rescue Flexirest::HTTPException => e
110
122
  puts e.result.reason.colorize(:red)
111
123
  exit 1
112
124
  end
113
125
 
114
- desc "tags ID 'tag1 tag2 tag3...'", "retag instance by ID (input no tags to clear all tags)"
126
+ desc "tags ID/HOSTNAME 'tag1 tag2 tag3...'", "retag instance by ID (input no tags to clear all tags)"
115
127
  def tags(id, newtags = nil)
116
128
  CivoCLI::Config.set_api_auth
117
129
  instance = detect_instance_id(id)
@@ -123,9 +135,13 @@ module CivoCLI
123
135
  exit 1
124
136
  end
125
137
 
126
- desc "update ID/HOSTNAME [--name=new_hostname] [--notes='txt']", "update details of instance. Use --hostname=new_name, --notes='notes' to specify update"
138
+ desc "update ID/HOSTNAME [--name] [--notes]", "update details of instance"
139
+
127
140
  option :name
128
141
  option :notes
142
+ long_desc <<-LONGDESC
143
+ Use --name=new_host_name, --notes='free text notes string' to specify the details you wish to update.
144
+ LONGDESC
129
145
  def update(id)
130
146
  CivoCLI::Config.set_api_auth
131
147
  instance = detect_instance_id(id)
@@ -219,7 +235,7 @@ module CivoCLI
219
235
  exit 1
220
236
  end
221
237
 
222
- desc "upgrade ID new-size", "Upgrade instance with ID to size provided (see civo sizes for size names)"
238
+ desc "upgrade ID/HOSTNAME new-size", "Upgrade instance with ID to size provided (see civo sizes for size names)"
223
239
  def upgrade(id, new_size)
224
240
  # {ENV["CIVO_API_VERSION"] || "1"}/instances/:id/resize", requires: [:size, :id]
225
241
  CivoCLI::Config.set_api_auth
@@ -233,7 +249,7 @@ module CivoCLI
233
249
  exit 1
234
250
  end
235
251
 
236
- desc "move-ip targetID IP_Address", "move a public IP_Address to target instance"
252
+ desc "move-ip ID/HOSTNAME IP_Address", "move a public IP_Address to target instance"
237
253
  def move_ip(id, ip_address)
238
254
  # {ENV["CIVO_API_VERSION"] || "1"}/instances/:id/ip/:ip", requires: [:ip, :id]
239
255
  CivoCLI::Config.set_api_auth
@@ -0,0 +1,10 @@
1
+ module CivoCLI
2
+
3
+ class NameGenerator
4
+ WORDS = %w{acrobat africa alaska albert albino album alcohol alex alpha amadeus amanda amazon america analog animal antenna antonio apollo april aroma artist aspirin athlete atlas banana bandit banjo bikini bingo bonus camera canada carbon casino catalog cinema citizen cobra comet compact complex context credit critic crystal culture david delta dialog diploma doctor domino dragon drama extra fabric final focus forum galaxy gallery global harmony hotel humor index japan kilo lemon liter lotus mango melon menu meter metro mineral model music object piano pirate plastic radio report signal sport studio subject super tango taxi tempo tennis textile tokyo total tourist video visa academy alfred atlanta atomic barbara bazaar brother budget cabaret cadet candle capsule caviar channel chapter circle cobalt comrade condor crimson cyclone darwin declare denver desert divide dolby domain double eagle echo eclipse editor educate edward effect electra emerald emotion empire eternal evening exhibit expand explore extreme ferrari forget freedom friday fuji galileo genesis gravity habitat hamlet harlem helium holiday hunter ibiza iceberg imagine infant isotope jackson jamaica jasmine java jessica kitchen lazarus letter license lithium loyal lucky magenta manual marble maxwell mayor monarch monday money morning mother mystery native nectar nelson network nikita nobel nobody nominal norway nothing number october office oliver opinion option order outside package pandora panther papa pattern pedro pencil people phantom philips pioneer pluto podium portal potato process proxy pupil python quality quarter quiet rabbit radical radius rainbow ramirez ravioli raymond respect respond result resume richard river roger roman rondo sabrina salary salsa sample samuel saturn savage scarlet scorpio sector serpent shampoo sharon silence simple society sonar sonata soprano sparta spider sponsor abraham action active actor adam address admiral adrian agenda agent airline airport alabama aladdin alarm algebra alibi alice alien almond alpine amber amigo ammonia analyze anatomy angel annual answer apple archive arctic arena arizona armada arnold arsenal arthur asia aspect athena audio august austria avenue average axiom aztec bagel baker balance ballad ballet bambino bamboo baron basic basket battery belgium benefit berlin bermuda bernard bicycle binary biology bishop blitz block blonde bonjour boris boston bottle boxer brandy bravo brazil bridge british bronze brown bruce bruno brush burger burma cabinet cactus cafe cairo calypso camel campus canal cannon canoe cantina canvas canyon capital caramel caravan career cargo carlo carol carpet cartel cartoon castle castro cecilia cement center century ceramic chamber chance change chaos charlie charm charter cheese chef chemist cherry chess chicago chicken chief china cigar circus city clara classic claudia clean client climax clinic clock club cockpit coconut cola collect colombo colony color combat comedy command company concert connect consul contact contour control convert copy corner corona correct cosmos couple courage cowboy craft crash cricket crown cuba dallas dance daniel decade decimal degree delete deliver delphi deluxe demand demo denmark derby design detect develop diagram diamond diana diego diesel diet digital dilemma direct disco disney distant dollar dolphin donald drink driver dublin duet dynamic earth east ecology economy edgar egypt elastic elegant element elite elvis email empty energy engine english episode equator escape escort ethnic europe everest evident exact example exit exotic export express factor falcon family fantasy fashion fiber fiction fidel fiesta figure film filter finance finish finland first flag flash florida flower fluid flute folio ford forest formal formula fortune forward fragile france frank fresh friend frozen future gabriel gamma garage garcia garden garlic gemini general genetic genius germany gloria gold golf gondola gong good gordon gorilla grand granite graph green group guide guitar guru hand happy harbor harvard havana hawaii helena hello henry hilton history horizon house human icon idea igloo igor image impact import india indigo input insect instant iris italian jacket jacob jaguar janet jargon jazz jeep john joker jordan judo jumbo june jungle junior jupiter karate karma kayak kermit king koala korea labor lady lagoon laptop laser latin lava lecture left legal level lexicon liberal libra lily limbo limit linda linear lion liquid little llama lobby lobster local logic logo lola london lucas lunar machine macro madam madonna madrid maestro magic magnet magnum mailbox major mama mambo manager manila marco marina market mars martin marvin mary master matrix maximum media medical mega melody memo mental mentor mercury message metal meteor method mexico miami micro milk million minimum minus minute miracle mirage miranda mister mixer mobile modem modern modular moment monaco monica monitor mono monster montana morgan motel motif motor mozart multi museum mustang natural neon nepal neptune nerve neutral nevada news next ninja nirvana normal nova novel nuclear numeric nylon oasis observe ocean octopus olivia olympic omega opera optic optimal orange orbit organic orient origin orlando oscar oxford oxygen ozone pablo pacific pagoda palace pamela panama pancake panda panel panic paradox pardon paris parker parking parody partner passage passive pasta pastel patent patient patriot patrol pegasus pelican penguin pepper percent perfect perfume period permit person peru phone photo picasso picnic picture pigment pilgrim pilot pixel pizza planet plasma plaza pocket poem poetic poker polaris police politic polo polygon pony popcorn popular postage precise prefix premium present price prince printer prism private prize product profile program project protect proton public pulse puma pump pyramid queen radar ralph random rapid rebel record recycle reflex reform regard regular relax reptile reverse ricardo right ringo risk ritual robert robot rocket rodeo romeo royal russian safari salad salami salmon salon salute samba sandra santana sardine school scoop scratch screen script scroll second secret section segment select seminar senator senior sensor serial service shadow sharp sheriff shock short shrink sierra silicon silk silver similar simon single siren slang slogan smart smoke snake social soda solar solid solo sonic source soviet special speed sphere spiral spirit spring static status stereo stone stop street strong student style sultan susan sushi suzuki switch symbol system tactic tahiti talent tarzan telex texas theory thermos tiger titanic tomato topic tornado toronto torpedo totem tractor traffic transit trapeze travel tribal trick trident trilogy tripod tropic trumpet tulip tuna turbo twist ultra uniform union uranium vacuum valid vampire vanilla vatican velvet ventura venus vertigo veteran victor vienna viking village vincent violet violin virtual virus vision visitor visual vitamin viva vocal vodka volcano voltage volume voyage water weekend welcome western window winter wizard wolf world xray yankee yoga yogurt yoyo zebra zero zigzag zipper zodiac zoom acid adios agatha alamo alert almanac aloha andrea anita arcade aurora avalon baby baggage balloon bank basil begin biscuit blue bombay botanic brain brenda brigade cable calibre carmen cello celtic chariot chrome citrus civil cloud combine common cool copper coral crater cubic cupid cycle depend door dream dynasty edison edition enigma equal eric event evita exodus extend famous farmer food fossil frog fruit geneva gentle george giant gilbert gossip gram greek grille hammer harvest hazard heaven herbert heroic hexagon husband immune inca inch initial isabel ivory jason jerome joel joshua journal judge juliet jump justice kimono kinetic leonid leopard lima maze medusa member memphis michael miguel milan mile miller mimic mimosa mission monkey moral moses mouse nancy natasha nebula nickel nina noise orchid oregano origami orinoco orion othello paper paprika prelude prepare pretend promise prosper provide puzzle remote repair reply rival riviera robin rose rover rudolf saga sahara scholar shelter ship shoe sigma sister sleep smile spain spark split spray square stadium star storm story strange stretch stuart subway sugar sulfur summer survive sweet swim table taboo target teacher telecom temple tibet ticket tina today toga tommy tower trivial tunnel turtle twin uncle unicorn unique update valery vega version voodoo warning william wonder year yellow young absent absorb absurd accent alfonso alias ambient anagram andy anvil appear apropos archer ariel armor arrow austin avatar axis baboon bahama bali balsa barcode bazooka beach beast beatles beauty before benny betty between beyond billy bison blast bless bogart bonanza book border brave bread break broken bucket buenos buffalo bundle button buzzer byte caesar camilla canary candid carrot cave chant child choice chris cipher clarion clark clever cliff clone conan conduct congo costume cotton cover crack current danube data decide deposit desire detail dexter dinner donor druid drum easy eddie enjoy enrico epoxy erosion except exile explain fame fast father felix field fiona fire fish flame flex flipper float flood floor forbid forever fractal frame freddie front fuel gallop game garbo gate gelatin gibson ginger giraffe gizmo glass goblin gopher grace gray gregory grid griffin ground guest gustav gyro hair halt harris heart heavy herman hippie hobby honey hope horse hostel hydro imitate info ingrid inside invent invest invite ivan james jester jimmy join joseph juice julius july kansas karl kevin kiwi ladder lake laura learn legacy legend lesson life light list locate lopez lorenzo love lunch malta mammal margin margo marion mask match mayday meaning mercy middle mike mirror modest morph morris mystic nadia nato navy needle neuron never newton nice night nissan nitro nixon north oberon octavia ohio olga open opus orca oval owner page paint palma parent parlor parole paul peace pearl perform phoenix phrase pierre pinball place plate plato plume pogo point polka poncho powder prague press presto pretty prime promo quest quick quiz quota race rachel raja ranger region remark rent reward rhino ribbon rider road rodent round rubber ruby rufus sabine saddle sailor saint salt scale scuba season secure shake shallow shannon shave shelf sherman shine shirt side sinatra sincere size slalom slow small snow sofia song sound south speech spell spend spoon stage stamp stand state stella stick sting stock store sunday sunset support supreme sweden swing tape tavern think thomas tictac time toast tobacco tonight torch torso touch toyota trade tribune trinity triton truck trust type under unit urban urgent user value vendor venice verona vibrate virgo visible vista vital voice vortex waiter watch wave weather wedding wheel whiskey wisdom android annex armani cake confide deal define dispute genuine idiom impress include ironic null nurse obscure prefer prodigy ego fax jet job rio ski yes}
5
+
6
+ def self.create(count = 2)
7
+ WORDS.sample(count).join("-")
8
+ end
9
+ end
10
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: civo_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Jeffries
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2019-06-19 00:00:00.000000000 Z
13
+ date: 2019-06-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -213,6 +213,7 @@ files:
213
213
  - lib/domain_record.rb
214
214
  - lib/firewall.rb
215
215
  - lib/instance.rb
216
+ - lib/namegenerator.rb
216
217
  - lib/network.rb
217
218
  - lib/quota.rb
218
219
  - lib/region.rb