Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Secure solution for nexus infrastructure
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
flg_masters
TM
Secure solution for nexus infrastructure
Commits
ff2838ab
Commit
ff2838ab
authored
2 years ago
by
Florent Gluck
Browse files
Options
Downloads
Patches
Plain Diff
Completed client-side of USB redirection
Bumped client to version 1.6.0
parent
181fa563
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/cmdVM/vmCreate.go
+1
-16
1 addition, 16 deletions
src/cmdVM/vmCreate.go
src/cmdVM/vmEdit.go
+14
-4
14 additions, 4 deletions
src/cmdVM/vmEdit.go
src/utils/utils.go
+15
-0
15 additions, 0 deletions
src/utils/utils.go
with
30 additions
and
20 deletions
src/cmdVM/vmCreate.go
+
1
−
16
View file @
ff2838ab
...
@@ -2,7 +2,6 @@ package cmdVM
...
@@ -2,7 +2,6 @@ package cmdVM
import
(
import
(
"fmt"
"fmt"
"strings"
"strconv"
"strconv"
u
"nexus-client/utils"
u
"nexus-client/utils"
g
"nexus-client/globals"
g
"nexus-client/globals"
...
@@ -68,7 +67,7 @@ func (cmd *Create)Run(args []string) int {
...
@@ -68,7 +67,7 @@ func (cmd *Create)Run(args []string) int {
return
1
return
1
}
}
nic
:=
NicType
(
args
[
3
])
nic
:=
NicType
(
args
[
3
])
usbDevs
:=
cmd
.
s
tr2UsbDevices
(
args
[
4
])
usbDevs
:=
u
.
S
tr2UsbDevices
(
args
[
4
])
templateID
,
err
:=
uuid
.
Parse
(
args
[
5
])
templateID
,
err
:=
uuid
.
Parse
(
args
[
5
])
if
err
!=
nil
{
if
err
!=
nil
{
u
.
PrintlnErr
(
err
)
u
.
PrintlnErr
(
err
)
...
@@ -153,17 +152,3 @@ func (cmd *Create)Run(args []string) int {
...
@@ -153,17 +152,3 @@ func (cmd *Create)Run(args []string) int {
return
statusCode
return
statusCode
}
}
// Convert a string of USB devices of the form "1fc9:001d,067b:2303"
// into a slice of string where each element is a string of the form "1fc9:001d".
// Returns an empty slice if the input string is "none".
func
(
cmd
*
Create
)
str2UsbDevices
(
s
string
)
[]
string
{
usbDevs
:=
[]
string
{}
if
s
!=
"none"
{
devs
:=
strings
.
Split
(
s
,
","
)
// Extracts USB devices
for
_
,
dev
:=
range
devs
{
usbDevs
=
append
(
usbDevs
,
dev
)
}
}
return
usbDevs
}
This diff is collapsed.
Click to expand it.
src/cmdVM/vmEdit.go
+
14
−
4
View file @
ff2838ab
...
@@ -16,7 +16,8 @@ type vmEditParameters struct {
...
@@ -16,7 +16,8 @@ type vmEditParameters struct {
Name
string
Name
string
Cpus
int
Cpus
int
Ram
int
Ram
int
Nic
string
Nic
NicType
UsbDevs
[]
string
}
}
func
(
cmd
*
Edit
)
GetName
()
string
{
func
(
cmd
*
Edit
)
GetName
()
string
{
...
@@ -34,13 +35,16 @@ func (cmd *Edit)PrintUsage() {
...
@@ -34,13 +35,16 @@ func (cmd *Edit)PrintUsage() {
u
.
PrintlnErr
(
desc
)
u
.
PrintlnErr
(
desc
)
}
}
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=
...
] [cpus=
...
] [ram=
...
] [nic=
...] [usb=...
]"
)
u
.
PrintlnErr
(
"―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――"
)
u
.
PrintlnErr
(
"―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――"
)
const
usage
string
=
`Parameters that can be changed (at least one must be specified):
const
usage
string
=
`Parameters that can be changed (at least one must be specified):
name Name of the VM.
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" (no network) or "user" (network access).`
nic Network interface, either "none" (no network) or "user" (network access).
usb List of USB devices exposed in the VM; either "none" or a list of comma separated
vendorID:productID (4-digit hex number), each specifying a USB device; example
exposing two USB devices: 1fc9:001d,067b:2303`
u
.
PrintlnErr
(
usage
)
u
.
PrintlnErr
(
usage
)
u
.
PrintlnErr
(
""
)
u
.
PrintlnErr
(
""
)
printRegexUsageDetails
()
printRegexUsageDetails
()
...
@@ -141,7 +145,13 @@ func (cmd *Edit)parseArgs(args []string) (*vmEditParameters, []string, error) {
...
@@ -141,7 +145,13 @@ func (cmd *Edit)parseArgs(args []string) (*vmEditParameters, []string, error) {
}
}
s
=
getStringVal
(
arg
,
"nic="
)
s
=
getStringVal
(
arg
,
"nic="
)
if
s
!=
""
{
if
s
!=
""
{
vmParams
.
Nic
=
s
vmParams
.
Nic
=
NicType
(
s
)
atLeastOneArg
=
true
continue
}
s
=
getStringVal
(
arg
,
"usb="
)
if
s
!=
""
{
vmParams
.
UsbDevs
=
u
.
Str2UsbDevices
(
s
)
atLeastOneArg
=
true
atLeastOneArg
=
true
continue
continue
}
}
...
...
This diff is collapsed.
Click to expand it.
src/utils/utils.go
+
15
−
0
View file @
ff2838ab
...
@@ -7,6 +7,7 @@ import (
...
@@ -7,6 +7,7 @@ import (
"io/fs"
"io/fs"
"bytes"
"bytes"
"errors"
"errors"
"strings"
"net/mail"
"net/mail"
"archive/tar"
"archive/tar"
"path/filepath"
"path/filepath"
...
@@ -112,3 +113,17 @@ func IsEmail(email string) bool {
...
@@ -112,3 +113,17 @@ func IsEmail(email string) bool {
_
,
err
:=
mail
.
ParseAddress
(
email
)
_
,
err
:=
mail
.
ParseAddress
(
email
)
return
err
==
nil
return
err
==
nil
}
}
// Convert a string of USB devices of the form "1fc9:001d,067b:2303"
// into a slice of string where each element is a string of the form "1fc9:001d".
// Returns an empty slice if the input string is "none".
func
Str2UsbDevices
(
s
string
)
[]
string
{
usbDevs
:=
[]
string
{}
if
s
!=
"none"
{
devs
:=
strings
.
Split
(
s
,
","
)
// Extracts USB devices
for
_
,
dev
:=
range
devs
{
usbDevs
=
append
(
usbDevs
,
dev
)
}
}
return
usbDevs
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment