blob: c0b8abe99f55971d3857ec70185dc3757a572242 [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 Mack29bf5e82014-04-29 21:40:24 -04007from core.models.slice import Slice, SliceDeployments
Andy Bavier5e243e12013-10-18 14:11:00 -04008from util.logger import Logger, logging
9
Andy Bavier33584c52013-10-28 15:17:16 -040010logger = Logger(level=logging.INFO)
Sapan Bhatia24836f12013-08-27 10:16:05 -040011
12class SyncSlices(OpenStackSyncStep):
Tony Mackdacfb982013-09-24 21:57:16 -040013 provides=[Slice]
14 requested_interval=0
Tony Mack66646d52013-09-24 21:47:12 -040015
Tony Mackdacfb982013-09-24 21:57:16 -040016 def sync_record(self, slice):
Tony Mack29bf5e82014-04-29 21:40:24 -040017 for slice_deployment in SliceDeployments.objects.filter(slice=slice):
18 # bump the 'updated' timestamp and trigger observer to update
19 # slice across all deployments
20 slice_deployment.save()
Sapan Bhatia88a23692014-07-23 09:33:44 -040021
22 def delete_record(self, slice):
23 slice_deployment_deleter = SliceDeploymentDeleter()
24 for slice_deployment in SliceDeployments.objects.filter(slice=slice):
25 try:
26 slice_deployment_deleter(slice_deployment.id)
27 except Exception,e:
28 logger.log_exc("Failed to delete slice_deployment %s" % slice_deployment)
29 raise e