blob: a4e95520bef9665b9c937413f65f93bf1db5eea4 [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 Mack336e0f92014-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 Mack336e0f92014-11-30 15:53:08 -050020 controller_networks_deleter = SyncControllerNetworks().delete_record
21 for controller_network in ControllerNetworks.objects.filter(network=network):
Sapan Bhatiaa5593a22014-07-23 08:51:18 -040022 try:
Tony Mack336e0f92014-11-30 15:53:08 -050023 controller_network_deleter(controller_network)
Tony Mack3f72d082014-11-12 10:11:09 -050024 except Exception,e:
Tony Mack336e0f92014-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