Revision 9068cd85 logic/callbacks.py
b/logic/callbacks.py | ||
---|---|---|
134 | 134 |
_logger.debug("Request to update credits") |
135 | 135 |
message.channel.basic_ack(message.delivery_tag) |
136 | 136 |
|
137 |
|
|
138 |
def update_build_progress(message): |
|
139 |
"""Process a progress update message""" |
|
140 |
try: |
|
141 |
msg = json.loads(message.body) |
|
142 |
|
|
143 |
if msg['type'] != "ganeti-create-progess": |
|
144 |
_logger.error("Message is of unknown type %s", msg["type"]) |
|
145 |
return |
|
146 |
|
|
147 |
# XXX: The following assumes names like snf-12 |
|
148 |
instid = msg['instance'].split('-')[1] |
|
149 |
|
|
150 |
vm = VirtualMachine.objects.get(id = instid) |
|
151 |
|
|
152 |
backend.process_net_status(vm, msg['percentage']) |
|
153 |
|
|
154 |
_logger.debug("Done processing ganeti-create-progess msg for vm %s.", |
|
155 |
msg["instance"]) |
|
156 |
message.channel.basic_ack(message.delivery_tag) |
|
157 |
|
|
158 |
except KeyError: |
|
159 |
_logger.error("Malformed incoming JSON, missing attributes: %s", |
|
160 |
message.body) |
|
161 |
except VirtualMachine.IllegalState: |
|
162 |
_logger.error("Build progress message for non-building VM %s: %s"% |
|
163 |
(instid, message.body)) |
|
164 |
except Exception as e: |
|
165 |
_logger.exception("Unexpected error") |
|
166 |
raise |
|
167 |
|
|
168 |
|
|
137 | 169 |
def trigger_status_update(message): |
138 | 170 |
""" |
139 | 171 |
Triggers a status update job for a specific VM id. |
Also available in: Unified diff