Revision 33b93f81

b/snf-cyclades-app/synnefo/logic/callbacks.py
80 80
                return
81 81

  
82 82
            # New message. Update the database!
83
            func(client, message)
83
            func(vm, msg)
84 84

  
85 85
        except ValueError:
86 86
            log.error("Incoming message not in JSON format: %s", message)
......
106 106

  
107 107

  
108 108
@is_update_required
109
def update_db(client, message):
109
def update_db(vm, msg):
110 110
    """Process a notification of type 'ganeti-op-status'"""
111
    log.debug("Processing ganeti-op-status msg: %s", message['body'])
112

  
113
    msg = json.loads(message['body'])
111
    log.debug("Processing ganeti-op-status msg: %s", msg)
114 112

  
115 113
    if msg['type'] != "ganeti-op-status":
116 114
        log.error("Message is of unknown type %s.", msg['type'])
117 115
        return
118 116

  
119
    vm_id = utils.id_from_instance_name(msg['instance'])
120
    vm = VirtualMachine.objects.get(id=vm_id)
121

  
122 117
    event_time = merge_time(msg['event_time'])
123 118
    backend.process_op_status(vm, event_time, msg['jobId'], msg['operation'],
124 119
                              msg['status'], msg['logmsg'])
......
128 123

  
129 124

  
130 125
@is_update_required
131
def update_net(client, message):
126
def update_net(vm, msg):
132 127
    """Process a notification of type 'ganeti-net-status'"""
133
    log.debug("Processing ganeti-net-status msg: %s", message['body'])
134

  
135
    msg = json.loads(message['body'])
128
    log.debug("Processing ganeti-net-status msg: %s", msg)
136 129

  
137 130
    if msg['type'] != "ganeti-net-status":
138 131
        log.error("Message is of unknown type %s", msg['type'])
139 132
        return
140 133

  
141
    vm_id = utils.id_from_instance_name(msg['instance'])
142
    vm = VirtualMachine.objects.get(id=vm_id)
143

  
144 134
    event_time = merge_time(msg['event_time'])
145 135
    backend.process_net_status(vm, event_time, msg['nics'])
146 136

  
......
149 139

  
150 140

  
151 141
@is_update_required
152
def update_build_progress(client, message):
142
def update_build_progress(vm, msg):
153 143
    """Process a create progress message"""
154
    log.debug("Processing ganeti-create-progress msg: %s", message['body'])
155

  
156
    msg = json.loads(message['body'])
144
    log.debug("Processing ganeti-create-progress msg: %s", msg)
157 145

  
158 146
    if msg['type'] != "ganeti-create-progress":
159 147
        log.error("Message is of unknown type %s", msg['type'])
160 148
        return
161 149

  
162
    vm_id = utils.id_from_instance_name(msg['instance'])
163
    vm = VirtualMachine.objects.get(id=vm_id)
164

  
165 150
    event_time = merge_time(msg['event_time'])
166 151
    backend.process_create_progress(vm, event_time, msg['rprogress'], None)
167 152

  
......
169 154
              msg['instance'])
170 155

  
171 156

  
172
@is_update_required
173 157
def dummy_proc(client, message):
174 158
    try:
175 159
        log.debug("Msg: %s", message['body'])
160
        client.basic_ack(message)
176 161
    except Exception as e:
177 162
        log.exception("Could not receive message")

Also available in: Unified diff