blob: 9f36ed5f732a5994efc15cf685e09d09d9fce06d [file] [log] [blame]
Sapan Bhatia24836f12013-08-27 10:16:05 -04001import os
2import base64
Tony Mackae7f30c2013-09-25 12:46:50 -04003from django.db.models import F, Q
Sapan Bhatia24836f12013-08-27 10:16:05 -04004from planetstack.config import Config
Sapan Bhatia04c94ad2013-09-02 18:00:28 -04005from observer.openstacksyncstep import OpenStackSyncStep
6from core.models.network import *
Andy Bavier49801322013-11-18 20:08:05 -05007from util.logger import Logger, logging
Tony Mack06c8e472014-11-30 15:53:08 -05008from observer.steps.sync_controller_networks import *
Andy Bavier49801322013-11-18 20:08:05 -05009
10logger = Logger(level=logging.INFO)
Sapan Bhatia24836f12013-08-27 10:16:05 -040011
12class SyncNetworks(OpenStackSyncStep):
Tony Mackce79de02013-09-24 10:12:33 -040013 provides=[Network]
14 requested_interval = 0
Sapan Bhatia24836f12013-08-27 10:16:05 -040015
Andy Bavier49801322013-11-18 20:08:05 -050016 def sync_record(self, network):
Tony Mack97402602014-04-10 12:24:45 -040017 network.save()
Sapan Bhatia24836f12013-08-27 10:16:05 -040018
Sapan Bhatiaa5593a22014-07-23 08:51:18 -040019 def delete_record(self, network):
Tony Mack3066a952015-01-05 22:48:11 -050020 controller_networks_deleter = SyncControllerNetwork().delete_record
21 for controller_network in ControllerNetwork.objects.filter(network=network):
Sapan Bhatiaa5593a22014-07-23 08:51:18 -040022 try:
Tony Mack06c8e472014-11-30 15:53:08 -050023 controller_network_deleter(controller_network)
Tony Mack4f9a5de2014-11-12 10:11:09 -050024 except Exception,e:
Tony Mack06c8e472014-11-30 15:53:08 -050025 logger.log_exc("Failed to delete controller network %s" % controller_network)
Sapan Bhatiaa5593a22014-07-23 08:51:18 -040026 raise e