Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
aaaa36f2
Commit
aaaa36f2
authored
Nov 05, 2012
by
Christos Stavrakakis
Browse files
Display VM build percentage in management commands
parent
aacdd39d
Changes
4
Hide whitespace changes
Inline
Side-by-side
snf-cyclades-app/synnefo/api/management/commands/_common.py
View file @
aaaa36f2
...
...
@@ -48,3 +48,10 @@ def format_date(d):
return
timesince
(
d
)
+
' ago'
else
:
return
'in '
+
timeuntil
(
d
)
def
format_vm_state
(
vm
):
if
vm
.
operstate
==
"BUILD"
:
return
"BUILD("
+
str
(
vm
.
buildpercentage
)
+
"%)"
else
:
return
vm
.
operstate
snf-cyclades-app/synnefo/
logic
/management/commands/server-inspect.py
→
snf-cyclades-app/synnefo/
api
/management/commands/server-inspect.py
View file @
aaaa36f2
...
...
@@ -40,6 +40,7 @@ from synnefo.api.util import get_image
from
synnefo.lib.utils
import
merge_time
from
synnefo.db.models
import
VirtualMachine
from
synnefo.logic.rapi
import
GanetiApiError
from
._common
import
format_vm_state
# Fields to print from a gnt-instance info
...
...
@@ -84,11 +85,11 @@ class Command(BaseCommand):
sep
=
'-'
*
80
+
'
\n
'
labels
=
(
'name'
,
'owner'
,
'flavor'
,
'image'
,
'state'
,
'backend'
,
'deleted'
,
'action'
,
'backendjobid'
,
'backendopcod
o
e'
,
'deleted'
,
'action'
,
'backendjobid'
,
'backendopcode'
,
'backendjobstatus'
,
'backend_time'
)
fields
=
(
vm
.
name
,
vm
.
userid
,
vm
.
flavor
.
name
,
image
,
vm
.
operstate
,
str
(
vm
.
backend
),
str
(
vm
.
deleted
),
str
(
vm
.
action
),
str
(
vm
.
backendjobid
),
str
(
vm
.
backendopcode
),
fields
=
(
vm
.
name
,
vm
.
userid
,
vm
.
flavor
.
name
,
image
,
format_vm_state
(
vm
),
str
(
vm
.
backend
),
str
(
vm
.
deleted
),
str
(
vm
.
action
),
str
(
vm
.
backendjobid
),
str
(
vm
.
backendopcode
),
str
(
vm
.
backendjobstatus
),
str
(
vm
.
backendtime
))
self
.
stdout
.
write
(
sep
)
...
...
snf-cyclades-app/synnefo/api/management/commands/server-list.py
View file @
aaaa36f2
...
...
@@ -37,6 +37,7 @@ from django.core.management.base import BaseCommand, CommandError
from
synnefo.api.util
import
get_image
from
synnefo.db.models
import
VirtualMachine
,
Backend
from
._common
import
format_vm_state
class
Command
(
BaseCommand
):
...
...
@@ -101,7 +102,9 @@ class Command(BaseCommand):
image
=
cache
.
get_image
(
server
.
imageid
,
server
.
userid
)[
'name'
]
except
:
image
=
server
.
imageid
fields
=
(
id
,
name
,
server
.
userid
,
flavor
,
image
,
server
.
operstate
,
state
=
format_vm_state
(
server
)
fields
=
(
id
,
name
,
server
.
userid
,
flavor
,
image
,
state
,
str
(
server
.
backend
))
if
options
[
'csv'
]:
...
...
snf-cyclades-app/synnefo/api/management/commands/server-show.py
View file @
aaaa36f2
...
...
@@ -36,7 +36,7 @@ from django.core.management.base import BaseCommand, CommandError
from
synnefo.api.util
import
get_image
from
synnefo.db.models
import
VirtualMachine
from
._common
import
format_bool
,
format_date
from
._common
import
format_bool
,
format_date
,
format_vm_state
class
Command
(
BaseCommand
):
...
...
@@ -68,7 +68,7 @@ class Command(BaseCommand):
'flavor'
:
flavor
,
'deleted'
:
format_bool
(
server
.
deleted
),
'suspended'
:
format_bool
(
server
.
suspended
),
'state'
:
server
.
operstate
'state'
:
format_vm_state
(
server
)
}
for
key
,
val
in
sorted
(
kv
.
items
()):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment