blob: 99f2c01902d06cb132850f6bd255d2ee1a1faf6b [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
Sapan Bhatiae89c4bb2014-08-19 02:59:00 -04008from observer.steps.sync_network_deployments 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):
Sapan Bhatiae89c4bb2014-08-19 02:59:00 -040020 network_deployment_deleter = SyncNetworkDeployments().delete_record
Sapan Bhatiaa5593a22014-07-23 08:51:18 -040021 for network_deployment in NetworkDeployments.objects.filter(network=network):
22 try:
Sapan Bhatiae89c4bb2014-08-19 02:59:00 -040023 network_deployment_deleter(network_deployment)
Tony Mack3f72d082014-11-12 10:11:09 -050024 except Exception,e:
Sapan Bhatiaa5593a22014-07-23 08:51:18 -040025 logger.log_exc("Failed to delete network deployment %s" % network_deployment)
26 raise e