Sapan Bhatia | 26d40bc | 2014-05-12 15:28:02 -0400 | [diff] [blame^] | 1 | import os |
| 2 | import base64 |
| 3 | from netaddr import IPAddress, IPNetwork |
| 4 | from django.db.models import F, Q |
| 5 | from planetstack.config import Config |
| 6 | from observer.openstacksyncstep import OpenStackSyncStep |
| 7 | from core.models.slice import Slice, SliceDeployments |
| 8 | from util.logger import Logger, logging |
| 9 | |
| 10 | logger = Logger(level=logging.INFO) |
| 11 | |
| 12 | class SyncSlices(OpenStackSyncStep): |
| 13 | provides=[Slice] |
| 14 | requested_interval=0 |
| 15 | |
| 16 | def fetch_pending(self): |
| 17 | return Slice.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None)) |
| 18 | |
| 19 | def sync_record(self, slice): |
| 20 | 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() |