From 872070f9c39295f4f11cac8962ddfd285b2394b9 Mon Sep 17 00:00:00 2001 From: Tynan Ford Date: Tue, 20 Oct 2020 23:37:56 -0700 Subject: [PATCH 1/3] initial pass at adding rtype, working in first tests --- server/recceiver/cfstore.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/recceiver/cfstore.py b/server/recceiver/cfstore.py index eb595b1..145bec2 100755 --- a/server/recceiver/cfstore.py +++ b/server/recceiver/cfstore.py @@ -73,9 +73,9 @@ def _startServiceWithLock(self): try: cf_props = [prop['name'] for prop in self.client.getAllProperties()] if (self.conf.get('alias', 'default') == 'on'): - reqd_props = {'hostName', 'iocName', 'pvStatus', 'time', 'iocid', 'alias'} + reqd_props = {'hostName', 'iocName', 'pvStatus', 'time', 'iocid', 'recordType', 'alias'} else: - reqd_props = {'hostName', 'iocName', 'pvStatus', 'time', 'iocid'} + reqd_props = {'hostName', 'iocName', 'pvStatus', 'time', 'recordType', 'iocid'} wl = self.conf.get('infotags', list()) whitelist = [s.strip(', ') for s in wl.split()] \ if wl else wl @@ -173,6 +173,7 @@ def _commitWithThread(self, TR): pvInfo = {} for rid, (rname, rtype) in TR.addrec.items(): pvInfo[rid] = {"pvName": rname} + pvInfo[rid]['recordType'] = rtype for rid, (recinfos) in TR.recinfos.items(): # find intersection of these sets if rid not in pvInfo: @@ -333,6 +334,7 @@ def __updateCF__(proc, pvInfoByName, delrec, hostName, iocName, iocid, owner, io {u'name': 'iocName', u'owner': owner, u'value': iocs[channels_dict[ch[u'name']][-1]]["iocname"]}, {u'name': 'iocid', u'owner': owner, u'value': channels_dict[ch[u'name']][-1]}, {u'name': 'pvStatus', u'owner': owner, u'value': 'Active'}, + {u'name': 'recordType', u'owner': owner, u'value': iocs[channels_dict[ch[u'name']][-1]]["recordType"]}, {u'name': 'time', u'owner': owner, u'value': iocTime}], ch[u'properties']) channels.append(ch) @@ -348,6 +350,7 @@ def __updateCF__(proc, pvInfoByName, delrec, hostName, iocName, iocid, owner, io {u'name': 'iocName', u'owner': owner, u'value': iocs[channels_dict[a[u'name']][-1]]["iocname"]}, {u'name': 'iocid', u'owner': owner, u'value': channels_dict[a[u'name']][-1]}, {u'name': 'pvStatus', u'owner': owner, u'value': 'Active'}, + {u'name': 'recordType', u'owner': owner, u'value': iocs[channels_dict[a[u'name']][-1]]["recordType"]}, {u'name': 'time', u'owner': owner, u'value': iocTime}], a[u'properties']) channels.append(a) @@ -437,6 +440,7 @@ def __updateCF__(proc, pvInfoByName, delrec, hostName, iocName, iocid, owner, io {u'name': 'iocName', u'owner': owner, u'value': iocName}, {u'name': 'iocid', u'owner': owner, u'value': iocid}, {u'name': 'pvStatus', u'owner': owner, u'value': "Active"}, + {u'name': 'recordType', u'owner': owner, u'value': pvInfoByName[pv]['recordType']}, {u'name': 'time', u'owner': owner, u'value': iocTime}] if pv in pvInfoByName and "infoProperties" in pvInfoByName[pv]: newProps = newProps + pvInfoByName[pv]["infoProperties"] From 21a85ab74905a9a1b292652800a012fa448d510b Mon Sep 17 00:00:00 2001 From: Tynan Ford Date: Tue, 19 Jan 2021 08:20:54 -0800 Subject: [PATCH 2/3] Make recordType an optional property --- server/cf.conf | 3 +++ server/recceiver/cfstore.py | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/server/cf.conf b/server/cf.conf index 28cad77..80be37b 100644 --- a/server/cf.conf +++ b/server/cf.conf @@ -37,3 +37,6 @@ procs = cf [cf] # a space-separated list of infotags to set as CF Properties #infotags = archive foo bar blah +# Turn on optional alias and recordType properties +#alias = on +#recordType = on diff --git a/server/recceiver/cfstore.py b/server/recceiver/cfstore.py index 145bec2..4fae718 100755 --- a/server/recceiver/cfstore.py +++ b/server/recceiver/cfstore.py @@ -72,10 +72,11 @@ def _startServiceWithLock(self): self.client = ChannelFinderClient() try: cf_props = [prop['name'] for prop in self.client.getAllProperties()] + reqd_props = {'hostName', 'iocName', 'pvStatus', 'time', 'iocid'} if (self.conf.get('alias', 'default') == 'on'): - reqd_props = {'hostName', 'iocName', 'pvStatus', 'time', 'iocid', 'recordType', 'alias'} - else: - reqd_props = {'hostName', 'iocName', 'pvStatus', 'time', 'recordType', 'iocid'} + reqd_props.add('alias') + if (self.conf.get('recordType', 'default') == 'on'): + reqd_props.add('recordType') wl = self.conf.get('infotags', list()) whitelist = [s.strip(', ') for s in wl.split()] \ if wl else wl @@ -173,7 +174,8 @@ def _commitWithThread(self, TR): pvInfo = {} for rid, (rname, rtype) in TR.addrec.items(): pvInfo[rid] = {"pvName": rname} - pvInfo[rid]['recordType'] = rtype + if (self.conf.get('recordType', 'default' == 'on')): + pvInfo[rid]['recordType'] = rtype for rid, (recinfos) in TR.recinfos.items(): # find intersection of these sets if rid not in pvInfo: @@ -334,9 +336,10 @@ def __updateCF__(proc, pvInfoByName, delrec, hostName, iocName, iocid, owner, io {u'name': 'iocName', u'owner': owner, u'value': iocs[channels_dict[ch[u'name']][-1]]["iocname"]}, {u'name': 'iocid', u'owner': owner, u'value': channels_dict[ch[u'name']][-1]}, {u'name': 'pvStatus', u'owner': owner, u'value': 'Active'}, - {u'name': 'recordType', u'owner': owner, u'value': iocs[channels_dict[ch[u'name']][-1]]["recordType"]}, {u'name': 'time', u'owner': owner, u'value': iocTime}], ch[u'properties']) + if (conf.get('recordType', 'default') == 'on'): + ch[u'properties'] = __merge_property_list(ch[u'properties'].append({u'name': 'recordType', u'owner': owner, u'value': iocs[channels_dict[ch[u'name']][-1]]["recordType"]}), ch[u'properties']) channels.append(ch) _log.debug("Add existing channel to previous IOC: %s", channels[-1]) """In case alias exist, also delete them""" @@ -350,9 +353,10 @@ def __updateCF__(proc, pvInfoByName, delrec, hostName, iocName, iocid, owner, io {u'name': 'iocName', u'owner': owner, u'value': iocs[channels_dict[a[u'name']][-1]]["iocname"]}, {u'name': 'iocid', u'owner': owner, u'value': channels_dict[a[u'name']][-1]}, {u'name': 'pvStatus', u'owner': owner, u'value': 'Active'}, - {u'name': 'recordType', u'owner': owner, u'value': iocs[channels_dict[a[u'name']][-1]]["recordType"]}, {u'name': 'time', u'owner': owner, u'value': iocTime}], a[u'properties']) + if (conf.get('recordType', 'default') == 'on'): + ch[u'properties'] = __merge_property_list(ch[u'properties'].append({u'name': 'recordType', u'owner': owner, u'value': iocs[channels_dict[a[u'name']][-1]]["recordType"]}), ch[u'properties']) channels.append(a) _log.debug("Add existing alias to previous IOC: %s", channels[-1]) @@ -440,8 +444,9 @@ def __updateCF__(proc, pvInfoByName, delrec, hostName, iocName, iocid, owner, io {u'name': 'iocName', u'owner': owner, u'value': iocName}, {u'name': 'iocid', u'owner': owner, u'value': iocid}, {u'name': 'pvStatus', u'owner': owner, u'value': "Active"}, - {u'name': 'recordType', u'owner': owner, u'value': pvInfoByName[pv]['recordType']}, {u'name': 'time', u'owner': owner, u'value': iocTime}] + if (conf.get('recordType', 'default') == 'on'): + newProps.add({u'name': 'recordType', u'owner': owner, u'value': pvInfoByName[pv]['recordType']}) if pv in pvInfoByName and "infoProperties" in pvInfoByName[pv]: newProps = newProps + pvInfoByName[pv]["infoProperties"] From e44e336ae53476b2bad40dc4f997ca9bddbc4728 Mon Sep 17 00:00:00 2001 From: Tynan Ford Date: Tue, 19 Jan 2021 08:41:06 -0800 Subject: [PATCH 3/3] Fix typo in cfstore, lists get appended not added --- server/recceiver/cfstore.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/recceiver/cfstore.py b/server/recceiver/cfstore.py index 4fae718..5d53f53 100755 --- a/server/recceiver/cfstore.py +++ b/server/recceiver/cfstore.py @@ -446,7 +446,7 @@ def __updateCF__(proc, pvInfoByName, delrec, hostName, iocName, iocid, owner, io {u'name': 'pvStatus', u'owner': owner, u'value': "Active"}, {u'name': 'time', u'owner': owner, u'value': iocTime}] if (conf.get('recordType', 'default') == 'on'): - newProps.add({u'name': 'recordType', u'owner': owner, u'value': pvInfoByName[pv]['recordType']}) + newProps.append({u'name': 'recordType', u'owner': owner, u'value': pvInfoByName[pv]['recordType']}) if pv in pvInfoByName and "infoProperties" in pvInfoByName[pv]: newProps = newProps + pvInfoByName[pv]["infoProperties"]