Scott Baker | b30aa08 | 2014-01-03 08:36:00 -0800 | [diff] [blame] | 1 | import os |
Scott Baker | 93661ea | 2014-01-03 12:01:40 -0800 | [diff] [blame] | 2 | import sys |
Scott Baker | b30aa08 | 2014-01-03 08:36:00 -0800 | [diff] [blame] | 3 | import base64 |
| 4 | from django.db.models import F, Q |
| 5 | from planetstack.config import Config |
| 6 | from observer.syncstep import SyncStep |
| 7 | from core.models import Service |
| 8 | from hpc.models import HpcService |
Scott Baker | 93661ea | 2014-01-03 12:01:40 -0800 | [diff] [blame] | 9 | from requestrouter.models import RequestRouterService |
Scott Baker | b30aa08 | 2014-01-03 08:36:00 -0800 | [diff] [blame] | 10 | from util.logger import Logger, logging |
| 11 | |
Scott Baker | 93661ea | 2014-01-03 12:01:40 -0800 | [diff] [blame] | 12 | # hpclibrary will be in steps/.. |
| 13 | parentdir = os.path.join(os.path.dirname(__file__),"..") |
| 14 | sys.path.insert(0,parentdir)
|
| 15 | |
| 16 | from hpclib import HpcLibrary |
| 17 | |
Scott Baker | b30aa08 | 2014-01-03 08:36:00 -0800 | [diff] [blame] | 18 | logger = Logger(level=logging.INFO) |
| 19 | |
Scott Baker | 93661ea | 2014-01-03 12:01:40 -0800 | [diff] [blame] | 20 | class SyncHpcService(SyncStep, HpcLibrary): |
Scott Baker | b30aa08 | 2014-01-03 08:36:00 -0800 | [diff] [blame] | 21 | provides=[HpcService] |
| 22 | requested_interval=0 |
| 23 | |
Scott Baker | e99e3df | 2014-01-06 16:05:46 -0800 | [diff] [blame] | 24 | def __init__(self, **args): |
| 25 | SyncStep.__init__(self, **args) |
| 26 | HpcLibrary.__init__(self) |
| 27 | |
Sapan Bhatia | ed66644 | 2014-07-23 10:18:31 -0400 | [diff] [blame^] | 28 | def fetch_pending(self, deleted): |
| 29 | # Looks like deletion is not supported for this object - Sapan |
| 30 | if (deleted): |
| 31 | return [] |
| 32 | else: |
| 33 | return HpcService.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None)) |
Scott Baker | b30aa08 | 2014-01-03 08:36:00 -0800 | [diff] [blame] | 34 | |
Scott Baker | b30aa08 | 2014-01-03 08:36:00 -0800 | [diff] [blame] | 35 | def sync_record(self, hpc_service): |
| 36 | logger.info("sync'ing hpc_service %s" % str(hpc_service)) |
Scott Baker | 93661ea | 2014-01-03 12:01:40 -0800 | [diff] [blame] | 37 | self.write_slices_file(hpc_service, None) |
Scott Baker | b30aa08 | 2014-01-03 08:36:00 -0800 | [diff] [blame] | 38 | hpc_service.save() |