void setup( const Record & record, const QModelIndex & idx ) { RecordItem::setup(record,idx); Job j = JobAssignment(record).job(); if( j.isRecord() ) services = j.jobServices().services().services().join(","); }
RecordList children( const QModelIndex & ) { return JobAssignment(record).jobTaskAssignments(); }
void Slave::startup() { registerBuiltinBurners(); loadEmbeddedPython(); LOG_5( "Slave::startup()" ); mHost = Host::currentHost(); mSpooler = new Spooler( this ); if( !mHost.isRecord() ) { if( mAutoRegister ) { LOG_3( "Slave::startup: no host record, auto-registering" ); mHost = Host::autoRegister(); } else { LOG_3( "Slave::startup: no host record, uh oh!" ); exit(-1); } } else mHost.updateHardwareInfo(); mHostStatus = mHost.hostStatus(); if( !mHostStatus.isRecord() ) { if( mAutoRegister ) { LOG_3( "Slave::startup: No host status record(are all your triggers installed?), creating one" ); mHostStatus.setHost( mHost ); mHostStatus.setOnline( 1 ); } else { LOG_3( "Slave::startup: no host status record, uh oh!" ); exit(-1); } } mHostStatus.setAvailableMemory( mHost.memory() ); mHostStatus.commit(); connect( Database::current()->connection(), SIGNAL( connectionLost() ), SLOT( slotConnectionLost() ) ); connect( Database::current()->connection(), SIGNAL( connected() ), SLOT( slotConnected() ) ); // The rest of the initialization is only for normal mode where we moniter and manipulate // the hosts status. In burn only mode we simply execute a job and exit if( mBurnOnlyJobAssignmentKey ) { burn( JobAssignment(mBurnOnlyJobAssignmentKey) ); return; } mService = Service::ensureServiceExists("Assburner"); // Start remote log server and set port in our Assburner HostService record RemoteLogServer * rls = new RemoteLogServer(); HostService hs = HostService::recordByHostAndService( mHost, mService ); if( hs.isRecord() && rls->tcpServer()->isListening() ) { hs.setRemoteLogPort( rls->tcpServer()->serverPort() ); hs.commit(); } // Set host version string. mHost.setAbVersion( "v" + QString(VERSION)); mHost.commit(); // Reset any frame assignments and set our host status // to ready. Do we need this anymore? The reaper // should now detect and re-assign frames if we are // offline, and this prevents a client-update from // happening when assburner starts. // // Nope, this doesn't f**k with the status, so it is // safe. It just clears fkeyJob to slaveFrames. And // returns any frames that have fkeyHost=this mHostStatus.returnSlaveFrames(); loadForbiddenProcesses(); mTimer = new QTimer( this ); connect( mTimer, SIGNAL( timeout() ), SLOT( loop() ) ); // Default 5000ms, min 200ms, max 600,000ms - 10 minutes mLoopTime = qMax( 200, qMin( 1000 * 60 * 10, Config::getInt( "assburnerLoopTime", 5000 ) ) ); // Default mLoopTime / 2, min 100ms, max mLoopTime mQuickLoopTime = qMax( 100, qMin( mLoopTime, Config::getInt( "assburnerQuickLoopTime", mLoopTime / 2 ) ) ); // Default 60 seconds, min 10 seconds. mPulsePeriod = qMax( 10, Config::getInt( "arsenalPulsePeriod", 600 ) ); // Default 60 seconds, min 10 seconds. mMemCheckPeriod = qMax( 10, Config::getInt( "abMemCheckPeriod", 60 ) ); IniConfig & c = config(); c.pushSection( "BackgroundMode" ); mBackgroundModeEnabled = c.readBool( "Enabled", true ); c.popSection(); // Pulse right away. pulse(); // We need to set our host status to offline when assburner quits connect( qApp, SIGNAL( aboutToQuit() ), SLOT( offlineFromAboutToQuit() ) ); if( mUseGui ) { mIdle = new Idle(); connect( mIdle, SIGNAL( secondsIdle( int ) ), SLOT( slotSecondsIdle( int ) ) ); mIdle->start(); } if( mHostStatus.slaveStatus() == "client-update-offline" ) offline(); else if( mHostStatus.slaveStatus() == "client-update" ) clientUpdate(); else { // Store the current status QString currentStatus = mHostStatus.slaveStatus(); // We run the host through the online method first online(); // Check if the old host status wasn't empty if( !currentStatus.isEmpty() ) { // Resume the state the host was in. LOG_3("Slave::startup() Resuming previous status of " + currentStatus); handleStatusChange(currentStatus, ""); } } // Create a timer for logged in user checks mUserTimer = new QTimer( this ); connect( mUserTimer, SIGNAL( timeout() ), SLOT( updateLoggedUsers() ) ); // Set it to trigger every 5 mins mUserTimer->start(300000); LOG_5( "Slave::startup() done" ); }