blob: c5e26794f25b5be01123276cacf84b1533a58a58 [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
Scott Baker76a840e2015-02-11 21:38:09 -08005from xos.config import Config
Scott Bakerb30aa082014-01-03 08:36:00 -08006from 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
Sapan Bhatiaed666442014-07-23 10:18:31 -040028 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 Bakerb30aa082014-01-03 08:36:00 -080034
Scott Bakerb30aa082014-01-03 08:36:00 -080035 def sync_record(self, hpc_service):
36 logger.info("sync'ing hpc_service %s" % str(hpc_service))
Scott Baker93661ea2014-01-03 12:01:40 -080037 self.write_slices_file(hpc_service, None)
Scott Bakerb30aa082014-01-03 08:36:00 -080038 hpc_service.save()