Sapan Bhatia | 24836f1 | 2013-08-27 10:16:05 -0400 | [diff] [blame] | 1 | import os |
| 2 | import base64 |
Tony Mack | ae7f30c | 2013-09-25 12:46:50 -0400 | [diff] [blame] | 3 | from django.db.models import F, Q |
Sapan Bhatia | 24836f1 | 2013-08-27 10:16:05 -0400 | [diff] [blame] | 4 | from planetstack.config import Config |
Sapan Bhatia | 04c94ad | 2013-09-02 18:00:28 -0400 | [diff] [blame] | 5 | from observer.openstacksyncstep import OpenStackSyncStep |
| 6 | from core.models.network import * |
Andy Bavier | 4980132 | 2013-11-18 20:08:05 -0500 | [diff] [blame] | 7 | from util.logger import Logger, logging |
Tony Mack | 06c8e47 | 2014-11-30 15:53:08 -0500 | [diff] [blame^] | 8 | from observer.steps.sync_controller_networks import * |
Andy Bavier | 4980132 | 2013-11-18 20:08:05 -0500 | [diff] [blame] | 9 | |
| 10 | logger = Logger(level=logging.INFO) |
Sapan Bhatia | 24836f1 | 2013-08-27 10:16:05 -0400 | [diff] [blame] | 11 | |
| 12 | class SyncNetworks(OpenStackSyncStep): |
Tony Mack | ce79de0 | 2013-09-24 10:12:33 -0400 | [diff] [blame] | 13 | provides=[Network] |
| 14 | requested_interval = 0 |
Sapan Bhatia | 24836f1 | 2013-08-27 10:16:05 -0400 | [diff] [blame] | 15 | |
Andy Bavier | 4980132 | 2013-11-18 20:08:05 -0500 | [diff] [blame] | 16 | def sync_record(self, network): |
Tony Mack | 9740260 | 2014-04-10 12:24:45 -0400 | [diff] [blame] | 17 | network.save() |
Sapan Bhatia | 24836f1 | 2013-08-27 10:16:05 -0400 | [diff] [blame] | 18 | |
Sapan Bhatia | a5593a2 | 2014-07-23 08:51:18 -0400 | [diff] [blame] | 19 | def delete_record(self, network): |
Tony Mack | 06c8e47 | 2014-11-30 15:53:08 -0500 | [diff] [blame^] | 20 | controller_networks_deleter = SyncControllerNetworks().delete_record |
| 21 | for controller_network in ControllerNetworks.objects.filter(network=network): |
Sapan Bhatia | a5593a2 | 2014-07-23 08:51:18 -0400 | [diff] [blame] | 22 | try: |
Tony Mack | 06c8e47 | 2014-11-30 15:53:08 -0500 | [diff] [blame^] | 23 | controller_network_deleter(controller_network) |
Tony Mack | 4f9a5de | 2014-11-12 10:11:09 -0500 | [diff] [blame] | 24 | except Exception,e: |
Tony Mack | 06c8e47 | 2014-11-30 15:53:08 -0500 | [diff] [blame^] | 25 | logger.log_exc("Failed to delete controller network %s" % controller_network) |
Sapan Bhatia | a5593a2 | 2014-07-23 08:51:18 -0400 | [diff] [blame] | 26 | raise e |