Revision af6a3bc5 snf-cyclades-app/synnefo/logic/management/commands/reconcile-pools.py

b/snf-cyclades-app/synnefo/logic/management/commands/reconcile-pools.py
31 31

  
32 32
from synnefo.db.models import (Network, BackendNetwork,
33 33
                               BridgePoolTable, MacPrefixPoolTable)
34
from synnefo.settings import MAC_POOL_BASE
34 35

  
35 36

  
36 37
class Command(BaseCommand):
......
89 90
        for i in xrange(0, macp_pool.size()):
90 91
            if not macp_pool.is_available(i, index=True) and \
91 92
               not macp_pool.is_reserved(i, index=True):
92
                macs.append(macp_pool.index_to_value(i))
93
                value = macp_pool.index_to_value(i)
94
                if value != MAC_POOL_BASE:
95
                    macs.append(macp_pool.index_to_value(i))
93 96

  
94 97
        write("Used MAC prefixes from Pool: %d\n" % len(macs))
95 98

  
96
        network_mac_prefixes = Network.objects.filter(deleted=False)\
97
                                         .values_list('mac_prefix', flat=True)
99
        network_mac_prefixes = \
100
            Network.objects.filter(deleted=False)\
101
                            .exclude(mac_prefix=MAC_POOL_BASE) \
102
                            .values_list('mac_prefix', flat=True)
98 103
        write("Used MAC prefixes from Networks: %d\n" %
99 104
                          len(network_mac_prefixes))
100 105

  
......
121 126

  
122 127
        mac_prefixes = BackendNetwork.objects.filter(deleted=False)\
123 128
                                      .values_list('mac_prefix', flat=True)
124

  
129
        mac_prefixes = filter(lambda x: not x.startswith(MAC_POOL_BASE),
130
                              mac_prefixes)
125 131
        set_mac_prefixes = set(mac_prefixes)
126 132
        if len(mac_prefixes) > len(set_mac_prefixes):
127 133
            write("Found duplicated mac_prefixes:\n")

Also available in: Unified diff