blob: a6073b694f7c54b385a86160ba427986a95b7aac [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
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):
Tony Mack29bf5e82014-04-29 21:40:24 -040018 for slice_deployment in SliceDeployments.objects.filter(slice=slice):
19 # 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 Bhatiadf8fda32014-08-19 02:59:34 -040024 slice_deployment_deleter = SyncSliceDeployments().delete_record
Sapan Bhatia88a23692014-07-23 09:33:44 -040025 for slice_deployment in SliceDeployments.objects.filter(slice=slice):
26 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