blob: 6cf0772bb03c8f7c4a24723fbf4959ddadb0d38d [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
16 def fetch_pending(self):
17 return Slice.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
18
Tony Mackdacfb982013-09-24 21:57:16 -040019 def sync_record(self, slice):
Tony Mack29bf5e82014-04-29 21:40:24 -040020 for slice_deployment in SliceDeployments.objects.filter(slice=slice):
21 # bump the 'updated' timestamp and trigger observer to update
22 # slice across all deployments
23 slice_deployment.save()