Revision efff6193 logic/backend.py
b/logic/backend.py | ||
---|---|---|
42 | 42 |
|
43 | 43 |
rapi = GanetiRapiClient(*settings.GANETI_CLUSTER_INFO) |
44 | 44 |
|
45 |
_firewall_tags = { |
|
46 |
'ENABLED': settings.GANETI_FIREWALL_ENABLED_TAG, |
|
47 |
'DISABLED': settings.GANETI_FIREWALL_DISABLED_TAG, |
|
48 |
'PROTECTED': settings.GANETI_FIREWALL_PROTECTED_TAG} |
|
49 |
|
|
50 |
_reverse_tags = dict((v.split(':')[3], k) for k, v in _firewall_tags.items()) |
|
51 |
|
|
45 | 52 |
|
46 | 53 |
def process_op_status(vm, jobid, opcode, status, logmsg): |
47 | 54 |
"""Process a job progress notification from the backend |
... | ... | |
103 | 110 |
"associated with an existing Network instance." % |
104 | 111 |
nic['link']) |
105 | 112 |
|
113 |
firewall_profile='' |
|
114 |
if 'firewall' in nic: |
|
115 |
firewall_profile = _reverse_tags.get(nic['firewall'], '') |
|
116 |
|
|
106 | 117 |
vm.nics.create( |
107 | 118 |
network=net, |
108 | 119 |
index=i, |
109 | 120 |
mac=nic.get('mac', ''), |
110 | 121 |
ipv4=nic.get('ip', ''), |
111 |
ipv6=nic.get('ipv6','')) |
|
122 |
ipv6=nic.get('ipv6',''), |
|
123 |
firewall_profile=firewall_profile) |
|
112 | 124 |
vm.save() |
113 | 125 |
|
114 | 126 |
|
... | ... | |
266 | 278 |
'link': nic.network.link.name})) |
267 | 279 |
rapi.ModifyInstance(vm.backend_id, nics=ops, dry_run=settings.TEST) |
268 | 280 |
|
269 |
|
|
270 |
_firewall_tags = { |
|
271 |
'ENABLED': settings.GANETI_FIREWALL_ENABLED_TAG, |
|
272 |
'DISABLED': settings.GANETI_FIREWALL_DISABLED_TAG, |
|
273 |
'PROTECTED': settings.GANETI_FIREWALL_PROTECTED_TAG} |
|
274 |
|
|
275 | 281 |
def set_firewall_profile(vm, profile): |
276 | 282 |
try: |
277 | 283 |
tag = _firewall_tags[profile] |
... | ... | |
279 | 285 |
raise ValueError("Unsopported Firewall Profile: %s" % profile) |
280 | 286 |
|
281 | 287 |
# Delete all firewall tags |
282 |
rapi.DeleteInstanceTags(vm.backend_id, _firewall_tags.values(),
|
|
283 |
dry_run=settings.TEST)
|
|
288 |
for t in _firewall_tags.values():
|
|
289 |
rapi.DeleteInstanceTags(vm.backend_id, [t], dry_run=settings.TEST)
|
|
284 | 290 |
|
285 | 291 |
rapi.AddInstanceTags(vm.backend_id, [tag], dry_run=settings.TEST) |
Also available in: Unified diff