Revision 22f54174 snf-cyclades-app/synnefo/logic/backend.py

b/snf-cyclades-app/synnefo/logic/backend.py
89 89
        # failed server
90 90
        serial = vm.serial
91 91
        if job_status == rapi.JOB_STATUS_SUCCESS:
92
            quotas.accept_serial(serial)
92
            quotas.accept_resource_serial(vm)
93 93
        elif job_status in [rapi.JOB_STATUS_ERROR, rapi.JOB_STATUS_CANCELED]:
94 94
            log.debug("Job %s failed. Rejecting related serial %s", job_id,
95 95
                      serial)
96
            quotas.reject_serial(serial)
97
        vm.serial = None
96
            quotas.reject_resource_serial(vm)
98 97
    elif job_status == rapi.JOB_STATUS_SUCCESS:
99 98
        commission_info = quotas.get_commission_info(resource=vm,
100 99
                                                     action=action,
......
103 102
            # Commission for this change has not been issued, or the issued
104 103
            # commission was unaware of the current change. Reject all previous
105 104
            # commissions and create a new one in forced mode!
106
            log.debug("Expected job was %s. Processing job %s.",
107
                      vm.task_job_id, job_id)
105
            log.debug("Expected job was %s. Processing job %s. "
106
                      "Attached serial %s",
107
                      vm.task_job_id, job_id, vm.serial)
108 108
            reason = ("client: dispatcher, resource: %s, ganeti_job: %s"
109 109
                      % (vm, job_id))
110
            quotas.handle_resource_commission(vm, action,
111
                                              action_fields=job_fields,
112
                                              commission_name=reason,
113
                                              force=True,
114
                                              auto_accept=True)
115
            log.debug("Issued new commission: %s", vm.serial)
116
            # NOTE: Since we rejected the serial that was associated with the
117
            # 'vm.task_job_id' job, we must also clear the 'vm.serial' field.
118
            # If not, there will be no new commission for the 'vm.task_job_id'
119
            # job!
120
            vm.serial = None
121

  
110
            serial = quotas.handle_resource_commission(
111
                vm, action,
112
                action_fields=job_fields,
113
                commission_name=reason,
114
                force=True,
115
                auto_accept=True)
116
            log.debug("Issued new commission: %s", serial)
122 117
    return vm
123 118

  
124 119

  

Also available in: Unified diff