|
1 | 1 | [](https://docs.outscale.com/en/userguide/Open-Source-Projects.html) |
2 | | - |
3 | | -# Outscale CLI |
4 | | - |
5 | | -Official Outscale CLI providing connectors to Outscale API. |
6 | | - |
7 | 2 | [](https://github.com/psf/black) |
| 3 | +[](https://discord.gg/HUVtY5gT6s) |
8 | 4 |
|
9 | | -## Maintenance mode ! |
10 | | - |
11 | | -This project is now in maintenance mode, we will still fix bugs here, but no new features will be work on. |
12 | | -If you want new features, you should use [oapi-cli](https://github.com/outscale/oapi-cli), |
13 | | -which support all of osc-api, and have some syntax suggar to ease complex argument manipulation in comparaison to osc-cli usage. |
14 | | - |
15 | | -## Getting Started |
16 | | - |
17 | | - |
18 | | -### Installing on Macos |
19 | | - |
20 | | -osc-cli is available on [brew](https://formulae.brew.sh/formula/osc-cli). |
21 | | - |
22 | | -### Installing on Linux |
23 | | - |
24 | | -osc-cli is pre-packaged for Linux as a standalone [AppImage](https://appimage.org/). |
25 | | -- Download `osc-cli-x86_64.AppImage` from latest version in [releases](https://github.com/outscale/osc-cli/releases). |
26 | | -- Allow file to be executed by running `chmod a+x osc-cli-x86_64.AppImage` |
27 | | -- Run osc-cli: `./osc-cli-x86_64.AppImage` |
28 | | - |
29 | | -Optionally, you can install it for all users: `sudo mv osc-cli-x86_64.AppImage /usr/local/bin/osc-cli` and just run `osc-cli`. |
30 | | - |
31 | | -you can also install `osc-cli-git` on Arch Linux using AUR: (`yay -S osc-cli-git`) |
32 | | - |
33 | | -#### Note: |
34 | | - |
35 | | -if you have this error (or one similar about fuse): |
36 | | -``` |
37 | | -fuse: failed to exec fusermount: No such file or directory |
38 | | -
|
39 | | -Cannot mount AppImage, please check your FUSE setup. |
40 | | -You might still be able to extract the contents of this AppImage |
41 | | -if you run it with the --appimage-extract option. |
42 | | -See https://github.com/AppImage/AppImageKit/wiki/FUSE |
43 | | -for more information |
44 | | -open dir error: No such file or directory |
45 | | -``` |
46 | | - |
47 | | -You can either install fuse yourself, or execute the appimage with `--appimage-extract-and-run` option |
48 | | - |
49 | | -Example: |
50 | | -``` |
51 | | -./osc-cli-x86_64.AppImage --appimage-extract-and-run osc-cli api ReadImages --profile=my |
52 | | -``` |
53 | | - |
54 | | -using `appimage-extract-and-run` extract the content of the AppImage in a temporary directory and execute it, |
55 | | -this operation is a **lot** slower than using fuse, and the fuse solution should be use if posible. |
56 | | - |
57 | | - |
58 | | -### Installing on Windows |
59 | | - |
60 | | -[Check dedicated documentation](windows-setup.md) regarding windows installation. |
| 5 | +<p align="center"> |
| 6 | + <img alt="Terminal Icon" src="https://img.icons8.com/ios-filled/100/console.png" width="100px"> |
| 7 | +</p> |
61 | 8 |
|
62 | | -### Installing from Python package |
| 9 | +# Outscale CLI (osc-cli) |
63 | 10 |
|
64 | | -#### Prerequisites |
| 11 | +Official command-line interface for the OUTSCALE API. |
65 | 12 |
|
66 | | -You will need [Python 3.6+](https://www.python.org/) or later. Earlier versions including Python 2 are not supported. |
67 | | - |
68 | | -#### Pip |
69 | | - |
70 | | -You can get the package from [pypi](https://pypi.org/project/osc-sdk/): |
71 | | -``` |
72 | | -pip3 install osc-sdk |
73 | | -``` |
| 13 | +> **Maintenance mode**: bug fixes only; no new features. |
| 14 | +> Looking for new features and an improved UX? See **[oapi-cli](https://github.com/outscale/oapi-cli)**. |
74 | 15 |
|
75 | | -If you are using Microsoft Windows, see [how to setup osc-cli on Windows](windows-setup.md). |
| 16 | +## Quick start |
76 | 17 |
|
77 | | -### Installing from sources |
| 18 | +**macOS (Homebrew)** |
| 19 | +```bash |
| 20 | +brew install osc-cli |
| 21 | +```` |
78 | 22 |
|
79 | | -It is a good practice to create a [dedicated virtualenv](https://virtualenv.pypa.io/en/latest/) first. Even if it usually won't harm to install Python libraries directly on the system, better to contain dependencies in a virtual environment. |
| 23 | +**Linux (AppImage)** |
80 | 24 |
|
81 | 25 | ```bash |
82 | | -python3 -m venv .venv |
83 | | -source .venv/bin/activate |
| 26 | +# get the latest release from GitHub |
| 27 | +chmod a+x osc-cli-x86_64.AppImage |
| 28 | +./osc-cli-x86_64.AppImage |
| 29 | +# (optional) sudo mv osc-cli-x86_64.AppImage /usr/local/bin/osc-cli |
84 | 30 | ``` |
85 | 31 |
|
86 | | -Then install osc-cli in your virtual env: |
| 32 | +**Python package** |
| 33 | + |
87 | 34 | ```bash |
88 | | -pip install -e . |
| 35 | +pip3 install osc-sdk |
89 | 36 | ``` |
90 | 37 |
|
91 | | -## Configure osc-cli |
| 38 | +**Windows** |
| 39 | +See [docs/install/windows.md](docs/install/windows.md). |
92 | 40 |
|
93 | | -The CLI requires a configuration file in `~/.osc/config.json` The content must be a JSON whose contents look like this: |
94 | | -/!\ the old configuration path using `.osc_sdk` folder is **deprecated**. Please use the new one with `.osc`. |
95 | | -```json |
96 | | -{"default": |
97 | | - {"access_key": "MYACCESSKEY", |
98 | | - "secret_key": "MYSECRETKEY", |
99 | | - "region": "eu-west-2" |
100 | | - }, |
101 | | - "us": |
102 | | - {"access_key": "MYACCESSKEY", |
103 | | - "secret_key": "MYSECRETKEY", |
104 | | - "host": "outscale.com", |
105 | | - "https": true, |
106 | | - "method": "POST", |
107 | | - "region": "us-east-2" |
108 | | - } |
109 | | -} |
110 | | -``` |
111 | | -You can add several profiles for different regions or users. |
| 41 | +## Minimal configuration |
112 | 42 |
|
113 | | -Optional parameters can be applied to each profile : |
114 | | -* client_certificate: if you need additional security, your pem must include your private key and your certificate |
115 | | -* version: if you want to query another version of the API |
| 43 | +Create `~/.osc/config.json`: |
116 | 44 |
|
117 | 45 | ```json |
118 | | -{"default": |
119 | | - {"access_key": "MYACCESSKEY", |
120 | | - "secret_key": "MYSECRETKEY", |
121 | | - "client_certificate" : "path_to_your_pem", |
122 | | - "host": "outscale.com", |
123 | | - "https": true, |
124 | | - "method": "POST", |
125 | | - "region": "eu-west-2", |
126 | | - "version": "2018-11-19" |
127 | | - } |
| 46 | +{ |
| 47 | + "default": { |
| 48 | + "access_key": "MYACCESSKEY", |
| 49 | + "secret_key": "MYSECRETKEY", |
| 50 | + "region": "eu-west-2" |
| 51 | + } |
128 | 52 | } |
129 | 53 | ``` |
130 | 54 |
|
131 | | -## Get osc-cli version |
132 | | - |
133 | | -`--version` option will print osc-cli version and exit. |
134 | | -``` |
135 | | -osc-cli --version |
136 | | -``` |
137 | | - |
138 | | -## Activate bash-completion |
139 | | - |
140 | | -### Activate the completion for the current bash session |
141 | | - |
142 | | -``` |
143 | | -source <(osc-cli --bash_completion) |
144 | | -``` |
145 | | - |
146 | | -### Generate the file to add it in your bach rc: |
147 | | -``` |
148 | | -osc-cli --bash_completion > ~/.osc/cli-completion.bash |
149 | | -``` |
150 | | -then in your bashrc add: |
151 | | - |
152 | | -``` |
153 | | -source ~/.osc/cli-completion.bash |
154 | | -``` |
155 | | - |
156 | 55 | ## Usage |
157 | 56 |
|
158 | | -``` |
159 | | -osc-cli SERVICE CALL [PROFILE] [CALL-PARAMETERS] |
160 | | -``` |
161 | | -or |
162 | | -``` |
163 | | -osc-cli --service SERVICE --call CALL [PROFILE] [--CALL_PARAMS ...] |
164 | | -``` |
165 | | -with |
166 | | -* SERVICE one of the [services](http://docs.outscale.com) provided by Outscale (`fcu`, `lbu`, `icu`, `eim`, `directlink`, `okms` and `api`) |
167 | | -* CALL the call you request (ie ReadVms, DescribeInstances...) |
168 | | -* PROFILE the profile you want to connect to (optional) |
169 | | -* CALL_PARAMS call arguments which are case-sensitive (optional) |
170 | | - |
171 | | - |
172 | | -Here is an example of a simple volume creation: |
173 | 57 | ```bash |
174 | | -osc-cli fcu CreateVolume --AvailabilityZone eu-west-2a --Size 10 |
175 | | -{ |
176 | | - "CreateVolumeResponse": { |
177 | | - "@xmlns": "http://ec2.amazonaws.com/doc/2014-06-15/", |
178 | | - "requestId": "508f428a-9fd8-4a49-9fe6-d0bf311de3b4", |
179 | | - "volumeId": "vol-6a2aa442", |
180 | | - "size": "10", |
181 | | - "snapshotId": null, |
182 | | - "availabilityZone": "eu-west-2a", |
183 | | - "status": "creating", |
184 | | - "createTime": "2019-01-17T12:53:57.836Z", |
185 | | - "volumeType": "standard" |
186 | | - } |
187 | | -} |
| 58 | +osc-cli SERVICE CALL [PROFILE] [CALL-PARAMETERS] |
| 59 | +# example: |
| 60 | +osc-cli api ReadVms |
188 | 61 | ``` |
189 | 62 |
|
190 | | -Be careful with your quotes ! If you want to pass the string `"12345678"` rather than the integer `12345678` you'll need to quote your quotes: |
191 | | -```bash |
192 | | -$ osc-cli icu CreateAccount --Email "example@email.com" \ |
193 | | - --FirstName "Osc" \ |
194 | | - --LastName "Cli" \ |
195 | | - --Password "12345toto" \ |
196 | | - --ZipCode '"92000"' \ |
197 | | - --Country "France" \ |
198 | | - --CustomerId '"12345678"' |
199 | | -``` |
| 63 | +## Documentation |
200 | 64 |
|
201 | | -Another example with an array of strings into args: |
202 | | -```bash |
203 | | -$ osc-cli api CreateDhcpOptions --DomainName="toot.toot" \ |
204 | | - --DomainNameServers="['1.1.1.1']" \ |
205 | | - --NtpServers="['1.1.1.1']" |
206 | | -``` |
| 65 | +* Installation guides (macOS, Linux/AppImage, Windows, pip, source): [docs/install/](docs/install/) |
| 66 | +* Configuration and profiles: [docs/configuration.md](docs/configuration.md) |
| 67 | +* Usage and argument parsing: [docs/usage.md](docs/usage.md), [docs/argument-parsing.md](docs/argument-parsing.md) |
| 68 | +* Shell completion: [docs/completion.md](docs/completion.md) |
| 69 | +* Troubleshooting & FAQ: [docs/troubleshooting.md](docs/troubleshooting.md) |
207 | 70 |
|
208 | | -Example with a complex structure: |
209 | | -```bash |
210 | | -osc-cli icu CreateListenerRule \ |
211 | | ---Instances '[{"InstanceId": "i-12345678"}]' \ |
212 | | ---ListenerDescription '{"LoadBalancerName": "osc", "LoadBalancerPort": 80}' |
213 | | ---ListenerRuleDescription '{"RuleName": "hello", "Priority": 100, "PathPattern": "/"}' |
214 | | -``` |
215 | | - |
216 | | -**Argument Parsing** |
217 | | -```bash |
218 | | -$ osc-cli api example --obj=[1,2] # list |
219 | | -$ osc-cli api example --obj=10 # int |
220 | | -$ osc-cli api example --obj="10" # int |
221 | | -$ osc-cli api example --obj="'10'" # str |
222 | | -$ osc-cli api example --obj=\"10\" # str |
223 | | - |
224 | | -$ osc-cli api example --obj="hello" # str |
225 | | -$ osc-cli api example --obj=hello # str |
226 | | -``` |
227 | | -**Warning** if you're adding a list which contain strings with specifics characteres, there is a workaround: |
228 | | -```bash |
229 | | -$ osc-cli api example --obj="['vol-12345678', 'vol-87654322']" # list |
230 | | -``` |
| 71 | +## Contributing |
231 | 72 |
|
232 | | -## Authentication |
| 73 | +See [CONTRIBUTING.md](CONTRIBUTING.md). |
233 | 74 |
|
234 | | -You API crendentials are composed of an Access Key and a Secret Key located in `.osc_sdk/config.json`. |
235 | | -You can list you access keys using your user and password: |
236 | | -```bash |
237 | | -osc-cli icu ListAccessKeys --authentication-method=password --login youremail@company.com --password=Y0URpAssOrd |
238 | | -``` |
239 | | -## Contributing |
240 | | -OSC-CLI is an **open source software** licensed under **BSD-3-Clause.** |
| 75 | +## License |
241 | 76 |
|
242 | | -Patches and discussions are welcome about bugs you've found or features you think are missing. If you would like to help making **osc-cli** better, take a look to [CONTRIBUTING.md](https://github.com/outscale/osc-cli/blob/master/CONTRIBUTING.md) file. |
| 77 | +BSD-3-Clause. See [LICENSE](LICENSE). |
0 commit comments