Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nexus
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
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
flg_projects
nexus_vdi
nexus
Commits
a0b4d1ee
Commit
a0b4d1ee
authored
1 year ago
by
Florent Gluck
Browse files
Options
Downloads
Patches
Plain Diff
Doh! Forgot src/client/cmdVM/vmListSingle.go
parent
bb4bda9c
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/client/cmdVM/vmListSingle.go
+66
-0
66 additions, 0 deletions
src/client/cmdVM/vmListSingle.go
with
66 additions
and
0 deletions
src/client/cmdVM/vmListSingle.go
0 → 100644
+
66
−
0
View file @
a0b4d1ee
package
cmdVM
import
(
u
"nexus-client/utils"
g
"nexus-client/globals"
)
type
ListSingle
struct
{
Name
string
}
func
(
cmd
*
ListSingle
)
GetName
()
string
{
return
cmd
.
Name
}
func
(
cmd
*
ListSingle
)
GetDesc
()
[]
string
{
return
[]
string
{
"Lists details about a VM."
,
"Requires VM_LIST VM access capability or VM_LIST_ANY user capability."
}
}
func
(
cmd
*
ListSingle
)
PrintUsage
()
{
for
_
,
desc
:=
range
cmd
.
GetDesc
()
{
u
.
PrintlnErr
(
desc
)
}
u
.
PrintlnErr
(
"―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――"
)
u
.
PrintlnErr
(
"USAGE: "
,
cmd
.
GetName
(),
" ID"
)
u
.
PrintlnErr
(
"―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――"
)
}
func
(
cmd
*
ListSingle
)
Run
(
args
[]
string
)
int
{
client
:=
g
.
GetInstance
()
.
Client
host
:=
g
.
GetInstance
()
.
Host
argc
:=
len
(
args
)
if
argc
<
1
{
cmd
.
PrintUsage
()
return
1
}
uuid
:=
args
[
0
]
resp
,
err
:=
client
.
R
()
.
Get
(
host
+
"/vms/"
+
uuid
)
if
err
!=
nil
{
u
.
PrintlnErr
(
"Failed retrieving VM
\"
"
+
uuid
+
"
\"
: "
+
err
.
Error
())
return
1
}
else
{
if
resp
.
IsSuccess
()
{
vm
,
err
:=
getVM
(
resp
)
if
err
!=
nil
{
u
.
PrintlnErr
(
"Failed retrieving server's response: "
+
err
.
Error
())
return
1
}
str
,
err
:=
vm
.
String
()
if
err
!=
nil
{
u
.
PrintlnErr
(
"Failed decoding VM "
+
vm
.
ID
.
String
()
+
" to string. Skipped."
)
}
else
{
u
.
Println
(
str
)
}
}
else
{
u
.
PrintlnErr
(
"Failed retrieving VM
\"
"
+
uuid
+
"
\"
: "
+
resp
.
Status
()
+
": "
+
resp
.
String
())
return
1
}
}
return
0
}
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