Revision 9068cd85 logic/backend.py
b/logic/backend.py | ||
---|---|---|
134 | 134 |
firewall_profile=firewall_profile) |
135 | 135 |
vm.save() |
136 | 136 |
|
137 |
@transaction.commit_on_success |
|
138 |
def process_progress_update(vm, pr_percentage): |
|
139 |
|
|
140 |
if not type(pr_percentage) == int: |
|
141 |
raise TypeError("Percentage not an integer") |
|
142 |
|
|
143 |
if pr_percentage < 0 or pr_percentage > 100: |
|
144 |
raise Exception("Percentage not in range (0, 100)") |
|
145 |
|
|
146 |
last_update = vm.buildpercentage |
|
147 |
|
|
148 |
if last_update > pr_percentage: |
|
149 |
raise Exception("Build percentage should increase monotonically" \ |
|
150 |
" (old=%d, new=%d)"%(last_update, pr_percentage)) |
|
151 |
|
|
152 |
if not vm.operstate == 'BUILD': |
|
153 |
raise VirtualMachine.IllegalState("VM is not in building state") |
|
154 |
|
|
155 |
vm.buildpercentage = pr_percentage |
|
156 |
vm.save() |
|
137 | 157 |
|
138 | 158 |
def start_action(vm, action): |
139 | 159 |
"""Update the state of a VM when a new action is initiated.""" |
Also available in: Unified diff