Revision de1fed2b

b/snf-cyclades-app/synnefo/logic/management/commands/reconcile-networks.py
107 107
        uses_pool = not network.public or PUBLIC_USE_POOL
108 108
        for bend in backends:
109 109
            bnet = get_backend_network(network, bend)
110
            if not bnet:
111
                try:
112
                    gnet = ganeti_networks[bend][network.id]
113
                    if not network.public and network.action != "DESTROY":
114
                        # Network exists in Ganeti backend, but not in DB.
115
                        reconcile_parted_network(network, bend)
116
                except KeyError:
117
                    # Network does not exist either in DB not in Ganeti.
118
                    # Nothing to reconcile..
119
                    continue
120

  
121
            try:
122
                gnet = ganeti_networks[bend][network.id]
123
            except KeyError:
124
                # Network does not exist in backend. If the network action is
125
                # DESTROY, then we must destroy the network in the backend.
126
                # Else we have to create it!
127
                if network.action == "DESTROY" and bnet.operstate != "DELETED":
128
                    # CASE-2: Stale DB network
129
                    reconcile_stale_network(bnet)
130
                    # Skip rest reconciliation as the backend is just being
131
                    # deleted
132
                    continue
110
            gnet = ganeti_networks[bend].get(network.id)
111
            if not (bnet or gnet):
112
                # Network does not exist either in Ganeti nor in BD.
113
                continue
114
            if not bnet and gnet:
115
                # Network exists in Ganeti and not in DB.
116
                if network.action != "DESTROY" and not network.public:
117
                    reconcile_parted_network(network, bend)
118

  
119
            if not gnet:
120
                # Network does not exist in Ganeti. If the network action is
121
                # DESTROY, we have to mark as deleted in DB, else we have to
122
                # create it in Ganeti.
123
                if network.action == "DESTROY":
124
                    if bnet.operstate != "DELETED":
125
                        reconcile_stale_network(bnet)
133 126
                else:
134
                    # CASE-3: Missing Ganeti network
135 127
                    reconcile_missing_network(network, bend)
136
                    # Skip rest reconciliation as the network is just
137
                    # being created
138
                    continue
128
                # Skip rest reconciliation!
129
                continue
139 130

  
140 131
            try:
141 132
                hanging_groups = ganeti_hanging_networks[bend][network.id]

Also available in: Unified diff