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

Removed unused commands that had been commented out for a while now (vmListXXX).

Help is now consistent across all commands.
templateExportDisk now takes a 2nd argument: the file into which to save the disk image.
parent ed7d6208
Branches
No related tags found
No related merge requests found
Showing
with 43 additions and 174 deletions
...@@ -25,9 +25,11 @@ func (cmd *Create)PrintUsage() { ...@@ -25,9 +25,11 @@ func (cmd *Create)PrintUsage() {
u.PrintlnErr(desc) u.PrintlnErr(desc)
} }
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――") u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("USAGE: "+cmd.Name+" vmID name access") u.PrintlnErr("USAGE: "+cmd.Name+" ID name access")
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――") u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("Notes: access is either \"public\" or \"private\"") u.PrintlnErr("ID ID of the VM used to create the template.")
u.PrintlnErr("name Name of the template to create.")
u.PrintlnErr("access Access type, either \"public\" or \"private\"")
} }
func (cmd *Create)Run(args []string) int { func (cmd *Create)Run(args []string) int {
......
...@@ -15,7 +15,7 @@ func (cmd *Del)GetName() string { ...@@ -15,7 +15,7 @@ func (cmd *Del)GetName() string {
func (cmd *Del)GetDesc() []string { func (cmd *Del)GetDesc() []string {
return []string{ return []string{
"Deletes one or more templates (regex).", "Deletes one or more templates.",
"Requires TPL_DESTROY or TPL_DESTROY_ANY user capability."} "Requires TPL_DESTROY or TPL_DESTROY_ANY user capability."}
} }
......
...@@ -9,6 +9,8 @@ type ExportDisk struct { ...@@ -9,6 +9,8 @@ type ExportDisk struct {
Name string Name string
} }
const outputFile = "disk.qcow"
func (cmd *ExportDisk)GetName() string { func (cmd *ExportDisk)GetName() string {
return cmd.Name return cmd.Name
} }
...@@ -24,8 +26,10 @@ func (cmd *ExportDisk)PrintUsage() { ...@@ -24,8 +26,10 @@ func (cmd *ExportDisk)PrintUsage() {
u.PrintlnErr(desc) u.PrintlnErr(desc)
} }
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――") u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("USAGE: ",cmd.GetName()," ID") u.PrintlnErr("USAGE: ",cmd.GetName()," ID file")
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――") u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("ID ID of the template for which the disk must be exported.")
u.PrintlnErr("file Name of the file to save the disk into.")
} }
func (cmd *ExportDisk)Run(args []string) int { func (cmd *ExportDisk)Run(args []string) int {
...@@ -33,14 +37,14 @@ func (cmd *ExportDisk)Run(args []string) int { ...@@ -33,14 +37,14 @@ func (cmd *ExportDisk)Run(args []string) int {
host := g.GetInstance().Host host := g.GetInstance().Host
argc := len(args) argc := len(args)
if argc != 1 { if argc != 2 {
cmd.PrintUsage() cmd.PrintUsage()
return 1 return 1
} }
tplID := args[0] tplID := args[0]
outputFile := args[1]
statusCode := 0 statusCode := 0
outputFile := "disk.qcow"
u.Println("Exporting disk from template \""+tplID+"\" into "+outputFile+" ...") u.Println("Exporting disk from template \""+tplID+"\" into "+outputFile+" ...")
......
...@@ -10,7 +10,7 @@ func (cmd *List)GetName() string { ...@@ -10,7 +10,7 @@ func (cmd *List)GetName() string {
func (cmd *List)GetDesc() []string { func (cmd *List)GetDesc() []string {
return []string{ return []string{
"Lists available templates (regex).", "Lists available templates.",
"Requires TPL_LIST or TPL_LIST_ANY user capability."} "Requires TPL_LIST or TPL_LIST_ANY user capability."}
} }
......
...@@ -14,7 +14,7 @@ func (cmd *List)GetName() string { ...@@ -14,7 +14,7 @@ func (cmd *List)GetName() string {
func (cmd *List)GetDesc() []string { func (cmd *List)GetDesc() []string {
return []string{ return []string{
"Lists users (regex).", "Lists users.",
"Requires USER_LIST user capability."} "Requires USER_LIST user capability."}
} }
......
...@@ -17,7 +17,7 @@ func (cmd *Attach)GetName() string { ...@@ -17,7 +17,7 @@ func (cmd *Attach)GetName() string {
func (cmd *Attach)GetDesc() []string { func (cmd *Attach)GetDesc() []string {
return []string{ return []string{
"Attaches to one or more VMs in order to use their desktop environment (regex).", "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."} "Requires VM_LIST VM access capability or VM_LIST_ANY user capability."}
} }
......
...@@ -20,7 +20,7 @@ func (cmd *Create)GetName() string { ...@@ -20,7 +20,7 @@ func (cmd *Create)GetName() string {
func (cmd *Create)GetDesc() []string { func (cmd *Create)GetDesc() []string {
return []string{ return []string{
"Creates one or more VMs (regex).", "Creates one or more VMs.",
"Requires VM_CREATE user capability."} "Requires VM_CREATE user capability."}
} }
...@@ -31,16 +31,16 @@ func (cmd *Create)PrintUsage() { ...@@ -31,16 +31,16 @@ func (cmd *Create)PrintUsage() {
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――") u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("USAGE: "+cmd.Name+" name cpus ram nic template [count|file.csv]") u.PrintlnErr("USAGE: "+cmd.Name+" name cpus ram nic template [count|file.csv]")
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――") u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
const usage string = `name name of the VM const usage string = `name Name of the VM to create.
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" (no network) or "user" (network access). 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, each VM's name is postfixed with [n],
where n ranges from 1..count. where n ranges from 1..count.
file.csv Single-column CSV file defining the students names. file.csv Single-column CSV file defining the students names.
Each VM name is postfixed with each entry in the CSV file.` Each VM's name is postfixed with each entry in the CSV file.`
u.PrintlnErr(usage) u.PrintlnErr(usage)
} }
......
...@@ -16,7 +16,7 @@ func (cmd *Cred2pdf)GetName() string { ...@@ -16,7 +16,7 @@ func (cmd *Cred2pdf)GetName() string {
func (cmd *Cred2pdf)GetDesc() []string { func (cmd *Cred2pdf)GetDesc() []string {
return []string{ return []string{
"Creates a PDF with the credentials required to attach to running VMs (regex).", "Creates a PDF with the credentials required to attach to running VMs.",
"Requires VM_LIST VM access capability or VM_LIST_ANY user capability."} "Requires VM_LIST VM access capability or VM_LIST_ANY user capability."}
} }
......
...@@ -15,7 +15,7 @@ func (cmd *Del)GetName() string { ...@@ -15,7 +15,7 @@ func (cmd *Del)GetName() string {
func (cmd *Del)GetDesc() []string { func (cmd *Del)GetDesc() []string {
return []string{ return []string{
"Deletes one or more VMs (regex).", "Deletes one or more VMs.",
"Requires VM_DESTROY VM access capability or VM_DESTROY_ANY user capability."} "Requires VM_DESTROY VM access capability or VM_DESTROY_ANY user capability."}
} }
......
...@@ -17,7 +17,7 @@ func (cmd *DelAccess)GetName() string { ...@@ -17,7 +17,7 @@ func (cmd *DelAccess)GetName() string {
func (cmd *DelAccess)GetDesc() []string { func (cmd *DelAccess)GetDesc() []string {
return []string{ return []string{
"Removes a user's VM access in one or more VMs (regex).", "Removes a user's VM access in one or more VMs.",
"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."}
} }
......
...@@ -25,7 +25,7 @@ func (cmd *Edit)GetName() string { ...@@ -25,7 +25,7 @@ func (cmd *Edit)GetName() string {
func (cmd *Edit)GetDesc() []string { func (cmd *Edit)GetDesc() []string {
return []string{ return []string{
"Edits one or more VMs' properties: name, cpus, ram or nic (regex).", "Edits one or more VMs' properties: name, cpus, ram or nic.",
"Requires VM_EDIT VM access capability or VM_EDIT_ANY user capability."} "Requires VM_EDIT VM access capability or VM_EDIT_ANY user capability."}
} }
...@@ -36,12 +36,14 @@ func (cmd *Edit)PrintUsage() { ...@@ -36,12 +36,14 @@ 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("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
printRegexUsageDetails() const usage string = `Parameters that can be changed (all optional):
const usage string = `VM parameters that can be edited: name Name of the VM.
cpus must be between 1 and 16 cpus Number of CPUs, between 1 and 16.
ram must be between 512 and 32768 ram Amount of RAM in MB, between 512 and 32768.
nic must be either "none" (no network) or "user (network access)` nic Network interface, either "none" (no network) or "user" (network access).`
u.PrintlnErr(usage) u.PrintlnErr(usage)
u.PrintlnErr("")
printRegexUsageDetails()
} }
func (cmd *Edit)Run(args []string) int { func (cmd *Edit)Run(args []string) int {
......
...@@ -21,7 +21,6 @@ func (cmd *ExportDir)GetName() string { ...@@ -21,7 +21,6 @@ func (cmd *ExportDir)GetName() string {
func (cmd *ExportDir)GetDesc() []string { func (cmd *ExportDir)GetDesc() []string {
return []string{ return []string{
"Exports one or more VMs' directory into one or more tar archives.", "Exports one or more VMs' directory into one or more tar archives.",
"Creates one archive per VM (regex).",
"Requires VM_READFS VM access capability or VM_READFS_ANY user capability."} "Requires VM_READFS VM access capability or VM_READFS_ANY user capability."}
} }
...@@ -30,9 +29,12 @@ func (cmd *ExportDir)PrintUsage() { ...@@ -30,9 +29,12 @@ func (cmd *ExportDir)PrintUsage() {
u.PrintlnErr(desc) u.PrintlnErr(desc)
} }
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――") u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("USAGE: ",cmd.GetName()," [ID ...] [regex ...] dir") u.PrintlnErr("USAGE: ",cmd.GetName()," [ID ...] [regex ...] vmDir")
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――") u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("\"dir\" is the directory in the VM to export into a tar archive named after the VM's name.") const usage string = `vmDir Directory (in the VM) to export into a tar archive.
Remark: one archive, named after the VM's name, is created per VM.`
u.PrintlnErr(usage)
u.PrintlnErr("")
printRegexUsageDetails() printRegexUsageDetails()
} }
......
...@@ -16,7 +16,7 @@ func (cmd *ImportDir)GetName() string { ...@@ -16,7 +16,7 @@ func (cmd *ImportDir)GetName() string {
func (cmd *ImportDir)GetDesc() []string { func (cmd *ImportDir)GetDesc() []string {
return []string{ return []string{
"Copy a local directory and all its content to one or more VMs (regex).", "Copies a local directory and all its content into one or more VMs.",
"Requires VM_WRITEFS VM access capability or VM_WRITEFS_ANY user capability."} "Requires VM_WRITEFS VM access capability or VM_WRITEFS_ANY user capability."}
} }
...@@ -27,8 +27,11 @@ func (cmd *ImportDir)PrintUsage() { ...@@ -27,8 +27,11 @@ func (cmd *ImportDir)PrintUsage() {
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――") u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("USAGE: ",cmd.GetName()," [ID ...] [regex ...] localDir vmDir") u.PrintlnErr("USAGE: ",cmd.GetName()," [ID ...] [regex ...] localDir vmDir")
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――") u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("\"localDir\" is the directory on the local filesystem to be copied into the VM.") const usage string = `localDir Directory on the local filesystem to be copied into the VM.
u.PrintlnErr("\"vmDir\" is the directory in the VM where localDir will be copied.") vmdir Directory in the VM where localDir will be copied.
IMPORTANT: to avoid disk corruption, files can only be imported into non-running VMs.`
u.PrintlnErr(usage)
u.PrintlnErr("")
printRegexUsageDetails() printRegexUsageDetails()
} }
......
...@@ -14,7 +14,7 @@ func (cmd *List)GetName() string { ...@@ -14,7 +14,7 @@ func (cmd *List)GetName() string {
func (cmd *List)GetDesc() []string { func (cmd *List)GetDesc() []string {
return []string{ return []string{
"Lists VMs that can be listed (regex).", "Lists VMs that can be listed.",
"Requires VM_LIST VM access capability or VM_LIST_ANY user capability."} "Requires VM_LIST VM access capability or VM_LIST_ANY user capability."}
} }
......
package cmdVM
type ListAttach struct {
Name string
}
func (cmd *ListAttach)GetName() string {
return cmd.Name
}
func (cmd *ListAttach)GetDesc() []string {
return []string{
"Lists VMs that can be attached to (regex).",
"Requires VM_LIST VM access capability or VM_LIST_ANY user capability."}
}
func (cmd *ListAttach)PrintUsage() {
printRegexUsage(cmd)
printRegexUsageDetails()
}
func (cmd *ListAttach)Run(args []string) int {
return printFilteredVMs(cmd, args, "/vms/attach")
}
package cmdVM
type ListDel struct {
Name string
}
func (cmd *ListDel)GetName() string {
return cmd.Name
}
func (cmd *ListDel)GetDesc() []string {
return []string{
"Lists VMs that can be deleted (regex).",
"Requires VM_DESTROY VM access capability or VM_DESTROY_ANY user capability."}
}
func (cmd *ListDel)PrintUsage() {
printRegexUsage(cmd)
printRegexUsageDetails()
}
func (cmd *ListDel)Run(args []string) int {
return printFilteredVMs(cmd, args, "/vms/del")
}
package cmdVM
type ListEdit struct {
Name string
}
func (cmd *ListEdit)GetName() string {
return cmd.Name
}
func (cmd *ListEdit)GetDesc() []string {
return []string{
"Lists VMs that can be edited (regex).",
"Requires VM_EDIT VM access capability or VM_EDIT_ANY user capability."}
}
func (cmd *ListEdit)PrintUsage() {
printRegexUsage(cmd)
printRegexUsageDetails()
}
func (cmd *ListEdit)Run(args []string) int {
return printFilteredVMs(cmd, args, "/vms/edit")
}
package cmdVM
type ListEditAccess struct {
Name string
}
func (cmd *ListEditAccess)GetName() string {
return cmd.Name
}
func (cmd *ListEditAccess)GetDesc() []string {
return []string{
"Lists VMs that can have their VM access edited (regex).",
"Requires VM_SET_ACCESS user capability and VM_SET_ACCESS VM access capability."}
}
func (cmd *ListEditAccess)PrintUsage() {
printRegexUsage(cmd)
printRegexUsageDetails()
}
func (cmd *ListEditAccess)Run(args []string) int {
return printFilteredVMs(cmd, args, "/vms/editaccess")
}
package cmdVM
type ListExportDir struct{
Name string
}
func (cmd *ListExportDir)GetName() string {
return cmd.Name
}
func (cmd *ListExportDir)GetDesc() []string {
return []string{
"List VMs that can have a directory exported (regex).",
"Requires VM_READFS VM access capability or VM_READFS_ANY user capability."}
}
func (cmd *ListExportDir)PrintUsage() {
printRegexUsage(cmd)
printRegexUsageDetails()
}
func (cmd *ListExportDir)Run(args []string) int {
return printFilteredVMs(cmd, args, "/vms/exportdir")
}
package cmdVM
type ListStart struct{
Name string
}
func (cmd *ListStart)GetName() string {
return cmd.Name
}
func (cmd *ListStart)GetDesc() []string {
return []string{
"Lists VMs that can be started (regex).",
"Requires VM_START VM access capability or VM_START_ANY user capability."}
}
func (cmd *ListStart)PrintUsage() {
printRegexUsage(cmd)
printRegexUsageDetails()
}
func (cmd *ListStart)Run(args []string) int {
return printFilteredVMs(cmd, args, "/vms/start")
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment