Revision f533f224 ganeti/hooks.py

b/ganeti/hooks.py
26 26
    
27 27
    Process all GANETI_INSTANCE_NICx_y environment variables,
28 28
    where x is the NIC index, starting at 0,
29
    and y is one of "MAC", "IP".
29
    and y is one of "MAC", "IP", "BRIDGE".
30 30

  
31 31
    The result is returned as a single notification message
32
    of type 'Ganeti-net-status', detailing the NIC configuration
32
    of type 'ganeti-net-status', detailing the NIC configuration
33 33
    of a Ganeti instance.
34 34

  
35 35
    """
36 36
    nics = {}
37 37

  
38
    key_to_attr = { 'IP': 'ip', 'MAC': 'mac', 'BRIDGE': 'link' }
39

  
38 40
    for env in environ.keys():
39 41
        if env.startswith("GANETI_INSTANCE_NIC"):
40 42
            s = env.replace("GANETI_INSTANCE_NIC", "").split('_', 1)
41
            if len(s) == 2 and s[0].isdigit() and s[1] in ('MAC', 'IP'):
43
            if len(s) == 2 and s[0].isdigit() and s[1] in ('MAC', 'IP', 'BRIDGE'):
42 44
                index = int(s[0])
43
                key = s[1].lower()
45
                key = key_to_attr[s[1]]
44 46

  
45 47
                if nics.has_key(index):
46 48
                    nics[index][key] = environ[env]

Also available in: Unified diff