Modify

Ticket #242 (closed defect: fixed)

Opened 16 years ago

Last modified 16 years ago

Cfg: only last probe gets used

Reported by: [email protected] Owned by: desai
Priority: blocker Milestone: Bcfg2 0.8.5 Release
Component: bcfg2-server Version:
Keywords: cfg,probes Cc:

Description

Currently only the last executed probe will be saved and available for host interpolation.

Possible fix:

Index: Cfg.py
===================================================================
--- Cfg.py      (Revision 2451)
+++ Cfg.py      (Arbeitskopie)
@@ -215,7 +215,8 @@
         if self.interpolate:
             if metadata.hostname in probeData:
                 for name, value in probeData[metadata.hostname].iteritems():
-                    filedata = filedata.replace("@@%[email protected]@"%name, value )
+                  if value != None:
+                    filedata = filedata.replace("@@%[email protected]@" % name, value )
             else:
                 logger.warning("Cannot interpolate data for client: %s for config file: %s"% (metadata.hostname, basefile.name))
         if self.paranoid:
@@ -277,7 +278,10 @@

     def ReceiveData(self, client, data):
         '''Receive probe results pertaining to client'''
-        probeData[client.hostname] = { data.get('name'):data.text }
+        try:
+            probeData[client.hostname].update({ data.get('name'):data.text })
+        except KeyError:
+            probeData[client.hostname] = { data.get('name'):data.text }

     def AddDirectoryMonitor(self, name):
         '''Add new directory to FAM structures'''

Attachments

Change History

comment:1 Changed 16 years ago by anonymous

  • Keywords cfg,probes added; probes removed
  • Component changed from bcfg2-client to bcfg2-server

comment:2 Changed 16 years ago by bradshaw

I don't truely understand the issue, probes are named by the filename of the script, so there is no way to have 2 probes with the same name fighting to change the value.

comment:3 Changed 16 years ago by anonymous

Current behaviour:

>>> probeData = {}
>>> probeData['host1'] = { 'probe1' : 'result1' }
>>> probeData
{'host1': {'probe1': 'result1'}}
>>> probeData['host1'] = { 'probe2' : 'result2' }
>>> probeData
{'host1': {'probe2': 'result2'}}

Expected behvaiour (at least for me):

>>> probeData = {}
>>> probeData['host1'] = { 'probe1' : 'result1' }
>>> probeData
{'host1': {'probe1': 'result1'}}
>>> probeData['host1'].update( { 'probe2' : 'result2' } )
>>> probeData
{'host1': {'probe1': 'result1', 'probe2': 'result2'}}

comment:4 Changed 16 years ago by bradshaw

  • Status changed from new to closed
  • Resolution set to fixed

Sorry about the confusion this patch has been commited in rev 2454

WARNING! You need to establish a session before you can create or edit tickets. Otherwise the ticket will get treated as spam.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.