@@ -268,6 +268,7 @@ def __init__(self, host, port, cayenneApiHost):
268
268
self .installDate = int (time ())
269
269
self .config .set ('Agent' , 'InstallDate' , self .installDate )
270
270
self .networkConfig = Config (NETWORK_SETTINGS )
271
+ self .sensorsClient = sensors .SensorsClient ()
271
272
self .schedulerEngine = SchedulerEngine (self , 'client_scheduler' )
272
273
self .Initialize ()
273
274
self .CheckSubscription ()
@@ -301,7 +302,6 @@ def Initialize(self):
301
302
self .count = 10000
302
303
self .buff = bytearray (self .count )
303
304
#start thread only after init of other fields
304
- self .sensorsClient = sensors .SensorsClient ()
305
305
self .sensorsClient .SetDataChanged (self .OnDataChanged , self .BuildPT_SYSTEM_INFO )
306
306
self .processManager = services .ProcessManager ()
307
307
self .serviceManager = services .ServiceManager ()
@@ -471,6 +471,7 @@ def CheckSubscription(self):
471
471
info ('Registration succeeded for invite code {}, auth id = {}' .format (inviteCode , authId ))
472
472
self .config .set ('Agent' , 'Initialized' , 'true' )
473
473
self .MachineId = authId
474
+ self .config .set ('Agent' , 'Id' , self .MachineId )
474
475
475
476
@property
476
477
def Start (self ):
@@ -622,9 +623,12 @@ def ReadMessage(self):
622
623
def RunAction (self , action ):
623
624
"""Run a specified action"""
624
625
debug ('RunAction' )
625
- if 'MachineName' in action and self .MachineId != action ['MachineName' ]:
626
- debug ('Scheduler action is not assigned for this machine: ' + str (action ))
627
- return
626
+ if 'MachineName' in action :
627
+ #Use the config file machine if self.MachineId has not been set yet due to connection issues
628
+ machine_id = self .MachineId if self .MachineId else self .config .get ('Agent' , 'Id' )
629
+ if machine_id != action ['MachineName' ]:
630
+ debug ('Scheduler action is not assigned for this machine: ' + str (action ))
631
+ return
628
632
self .ExecuteMessage (action )
629
633
630
634
def SendNotification (self , notify , subject , body ):
0 commit comments