Skip to content

Commit

Permalink
Describe different means to set objects
Browse files Browse the repository at this point in the history
  • Loading branch information
ldmberman committed Sep 21, 2015
1 parent acb24aa commit 483b6b3
Showing 1 changed file with 37 additions and 5 deletions.
42 changes: 37 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,19 @@ Alternatively, a name of an entity can be specified (the common pattern is `--<e

### Enjoy the tool

Below are some examples of CLI commands so that you can faster get to use it efficiently.
Below are some examples of CLI commands to help you faster get to use the tool.

Explore the list of data centers:

`clc data-center list`

Find server template ids that contain the word "UBUNTU" in some data center `<data-center>`:
Find server template IDs that contain the word "UBUNTU" in some data center `<data-center>`:

```
clc data-center get-deployment-capabilities --data-center <data-center> --query templates.name --output text | grep UBUNTU
```

Search for the root group id of the data center under consideration:
Search for the root group ID of the data center under consideration:

```
clc group list --all --filter location-id=<data-center> --query id --output text
Expand All @@ -118,18 +118,50 @@ Or, the same thing can be accomplished by issuing:
clc group list --data-center <data-center> --query id --output text
```

Get the list of subgroups. Use a "SubGroup" alias for subgroups ids in the output:
Get the list of subgroups. Use a "SubGroup" alias for subgroups IDs in the output:

```
clc group get --group-id <root-group-id> --query 'groups.{SubGroup:id}'
```

Create your own group inside the one queried:

```
clc group create --name "my group" --description "A group of mine" --parent-group-id <group-id> --custom-fields "id=<some-field>,value=<some-value>" "id=<another-field>,value=<another-value>"
```

Note how we set custom fields here. According to the command help, the `--custom-fields` argument accepts an array of objects with 2 keys each: `id` and `value`. The tool interprets multiple space-separated values as an array and each object can be specified using the `key1=value1,key2=value2,..`-notation, which is described in more detail further in the document.

Create a server:

```
clc server create --name myserv --source-server-id <template-id> --group-id <group-id> --cpu 1 --memoryGB 1
clc server create --name myserv --source-server-id <template-id> --group-id <group-id> --cpu 1 --memory-gb 1
```

The same can be accomplished with a piece of JSON:

```
clc server create '{"name":"myserv","source-server-id":"<template-id>","group-id":"<group-id>","cpu":1,"memory-gb":1}'
```

Be careful with JSON though. Keys and string values have to be enclosed in **double** quotes. Also, an expression may fail to be parsed unless it is enclosed in quotes, mainly because commas and spaces usually have special meanings in shells.

Moreover, there is yet another notation for describing objects:

```
clc server create "name=myserv,source-server-id='<template-id>',group-id='<group-id>',cpu=1,memory-gb=1"
```

In this case you can use both `'` and `"` for both values and the whole expression but be sure to escape special characters as it has been partly described for JSON. Note that this notation does not support nested objects and arrays.

Finally, you can mix the ways described:

```
clc server create '{"name":"myserv"}' source-server-id='<template-id>' --group-id <group-id> --cpu 1 --memory-gb 1
```

Be sure to put all the data **not bound to any command key** first, otherwise it will be interpreted as a value or an item of an array for the preceding command key.

Wait until the server has been created:

```
Expand Down

0 comments on commit 483b6b3

Please sign in to comment.