diff --git a/README.md b/README.md index f3ff08fbb878bc2533d1a04c8c56ab9097ed078d..2f916c968be71557e82e2865d077cbb8d60bd8d0 100644 --- a/README.md +++ b/README.md @@ -33,35 +33,94 @@ Usage: nexus-client CMD CMD is the Command to run. Except for "login", all Commands require an access token. The access token is read from the env. variable "NEXUS_TOKEN". List of supported Commands: - login Login and obtain an access token. - whoami Display the current user's details. - passwd Update the current user's password. - userlist List users (regex matching). - useradd Add a user. - userdel Delete one or more users. - usersetcaps Set a user's capabilities. - vmlist List VMs that can be listed (regex matching). - vmliststart List VMs that can be started (regex matching). - vmlistattach List VMs that can be attached to (regex matching). - vmliststop List VMs that can be stopped or shutdown (regex matching). - vmlistedit List VMs that can be edited (regex matching). - vmlisteditaccess List VMs that can have their VM access edited (regex matching). - vmlistdel List VMs that can be deleted (regex matching). + + login Obtains an access token. + Requires no capabilities. + + whoami Displays the current user's details. + Requires no capabilities. + + passwd Updates the current user's password. + Requires no capabilities. + + userlist Lists users (regex matching). + Requires USER_LIST user capability. + + useradd Adds a user. + Requires USER_CREATE user capability. + + userdel Deletes one or more users. + Requires USER_DESTROY user capability. + + usersetcaps Sets a user's capabilities. + Requires USER_SET_CAPS user capability. + + vmlist Lists VMs that can be listed (regex matching). + Requires VM_LIST VM access capability or VM_LIST_ANY user capability. + + vmliststart Lists VMs that can be started (regex matching). + Requires VM_START VM access capability or VM_START_ANY user capability. + + vmlistattach Lists VMs that can be attached to (regex matching). + Requires VM_LIST VM access capability or VM_LIST_ANY user capability. + + vmliststop Lists VMs that can be stopped or shutdown (regex matching). + Requires VM_STOP VM access capability or VM_STOP_ANY user capability. + + vmlistedit Lists VMs that can be edited (regex matching). + Requires VM_EDIT VM access capability or VM_EDIT_ANY user capability. + + vmlisteditaccess Lists VMs that can have their VM access edited (regex matching). + Requires VM_SET_ACCESS user capability and VM_SET_ACCESS VM access capability. + + vmlistdel Lists VMs that can be deleted (regex matching). + Requires VM_DESTROY VM access capability or VM_DESTROY_ANY user capability. + vmlistexportdir List VMs that can have a directory exported (regex matching). - vmcred2pdf Create a PDF with the credentials required to attach to running VMs (regex matching). - vmstart Start one or more VMs (regex matching). - vmstop Stop by force one or more VMs (regex matching). - vmshutdown Gracefully shutdown one or more VMs (regex matching). - vmattach Attach to one or more VMs in order to use their desktop environment (regex matching). - vmcreate Create one or more VMs (regex matching). - vmedit Edit one or more VMs' properties: name, cpus, ram or nic (regex matching). - vmdel Delete one or more VMs (regex matching). - vmsetaccess Set a user's VM access in one or more VMs (regex matching). - vmdelaccess Delete a user's VM access in one or more VMs (regex matching). - vmexportdir Export one or more VMs' directory into one or more tar archives. Create one archive per VM (regex matching). - tpllist List available templates (regex matching). - tplcreate Create a template, either from an existing VM or from a .qcow file. - tpldel Delete one or more templates (regex matching). + Requires VM_READFS VM access capability or VM_READFS_ANY user capability. + + vmcred2pdf Creates a PDF with the credentials required to attach to running VMs (regex matching). + Requires VM_LIST VM access capability or VM_LIST_ANY user capability. + + vmstart Starts one or more VMs (regex matching). + Requires VM_START VM access capability or VM_START_ANY user capability. + + vmstop Stops by force one or more VMs (regex matching). + Requires VM_STOP VM access capability or VM_STOP_ANY user capability. + + vmshutdown Gracefully shutdowns one or more VMs (regex matching). + Requires VM_STOP VM access capability or VM_STOP_ANY user capability. + + vmattach Attaches to one or more VMs in order to use their desktop environment (regex matching). + Requires VM_LIST VM access capability or VM_LIST_ANY user capability. + + vmcreate Creates one or more VMs (regex matching). + Requires VM_CREATE user capability. + + vmedit Edits one or more VMs' properties: name, cpus, ram or nic (regex matching). + Requires VM_EDIT VM access capability or VM_EDIT_ANY user capability. + + vmdel Deletes one or more VMs (regex matching). + 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 matching). + Requires VM_SET_ACCESS user capability and VM_SET_ACCESS VM access capability. + + vmdelaccess Deletes a user's VM access in one or more VMs (regex matching). + Requires VM_SET_ACCESS user capability and VM_SET_ACCESS VM access capability. + + vmexportdir Exports one or more VMs' directory into one or more tar archives. + Creates one archive per VM (regex matching). + Requires VM_READFS VM access capability or VM_READFS_ANY user capability. + + tpllist Lists available templates (regex matching). + Requires TPL_LIST or TPL_LIST_ANY user capabilities. + + tplcreate Creates a template, either from an existing VM or from a .qcow file. + Requires TPL_CREATE user capability. + + tpldel Deletes one or more templates (regex matching). + Requires TPL_DESTROY or TPL_DESTROY_ANY user capabilities. ``` When attached to a VM's desktop (`vmattach` command), ctrl+F12 toggles between fullscreen/non-fullscreen modes. diff --git a/src/client_cli/cmd/Command.go b/src/client_cli/cmd/Command.go index b59e32cbf97570a7e081a41906c06c0541a0228f..261bef7c6b13bf91c79b8610dd8b9763f1cd84fe 100644 --- a/src/client_cli/cmd/Command.go +++ b/src/client_cli/cmd/Command.go @@ -2,7 +2,7 @@ package cmd type Command interface { GetName() string - GetDesc() string + GetDesc() []string PrintUsage() Run(args []string) int // Returns 0 if the Command was successful. } diff --git a/src/client_cli/cmdLogin/login.go b/src/client_cli/cmdLogin/login.go index a34fcd8f658cd9f4c999c3a808eadf2cf2020ec4..788a95b18b0c3977e2f97219e98529d37a662b46 100644 --- a/src/client_cli/cmdLogin/login.go +++ b/src/client_cli/cmdLogin/login.go @@ -18,13 +18,17 @@ func (cmd *Login)GetName() string { return cmd.Name } -func (cmd *Login)GetDesc() string { - return "Login and obtain an access token." +func (cmd *Login)GetDesc() []string { + return []string{ + "Obtains an access token.", + "Requires no capabilities."} } func (cmd *Login)PrintUsage() { - u.PrintlnErr(cmd.GetDesc()) - u.PrintlnErr("Usage: "+cmd.Name+" email password") + for _, desc := range cmd.GetDesc() { + u.PrintlnErr(desc) + } + u.PrintlnErr("USAGE: "+cmd.Name+" email password") } func (cmd *Login)Run(args []string) int { diff --git a/src/client_cli/cmdTemplate/helper.go b/src/client_cli/cmdTemplate/helper.go index 394f685d0596b9a3f622e2f7f62aefb14bafd99a..593167497e90ae7e157806501af5f279786acbbc 100644 --- a/src/client_cli/cmdTemplate/helper.go +++ b/src/client_cli/cmdTemplate/helper.go @@ -32,8 +32,10 @@ func (tpl *Template)String() string { } func printUsage(c cmd.Command, action string) { - u.PrintlnErr(c.GetDesc()) - u.PrintlnErr("Usage: ",c.GetName()," [ID ...] [regex ...]") + for _, desc := range c.GetDesc() { + u.PrintlnErr(desc) + } + u.PrintlnErr("USAGE: ",c.GetName()," [ID ...] [regex ...]") 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. The regex only matches the templates's name and is case-insensitive. diff --git a/src/client_cli/cmdTemplate/templateCreate.go b/src/client_cli/cmdTemplate/templateCreate.go index b159edfbf547f67472fe96b356ef8c657efa0551..25f30f196723eebef599a464dcdcad6d05993f7a 100644 --- a/src/client_cli/cmdTemplate/templateCreate.go +++ b/src/client_cli/cmdTemplate/templateCreate.go @@ -22,13 +22,17 @@ func (cmd *Create)GetName() string { return cmd.Name } -func (cmd *Create)GetDesc() string { - return "Create a template, either from an existing VM or from a .qcow file." +func (cmd *Create)GetDesc() []string { + return []string{ + "Creates a template, either from an existing VM or from a .qcow file.", + "Requires TPL_CREATE user capability."} } func (cmd *Create)PrintUsage() { - u.PrintlnErr(cmd.GetDesc()) - u.PrintlnErr("Usage: "+cmd.Name+" vmID|qcowFile name access") + for _, desc := range cmd.GetDesc() { + u.PrintlnErr(desc) + } + u.PrintlnErr("USAGE: "+cmd.Name+" vmID|qcowFile name access") u.PrintlnErr("Notes: access is either \"public\" or \"private\"") } diff --git a/src/client_cli/cmdTemplate/templateDel.go b/src/client_cli/cmdTemplate/templateDel.go index 0c70aa877c90bd1e5f67ad0e282c7a3b169a1ab4..e8d872d8a54065dd4cf80e4efe118d5c2fc5ddaf 100644 --- a/src/client_cli/cmdTemplate/templateDel.go +++ b/src/client_cli/cmdTemplate/templateDel.go @@ -13,8 +13,10 @@ func (cmd *Del)GetName() string { return cmd.Name } -func (cmd *Del)GetDesc() string { - return "Delete one or more templates (regex matching)." +func (cmd *Del)GetDesc() []string { + return []string{ + "Deletes one or more templates (regex matching).", + "Requires TPL_DESTROY or TPL_DESTROY_ANY user capabilities."} } func (cmd *Del)PrintUsage() { diff --git a/src/client_cli/cmdTemplate/templateList.go b/src/client_cli/cmdTemplate/templateList.go index 5e621045bc8f5dfb4b1cc7d25379404b6f4ae5df..d361fe25c114e26af70d0264d083f083bd784bce 100644 --- a/src/client_cli/cmdTemplate/templateList.go +++ b/src/client_cli/cmdTemplate/templateList.go @@ -8,8 +8,10 @@ func (cmd *List)GetName() string { return cmd.Name } -func (cmd *List)GetDesc() string { - return "List available templates (regex matching)." +func (cmd *List)GetDesc() []string { + return []string{ + "Lists available templates (regex matching).", + "Requires TPL_LIST or TPL_LIST_ANY user capabilities."} } func (cmd *List)PrintUsage() { diff --git a/src/client_cli/cmdUser/helper.go b/src/client_cli/cmdUser/helper.go index 332c283f26fd9c4ad2e36a5590fd09094f3767db..38070ec197dd87db52234ab051c4c6a286208eae 100644 --- a/src/client_cli/cmdUser/helper.go +++ b/src/client_cli/cmdUser/helper.go @@ -33,8 +33,10 @@ func (user *User)String() string { } func printUsage(c cmd.Command) { - u.PrintlnErr(c.GetDesc()) - u.PrintlnErr("Usage: ",c.GetName()," [regex ...]") + for _, desc := range c.GetDesc() { + u.PrintlnErr(desc) + } + u.PrintlnErr("USAGE: ",c.GetName()," [regex ...]") const usage string = `Only users matching the specified regexes will be listed. Any number of regexes can be specified. The regex matches the user email, first name and last name and is case-insensitive. diff --git a/src/client_cli/cmdUser/userAdd.go b/src/client_cli/cmdUser/userAdd.go index bba0dddf956f80b1517a72817eede0a430f2f4ff..028f9a4de84920fd211deebca07df96c9e4fd1dc 100644 --- a/src/client_cli/cmdUser/userAdd.go +++ b/src/client_cli/cmdUser/userAdd.go @@ -13,13 +13,17 @@ func (cmd *Add)GetName() string { return cmd.Name } -func (cmd *Add)GetDesc() string { - return "Add a user." +func (cmd *Add)GetDesc() []string { + return []string{ + "Adds a user.", + "Requires USER_CREATE user capability."} } func (cmd *Add)PrintUsage() { - u.PrintlnErr(cmd.GetDesc()) - u.PrintlnErr("Usage: "+cmd.Name+" email firstname lastname password [capability ...]") + for _, desc := range cmd.GetDesc() { + u.PrintlnErr(desc) + } + u.PrintlnErr("USAGE: "+cmd.Name+" email firstname lastname password [capability ...]") } func (cmd *Add)Run(args []string) int { diff --git a/src/client_cli/cmdUser/userDel.go b/src/client_cli/cmdUser/userDel.go index 2f57f5d969d13360ff847ac7d86c1eb2934554ba..00a80a19d6a33ea947814a89434e880b57ddc0dc 100644 --- a/src/client_cli/cmdUser/userDel.go +++ b/src/client_cli/cmdUser/userDel.go @@ -13,13 +13,17 @@ func (cmd *Del)GetName() string { return cmd.Name } -func (cmd *Del)GetDesc() string { - return "Delete one or more users." +func (cmd *Del)GetDesc() []string { + return []string{ + "Deletes one or more users.", + "Requires USER_DESTROY user capability."} } func (cmd *Del)PrintUsage() { - u.PrintlnErr(cmd.GetDesc()) - u.PrintlnErr("Usage: "+cmd.Name+" email [email ...]") + for _, desc := range cmd.GetDesc() { + u.PrintlnErr(desc) + } + u.PrintlnErr("USAGE: "+cmd.Name+" email [email ...]") } func (cmd *Del)Run(args []string) int { diff --git a/src/client_cli/cmdUser/userList.go b/src/client_cli/cmdUser/userList.go index 5b0712d92a68c450a6fa6a2868ce3044f82cb6ee..c00ab4ead320a451848d502036d998ac2e84a69e 100644 --- a/src/client_cli/cmdUser/userList.go +++ b/src/client_cli/cmdUser/userList.go @@ -8,8 +8,10 @@ func (cmd *List)GetName() string { return cmd.Name } -func (cmd *List)GetDesc() string { - return "List users (regex matching)." +func (cmd *List)GetDesc() []string { + return []string{ + "Lists users (regex matching).", + "Requires USER_LIST user capability."} } func (cmd *List)PrintUsage() { diff --git a/src/client_cli/cmdUser/userSetCaps.go b/src/client_cli/cmdUser/userSetCaps.go index ea6eacad3894889f0e3a6becf30427900e6f6b56..e40fe80910d8d8ea7ceb61636458e56b74dbfa6f 100644 --- a/src/client_cli/cmdUser/userSetCaps.go +++ b/src/client_cli/cmdUser/userSetCaps.go @@ -13,13 +13,17 @@ func (cmd *SetCaps)GetName() string { return cmd.Name } -func (cmd *SetCaps)GetDesc() string { - return "Set a user's capabilities." +func (cmd *SetCaps)GetDesc() []string { + return []string{ + "Sets a user's capabilities.", + "Requires USER_SET_CAPS user capability."} } func (cmd *SetCaps)PrintUsage() { - u.PrintlnErr(cmd.GetDesc()) - u.PrintlnErr("Usage: "+cmd.Name+" email [capability ...]") + for _, desc := range cmd.GetDesc() { + u.PrintlnErr(desc) + } + u.PrintlnErr("USAGE: "+cmd.Name+" email [capability ...]") } func (cmd *SetCaps)Run(args []string) int { diff --git a/src/client_cli/cmdUser/userUpdatePwd.go b/src/client_cli/cmdUser/userUpdatePwd.go index 52661ea51bc7776f048b46dab2cbee3090dc1827..4a8df0a4e47d82c2228726fa3016f465d4dd6c8e 100644 --- a/src/client_cli/cmdUser/userUpdatePwd.go +++ b/src/client_cli/cmdUser/userUpdatePwd.go @@ -18,13 +18,17 @@ func (cmd *UpdatePwd)GetName() string { return cmd.Name } -func (cmd *UpdatePwd)GetDesc() string { - return "Update the current user's password." +func (cmd *UpdatePwd)GetDesc() []string { + return []string{ + "Updates the current user's password.", + "Requires no capabilities."} } func (cmd *UpdatePwd)PrintUsage() { - u.PrintlnErr(cmd.GetDesc()) - u.PrintlnErr("Usage: "+cmd.Name) + for _, desc := range cmd.GetDesc() { + u.PrintlnErr(desc) + } + u.PrintlnErr("USAGE: "+cmd.Name) } func (cmd *UpdatePwd)Run(args []string) int { diff --git a/src/client_cli/cmdUser/userWhoami.go b/src/client_cli/cmdUser/userWhoami.go index 2275313a11e1d1433a27ad1ba145e87b86498480..dd46ed9056afd29ba67d99aec5fee25948647065 100644 --- a/src/client_cli/cmdUser/userWhoami.go +++ b/src/client_cli/cmdUser/userWhoami.go @@ -13,13 +13,17 @@ func (cmd *Whoami)GetName() string { return cmd.Name } -func (cmd *Whoami)GetDesc() string { - return "Display the current user's details." +func (cmd *Whoami)GetDesc() []string { + return []string{ + "Displays the current user's details.", + "Requires no capabilities."} } func (cmd *Whoami)PrintUsage() { - u.PrintlnErr(cmd.GetDesc()) - u.PrintlnErr("Usage: "+cmd.Name) + for _, desc := range cmd.GetDesc() { + u.PrintlnErr(desc) + } + u.PrintlnErr("USAGE: "+cmd.Name) } func (cmd *Whoami)Run(args []string) int { diff --git a/src/client_cli/cmdVM/helper.go b/src/client_cli/cmdVM/helper.go index 7d3121ee4afa7f3f8c067aa04a0aba2917692cfd..f553a99977b580bb69e33e7fdab56c5f5cc230b2 100644 --- a/src/client_cli/cmdVM/helper.go +++ b/src/client_cli/cmdVM/helper.go @@ -53,8 +53,10 @@ func (vm *VM)String() string { } func printRegexUsage(c cmd.Command) { - u.PrintlnErr(c.GetDesc()) - u.PrintlnErr("Usage: ",c.GetName()," [ID ...] [regex ...]") + for _, desc := range c.GetDesc() { + u.PrintlnErr(desc) + } + u.PrintlnErr("USAGE: ",c.GetName()," [ID ...] [regex ...]") } func printRegexUsageDetails() { diff --git a/src/client_cli/cmdVM/vmAttach.go b/src/client_cli/cmdVM/vmAttach.go index ff3ee6b4ac42f9b27cdfb5792142bb62d7feb09d..b67bba79ed99221423a1f7b4c899a56d08ebba19 100644 --- a/src/client_cli/cmdVM/vmAttach.go +++ b/src/client_cli/cmdVM/vmAttach.go @@ -22,8 +22,10 @@ func (cmd *Attach)GetName() string { return cmd.Name } -func (cmd *Attach)GetDesc() string { - return "Attach to one or more VMs in order to use their desktop environment (regex matching)." +func (cmd *Attach)GetDesc() []string { + return []string{ + "Attaches to one or more VMs in order to use their desktop environment (regex matching).", + "Requires VM_LIST VM access capability or VM_LIST_ANY user capability."} } func (cmd *Attach)PrintUsage() { diff --git a/src/client_cli/cmdVM/vmCreate.go b/src/client_cli/cmdVM/vmCreate.go index 1c507ee657cf6c5ec3d1ee1c476214815e79bd6c..984f2a4c262eb336bb92ee5dbf14227b3cab0fcd 100644 --- a/src/client_cli/cmdVM/vmCreate.go +++ b/src/client_cli/cmdVM/vmCreate.go @@ -17,13 +17,17 @@ func (cmd *Create)GetName() string { return cmd.Name } -func (cmd *Create)GetDesc() string { - return "Create one or more VMs (regex matching)." +func (cmd *Create)GetDesc() []string { + return []string{ + "Creates one or more VMs (regex matching).", + "Requires VM_CREATE user capability."} } func (cmd *Create)PrintUsage() { - u.PrintlnErr(cmd.GetDesc()) - u.PrintlnErr("Usage: "+cmd.Name+" name cpus ram nic template [count|file.csv]") + for _, desc := range cmd.GetDesc() { + u.PrintlnErr(desc) + } + u.PrintlnErr("USAGE: "+cmd.Name+" name cpus ram nic template [count|file.csv]") const usage string = `name name of the VM cpus Number of CPUs, between 1 and 16. ram Amount of RAM in MB, between 512 and 32768. diff --git a/src/client_cli/cmdVM/vmCred2pdf.go b/src/client_cli/cmdVM/vmCred2pdf.go index 1f791a8a55930bda56cac0e1405d0ebbef0dc43c..1c3f7bd72b22ce994fbce31ed08f9f17269e1338 100644 --- a/src/client_cli/cmdVM/vmCred2pdf.go +++ b/src/client_cli/cmdVM/vmCred2pdf.go @@ -14,13 +14,17 @@ func (cmd *Cred2pdf)GetName() string { return cmd.Name } -func (cmd *Cred2pdf)GetDesc() string { - return "Create a PDF with the credentials required to attach to running VMs (regex matching)." +func (cmd *Cred2pdf)GetDesc() []string { + return []string{ + "Creates a PDF with the credentials required to attach to running VMs (regex matching).", + "Requires VM_LIST VM access capability or VM_LIST_ANY user capability."} } func (cmd *Cred2pdf)PrintUsage() { - u.PrintlnErr(cmd.GetDesc()) - u.PrintlnErr("Usage: ",cmd.GetName()," [ID ...] [regex ...] pdfile") + for _, desc := range cmd.GetDesc() { + u.PrintlnErr(desc) + } + u.PrintlnErr("USAGE: ",cmd.GetName()," [ID ...] [regex ...] pdfile") printRegexUsageDetails() } diff --git a/src/client_cli/cmdVM/vmDel.go b/src/client_cli/cmdVM/vmDel.go index 71a27f720ad56bedc66c9c5eff7e417572513d0c..a5cf919a5e50ae6aabd1ab484eaf05fb98c99594 100644 --- a/src/client_cli/cmdVM/vmDel.go +++ b/src/client_cli/cmdVM/vmDel.go @@ -13,8 +13,10 @@ func (cmd *Del)GetName() string { return cmd.Name } -func (cmd *Del)GetDesc() string { - return "Delete one or more VMs (regex matching)." +func (cmd *Del)GetDesc() []string { + return []string{ + "Deletes one or more VMs (regex matching).", + "Requires VM_DESTROY VM access capability or VM_DESTROY_ANY user capability."} } func (cmd *Del)PrintUsage() { diff --git a/src/client_cli/cmdVM/vmDelAccess.go b/src/client_cli/cmdVM/vmDelAccess.go index 3c80b2e0d5d6280b254f30fcb3ee83dedc4b8a2a..f57a0896708689e13d5add6b635d1aadb887505b 100644 --- a/src/client_cli/cmdVM/vmDelAccess.go +++ b/src/client_cli/cmdVM/vmDelAccess.go @@ -19,13 +19,17 @@ func (cmd *DelAccess)GetName() string { return cmd.Name } -func (cmd *DelAccess)GetDesc() string { - return "Delete a user's VM access in one or more VMs (regex matching)." +func (cmd *DelAccess)GetDesc() []string { + return []string{ + "Deletes a user's VM access in one or more VMs (regex matching).", + "Requires VM_SET_ACCESS user capability and VM_SET_ACCESS VM access capability."} } func (cmd *DelAccess)PrintUsage() { - u.PrintlnErr(cmd.GetDesc()) - u.PrintlnErr("Usage: "+cmd.GetName()+" [ID ...] [regex ...] email") + for _, desc := range cmd.GetDesc() { + u.PrintlnErr(desc) + } + u.PrintlnErr("USAGE: "+cmd.GetName()+" [ID ...] [regex ...] email") 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. The regex only matches the VM's name and is case-insensitive. diff --git a/src/client_cli/cmdVM/vmEdit.go b/src/client_cli/cmdVM/vmEdit.go index dc81d3c486d708424cbee761c049a7091dc79d8d..02f1290df0e5d3cf7ad0640472bfccfc87566822 100644 --- a/src/client_cli/cmdVM/vmEdit.go +++ b/src/client_cli/cmdVM/vmEdit.go @@ -23,13 +23,17 @@ func (cmd *Edit)GetName() string { return cmd.Name } -func (cmd *Edit)GetDesc() string { - return "Edit one or more VMs' properties: name, cpus, ram or nic (regex matching)." +func (cmd *Edit)GetDesc() []string { + return []string{ + "Edits one or more VMs' properties: name, cpus, ram or nic (regex matching).", + "Requires VM_EDIT VM access capability or VM_EDIT_ANY user capability."} } func (cmd *Edit)PrintUsage() { - u.PrintlnErr(cmd.GetDesc()) - u.PrintlnErr("Usage: "+cmd.GetName()+" [ID ...] [regex ...] [name=\"new name\"] [cpus=n] [ram=n] [nic=none/user]") + for _, desc := range cmd.GetDesc() { + u.PrintlnErr(desc) + } + u.PrintlnErr("USAGE: "+cmd.GetName()+" [ID ...] [regex ...] [name=\"new name\"] [cpus=n] [ram=n] [nic=none/user]") const usage string = `Only VMs matching the specified IDs or regexes will be edited. Any number of IDs or regexes can be specified. The regex only matches the VM's name and is case-insensitive. diff --git a/src/client_cli/cmdVM/vmExportDir.go b/src/client_cli/cmdVM/vmExportDir.go index b9c56947a4fdf79cd90310665616d25c73b60efa..9d9af86359bf0da689fee0b1a7f44a40bac97f94 100644 --- a/src/client_cli/cmdVM/vmExportDir.go +++ b/src/client_cli/cmdVM/vmExportDir.go @@ -17,13 +17,18 @@ func (cmd *ExportDir)GetName() string { return cmd.Name } -func (cmd *ExportDir)GetDesc() string { - return "Export one or more VMs' directory into one or more tar archives. Create one archive per VM (regex matching)." +func (cmd *ExportDir)GetDesc() []string { + return []string{ + "Exports one or more VMs' directory into one or more tar archives.", + "Creates one archive per VM (regex matching).", + "Requires VM_READFS VM access capability or VM_READFS_ANY user capability."} } func (cmd *ExportDir)PrintUsage() { - u.PrintlnErr(cmd.GetDesc()) - u.PrintlnErr("Usage: ",cmd.GetName()," [ID ...] [regex ...] dir") + for _, desc := range cmd.GetDesc() { + u.PrintlnErr(desc) + } + u.PrintlnErr("USAGE: ",cmd.GetName()," [ID ...] [regex ...] dir") u.PrintlnErr("\"dir\" is the directory in the VM to export into a tar archive named after the VM ID.") printRegexUsageDetails() } diff --git a/src/client_cli/cmdVM/vmList.go b/src/client_cli/cmdVM/vmList.go index d8b1fe158b8209ae5f3d72776cc5b8d149dc013c..83a3a4a01f3045e43b8725fd9521b50a8cab87a1 100644 --- a/src/client_cli/cmdVM/vmList.go +++ b/src/client_cli/cmdVM/vmList.go @@ -12,13 +12,17 @@ func (cmd *List)GetName() string { return cmd.Name } -func (cmd *List)GetDesc() string { - return "List VMs that can be listed (regex matching)." +func (cmd *List)GetDesc() []string { + return []string{ + "Lists VMs that can be listed (regex matching).", + "Requires VM_LIST VM access capability or VM_LIST_ANY user capability."} } func (cmd *List)PrintUsage() { - u.PrintlnErr(cmd.GetDesc()) - u.PrintlnErr("Usage: ",cmd.GetName(), " [-l] [ID ...] [regex ...]") + for _, desc := range cmd.GetDesc() { + u.PrintlnErr(desc) + } + u.PrintlnErr("USAGE: ",cmd.GetName(), " [-l] [ID ...] [regex ...]") u.PrintlnErr("Use \"-l\" to specify detailed VMs output.") printRegexUsageDetails() } diff --git a/src/client_cli/cmdVM/vmListAttach.go b/src/client_cli/cmdVM/vmListAttach.go index bc5a3adf7ec0b13a4df0c2440ef59241ab6923e2..77b73225c549d45307833f17f013a61ee84f0525 100644 --- a/src/client_cli/cmdVM/vmListAttach.go +++ b/src/client_cli/cmdVM/vmListAttach.go @@ -8,8 +8,10 @@ func (cmd *ListAttach)GetName() string { return cmd.Name } -func (cmd *ListAttach)GetDesc() string { - return "List VMs that can be attached to (regex matching)." +func (cmd *ListAttach)GetDesc() []string { + return []string{ + "Lists VMs that can be attached to (regex matching).", + "Requires VM_LIST VM access capability or VM_LIST_ANY user capability."} } func (cmd *ListAttach)PrintUsage() { diff --git a/src/client_cli/cmdVM/vmListDel.go b/src/client_cli/cmdVM/vmListDel.go index 0e22640a3a7110db041a99bbad8f7ca4c1731950..0da557d5be6fad231738c6a688fa3d012f21a26f 100644 --- a/src/client_cli/cmdVM/vmListDel.go +++ b/src/client_cli/cmdVM/vmListDel.go @@ -8,8 +8,10 @@ func (cmd *ListDel)GetName() string { return cmd.Name } -func (cmd *ListDel)GetDesc() string { - return "List VMs that can be deleted (regex matching)." +func (cmd *ListDel)GetDesc() []string { + return []string{ + "Lists VMs that can be deleted (regex matching).", + "Requires VM_DESTROY VM access capability or VM_DESTROY_ANY user capability."} } func (cmd *ListDel)PrintUsage() { diff --git a/src/client_cli/cmdVM/vmListEdit.go b/src/client_cli/cmdVM/vmListEdit.go index 7d45a9bc1ace3b13dad8b5f2f65fb9b5628226d7..4c3c20728b4439d5d9cc0a65acb7ea2ee78c2482 100644 --- a/src/client_cli/cmdVM/vmListEdit.go +++ b/src/client_cli/cmdVM/vmListEdit.go @@ -8,8 +8,10 @@ func (cmd *ListEdit)GetName() string { return cmd.Name } -func (cmd *ListEdit)GetDesc() string { - return "List VMs that can be edited (regex matching)." +func (cmd *ListEdit)GetDesc() []string { + return []string{ + "Lists VMs that can be edited (regex matching).", + "Requires VM_EDIT VM access capability or VM_EDIT_ANY user capability."} } func (cmd *ListEdit)PrintUsage() { diff --git a/src/client_cli/cmdVM/vmListEditAccess.go b/src/client_cli/cmdVM/vmListEditAccess.go index 7de1addf76588ca6c804622d5280a30e5ffa360c..47bf73cd48414a0dd721d54f04574f851f5a746e 100644 --- a/src/client_cli/cmdVM/vmListEditAccess.go +++ b/src/client_cli/cmdVM/vmListEditAccess.go @@ -8,8 +8,10 @@ func (cmd *ListEditAccess)GetName() string { return cmd.Name } -func (cmd *ListEditAccess)GetDesc() string { - return "List VMs that can have their VM access edited (regex matching)." +func (cmd *ListEditAccess)GetDesc() []string { + return []string{ + "Lists VMs that can have their VM access edited (regex matching).", + "Requires VM_SET_ACCESS user capability and VM_SET_ACCESS VM access capability."} } func (cmd *ListEditAccess)PrintUsage() { diff --git a/src/client_cli/cmdVM/vmListExportDir.go b/src/client_cli/cmdVM/vmListExportDir.go index d6e56535bf5f408da2260308653f6c0abe1f52ae..abe2593231171e3547fcf4f67b32cbb3baa9e08f 100644 --- a/src/client_cli/cmdVM/vmListExportDir.go +++ b/src/client_cli/cmdVM/vmListExportDir.go @@ -8,8 +8,10 @@ func (cmd *ListExportDir)GetName() string { return cmd.Name } -func (cmd *ListExportDir)GetDesc() string { - return "List VMs that can have a directory exported (regex matching)." +func (cmd *ListExportDir)GetDesc() []string { + return []string{ + "List VMs that can have a directory exported (regex matching).", + "Requires VM_READFS VM access capability or VM_READFS_ANY user capability."} } func (cmd *ListExportDir)PrintUsage() { diff --git a/src/client_cli/cmdVM/vmListStart.go b/src/client_cli/cmdVM/vmListStart.go index 2a04678561ef9b522e66dc0a2bf98ead5916a19b..85ba5d6de77b198dbba0e78f2e80c26504b7ced1 100644 --- a/src/client_cli/cmdVM/vmListStart.go +++ b/src/client_cli/cmdVM/vmListStart.go @@ -8,8 +8,10 @@ func (cmd *ListStart)GetName() string { return cmd.Name } -func (cmd *ListStart)GetDesc() string { - return "List VMs that can be started (regex matching)." +func (cmd *ListStart)GetDesc() []string { + return []string{ + "Lists VMs that can be started (regex matching).", + "Requires VM_START VM access capability or VM_START_ANY user capability."} } func (cmd *ListStart)PrintUsage() { diff --git a/src/client_cli/cmdVM/vmListStop.go b/src/client_cli/cmdVM/vmListStop.go index 99bac9f265f54201e05ca89af000a6a41abf61a8..76da9b65af8713c5964336a5a375665dcc522093 100644 --- a/src/client_cli/cmdVM/vmListStop.go +++ b/src/client_cli/cmdVM/vmListStop.go @@ -8,8 +8,10 @@ func (cmd *ListStop)GetName() string { return cmd.Name } -func (cmd *ListStop)GetDesc() string { - return "List VMs that can be stopped or shutdown (regex matching)." +func (cmd *ListStop)GetDesc() []string { + return []string{ + "Lists VMs that can be stopped or shutdown (regex matching).", + "Requires VM_STOP VM access capability or VM_STOP_ANY user capability."} } func (cmd *ListStop)PrintUsage() { diff --git a/src/client_cli/cmdVM/vmSetAccess.go b/src/client_cli/cmdVM/vmSetAccess.go index 50cd240eed12d45f4f0c238716878227d384406f..f6c1c801cdd43f579739272aa9a7c4705459981b 100644 --- a/src/client_cli/cmdVM/vmSetAccess.go +++ b/src/client_cli/cmdVM/vmSetAccess.go @@ -15,13 +15,17 @@ func (cmd *SetAccess)GetName() string { return cmd.Name } -func (cmd *SetAccess)GetDesc() string { - return "Set a user's VM access in one or more VMs (regex matching)." +func (cmd *SetAccess)GetDesc() []string { + return []string{ + "Sets a user's VM access in one or more VMs (regex matching).", + "Requires VM_SET_ACCESS user capability and VM_SET_ACCESS VM access capability."} } func (cmd *SetAccess)PrintUsage() { - u.PrintlnErr(cmd.GetDesc()) - u.PrintlnErr("Usage: "+cmd.GetName()+" [ID ...] [regex ...] email [capability ...]") + for _, desc := range cmd.GetDesc() { + u.PrintlnErr(desc) + } + u.PrintlnErr("USAGE: "+cmd.GetName()+" [ID ...] [regex ...] email [capability ...]") const usage string = `Capabilities must be specified after the email. Only VMs matching the specified IDs or regexes will have their VM access set. Any number of IDs or regexes can be specified. diff --git a/src/client_cli/cmdVM/vmShutdown.go b/src/client_cli/cmdVM/vmShutdown.go index 22be937e33c7335443135fcc9d0b5be45a33a4ec..a091036fa45e72d04f7ed1e7850b88fc2cc7c36e 100644 --- a/src/client_cli/cmdVM/vmShutdown.go +++ b/src/client_cli/cmdVM/vmShutdown.go @@ -13,8 +13,10 @@ func (cmd *Shutdown)GetName() string { return cmd.Name } -func (cmd *Shutdown)GetDesc() string { - return "Gracefully shutdown one or more VMs (regex matching)." +func (cmd *Shutdown)GetDesc() []string { + return []string{ + "Gracefully shutdowns one or more VMs (regex matching).", + "Requires VM_STOP VM access capability or VM_STOP_ANY user capability."} } func (cmd *Shutdown)PrintUsage() { diff --git a/src/client_cli/cmdVM/vmStart.go b/src/client_cli/cmdVM/vmStart.go index 33c73407f500f575aaa8c53c860334c818824123..1fa62e52c805dcd6c392c1a70a5e0c1c2c328b4d 100644 --- a/src/client_cli/cmdVM/vmStart.go +++ b/src/client_cli/cmdVM/vmStart.go @@ -13,8 +13,10 @@ func (cmd *Start)GetName() string { return cmd.Name } -func (cmd *Start)GetDesc() string { - return "Start one or more VMs (regex matching)." +func (cmd *Start)GetDesc() []string { + return []string{ + "Starts one or more VMs (regex matching).", + "Requires VM_START VM access capability or VM_START_ANY user capability."} } func (cmd *Start)PrintUsage() { diff --git a/src/client_cli/cmdVM/vmStop.go b/src/client_cli/cmdVM/vmStop.go index f67528b8f76c29e081126345f3d2e760a6ea2fbd..edc3a8edf3848daff70583c2152f19e3baf2e211 100644 --- a/src/client_cli/cmdVM/vmStop.go +++ b/src/client_cli/cmdVM/vmStop.go @@ -13,8 +13,10 @@ func (cmd *Stop)GetName() string { return cmd.Name } -func (cmd *Stop)GetDesc() string { - return "Stop by force one or more VMs (regex matching)." +func (cmd *Stop)GetDesc() []string { + return []string{ + "Stops by force one or more VMs (regex matching).", + "Requires VM_STOP VM access capability or VM_STOP_ANY user capability."} } func (cmd *Stop)PrintUsage() { diff --git a/src/client_cli/nexus-client.go b/src/client_cli/nexus-client.go index 939387d57550bea0b99f0aae7c29faace269cb9e..8202ece0bdb0513fc09c45409b8a436ad345965b 100644 --- a/src/client_cli/nexus-client.go +++ b/src/client_cli/nexus-client.go @@ -91,9 +91,16 @@ func main() { u.PrintlnErr("List of supported Commands:") padding := 20 for _, cmd := range cmdList { - u.PrintErr(" "+cmd.GetName()) + u.PrintlnErr("") + cmdStr := " "+cmd.GetName() + u.PrintErr(cmdStr) pad := strings.Repeat(" ", padding-len(cmd.GetName())) - u.PrintlnErr(pad+cmd.GetDesc()) + for i, desc := range cmd.GetDesc() { + if i > 0 { + u.PrintErr(strings.Repeat(" ", len(cmdStr))) + } + u.PrintlnErr(pad+desc) + } } os.Exit(1) }