blob: 6d6ca464ccc22b0b70a56526c19c60890e3329be [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
Sapan Bhatia84ba65d2014-11-11 21:44:35 -05007from core.models.slice import Slice, SliceDeployment
Andy Bavier5e243e12013-10-18 14:11:00 -04008from util.logger import Logger, logging
Sapan Bhatiadf8fda32014-08-19 02:59:34 -04009from observer.steps.sync_slice_deployments 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):
Sapan Bhatia7a8b7e92014-11-11 21:43:31 -050018 for slice_deployment in SliceDeployment.objects.filter(slice=slice):
Tony Mack29bf5e82014-04-29 21:40:24 -040019 # bump the 'updated' timestamp and trigger observer to update
20 # slice across all deployments
21 slice_deployment.save()
Sapan Bhatia88a23692014-07-23 09:33:44 -040022
23 def delete_record(self, slice):
Sapan Bhatia7a8b7e92014-11-11 21:43:31 -050024 slice_deployment_deleter = SyncSliceDeployment().delete_record
25 for slice_deployment in SliceDeployment.objects.filter(slice=slice):
Sapan Bhatia88a23692014-07-23 09:33:44 -040026 try:
Sapan Bhatiadf8fda32014-08-19 02:59:34 -040027 slice_deployment_deleter(slice_deployment)
Sapan Bhatia88a23692014-07-23 09:33:44 -040028 except Exception,e:
29 logger.log_exc("Failed to delete slice_deployment %s" % slice_deployment)
30 raise e