Revision 2f355fb5

b/logic/dispatcher_callbacks.py
149 149
        if msg["status"] != "success" :
150 150
            _logger.warn("Ignoring non-success status update from job %d on VM %s",
151 151
                          msg['jobId'], msg['instance'])
152
            message.channel.basic_ack(message.delivery_tag)
152 153
            return
153 154

  
154 155
        status = backend.get_job_status(msg['jobId'])
155 156

  
156 157
        _logger.debug("Node status job result: %s" % status)
157 158

  
158
        stat = _parse_json(status)
159

  
160
        if stat["summary"] != "INSTANCE_QUERY_DATA" or \
161
           type(stat["opresult"]) is not list:
162
             _logger.error("Status is of unknown type %s", stat["summary"])
159
        if status['summary'][0] != u'INSTANCE_QUERY_DATA' :
160
             _logger.error("Status update is of unknown type %s", status['summary'])
163 161
             return
164 162

  
165
        req_state = stat['opresult'][msg['instance']]['config_state']
166
        run_state = stat['opresult'][msg['instance']]['run_state']
167
        vm = VirtualMachine.objects.get(name=msg['instance'])
168
        backend.update_status(vm, run_state)
169
        
163
        conf_state = status['opresult'][0][msg['instance']]['config_state']
164
        run_state = status['opresult'][0][msg['instance']]['run_state']
165

  
166
        # XXX: The following assumes names like snf-12
167
        instid = msg['instance'].split('-')[1]
168

  
169
        vm = VirtualMachine.objects.get(id = instid)
170

  
171
        if run_state == "up":
172
            opcode = "OP_INSTANCE_REBOOT"
173
        else :
174
            opcode = "OP_INSTANCE_SHUTDOWN"
175

  
176
        backend.process_op_status(vm=vm, jobid=msg['jobId'],opcode=opcode,
177
                                  status="success",
178
                                  logmsg="Reconciliation: simulated event")
179

  
170 180
        message.channel.basic_ack(message.delivery_tag)
171 181
    except KeyError as k:
172 182
        _logger.error("Malformed incoming JSON, missing attributes: %s", k)

Also available in: Unified diff