Sapan Bhatia | 24836f1 | 2013-08-27 10:16:05 -0400 | [diff] [blame] | 1 | import os |
| 2 | import base64 |
Tony Mack | 0ae3fe3 | 2013-10-08 08:47:53 -0400 | [diff] [blame] | 3 | from netaddr import IPAddress, IPNetwork |
Tony Mack | ae7f30c | 2013-09-25 12:46:50 -0400 | [diff] [blame] | 4 | from django.db.models import F, Q |
Sapan Bhatia | 24836f1 | 2013-08-27 10:16:05 -0400 | [diff] [blame] | 5 | from planetstack.config import Config |
Sapan Bhatia | 04c94ad | 2013-09-02 18:00:28 -0400 | [diff] [blame] | 6 | from observer.openstacksyncstep import OpenStackSyncStep |
Tony Mack | 29bf5e8 | 2014-04-29 21:40:24 -0400 | [diff] [blame] | 7 | from core.models.slice import Slice, SliceDeployments |
Andy Bavier | 5e243e1 | 2013-10-18 14:11:00 -0400 | [diff] [blame] | 8 | from util.logger import Logger, logging |
| 9 | |
Andy Bavier | 33584c5 | 2013-10-28 15:17:16 -0400 | [diff] [blame] | 10 | logger = Logger(level=logging.INFO) |
Sapan Bhatia | 24836f1 | 2013-08-27 10:16:05 -0400 | [diff] [blame] | 11 | |
| 12 | class SyncSlices(OpenStackSyncStep): |
Tony Mack | dacfb98 | 2013-09-24 21:57:16 -0400 | [diff] [blame] | 13 | provides=[Slice] |
| 14 | requested_interval=0 |
Tony Mack | 66646d5 | 2013-09-24 21:47:12 -0400 | [diff] [blame] | 15 | |
| 16 | def fetch_pending(self): |
| 17 | return Slice.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None)) |
| 18 | |
Tony Mack | dacfb98 | 2013-09-24 21:57:16 -0400 | [diff] [blame] | 19 | def sync_record(self, slice): |
Tony Mack | 29bf5e8 | 2014-04-29 21:40:24 -0400 | [diff] [blame] | 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() |