Commit aaaa36f2 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

Display VM build percentage in management commands

parent aacdd39d
......@@ -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
......@@ -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', 'backendopcodoe',
'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)
......
......@@ -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']:
......
......@@ -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()):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment