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

- archive exported with vmexportdir is now prefixed with "exportdir_"

- for better readability, each command's USAGE is surrounded by horizontal lines
parent ddd50748
No related branches found
No related tags found
No related merge requests found
Showing
with 52 additions and 16 deletions
...@@ -27,7 +27,9 @@ func (cmd *Login)PrintUsage() { ...@@ -27,7 +27,9 @@ func (cmd *Login)PrintUsage() {
for _, desc := range cmd.GetDesc() { for _, desc := range cmd.GetDesc() {
u.PrintlnErr(desc) u.PrintlnErr(desc)
} }
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("USAGE: "+cmd.Name+" email password") u.PrintlnErr("USAGE: "+cmd.Name+" email password")
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
} }
func (cmd *Login)Run(args []string) int { func (cmd *Login)Run(args []string) int {
......
...@@ -35,7 +35,9 @@ func printUsage(c cmd.Command, action string) { ...@@ -35,7 +35,9 @@ func printUsage(c cmd.Command, action string) {
for _, desc := range c.GetDesc() { for _, desc := range c.GetDesc() {
u.PrintlnErr(desc) u.PrintlnErr(desc)
} }
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("USAGE: ",c.GetName()," [ID ...] [regex ...]") u.PrintlnErr("USAGE: ",c.GetName()," [ID ...] [regex ...]")
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("Only templates matching the specified IDs or regexes will be "+action+".") u.PrintlnErr("Only templates matching the specified IDs or regexes will be "+action+".")
const usage string = `Any number of IDs or regexes can be specified. const usage string = `Any number of IDs or regexes can be specified.
The regex only matches the templates's name and is case-insensitive. The regex only matches the templates's name and is case-insensitive.
......
...@@ -24,7 +24,9 @@ func (cmd *Create)PrintUsage() { ...@@ -24,7 +24,9 @@ func (cmd *Create)PrintUsage() {
for _, desc := range cmd.GetDesc() { for _, desc := range cmd.GetDesc() {
u.PrintlnErr(desc) u.PrintlnErr(desc)
} }
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("USAGE: "+cmd.Name+" vmID name access") u.PrintlnErr("USAGE: "+cmd.Name+" vmID name access")
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("Notes: access is either \"public\" or \"private\"") u.PrintlnErr("Notes: access is either \"public\" or \"private\"")
} }
......
...@@ -50,13 +50,13 @@ func (cmd *Del)Run(args []string) int { ...@@ -50,13 +50,13 @@ func (cmd *Del)Run(args []string) int {
uuid := template.ID.String() uuid := template.ID.String()
resp, err := client.R().Delete(host+"/templates/"+uuid) resp, err := client.R().Delete(host+"/templates/"+uuid)
if err != nil { if err != nil {
u.PrintlnErr("Failed deleting template \""+template.Name+"\" | "+uuid+" : "+err.Error()) u.PrintlnErr("Failed deleting template \""+template.Name+"\" : "+err.Error())
statusCode = 1 statusCode = 1
} else { } else {
if resp.IsSuccess() { if resp.IsSuccess() {
u.Println("Deleted template \""+template.Name+"\" | "+uuid) u.Println("Deleted template \""+template.Name+"\"")
} else { } else {
u.PrintlnErr("Failed deleting template \""+template.Name+"\" | "+uuid+" : "+resp.Status()+": "+resp.String()) u.PrintlnErr("Failed deleting template \""+template.Name+"\" : "+resp.Status()+": "+resp.String())
statusCode = 1 statusCode = 1
} }
} }
......
...@@ -24,7 +24,9 @@ func (cmd *Refresh)PrintUsage() { ...@@ -24,7 +24,9 @@ func (cmd *Refresh)PrintUsage() {
for _, desc := range cmd.GetDesc() { for _, desc := range cmd.GetDesc() {
u.PrintlnErr(desc) u.PrintlnErr(desc)
} }
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("USAGE: "+cmd.Name) u.PrintlnErr("USAGE: "+cmd.Name)
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
} }
func (cmd *Refresh)Run(args []string) int { func (cmd *Refresh)Run(args []string) int {
......
...@@ -37,7 +37,9 @@ func printRegexUsage(c cmd.Command) { ...@@ -37,7 +37,9 @@ func printRegexUsage(c cmd.Command) {
for _, desc := range c.GetDesc() { for _, desc := range c.GetDesc() {
u.PrintlnErr(desc) u.PrintlnErr(desc)
} }
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("USAGE: ",c.GetName()," [regex ...]") u.PrintlnErr("USAGE: ",c.GetName()," [regex ...]")
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
} }
func printRegexUsageDetails() { func printRegexUsageDetails() {
......
...@@ -23,7 +23,9 @@ func (cmd *Add)PrintUsage() { ...@@ -23,7 +23,9 @@ func (cmd *Add)PrintUsage() {
for _, desc := range cmd.GetDesc() { for _, desc := range cmd.GetDesc() {
u.PrintlnErr(desc) u.PrintlnErr(desc)
} }
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("USAGE: "+cmd.Name+" email firstname lastname password [capability ...]") u.PrintlnErr("USAGE: "+cmd.Name+" email firstname lastname password [capability ...]")
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
} }
func (cmd *Add)Run(args []string) int { func (cmd *Add)Run(args []string) int {
......
...@@ -23,7 +23,9 @@ func (cmd *Del)PrintUsage() { ...@@ -23,7 +23,9 @@ func (cmd *Del)PrintUsage() {
for _, desc := range cmd.GetDesc() { for _, desc := range cmd.GetDesc() {
u.PrintlnErr(desc) u.PrintlnErr(desc)
} }
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("USAGE: "+cmd.Name+" email [email ...]") u.PrintlnErr("USAGE: "+cmd.Name+" email [email ...]")
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
} }
func (cmd *Del)Run(args []string) int { func (cmd *Del)Run(args []string) int {
......
...@@ -22,7 +22,9 @@ func (cmd *List)PrintUsage() { ...@@ -22,7 +22,9 @@ func (cmd *List)PrintUsage() {
for _, desc := range cmd.GetDesc() { for _, desc := range cmd.GetDesc() {
u.PrintlnErr(desc) u.PrintlnErr(desc)
} }
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("USAGE: ",cmd.GetName(), " [-l] [regex ...]") u.PrintlnErr("USAGE: ",cmd.GetName(), " [-l] [regex ...]")
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("Use \"-l\" to specify detailed user output.") u.PrintlnErr("Use \"-l\" to specify detailed user output.")
printRegexUsageDetails() printRegexUsageDetails()
} }
......
...@@ -23,7 +23,9 @@ func (cmd *SetCaps)PrintUsage() { ...@@ -23,7 +23,9 @@ func (cmd *SetCaps)PrintUsage() {
for _, desc := range cmd.GetDesc() { for _, desc := range cmd.GetDesc() {
u.PrintlnErr(desc) u.PrintlnErr(desc)
} }
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("USAGE: "+cmd.Name+" email [capability ...]") u.PrintlnErr("USAGE: "+cmd.Name+" email [capability ...]")
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
} }
func (cmd *SetCaps)Run(args []string) int { func (cmd *SetCaps)Run(args []string) int {
......
...@@ -27,7 +27,9 @@ func (cmd *UpdatePwd)PrintUsage() { ...@@ -27,7 +27,9 @@ func (cmd *UpdatePwd)PrintUsage() {
for _, desc := range cmd.GetDesc() { for _, desc := range cmd.GetDesc() {
u.PrintlnErr(desc) u.PrintlnErr(desc)
} }
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("USAGE: "+cmd.Name) u.PrintlnErr("USAGE: "+cmd.Name)
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
} }
func (cmd *UpdatePwd)Run(args []string) int { func (cmd *UpdatePwd)Run(args []string) int {
......
...@@ -22,7 +22,9 @@ func (cmd *Whoami)PrintUsage() { ...@@ -22,7 +22,9 @@ func (cmd *Whoami)PrintUsage() {
for _, desc := range cmd.GetDesc() { for _, desc := range cmd.GetDesc() {
u.PrintlnErr(desc) u.PrintlnErr(desc)
} }
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("USAGE: "+cmd.Name) u.PrintlnErr("USAGE: "+cmd.Name)
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
} }
func (cmd *Whoami)Run(args []string) int { func (cmd *Whoami)Run(args []string) int {
......
...@@ -56,7 +56,9 @@ func printRegexUsage(c cmd.Command) { ...@@ -56,7 +56,9 @@ func printRegexUsage(c cmd.Command) {
for _, desc := range c.GetDesc() { for _, desc := range c.GetDesc() {
u.PrintlnErr(desc) u.PrintlnErr(desc)
} }
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("USAGE: ",c.GetName()," [ID ...] [regex ...]") u.PrintlnErr("USAGE: ",c.GetName()," [ID ...] [regex ...]")
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
} }
func printRegexUsageDetails() { func printRegexUsageDetails() {
......
...@@ -27,7 +27,9 @@ func (cmd *Create)PrintUsage() { ...@@ -27,7 +27,9 @@ func (cmd *Create)PrintUsage() {
for _, desc := range cmd.GetDesc() { for _, desc := range cmd.GetDesc() {
u.PrintlnErr(desc) u.PrintlnErr(desc)
} }
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("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
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.
......
...@@ -24,7 +24,9 @@ func (cmd *Cred2pdf)PrintUsage() { ...@@ -24,7 +24,9 @@ func (cmd *Cred2pdf)PrintUsage() {
for _, desc := range cmd.GetDesc() { for _, desc := range cmd.GetDesc() {
u.PrintlnErr(desc) u.PrintlnErr(desc)
} }
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("USAGE: ",cmd.GetName()," [ID ...] [regex ...] pdfile") u.PrintlnErr("USAGE: ",cmd.GetName()," [ID ...] [regex ...] pdfile")
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
printRegexUsageDetails() printRegexUsageDetails()
} }
......
...@@ -51,13 +51,13 @@ func (cmd *Del)Run(args []string) int { ...@@ -51,13 +51,13 @@ func (cmd *Del)Run(args []string) int {
uuid := vm.ID.String() uuid := vm.ID.String()
resp, err := client.R().Delete(host+"/vms/"+uuid) resp, err := client.R().Delete(host+"/vms/"+uuid)
if err != nil { if err != nil {
u.PrintlnErr("Failed deleting VM \""+vm.Name+"\" | "+uuid+" : "+err.Error()) u.PrintlnErr("Failed deleting VM \""+vm.Name+"\" : "+err.Error())
statusCode = 1 statusCode = 1
} else { } else {
if resp.IsSuccess() { if resp.IsSuccess() {
u.Println("Deleted VM \""+vm.Name+"\" | "+uuid) u.Println("Deleted VM \""+vm.Name+"\"")
} else { } else {
u.PrintlnErr("Failed deleting VM \""+vm.Name+"\" | "+uuid+" : "+resp.Status()+": "+resp.String()) u.PrintlnErr("Failed deleting VM \""+vm.Name+"\" : "+resp.Status()+": "+resp.String())
statusCode = 1 statusCode = 1
} }
} }
......
...@@ -29,7 +29,9 @@ func (cmd *DelAccess)PrintUsage() { ...@@ -29,7 +29,9 @@ func (cmd *DelAccess)PrintUsage() {
for _, desc := range cmd.GetDesc() { for _, desc := range cmd.GetDesc() {
u.PrintlnErr(desc) u.PrintlnErr(desc)
} }
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("USAGE: "+cmd.GetName()+" [ID ...] [regex ...] email") u.PrintlnErr("USAGE: "+cmd.GetName()+" [ID ...] [regex ...] email")
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
const usage string = `Only VMs matching the specified IDs or regexes will have their VM access deleted. const usage string = `Only VMs matching the specified IDs or regexes will have their VM access deleted.
Any number of IDs or regexes can be specified. Any number of IDs or regexes can be specified.
The regex only matches the VM's name and is case-insensitive. The regex only matches the VM's name and is case-insensitive.
...@@ -72,13 +74,13 @@ func (cmd *DelAccess)Run(args []string) int { ...@@ -72,13 +74,13 @@ func (cmd *DelAccess)Run(args []string) int {
uuid := vm.ID.String() uuid := vm.ID.String()
resp, err := client.R().Delete(host+"/vms/"+uuid+"/access/"+email) resp, err := client.R().Delete(host+"/vms/"+uuid+"/access/"+email)
if err != nil { if err != nil {
u.PrintlnErr("Failed removing VM access for "+email+" in VM \""+vm.Name+"\" | "+uuid+" : "+err.Error()) u.PrintlnErr("Failed removing VM access for "+email+" in VM \""+vm.Name+"\" : "+err.Error())
statusCode = 1 statusCode = 1
} else { } else {
if resp.IsSuccess() { if resp.IsSuccess() {
u.Println("Removed VM access for "+email+" in VM \""+vm.Name+"\" | "+uuid) u.Println("Removed VM access for "+email+" in VM \""+vm.Name+"\"")
} else { } else {
u.PrintlnErr("Failed removing VM access for "+email+" in VM \""+vm.Name+"\" | "+uuid+" : "+resp.Status()+": "+resp.String()) u.PrintlnErr("Failed removing VM access for "+email+" in VM \""+vm.Name+"\" : "+resp.Status()+": "+resp.String())
statusCode = 1 statusCode = 1
} }
} }
......
...@@ -33,7 +33,9 @@ func (cmd *Edit)PrintUsage() { ...@@ -33,7 +33,9 @@ func (cmd *Edit)PrintUsage() {
for _, desc := range cmd.GetDesc() { for _, desc := range cmd.GetDesc() {
u.PrintlnErr(desc) u.PrintlnErr(desc)
} }
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("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
const usage string = `Only VMs matching the specified IDs or regexes will be edited. const usage string = `Only VMs matching the specified IDs or regexes will be edited.
Any number of IDs or regexes can be specified. Any number of IDs or regexes can be specified.
The regex only matches the VM's name and is case-insensitive. The regex only matches the VM's name and is case-insensitive.
...@@ -85,13 +87,13 @@ func (cmd *Edit)Run(args []string) int { ...@@ -85,13 +87,13 @@ func (cmd *Edit)Run(args []string) int {
uuid := vm.ID.String() uuid := vm.ID.String()
resp, err := client.R().SetBody(vmParams).Put(host+"/vms/"+uuid) resp, err := client.R().SetBody(vmParams).Put(host+"/vms/"+uuid)
if err != nil { if err != nil {
u.PrintlnErr("Failed editing VM \""+vm.Name+"\" | "+uuid+" : "+err.Error()) u.PrintlnErr("Failed editing VM \""+vm.Name+"\" : "+err.Error())
statusCode = 1 statusCode = 1
} else { } else {
if resp.IsSuccess() { if resp.IsSuccess() {
u.Println("Edited VM \""+vm.Name+"\" | "+uuid) u.Println("Edited VM \""+vm.Name+"\"")
} else { } else {
u.PrintlnErr("Failed editing VM \""+vm.Name+"\" | "+uuid+" : "+resp.Status()+": "+resp.String()) u.PrintlnErr("Failed editing VM \""+vm.Name+"\" : "+resp.Status()+": "+resp.String())
statusCode = 1 statusCode = 1
} }
} }
......
...@@ -28,7 +28,9 @@ func (cmd *ExportDir)PrintUsage() { ...@@ -28,7 +28,9 @@ func (cmd *ExportDir)PrintUsage() {
for _, desc := range cmd.GetDesc() { for _, desc := range cmd.GetDesc() {
u.PrintlnErr(desc) u.PrintlnErr(desc)
} }
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("USAGE: ",cmd.GetName()," [ID ...] [regex ...] dir") u.PrintlnErr("USAGE: ",cmd.GetName()," [ID ...] [regex ...] dir")
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("\"dir\" is the directory in the VM to export into a tar archive named after the VM ID.") u.PrintlnErr("\"dir\" is the directory in the VM to export into a tar archive named after the VM ID.")
printRegexUsageDetails() printRegexUsageDetails()
} }
...@@ -64,16 +66,16 @@ func (cmd *ExportDir)Run(args []string) int { ...@@ -64,16 +66,16 @@ func (cmd *ExportDir)Run(args []string) int {
for _, vm := range(vms) { for _, vm := range(vms) {
uuid := vm.ID.String() uuid := vm.ID.String()
outputFile := uuid+".tar" outputFile := "exportdir_"+uuid+".tar"
resp, err := client.R().SetOutput(outputFile).SetBody(params).Get(host+"/vms/"+uuid+"/exportdir") resp, err := client.R().SetOutput(outputFile).SetBody(params).Get(host+"/vms/"+uuid+"/exportdir")
if err != nil { if err != nil {
u.PrintlnErr("Failed exporting "+dir+" from VM \""+vm.Name+"\" | "+uuid+" : "+err.Error()) u.PrintlnErr("Failed exporting "+dir+" from VM \""+vm.Name+"\" : "+err.Error())
statusCode = 1 statusCode = 1
} else { } else {
if resp.IsSuccess() { if resp.IsSuccess() {
u.Println("Successfully exported "+dir+" from VM \""+vm.Name+"\" ("+uuid+") into "+outputFile) u.Println("Successfully exported "+dir+" from VM \""+vm.Name+"\" into "+outputFile)
} else { } else {
u.PrintlnErr("Failed exporting "+dir+" from VM \""+vm.Name+"\" | "+uuid+" : "+resp.Status()+": "+resp.String()) u.PrintlnErr("Failed exporting "+dir+" from VM \""+vm.Name+"\" : "+resp.Status()+": "+resp.String())
statusCode = 1 statusCode = 1
} }
} }
......
...@@ -22,7 +22,9 @@ func (cmd *List)PrintUsage() { ...@@ -22,7 +22,9 @@ func (cmd *List)PrintUsage() {
for _, desc := range cmd.GetDesc() { for _, desc := range cmd.GetDesc() {
u.PrintlnErr(desc) u.PrintlnErr(desc)
} }
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("USAGE: ",cmd.GetName(), " [-l] [ID ...] [regex ...]") u.PrintlnErr("USAGE: ",cmd.GetName(), " [-l] [ID ...] [regex ...]")
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("Use \"-l\" to specify detailed VMs output.") u.PrintlnErr("Use \"-l\" to specify detailed VMs output.")
printRegexUsageDetails() printRegexUsageDetails()
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment