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 | |
| 24 | def fetch_pending(self): |
| 25 | return HpcService.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None)) |
| 26 | |
Scott Baker | b30aa08 | 2014-01-03 08:36:00 -0800 | [diff] [blame] | 27 | def sync_record(self, hpc_service): |
| 28 | logger.info("sync'ing hpc_service %s" % str(hpc_service)) |
Scott Baker | 93661ea | 2014-01-03 12:01:40 -0800 | [diff] [blame] | 29 | self.write_slices_file(hpc_service, None) |
Scott Baker | b30aa08 | 2014-01-03 08:36:00 -0800 | [diff] [blame] | 30 | hpc_service.save() |