Revision eab0602e
b/ganeti/hooks.py | ||
---|---|---|
57 | 57 |
nics[0]['ipv6'] = mac2eui64(nics[0]['mac'], |
58 | 58 |
settings.PUBLIC_IPV6_PREFIX) |
59 | 59 |
|
60 |
# Amend notification with firewall settings |
|
61 |
tags = environ.get('GANETI_INSTANCE_TAGS', '') |
|
62 |
for tag in tags.split(' '): |
|
63 |
t = tag.split(':') |
|
64 |
if t[0:2] == ['synnefo', 'network']: |
|
65 |
if len(t) != 4: |
|
66 |
logger.error("Malformed synnefo tag %s", tag) |
|
67 |
continue |
|
68 |
try: |
|
69 |
index = int(t[2]) |
|
70 |
nics[index]['firewall'] = t[3] |
|
71 |
except ValueError: |
|
72 |
logger.error("Malformed synnefo tag %s", tag) |
|
73 |
except KeyError: |
|
74 |
logger.error("Found tag %s for non-existent NIC %d", |
|
75 |
tag, index) |
|
76 |
|
|
60 | 77 |
# Verify our findings are consistent with the Ganeti environment |
61 | 78 |
indexes = list(nics.keys()) |
62 | 79 |
ganeti_nic_count = int(environ['GANETI_INSTANCE_NIC_COUNT']) |
b/ganeti/tests.py | ||
---|---|---|
29 | 29 |
'GANETI_INSTANCE_DISK_COUNT': '1', |
30 | 30 |
'GANETI_INSTANCE_DISK_TEMPLATE': 'drbd', |
31 | 31 |
'GANETI_INSTANCE_MEMORY': '128', |
32 |
'GANETI_INSTANCE_TAGS': 'tag1 synnefo:network:0:protected tag2', |
|
32 | 33 |
'GANETI_INSTANCE_NAME': 'instance2.example.com', |
33 | 34 |
'GANETI_INSTANCE_NIC0_BRIDGE': 'xen-br0', |
34 | 35 |
'GANETI_INSTANCE_NIC0_IP': '147.102.3.1', |
... | ... | |
56 | 57 |
'nics': [ |
57 | 58 |
{ |
58 | 59 |
'ip': '147.102.3.1', 'mac': '00:01:de:ad:be:ef', |
59 |
'link': 'xen-br0', 'ipv6': '2001:db8::201:deff:fead:beef' |
|
60 |
'link': 'xen-br0', 'ipv6': '2001:db8::201:deff:fead:beef', |
|
61 |
'firewall': 'protected' |
|
60 | 62 |
}, |
61 | 63 |
{ 'mac': '00:01:de:ad:ba:be' }, |
62 | 64 |
{ 'ip': '147.102.3.98', 'mac': '00:01:02:03:04:05' } |
Also available in: Unified diff