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

nexush 1.1.0

- added vmreboot command
- vmattach is not blocking anymore
parent c3c6f860
No related branches found
No related tags found
No related merge requests found
......@@ -45,7 +45,8 @@ The table below lists all potential capabilities associated to a user:
| VM_DESTROY_ANY | Can destoy **ANY** VM |
| VM_EDIT_ANY | Can edit **ANY** VM |
| VM_START_ANY | Can start **ANY** VM |
| VM_STOP_ANY | Can stop **ANY** VM |
| VM_STOP_ANY | Can kill/shutdown **ANY** VM |
| VM_REBOOT_ANY | Can Reboot **ANY** VM |
| VM_LIST_ANY | Can list **ANY** VM |
| VM_READFS_ANY | Can export files from **ANY** VM |
| VM_WRITEFS_ANY | Can import files into **ANY** VM |
......@@ -72,7 +73,8 @@ These capabilities are called "VM access capabilities":
| VM_DESTROY | User can destroy the VM |
| VM_EDIT | User can edit the VM |
| VM_START | User can start the VM |
| VM_STOP | User can stop/shutdown the VM |
| VM_STOP | User can kill/shutdown the VM |
| VM_REBOOT | User can reboot the VM |
| VM_LIST | User can list or attach to the VM |
| VM_READFS | User can export files from the VM |
| VM_WRITEFS | User can import files into the VM |
......@@ -115,7 +117,7 @@ userdel Deletes one or more users.
usersetcaps Sets a user's capabilities.
Requires USER_SET_CAPS user capability.
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
vmlist Lists VMs that can be listed.
vmlist Lists VMs.
Requires VM_LIST VM access capability or VM_LIST_ANY user capability.
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
vmcred2pdf Creates a PDF with the credentials required to attach to running VMs.
......@@ -130,6 +132,9 @@ vmkill Kills one or more VMs.
vmshutdown Gracefully shutdowns one or more VMs.
Requires VM_STOP VM access capability or VM_STOP_ANY user capability.
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
vmreboot Gracefully reboots one or more VMs.
Requires VM_REBOOT VM access capability or VM_REBOOT_ANY user capability.
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
vmattach Attaches to one or more VMs in order to use their desktop environment.
Requires VM_LIST VM access capability or VM_LIST_ANY user capability.
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
......@@ -244,11 +249,6 @@ List listable VMs matching the "ubuntu" pattern and also the VM with ID `6713ce2
vmlist ubuntu 6713ce26-941e-4d95-8e92-6b71d44bf75a
```
List all VMs that can be started:
```
vmliststart .
```
Start VM `6713ce26-941e-4d95-8e92-6b71d44bf75a`:
```
vmstart 6713ce26-941e-4d95-8e92-6b71d44bf75a
......@@ -259,21 +259,11 @@ Start VMs matching the "exam ISC_433 PCO" pattern:
vmstart "exam ISC_433 PCO"
```
List all VMs that can be attached to:
```
vmlistattach .
```
Attach to VM `6713ce26-941e-4d95-8e92-6b71d44bf75a` and all VMs matching the pattern "zorglub":
```
vmattach 6713ce26-941e-4d95-8e92-6b71d44bf75a zorglub
```
List all VMs that can be shutdowned or stopped:
```
vmliststop .
```
Shutdown VMs matching the "exam ISC_433 PCO" pattern (for this to work, `qemu-guest-agent` must be running in the VM's guest OS!):
```
vmshutdown "exam ISC_433 PCO"
......@@ -302,11 +292,6 @@ ISC_433 Exam [2]
ISC_433 Exam [50]
```
List all VMs that can be edited:
```
vmlistedit .
```
Edit VM `6713ce26-941e-4d95-8e92-6b71d44bf75a` by changing its name to "Tagada VM", changing it to 1 CPU and no network interface (`none`):
```
vmedit 6713ce26-941e-4d95-8e92-6b71d44bf75a name="Tagada VM" cpus=1 nic=none
......@@ -317,11 +302,6 @@ Edit VMs matching the "PCO lab2" pattern by changing their CPU to 1 core and a n
vmedit "PCO lab2" cpus=1 nic=user
```
List all VMs that can be deleted:
```
vmlistdel .
```
Delete VM `6713ce26-941e-4d95-8e92-6b71d44bf75a`:
```
vmdel 6713ce26-941e-4d95-8e92-6b71d44bf75a
......@@ -332,11 +312,6 @@ Delete VMs matching the "exam ISC_433 PCO" pattern:
vmdel "exam ISC_433 PCO"
```
List all VMs that can have their access edited:
```
vmlisteditaccess .
```
Set the VM access for VM `89649fe3-4940-4b77-929e-50903789cd87` with: `VM_LIST` and `VM_DESTROY` for user `student@nexus.org`:
```
vmsetaccess 89649fe3-4940-4b77-929e-50903789cd87 student@nexus.org VM_LIST VM_DESTROY
......@@ -364,7 +339,7 @@ vmcred2pdf "exam prog sys" output.pdf
Extract and download the `/home` directory of all VMs matching "exam prog sys" (each directory is saved in a `.tar` archive named after the VM's ID):
```
vmlistexportdir "exam prog sys" /home
vmexportdir "exam prog sys" /home
```
List all available templates:
......
package cmdVM
import (
"sync"
// "sync"
"nexus-client/exec"
u "nexus-client/utils"
g "nexus-client/globals"
......@@ -48,17 +48,17 @@ func (cmd *Attach)Run(args []string) int {
}
// Use wait groups to wait until all viewers threads have completed.
var wg sync.WaitGroup
wg.Add(len(vms))
// var wg sync.WaitGroup
// wg.Add(len(vms))
for _, vm := range(vms) {
go func(vm VM) {
exec.RunRemoteViewer(hostname, cert, vm.Name, vm.Run.Port, vm.Run.Pwd, false)
wg.Done()
// wg.Done()
} (vm)
}
wg.Wait()
// wg.Wait()
return 0
}
......@@ -14,7 +14,7 @@ func (cmd *List)GetName() string {
func (cmd *List)GetDesc() []string {
return []string{
"Lists VMs that can be listed.",
"Lists VMs.",
"Requires VM_LIST VM access capability or VM_LIST_ANY user capability."}
}
......
package cmdVM
import (
u "nexus-client/utils"
g "nexus-client/globals"
)
type Reboot struct {
Name string
}
func (cmd *Reboot)GetName() string {
return cmd.Name
}
func (cmd *Reboot)GetDesc() []string {
return []string{
"Gracefully reboots one or more VMs.",
"Requires VM_REBOOT VM access capability or VM_REBOOT_ANY user capability."}
}
func (cmd *Reboot)PrintUsage() {
printRegexUsage(cmd)
printRegexUsageDetails()
}
func (cmd *Reboot)Run(args []string) int {
client := g.GetInstance().Client
host := g.GetInstance().Host
argc := len(args)
if argc < 1 {
cmd.PrintUsage()
return 1
}
vms, err := getFilteredVMs("/vms/reboot", args)
if err != nil {
u.PrintlnErr(err.Error())
return 1
}
if len(vms) == 0 {
u.PrintlnErr("No match.")
return 1
}
statusCode := 0
for _, vm := range(vms) {
uuid := vm.ID.String()
resp, err := client.R().Put(host+"/vms/"+uuid+"/reboot")
if err != nil {
u.PrintlnErr("Reboot failed for VM \""+vm.Name+"\": "+err.Error())
statusCode = 1
} else {
if resp.IsSuccess() {
u.Println("Sent reboot message to VM \""+vm.Name+"\"")
} else {
u.PrintlnErr("Reboot failed for VM \""+vm.Name+"\": "+resp.Status()+": "+resp.String())
statusCode = 1
}
}
}
return statusCode
}
......@@ -35,6 +35,7 @@ var cmdList = []cmd.Command {
&cmdVM.Start{"vmstart"},
&cmdVM.Stop{"vmkill"},
&cmdVM.Shutdown{"vmshutdown"},
&cmdVM.Reboot{"vmreboot"},
&cmdVM.Attach{"vmattach"},
&cmdVM.Create{"vmcreate"},
&cmdVM.Edit{"vmedit"},
......
......@@ -43,6 +43,7 @@ var cmdList = []cmd.Command {
&cmdVM.Start{"vmstart"},
&cmdVM.Stop{"vmkill"},
&cmdVM.Shutdown{"vmshutdown"},
&cmdVM.Reboot{"vmreboot"},
&cmdVM.Attach{"vmattach"},
&cmdVM.Create{"vmcreate"},
&cmdVM.Edit{"vmedit"},
......
......@@ -7,8 +7,8 @@ import (
const (
major = 1
minor = 0
bugfix = 4
minor = 1
bugfix = 0
)
type Version struct {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment