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

Bumpped to version 1.0.1

Renamed some commands for better clarity:
- useradd -> usercreate
- vmstop -> vmkill
- vmsetaccess -> vmaddaccess
Fixed a bug in the validate script in case more than 1 VM is named Xubuntu
parent 54c8c684
No related branches found
No related tags found
No related merge requests found
...@@ -106,7 +106,7 @@ passwd Updates the current user's password. ...@@ -106,7 +106,7 @@ passwd Updates the current user's password.
userlist Lists users (regex). userlist Lists users (regex).
Requires USER_LIST user capability. Requires USER_LIST user capability.
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
useradd Adds a user. usercreate Creates a user.
Requires USER_CREATE user capability. Requires USER_CREATE user capability.
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
userdel Deletes one or more users. userdel Deletes one or more users.
...@@ -124,7 +124,7 @@ vmcred2pdf Creates a PDF with the credentials required to attach to run ...@@ -124,7 +124,7 @@ vmcred2pdf Creates a PDF with the credentials required to attach to run
vmstart Starts one or more VMs (regex). vmstart Starts one or more VMs (regex).
Requires VM_START VM access capability or VM_START_ANY user capability. Requires VM_START VM access capability or VM_START_ANY user capability.
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
vmstop Stops by force one or more VMs (regex). vmkill Kill one or more VMs (regex).
Requires VM_STOP VM access capability or VM_STOP_ANY user capability. Requires VM_STOP VM access capability or VM_STOP_ANY user capability.
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
vmshutdown Gracefully shutdowns one or more VMs (regex). vmshutdown Gracefully shutdowns one or more VMs (regex).
...@@ -142,7 +142,7 @@ vmedit Edits one or more VMs' properties: name, cpus, ram or nic (r ...@@ -142,7 +142,7 @@ vmedit Edits one or more VMs' properties: name, cpus, ram or nic (r
vmdel Deletes one or more VMs (regex). vmdel Deletes one or more VMs (regex).
Requires VM_DESTROY VM access capability or VM_DESTROY_ANY user capability. Requires VM_DESTROY VM access capability or VM_DESTROY_ANY user capability.
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
vmsetaccess Sets a user's VM access in one or more VMs (regex). vmaddaccess Adds a user's VM access in one or more VMs (regex).
Requires VM_SET_ACCESS user capability and VM_SET_ACCESS VM access capability. Requires VM_SET_ACCESS user capability and VM_SET_ACCESS VM access capability.
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
vmdelaccess Removes a user's VM access in one or more VMs (regex). vmdelaccess Removes a user's VM access in one or more VMs (regex).
......
...@@ -15,7 +15,7 @@ func (cmd *Add)GetName() string { ...@@ -15,7 +15,7 @@ func (cmd *Add)GetName() string {
func (cmd *Add)GetDesc() []string { func (cmd *Add)GetDesc() []string {
return []string{ return []string{
"Adds a user.", "Creates a user.",
"Requires USER_CREATE user capability."} "Requires USER_CREATE user capability."}
} }
......
...@@ -34,7 +34,7 @@ func (cmd *Create)PrintUsage() { ...@@ -34,7 +34,7 @@ func (cmd *Create)PrintUsage() {
const usage string = `name name of the VM const usage string = `name name of the VM
cpus Number of CPUs, between 1 and 16. cpus Number of CPUs, between 1 and 16.
ram Amount of RAM in MB, between 512 and 32768. ram Amount of RAM in MB, between 512 and 32768.
nic Network interface, either "none" or "user". nic Network interface, either "none" (no network) or "user" (network access).
template ID of the template to VM will be based on. template ID of the template to VM will be based on.
count Number of VMs to create (if not specified, one is created). count Number of VMs to create (if not specified, one is created).
If specified and > 1, the VM name is postfixed with [n], If specified and > 1, the VM name is postfixed with [n],
......
...@@ -28,13 +28,7 @@ func (cmd *DelAccess)PrintUsage() { ...@@ -28,13 +28,7 @@ func (cmd *DelAccess)PrintUsage() {
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――") u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("USAGE: "+cmd.GetName()+" [ID ...] [regex ...] email") u.PrintlnErr("USAGE: "+cmd.GetName()+" [ID ...] [regex ...] email")
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――") u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
const usage string = `Only VMs matching the specified IDs or regexes will have their VM access removed. printRegexUsageDetails()
Any number of IDs or regexes can be specified.
The regex only matches the VM's name and is case-insensitive.
Regex examples:
"." -> matches any VMs
"bla" -> matches any VMs containing "bla" in their name`
u.PrintlnErr(usage)
} }
func (cmd *DelAccess)Run(args []string) int { func (cmd *DelAccess)Run(args []string) int {
......
...@@ -36,16 +36,11 @@ func (cmd *Edit)PrintUsage() { ...@@ -36,16 +36,11 @@ func (cmd *Edit)PrintUsage() {
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――") u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("USAGE: "+cmd.GetName()+" [ID ...] [regex ...] [name=\"new name\"] [cpus=n] [ram=n] [nic=none/user]") u.PrintlnErr("USAGE: "+cmd.GetName()+" [ID ...] [regex ...] [name=\"new name\"] [cpus=n] [ram=n] [nic=none/user]")
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――") u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
const usage string = `Only VMs matching the specified IDs or regexes will be edited. printRegexUsageDetails()
Any number of IDs or regexes can be specified. const usage string = `VM parameters that can be edited:
The regex only matches the VM's name and is case-insensitive.
Regex examples:
"." -> matches any VMs
"bla" -> matches any VMs containing "bla" in their name
VM parameters that can be edited are the following:
cpus must be between 1 and 16 cpus must be between 1 and 16
ram must be between 512 and 32768 ram must be between 512 and 32768
nic must be either "none" or "user` nic must be either "none" (no network) or "user (network access)`
u.PrintlnErr(usage) u.PrintlnErr(usage)
} }
......
...@@ -10,7 +10,7 @@ func (cmd *ListStop)GetName() string { ...@@ -10,7 +10,7 @@ func (cmd *ListStop)GetName() string {
func (cmd *ListStop)GetDesc() []string { func (cmd *ListStop)GetDesc() []string {
return []string{ return []string{
"Lists VMs that can be stopped or shutdown (regex).", "Lists VMs that can be killed or shutdown (regex).",
"Requires VM_STOP VM access capability or VM_STOP_ANY user capability."} "Requires VM_STOP VM access capability or VM_STOP_ANY user capability."}
} }
......
...@@ -17,7 +17,7 @@ func (cmd *SetAccess)GetName() string { ...@@ -17,7 +17,7 @@ func (cmd *SetAccess)GetName() string {
func (cmd *SetAccess)GetDesc() []string { func (cmd *SetAccess)GetDesc() []string {
return []string{ return []string{
"Sets a user's VM access in one or more VMs (regex).", "Adds a user's VM access in one or more VMs (regex).",
"Requires VM_SET_ACCESS user capability and VM_SET_ACCESS VM access capability."} "Requires VM_SET_ACCESS user capability and VM_SET_ACCESS VM access capability."}
} }
...@@ -28,13 +28,7 @@ func (cmd *SetAccess)PrintUsage() { ...@@ -28,13 +28,7 @@ func (cmd *SetAccess)PrintUsage() {
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――") u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("USAGE: "+cmd.GetName()+" [ID ...] [regex ...] email [capability ...]") u.PrintlnErr("USAGE: "+cmd.GetName()+" [ID ...] [regex ...] email [capability ...]")
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――") u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
const usage string = `Only VMs matching the specified IDs or regexes will have their VM access set. printRegexUsageDetails()
Any number of IDs or regexes can be specified.
The regex only matches the VM's name and is case-insensitive.
Regex examples:
"." -> matches any VMs
"bla" -> matches any VMs containing "bla" in their name`
u.PrintlnErr(usage)
} }
func (cmd *SetAccess)Run(args []string) int { func (cmd *SetAccess)Run(args []string) int {
......
...@@ -15,7 +15,7 @@ func (cmd *Stop)GetName() string { ...@@ -15,7 +15,7 @@ func (cmd *Stop)GetName() string {
func (cmd *Stop)GetDesc() []string { func (cmd *Stop)GetDesc() []string {
return []string{ return []string{
"Stops by force one or more VMs (regex).", "Kill one or more VMs (regex).",
"Requires VM_STOP VM access capability or VM_STOP_ANY user capability."} "Requires VM_STOP VM access capability or VM_STOP_ANY user capability."}
} }
......
...@@ -26,7 +26,7 @@ var cmdList = []cmd.Command { ...@@ -26,7 +26,7 @@ var cmdList = []cmd.Command {
&cmdUser.Whoami{"whoami"}, &cmdUser.Whoami{"whoami"},
&cmdUser.UpdatePwd{"passwd"}, &cmdUser.UpdatePwd{"passwd"},
&cmdUser.List{"userlist"}, &cmdUser.List{"userlist"},
&cmdUser.Add{"useradd"}, &cmdUser.Add{"usercreate"},
&cmdUser.Del{"userdel"}, &cmdUser.Del{"userdel"},
&cmdUser.SetCaps{"usersetcaps"}, &cmdUser.SetCaps{"usersetcaps"},
...@@ -42,13 +42,13 @@ var cmdList = []cmd.Command { ...@@ -42,13 +42,13 @@ var cmdList = []cmd.Command {
&cmdVM.Cred2pdf{"vmcred2pdf"}, &cmdVM.Cred2pdf{"vmcred2pdf"},
&cmdVM.Start{"vmstart"}, &cmdVM.Start{"vmstart"},
&cmdVM.Stop{"vmstop"}, &cmdVM.Stop{"vmkill"},
&cmdVM.Shutdown{"vmshutdown"}, &cmdVM.Shutdown{"vmshutdown"},
&cmdVM.Attach{"vmattach"}, &cmdVM.Attach{"vmattach"},
&cmdVM.Create{"vmcreate"}, &cmdVM.Create{"vmcreate"},
&cmdVM.Edit{"vmedit"}, &cmdVM.Edit{"vmedit"},
&cmdVM.Del{"vmdel"}, &cmdVM.Del{"vmdel"},
&cmdVM.SetAccess{"vmsetaccess"}, &cmdVM.SetAccess{"vmaddaccess"},
&cmdVM.DelAccess{"vmdelaccess"}, &cmdVM.DelAccess{"vmdelaccess"},
&cmdVM.ExportDir{"vmexportdir"}, &cmdVM.ExportDir{"vmexportdir"},
&cmdVM.ImportDir{"vmimportdir"}, &cmdVM.ImportDir{"vmimportdir"},
...@@ -61,7 +61,7 @@ var cmdList = []cmd.Command { ...@@ -61,7 +61,7 @@ var cmdList = []cmd.Command {
func main() { func main() {
var appname = path.Base(os.Args[0]) var appname = path.Base(os.Args[0])
u.Println(appname+" version "+version.Get().String()) u.PrintlnErr(appname+" version "+version.Get().String())
if err := exec.CheckRemoteViewer(); err != nil { if err := exec.CheckRemoteViewer(); err != nil {
u.PrintlnErr(err.Error()) u.PrintlnErr(err.Error())
......
...@@ -16,7 +16,7 @@ del_gen_files () { ...@@ -16,7 +16,7 @@ del_gen_files () {
cleanup () { cleanup () {
echo "" echo ""
echo "Cleaning up..." echo "Cleaning up..."
$nexus_cli vmstop "$full_name" $nexus_cli vmkill "$full_name"
sleep 3 sleep 3
$nexus_cli vmdel "$partial_name" $nexus_cli vmdel "$partial_name"
$nexus_cli tpldel "$partial_name" $nexus_cli tpldel "$partial_name"
...@@ -54,61 +54,64 @@ pwd=$2 ...@@ -54,61 +54,64 @@ pwd=$2
echo "Log in..." echo "Log in..."
export NEXUS_TOKEN=`$nexus_cli login $email $pwd` export NEXUS_TOKEN=`$nexus_cli login $email $pwd`
checkVar $NEXUS_TOKEN "login" if [ -z "$NEXUS_TOKEN" ]; then
echo "[FATAL] login failed."
exit 1
fi
OK OK
echo "Listing templates..." echo "List templates..."
baseTemplateID=`$nexus_cli tpllist . | grep "Xubuntu 22.04" | awk -F"|" '{print $2}'` baseTemplateID=`$nexus_cli tpllist . | grep "Xubuntu 22.04" | awk -F"|" '{print $2}'|head -n1`
checkVar $baseTemplateID "tpllist" checkVar $baseTemplateID "tpllist"
OK OK
echo "Creating base VM..." echo "Create base VM..."
vmID=`$nexus_cli vmcreate "$partial_name" 2 3000 user $baseTemplateID | awk -F"|" '{print $2}'` vmID=`$nexus_cli vmcreate "$partial_name" 2 3000 user $baseTemplateID | awk -F"|" '{print $2}'`
checkVar $vmID "vmcreate base VM" checkVar $vmID "vmcreate base VM"
OK OK
echo "Importing files into VM..." echo "Import files into VM..."
$nexus_cli vmimportdir "$partial_name" validation_data/exam /home $nexus_cli vmimportdir "$partial_name" validation_data/exam /home
check "vmimportdir" check "vmimportdir"
OK OK
echo "Creating template from VM (can take a few minutes)..." echo "Create template from VM (can take a few minutes)..."
templateID=`$nexus_cli tplcreate $vmID "$partial_name" private | grep \"id\" | awk -F'"' '{print $4}'` templateID=`$nexus_cli tplcreate $vmID "$partial_name" private | grep \"id\" | awk -F'"' '{print $4}'`
checkVar $templateID "tplcreate" checkVar $templateID "tplcreate"
OK OK
echo "Creating students VMs..." echo "Create students VMs..."
$nexus_cli vmcreate "$full_name" 1 2000 none $templateID validation_data/students.csv $nexus_cli vmcreate "$full_name" 1 2000 none $templateID validation_data/students.csv
check "vmcreate VMs" check "vmcreate VMs"
OK OK
echo "Starting students VMs..." echo "Start students VMs..."
$nexus_cli vmstart "$full_name" $nexus_cli vmstart "$full_name"
check "vmstart VMs" check "vmstart VMs"
OK OK
echo "Generating credentials pdf..." echo "Generate credentials pdf..."
$nexus_cli vmcred2pdf "$full_name" $creds_file $nexus_cli vmcred2pdf "$full_name" $creds_file
check "vmcred2pdf" check "vmcred2pdf"
OK OK
echo "Exporting files from VMs..." echo "Export files from VMs..."
$nexus_cli vmexportdir "$full_name" /home $nexus_cli vmexportdir "$full_name" /home
check "vmexportdir" check "vmexportdir"
OK OK
echo "Stopping students VMs..." echo "Kill students VMs..."
$nexus_cli vmstop "$full_name" $nexus_cli vmkill "$full_name"
sleep 3 sleep 3
check "vmstop VMs" check "vmstop VMs"
OK OK
echo "Deleting students VMs..." echo "Delete students VMs..."
$nexus_cli vmdel "$partial_name" $nexus_cli vmdel "$partial_name"
check "vmdel VMs" check "vmdel VMs"
OK OK
echo "Deleting template..." echo "Delete template..."
$nexus_cli tpldel "$partial_name" $nexus_cli tpldel "$partial_name"
check "tpldel" check "tpldel"
OK OK
......
...@@ -33,7 +33,7 @@ var cmdList = []cmd.Command { ...@@ -33,7 +33,7 @@ var cmdList = []cmd.Command {
&cmdUser.Whoami{"whoami"}, &cmdUser.Whoami{"whoami"},
&cmdUser.UpdatePwd{"passwd"}, &cmdUser.UpdatePwd{"passwd"},
&cmdUser.List{"userlist"}, &cmdUser.List{"userlist"},
&cmdUser.Add{"useradd"}, &cmdUser.Add{"usercreate"},
&cmdUser.Del{"userdel"}, &cmdUser.Del{"userdel"},
&cmdUser.SetCaps{"usersetcaps"}, &cmdUser.SetCaps{"usersetcaps"},
...@@ -49,13 +49,13 @@ var cmdList = []cmd.Command { ...@@ -49,13 +49,13 @@ var cmdList = []cmd.Command {
&cmdVM.Cred2pdf{"vmcred2pdf"}, &cmdVM.Cred2pdf{"vmcred2pdf"},
&cmdVM.Start{"vmstart"}, &cmdVM.Start{"vmstart"},
&cmdVM.Stop{"vmstop"}, &cmdVM.Stop{"vmkill"},
&cmdVM.Shutdown{"vmshutdown"}, &cmdVM.Shutdown{"vmshutdown"},
&cmdVM.Attach{"vmattach"}, &cmdVM.Attach{"vmattach"},
&cmdVM.Create{"vmcreate"}, &cmdVM.Create{"vmcreate"},
&cmdVM.Edit{"vmedit"}, &cmdVM.Edit{"vmedit"},
&cmdVM.Del{"vmdel"}, &cmdVM.Del{"vmdel"},
&cmdVM.SetAccess{"vmsetaccess"}, &cmdVM.SetAccess{"vmaddaccess"},
&cmdVM.DelAccess{"vmdelaccess"}, &cmdVM.DelAccess{"vmdelaccess"},
&cmdVM.ExportDir{"vmexportdir"}, &cmdVM.ExportDir{"vmexportdir"},
&cmdVM.ImportDir{"vmimportdir"}, &cmdVM.ImportDir{"vmimportdir"},
...@@ -68,7 +68,7 @@ var cmdList = []cmd.Command { ...@@ -68,7 +68,7 @@ var cmdList = []cmd.Command {
func main() { func main() {
var appname = path.Base(os.Args[0]) var appname = path.Base(os.Args[0])
u.Println(appname+" version "+version.Get().String()) u.PrintlnErr(appname+" version "+version.Get().String())
if err := exec.CheckRemoteViewer(); err != nil { if err := exec.CheckRemoteViewer(); err != nil {
u.PrintlnErr(err.Error()) u.PrintlnErr(err.Error())
...@@ -126,7 +126,7 @@ func main() { ...@@ -126,7 +126,7 @@ func main() {
// Logins and obtains a JWT token. // Logins and obtains a JWT token.
token, err := cmdLogin.GetToken(email, pwd) token, err := cmdLogin.GetToken(email, pwd)
u.Println("") u.PrintlnErr("")
if err != nil { if err != nil {
u.PrintlnErr("Error: "+err.Error()) u.PrintlnErr("Error: "+err.Error())
os.Exit(1) os.Exit(1)
......
...@@ -8,7 +8,7 @@ import ( ...@@ -8,7 +8,7 @@ import (
const ( const (
major = 1 major = 1
minor = 0 minor = 0
bugfix = 0 bugfix = 1
) )
type Version struct { type Version struct {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment