Skip to content
Snippets Groups Projects
Commit 622452e0 authored by Florent Gluck's avatar Florent Gluck
Browse files

Updated README.md with the latest commands and regex arguments

parent c5074946
No related branches found
No related tags found
No related merge requests found
...@@ -36,7 +36,7 @@ CMD is the Command to run. Except for "login", all Commands require an access to ...@@ -36,7 +36,7 @@ CMD is the Command to run. Except for "login", all Commands require an access to
The access token is read from the env. variable "NEXUS_TOKEN". The access token is read from the env. variable "NEXUS_TOKEN".
List of supported Commands: List of supported Commands:
login Login and obtain an access token. login Login and obtain an access token.
whoami Display the authenticated user's details. whoami Display the current user's details.
passwd Update the current user's password. passwd Update the current user's password.
user_list List users (regex matching). user_list List users (regex matching).
user_add Add a user. user_add Add a user.
...@@ -52,11 +52,11 @@ List of supported Commands: ...@@ -52,11 +52,11 @@ List of supported Commands:
vm_start Start one or more VMs (regex matching). vm_start Start one or more VMs (regex matching).
vm_stop Stop one or more VMs (regex matching). vm_stop Stop one or more VMs (regex matching).
vm_attach Attach to a VM in order to use its desktop environment. vm_attach Attach to a VM in order to use its desktop environment.
vm_create Create one or more VMs. vm_create Create one or more VMs (regex matching).
vm_edit Edit a VM's properties: name, cpus, ram or nic (regex matching). vm_edit Edit one or more VMs' properties: name, cpus, ram or nic (regex matching).
vm_del Delete one or more VMs (regex matching). vm_del Delete one or more VMs (regex matching).
vm_setaccess Set the VM access for a given user. vm_setaccess Set a user's VM access in one or more VMs (regex matching).
vm_delaccess Delete the VM access for a given user. vm_delaccess Delete a user's VM access in one or more VMs (regex matching).
tpl_list List available templates (regex matching). tpl_list List available templates (regex matching).
tpl_create Create a template. tpl_create Create a template.
tpl_del Delete one or more templates. tpl_del Delete one or more templates.
...@@ -69,7 +69,7 @@ Get the source code with: ...@@ -69,7 +69,7 @@ Get the source code with:
git clone ssh://git@ssh.hesge.ch:10572/flg_projects/nexus_vdi/nexus-client.git git clone ssh://git@ssh.hesge.ch:10572/flg_projects/nexus_vdi/nexus-client.git
``` ```
To build and run `nexus-client`, go into `src/client_cli`, then run: To build and run `nexus-client`, go into `src/client_cli` and run:
``` ```
go run . go run .
``` ```
...@@ -94,6 +94,16 @@ export NEXUS_CERT=ca-cert.pem ...@@ -94,6 +94,16 @@ export NEXUS_CERT=ca-cert.pem
### nexus-client usage examples ### nexus-client usage examples
List all available commands:
```
nexus-client
```
Display the help for the `vm_create` command:
```
nexus-client vm_create
```
Authentify user `janedoe@nexus.org` and obtain an access token: Authentify user `janedoe@nexus.org` and obtain an access token:
``` ```
export NEXUS_TOKEN=`nexus-client login janedoe@nexus.org pipomolo` export NEXUS_TOKEN=`nexus-client login janedoe@nexus.org pipomolo`
...@@ -106,7 +116,12 @@ nexus-client whoami ...@@ -106,7 +116,12 @@ nexus-client whoami
List all users: List all users:
``` ```
nexus-client user_list nexus-client user_list .
```
List users matching the "jane" pattern:
```
nexus-client user_list jane
``` ```
Add new user `lukesky@force.org` with a list of capabilities: Add new user `lukesky@force.org` with a list of capabilities:
...@@ -114,14 +129,24 @@ Add new user `lukesky@force.org` with a list of capabilities: ...@@ -114,14 +129,24 @@ Add new user `lukesky@force.org` with a list of capabilities:
nexus-client user_add lukesky@force.org Luke Skywalker pipomolo USER_CREATE USER_DESTROY USER_LIST USER_SET_CAPS VM_CREATE nexus-client user_add lukesky@force.org Luke Skywalker pipomolo USER_CREATE USER_DESTROY USER_LIST USER_SET_CAPS VM_CREATE
``` ```
List listable VMs: List all listable VMs:
```
nexus-client vmlist .
```
List listable VMs matching the "ubuntu" pattern:
```
nexus-client vmlist ubuntu
```
List listable VMs matching the "ubuntu" pattern and also the VM with ID `6713ce26-941e-4d95-8e92-6b71d44bf75a`:
``` ```
nexus-client vmlist nexus-client vmlist ubuntu 6713ce26-941e-4d95-8e92-6b71d44bf75a
``` ```
List VMs that can be started: List all VMs that can be started:
``` ```
nexus-client vmlist_start nexus-client vmlist_start .
``` ```
Start VM `6713ce26-941e-4d95-8e92-6b71d44bf75a`: Start VM `6713ce26-941e-4d95-8e92-6b71d44bf75a`:
...@@ -129,9 +154,14 @@ Start VM `6713ce26-941e-4d95-8e92-6b71d44bf75a`: ...@@ -129,9 +154,14 @@ Start VM `6713ce26-941e-4d95-8e92-6b71d44bf75a`:
nexus-client vm_start 6713ce26-941e-4d95-8e92-6b71d44bf75a nexus-client vm_start 6713ce26-941e-4d95-8e92-6b71d44bf75a
``` ```
List VMs that can be attached to: Start VMs matching the "exam ISC_433 PCO" pattern:
``` ```
nexus-client vmlist_start nexus-client vm_start "exam ISC_433 PCO"
```
List all VMs that can be attached to:
```
nexus-client vmlist_attach .
``` ```
Attach to VM `6713ce26-941e-4d95-8e92-6b71d44bf75a`: Attach to VM `6713ce26-941e-4d95-8e92-6b71d44bf75a`:
...@@ -139,9 +169,14 @@ Attach to VM `6713ce26-941e-4d95-8e92-6b71d44bf75a`: ...@@ -139,9 +169,14 @@ Attach to VM `6713ce26-941e-4d95-8e92-6b71d44bf75a`:
nexus-client vm_attach 6713ce26-941e-4d95-8e92-6b71d44bf75a nexus-client vm_attach 6713ce26-941e-4d95-8e92-6b71d44bf75a
``` ```
List VMs that can be stopped: List all VMs that can be stopped:
``` ```
nexus-client vmlist_stop nexus-client vmlist_stop .
```
Stop VMs matching the "exam ISC_433 PCO" pattern:
```
nexus-client vm_stop "exam ISC_433 PCO"
``` ```
Stop VM `6713ce26-941e-4d95-8e92-6b71d44bf75a`: Stop VM `6713ce26-941e-4d95-8e92-6b71d44bf75a`:
...@@ -149,14 +184,27 @@ Stop VM `6713ce26-941e-4d95-8e92-6b71d44bf75a`: ...@@ -149,14 +184,27 @@ Stop VM `6713ce26-941e-4d95-8e92-6b71d44bf75a`:
nexus-client vm_stop 6713ce26-941e-4d95-8e92-6b71d44bf75a nexus-client vm_stop 6713ce26-941e-4d95-8e92-6b71d44bf75a
``` ```
Create the ChocDoom VM with 4 CPUs, 2GB RAM, a network interface with NAT translation (`user`) and based on the `fbccb584-9ea6-40f7-926d-dabf3970525e` template (chocolate-doom): Create a VM named "Doom", based on the `fbccb584-9ea6-40f7-926d-dabf3970525e` (Doom) template, with 4 CPUs, 4GB RAM, and a network interface with NAT translation:
```
nexus-client vm_create Doom 4 4096 user fbccb584-9ea6-40f7-926d-dabf3970525e
```
Create 50 VMs with the base name "ISC_433 Exam" based on the `6713ce26-941e-4d95-8e92-6b71d44bf75a` template, with 2 CPUs, 2GB RAM, and no network interface:
```
nexus-client vm_create "ISC_433 Exam" 2 2048 none 6713ce26-941e-4d95-8e92-6b71d44bf75a 50
``` ```
nexus-client vm_create HepiaDoom 4 2048 user fbccb584-9ea6-40f7-926d-dabf3970525e It takes about 30 seconds and 11MB of disk space to create these 50 VMs.
They will have the following names:
```
ISC_433 Exam [1]
ISC_433 Exam [2]
...
ISC_433 Exam [50]
``` ```
List VMs that can be edited: List all VMs that can be edited:
``` ```
nexus-client vmlist_edit nexus-client vmlist_edit .
``` ```
Edit VM `6713ce26-941e-4d95-8e92-6b71d44bf75a` by changing its name to "Tagada VM", changing it to 1 CPU and no network interface (`none`): Edit VM `6713ce26-941e-4d95-8e92-6b71d44bf75a` by changing its name to "Tagada VM", changing it to 1 CPU and no network interface (`none`):
...@@ -164,9 +212,14 @@ Edit VM `6713ce26-941e-4d95-8e92-6b71d44bf75a` by changing its name to "Tagada V ...@@ -164,9 +212,14 @@ Edit VM `6713ce26-941e-4d95-8e92-6b71d44bf75a` by changing its name to "Tagada V
nexus-client vm_edit 6713ce26-941e-4d95-8e92-6b71d44bf75a name="Tagada VM" cpus=1 nic=none nexus-client vm_edit 6713ce26-941e-4d95-8e92-6b71d44bf75a name="Tagada VM" cpus=1 nic=none
``` ```
List VMs that can be deleted: Edit VMs matching the "PCO lab2" pattern by changing their CPU to 1 core and a network interface with NAT translation (`user`):
``` ```
nexus-client vmlist_del nexus-client vm_edit "PCO lab2" cpus=1 nic=user
```
List all VMs that can be deleted:
```
nexus-client vmlist_del .
``` ```
Delete VM `6713ce26-941e-4d95-8e92-6b71d44bf75a`: Delete VM `6713ce26-941e-4d95-8e92-6b71d44bf75a`:
...@@ -174,16 +227,14 @@ Delete VM `6713ce26-941e-4d95-8e92-6b71d44bf75a`: ...@@ -174,16 +227,14 @@ Delete VM `6713ce26-941e-4d95-8e92-6b71d44bf75a`:
nexus-client vm_del 6713ce26-941e-4d95-8e92-6b71d44bf75a nexus-client vm_del 6713ce26-941e-4d95-8e92-6b71d44bf75a
``` ```
Automatically create 50 VMs (`Student_VM1` to `Student_VM50`) based on the `8ae56a30-3195-4aea-960d-abb45c47f99e` template (Xubuntu 22.04) with 2 CPUs, 2GB RAM and no network interface: Delete VMs matching the "exam ISC_433 PCO" pattern:
``` ```
for i in {1..50}; do nexus_client vm_create Student_VM$i 2 2048 none 8ae56a30-3195-4aea-960d-abb45c47f99e; done nexus-client vm_del "exam ISC_433 PCO"
``` ```
Remark: it takes about 30 seconds and 11MB of disk space to create the 50 VMs above. List all VMs that can have their access edited:
List VMs that can have their access edited:
``` ```
nexus-client vmlist_editaccess nexus-client vmlist_editaccess .
``` ```
Set the VM access for VM `89649fe3-4940-4b77-929e-50903789cd87` with: `VM_LIST` and `VM_DESTROY` for user `student@nexus.org`: Set the VM access for VM `89649fe3-4940-4b77-929e-50903789cd87` with: `VM_LIST` and `VM_DESTROY` for user `student@nexus.org`:
...@@ -191,14 +242,29 @@ Set the VM access for VM `89649fe3-4940-4b77-929e-50903789cd87` with: `VM_LIST` ...@@ -191,14 +242,29 @@ Set the VM access for VM `89649fe3-4940-4b77-929e-50903789cd87` with: `VM_LIST`
nexus-client vm_setaccess 89649fe3-4940-4b77-929e-50903789cd87 student@nexus.org VM_LIST VM_DESTROY nexus-client vm_setaccess 89649fe3-4940-4b77-929e-50903789cd87 student@nexus.org VM_LIST VM_DESTROY
``` ```
Remove any VM access for `student@nexus.org` from VM `89649fe3-4940-4b77-929e-50903789cd87`: Set VM access for VMs matching the "alpine" pattern with: `VM_START` and `VM_STOP` for user `student@nexus.org`:
```
nexus-client vm_setaccess alpine student@nexus.org VM_START VM_STOP
```
Remove VM access for `student@nexus.org` from VM `89649fe3-4940-4b77-929e-50903789cd87`:
``` ```
nexus-client vm_delaccess 89649fe3-4940-4b77-929e-50903789cd87 student@nexus.org nexus-client vm_delaccess 89649fe3-4940-4b77-929e-50903789cd87 student@nexus.org
``` ```
List available templates: Remove VM access for `student@nexus.org` from VMs matching the "lab2" pattern:
```
nexus-client vm_delaccess lab2 student@nexus.org
```
List all available templates:
```
nexus-client tpl_list .
```
List templates matching the "ubuntu" pattern:
``` ```
nexus-client tpl_list nexus-client tpl_list ubuntu
``` ```
Create a new `public` template, named "Xubuntu 22.04 + golang toolchain" based on VM `89649fe3-4940-4b77-929e-50903789cd87` (`public` templates are accessible to everyone while `private` templates are only accessible to their creators): Create a new `public` template, named "Xubuntu 22.04 + golang toolchain" based on VM `89649fe3-4940-4b77-929e-50903789cd87` (`public` templates are accessible to everyone while `private` templates are only accessible to their creators):
...@@ -220,7 +286,7 @@ Get the source code with: ...@@ -220,7 +286,7 @@ Get the source code with:
git clone ssh://git@ssh.hesge.ch:10572/flg_projects/nexus_vdi/nexus-client.git git clone ssh://git@ssh.hesge.ch:10572/flg_projects/nexus_vdi/nexus-client.git
``` ```
To build and run `nexus-client-exam`, go into `src/client_exam`, then run: To build and run `nexus-client-exam`, go into `src/client_exam` and run:
``` ```
go run . go run .
``` ```
......
...@@ -15,7 +15,7 @@ func (cmd *Create)GetName() string { ...@@ -15,7 +15,7 @@ func (cmd *Create)GetName() string {
} }
func (cmd *Create)GetDesc() string { func (cmd *Create)GetDesc() string {
return "Create one or more VMs." return "Create one or more VMs (regex matching)."
} }
func (cmd *Create)PrintUsage() { func (cmd *Create)PrintUsage() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment