blob: 63bf19b82c3ab1c0696b74bfc406a7fa0d3b3b99 [file] [log] [blame]
Scott Baker25467ff2016-08-04 09:50:22 -07001import os
2import sys
3import base64
4from django.db.models import F, Q
5from xos.config import Config
6from synchronizers.base.syncstep import SyncStep
7from core.models import Service
8from services.hpc.models import HpcService
9from services.requestrouter.models import RequestRouterService
10from xos.logger import Logger, logging
11
12# hpclibrary will be in steps/..
13parentdir = os.path.join(os.path.dirname(__file__),"..")
14sys.path.insert(0,parentdir)
15
16from hpclib import HpcLibrary
17
18logger = Logger(level=logging.INFO)
19
20class SyncHpcService(SyncStep, HpcLibrary):
21 provides=[HpcService]
22 observes=HpcService
23 requested_interval=0
24
25 def __init__(self, **args):
26 SyncStep.__init__(self, **args)
27 HpcLibrary.__init__(self)
28
29 def filter_hpc_service(self, objs):
30 hpcService = self.get_hpc_service()
31
32 return [x for x in objs if x == hpcService]
33
34 def fetch_pending(self, deleted):
35 # Looks like deletion is not supported for this object - Sapan
36 if (deleted):
37 return []
38 else:
39 return self.filter_hpc_service(HpcService.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None)))
40
41 def sync_record(self, hpc_service):
42 logger.info("sync'ing hpc_service %s" % str(hpc_service),extra=hpc_service.tologdict())
43 hpc_service.save()