Revision 35f2fc07 snf-cyclades-app/synnefo/management/common.py

b/snf-cyclades-app/synnefo/management/common.py
37 37

  
38 38
from snf_django.lib.api import faults
39 39
from synnefo.api import util
40
from synnefo.logic import backend as backend_mod
40 41
from synnefo.logic.rapi import GanetiApiError, GanetiRapiClient
41 42
from synnefo.logic.utils import (id_from_instance_name,
42 43
                                 id_from_network_name)
......
166 167

  
167 168
class Omit(object):
168 169
    pass
170

  
171

  
172
def wait_server_task(server, wait, stdout):
173
    jobID = server.task_job_id
174
    if wait:
175
        msg = "Issued job '%s'. Waiting to complete...\n"
176
        stdout.write(msg % jobID)
177
        client = server.get_client()
178
        wait_ganeti_job(client, jobID, stdout)
179
    else:
180
        msg = "Issued job '%s'.\n"
181
        stdout.write(msg % jobID)
182

  
183

  
184
def wait_ganeti_job(client, jobID, stdout):
185
    status, error = backend_mod.wait_for_job(client, jobID)
186
    if status == "success":
187
        stdout.write("Job finished successfully.\n")
188
    else:
189
        raise CommandError("Job failed! Error: %s\n" % error)

Also available in: Unified diff