Revision fd95834e snf-cyclades-app/synnefo/logic/backend.py
b/snf-cyclades-app/synnefo/logic/backend.py | ||
---|---|---|
39 | 39 |
|
40 | 40 |
from synnefo.db.models import (Backend, VirtualMachine, Network, |
41 | 41 |
BackendNetwork, BACKEND_STATUSES, |
42 |
pooled_rapi_client, BridgePoolTable, |
|
43 |
MacPrefixPoolTable, VirtualMachineDiagnostic) |
|
42 |
pooled_rapi_client, VirtualMachineDiagnostic) |
|
44 | 43 |
from synnefo.logic import utils |
45 | 44 |
from synnefo import quotas |
46 | 45 |
from synnefo.api.util import release_resource |
46 |
from synnefo.util.mac2eui64 import mac2eui64 |
|
47 | 47 |
|
48 | 48 |
from logging import getLogger |
49 | 49 |
log = getLogger(__name__) |
... | ... | |
58 | 58 |
|
59 | 59 |
|
60 | 60 |
@transaction.commit_on_success |
61 |
def process_op_status(vm, etime, jobid, opcode, status, logmsg): |
|
61 |
def process_op_status(vm, etime, jobid, opcode, status, logmsg, nics=None):
|
|
62 | 62 |
"""Process a job progress notification from the backend |
63 | 63 |
|
64 | 64 |
Process an incoming message from the backend (currently Ganeti). |
... | ... | |
81 | 81 |
if status == 'success' and state_for_success is not None: |
82 | 82 |
vm.operstate = state_for_success |
83 | 83 |
|
84 |
# Update the NICs of the VM |
|
85 |
if status == "success" and nics is not None: |
|
86 |
_process_net_status(vm, etime, nics) |
|
87 |
|
|
84 | 88 |
# Special case: if OP_INSTANCE_CREATE fails --> ERROR |
85 | 89 |
if opcode == 'OP_INSTANCE_CREATE' and status in ('canceled', 'error'): |
86 | 90 |
vm.operstate = 'ERROR' |
... | ... | |
113 | 117 |
|
114 | 118 |
@transaction.commit_on_success |
115 | 119 |
def process_net_status(vm, etime, nics): |
120 |
"""Wrap _process_net_status inside transaction.""" |
|
121 |
_process_net_status(vm, etime, nics) |
|
122 |
|
|
123 |
|
|
124 |
def _process_net_status(vm, etime, nics): |
|
116 | 125 |
"""Process a net status notification from the backend |
117 | 126 |
|
118 | 127 |
Process an incoming message from the Ganeti backend, |
... | ... | |
156 | 165 |
# Get the new nic info |
157 | 166 |
mac = new_nic.get('mac', '') |
158 | 167 |
ipv4 = new_nic.get('ip', '') |
159 |
ipv6 = new_nic.get('ipv6', '') |
|
168 |
if net.subnet6: |
|
169 |
ipv6 = mac2eui64(mac, net.subnet6) |
|
170 |
else: |
|
171 |
ipv6 = '' |
|
160 | 172 |
|
161 | 173 |
firewall = new_nic.get('firewall', '') |
162 | 174 |
firewall_profile = _reverse_tags.get(firewall, '') |
Also available in: Unified diff