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 | |
Tony Mack | dacfb98 | 2013-09-24 21:57:16 -0400 | [diff] [blame] | 16 | def sync_record(self, slice): |
Tony Mack | 29bf5e8 | 2014-04-29 21:40:24 -0400 | [diff] [blame] | 17 | 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 Bhatia | 88a2369 | 2014-07-23 09:33:44 -0400 | [diff] [blame] | 21 | |
| 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 |