def execute_sync_action(self, hostname, compute): log.msg("Syncing started: '%s' (%s)" % (hostname, str(compute)), system='sync') curtime = datetime.now().isoformat() syncaction = SyncAction(compute) deferred = syncaction.execute(DetachedProtocol(), object()) self.outstanding_requests[str(compute)] = [deferred, curtime, 0, defer.Deferred()] deferred.addCallback(self.handle_success, 'synchronization', hostname, compute, 'suspicious') deferred.addErrback(self.handle_remote_error, hostname, compute, 'suspicious') deferred.addErrback(self.handle_error, 'Synchronization', hostname, compute, 'suspicious') return deferred
def execute_sync_action(self, hostname, compute): log.msg("Syncing started: '%s' (%s)" % (hostname, str(compute)), system='sync') curtime = datetime.now().isoformat() syncaction = SyncAction(compute) deferred = syncaction.execute(DetachedProtocol(), object()) self.outstanding_requests[str(compute)] = [ deferred, curtime, 0, defer.Deferred() ] deferred.addCallback(self.handle_success, 'synchronization', hostname, compute, 'suspicious') deferred.addErrback(self.handle_remote_error, hostname, compute, 'suspicious') deferred.addErrback(self.handle_error, 'Synchronization', hostname, compute, 'suspicious') return deferred
def execute(self, cmd, args): yield BaseHostRequestAction.execute(self, cmd, args) hostname = yield db.get(self.context, 'hostname') # Acceptance of a new HN should trigger its syncing uuid = yield register_machine(hostname, mgt_stack=ISaltInstalled) cmd.write('Host %s accepted. Syncing shortly...\n' % hostname) log.msg('Host %s accepted. Syncing in 5 seconds...' % hostname, system='action-accept') yield async_sleep(5) compute = yield get_machine_by_uuid(uuid) assert compute is not None, 'Machine not found after accept: %s' % uuid log.msg('Syncing NOW...', system='action-accept') syncaction = SyncAction(compute) syncaction._do_not_enqueue = False args = argparse.Namespace() args.full = True yield syncaction.execute(DetachedProtocol(), args)