Revision cc92b70f snf-cyclades-app/synnefo/logic/backend.py
b/snf-cyclades-app/synnefo/logic/backend.py | ||
---|---|---|
170 | 170 |
firewall_profile = settings.DEFAULT_FIREWALL_PROFILE |
171 | 171 |
|
172 | 172 |
nic = { |
173 |
'index': i,
|
|
174 |
'network': net,
|
|
175 |
'mac': mac,
|
|
176 |
'ipv4': ipv4,
|
|
177 |
'ipv6': ipv6,
|
|
178 |
'firewall_profile': firewall_profile}
|
|
173 |
'index': i, |
|
174 |
'network': net, |
|
175 |
'mac': mac, |
|
176 |
'ipv4': ipv4, |
|
177 |
'ipv6': ipv6, |
|
178 |
'firewall_profile': firewall_profile} |
|
179 | 179 |
|
180 | 180 |
new_nics.append(nic) |
181 | 181 |
return new_nics |
... | ... | |
186 | 186 |
if len(old_nics) != len(new_nics): |
187 | 187 |
return True |
188 | 188 |
for old_nic, new_nic in zip(old_nics, new_nics): |
189 |
if not (old_nic.ipv4 == new_nic['ipv4'] and\
|
|
190 |
old_nic.ipv6 == new_nic['ipv6'] and\
|
|
191 |
old_nic.mac == new_nic['mac'] and\
|
|
192 |
old_nic.firewall_profile == new_nic['firewall_profile'] and\
|
|
193 |
old_nic.index == new_nic['index'] and\
|
|
189 |
if not (old_nic.ipv4 == new_nic['ipv4'] and |
|
190 |
old_nic.ipv6 == new_nic['ipv6'] and |
|
191 |
old_nic.mac == new_nic['mac'] and |
|
192 |
old_nic.firewall_profile == new_nic['firewall_profile'] and |
|
193 |
old_nic.index == new_nic['index'] and |
|
194 | 194 |
old_nic.network == new_nic['network']): |
195 | 195 |
return True |
196 | 196 |
return False |
... | ... | |
243 | 243 |
old_state = network.state |
244 | 244 |
|
245 | 245 |
backend_states = [s.operstate for s in |
246 |
network.backend_networks.filter(backend__offline=False)] |
|
246 |
network.backend_networks.filter(backend__offline=False)]
|
|
247 | 247 |
if not backend_states: |
248 | 248 |
network.state = 'PENDING' |
249 | 249 |
network.save() |
... | ... | |
332 | 332 |
|
333 | 333 |
|
334 | 334 |
def create_instance_diagnostic(vm, message, source, level="DEBUG", etime=None, |
335 |
details=None): |
|
335 |
details=None):
|
|
336 | 336 |
""" |
337 | 337 |
Create virtual machine instance diagnostic entry. |
338 | 338 |
|
... | ... | |
344 | 344 |
:param details: Additional details or debug information. |
345 | 345 |
""" |
346 | 346 |
VirtualMachineDiagnostic.objects.create_for_vm(vm, level, source=source, |
347 |
source_date=etime, message=message, details=details) |
|
347 |
source_date=etime, |
|
348 |
message=message, |
|
349 |
details=details) |
|
348 | 350 |
|
349 | 351 |
|
350 | 352 |
def create_instance(vm, public_nic, flavor, image, password=None): |
... | ... | |
389 | 391 |
kw['dry_run'] = settings.TEST |
390 | 392 |
|
391 | 393 |
kw['beparams'] = { |
392 |
'auto_balance': True, |
|
393 |
'vcpus': flavor.cpu, |
|
394 |
'memory': flavor.ram} |
|
394 |
'auto_balance': True,
|
|
395 |
'vcpus': flavor.cpu,
|
|
396 |
'memory': flavor.ram}
|
|
395 | 397 |
|
396 | 398 |
kw['osparams'] = { |
397 | 399 |
'config_url': vm.config_url, |
... | ... | |
497 | 499 |
bn = BackendNetwork.objects.get(network=network, backend=backend) |
498 | 500 |
mac_prefix = bn.mac_prefix |
499 | 501 |
except BackendNetwork.DoesNotExist: |
500 |
raise Exception("BackendNetwork for network '%s' in backend '%s'"\
|
|
502 |
raise Exception("BackendNetwork for network '%s' in backend '%s'" |
|
501 | 503 |
" does not exist" % (network.id, backend.id)) |
502 | 504 |
|
503 | 505 |
with pooled_rapi_client(backend) as client: |
... | ... | |
605 | 607 |
|
606 | 608 |
# XXX NOP ModifyInstance call to force process_net_status to run |
607 | 609 |
# on the dispatcher |
610 |
os_name = settings.GANETI_CREATEINSTANCE_KWARGS['os'] |
|
608 | 611 |
client.ModifyInstance(vm.backend_vm_id, |
609 |
os_name=settings.GANETI_CREATEINSTANCE_KWARGS['os'])
|
|
612 |
os_name=os_name)
|
|
610 | 613 |
|
611 | 614 |
|
612 | 615 |
def get_ganeti_instances(backend=None, bulk=False): |
... | ... | |
661 | 664 |
for n in nodes: |
662 | 665 |
# Filter out drained, offline and not vm_capable nodes since they will |
663 | 666 |
# not take part in the vm allocation process |
664 |
if n['vm_capable'] and not n['drained'] and not n['offline']\
|
|
665 |
and n['cnodes']:
|
|
667 |
can_host_vms = n['vm_capable'] and not (n['drained'] or n['offline'])
|
|
668 |
if can_host_vms and n['cnodes']:
|
|
666 | 669 |
for a in attr: |
667 | 670 |
res[a] += int(n[a]) |
668 | 671 |
return res |
... | ... | |
737 | 740 |
status = result['job_info'][0] |
738 | 741 |
while status not in ['success', 'error', 'cancel']: |
739 | 742 |
result = client.WaitForJobChange(jobid, ['status', 'opresult'], |
740 |
[result], None) |
|
743 |
[result], None)
|
|
741 | 744 |
status = result['job_info'][0] |
742 | 745 |
|
743 | 746 |
if status == 'success': |
Also available in: Unified diff