Revision ad297723 snf-cyclades-app/synnefo/logic/management/commands/reconcile-networks.py

b/snf-cyclades-app/synnefo/logic/management/commands/reconcile-networks.py
39 39

  
40 40
from optparse import make_option
41 41

  
42
from synnefo.settings import PUBLIC_ROUTED_USE_POOL
42 43
from django.core.management.base import BaseCommand
43 44
from django.db import transaction
44 45

  
......
48 49

  
49 50
class Command(BaseCommand):
50 51
    help = 'Reconcile contents of Synnefo DB with state of Ganeti backend'
52
    can_import_settings = True
51 53
    output_transaction = True  # The management command runs inside
52 54
                               # an SQL transaction
53 55
    option_list = BaseCommand.option_list + (
......
84 86
    for network in networks:
85 87
        net_id = network.id
86 88
        destroying = network.action == 'DESTROY'
89
        uses_pool = not (network.type == 'PUBLIC_ROUTED' and (not
90
                        PUBLIC_ROUTED_USE_POOL))
87 91
        ip_address_maps = []
88 92

  
89 93
        # Perform reconcilliation for each backend
......
153 157
                                        0, 'OP_NETWORK_CONNECT', 'success',
154 158
                                        'Reconciliation simulated event.')
155 159

  
156
            # Reconcile IP Pools
157
            ip_map = ganeti_networks[b][net_id]['map']
158
            ip_address_maps.append(bitarray_from_o1(ip_map))
160
            if uses_pool:
161
                # Reconcile IP Pools
162
                ip_map = ganeti_networks[b][net_id]['map']
163
                ip_address_maps.append(bitarray_from_o1(ip_map))
159 164

  
160
        if ip_address_maps:
165
        if ip_address_maps and uses_pool:
161 166
            network_bitarray = reduce(lambda x, y: x | y, ip_address_maps)
162 167
            if not network.pool.reservations == network_bitarray:
163 168
                out.write('D: Unsynced pool of network %d\n' % net_id)

Also available in: Unified diff