blob: a792b480c54b50a87fc24323ee44c13f2ae1c269 [file] [log] [blame]
Sapan Bhatia24836f12013-08-27 10:16:05 -04001import os
2import base64
Tony Mack0ae3fe32013-10-08 08:47:53 -04003from netaddr import IPAddress, IPNetwork
Tony Mackae7f30c2013-09-25 12:46:50 -04004from django.db.models import F, Q
Sapan Bhatia24836f12013-08-27 10:16:05 -04005from planetstack.config import Config
Sapan Bhatia04c94ad2013-09-02 18:00:28 -04006from observer.openstacksyncstep import OpenStackSyncStep
Tony Mack06c8e472014-11-30 15:53:08 -05007from core.models.slice import Slice, ControllerSlices
Andy Bavier5e243e12013-10-18 14:11:00 -04008from util.logger import Logger, logging
Tony Mack06c8e472014-11-30 15:53:08 -05009from observer.steps.sync_controller_slices import *
Andy Bavier5e243e12013-10-18 14:11:00 -040010
Andy Bavier33584c52013-10-28 15:17:16 -040011logger = Logger(level=logging.INFO)
Sapan Bhatia24836f12013-08-27 10:16:05 -040012
13class SyncSlices(OpenStackSyncStep):
Tony Mackdacfb982013-09-24 21:57:16 -040014 provides=[Slice]
15 requested_interval=0
Tony Mack66646d52013-09-24 21:47:12 -040016
Tony Mackdacfb982013-09-24 21:57:16 -040017 def sync_record(self, slice):
Tony Mack06c8e472014-11-30 15:53:08 -050018 for controller_slice in ControllerSlices.objects.filter(slice=slice):
Tony Mack29bf5e82014-04-29 21:40:24 -040019 # bump the 'updated' timestamp and trigger observer to update
Tony Mack06c8e472014-11-30 15:53:08 -050020 # slice across all controllers
21 controller_slice.save()
Sapan Bhatia88a23692014-07-23 09:33:44 -040022
23 def delete_record(self, slice):
Tony Mack06c8e472014-11-30 15:53:08 -050024 controller_slice_deleter = SyncControllerSlices().delete_record
25 for controller_slice in ControllerSlices.objects.filter(slice=slice):
Sapan Bhatia88a23692014-07-23 09:33:44 -040026 try:
Tony Mack06c8e472014-11-30 15:53:08 -050027 controller_slice_deleter(controller_slice)
Sapan Bhatia88a23692014-07-23 09:33:44 -040028 except Exception,e:
Tony Mack06c8e472014-11-30 15:53:08 -050029 logger.log_exc("Failed to delete controller_slice %s" % controller_slice)
Sapan Bhatia88a23692014-07-23 09:33:44 -040030 raise e