blob: a4c9e77a66d83b138f6fde28867f6cd40b7af3b7 [file] [log] [blame]
Scott Bakerb30aa082014-01-03 08:36:00 -08001import os
Scott Baker93661ea2014-01-03 12:01:40 -08002import sys
Scott Bakerb30aa082014-01-03 08:36:00 -08003import base64
4from django.db.models import F, Q
5from planetstack.config import Config
6from observer.syncstep import SyncStep
7from core.models import Service
8from hpc.models import HpcService
Scott Baker93661ea2014-01-03 12:01:40 -08009from requestrouter.models import RequestRouterService
Scott Bakerb30aa082014-01-03 08:36:00 -080010from util.logger import Logger, logging
11
Scott Baker93661ea2014-01-03 12:01:40 -080012# hpclibrary will be in steps/..
13parentdir = os.path.join(os.path.dirname(__file__),"..")
14sys.path.insert(0,parentdir)
15
16from hpclib import HpcLibrary
17
Scott Bakerb30aa082014-01-03 08:36:00 -080018logger = Logger(level=logging.INFO)
19
Scott Baker93661ea2014-01-03 12:01:40 -080020class SyncHpcService(SyncStep, HpcLibrary):
Scott Bakerb30aa082014-01-03 08:36:00 -080021 provides=[HpcService]
22 requested_interval=0
23
Scott Bakere99e3df2014-01-06 16:05:46 -080024 def __init__(self, **args):
25 SyncStep.__init__(self, **args)
26 HpcLibrary.__init__(self)
27
Scott Bakerb30aa082014-01-03 08:36:00 -080028 def fetch_pending(self):
29 return HpcService.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
30
Scott Bakerb30aa082014-01-03 08:36:00 -080031 def sync_record(self, hpc_service):
32 logger.info("sync'ing hpc_service %s" % str(hpc_service))
Scott Baker93661ea2014-01-03 12:01:40 -080033 self.write_slices_file(hpc_service, None)
Scott Bakerb30aa082014-01-03 08:36:00 -080034 hpc_service.save()