protected function execute($arguments = array(), $options = array())
 {
     $context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', 'dev', true));
     parent::execute($arguments, $options);
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $con = $databaseManager->getDatabase($options['connection'])->getConnection();
     // add your code here
     $this->log('[INFO] Flushing old data...' . "\n");
     $eventlog_flush = EtvaSettingPeer::retrieveByPK('eventlog_flush');
     $flush_range = $eventlog_flush->getValue();
     $con->beginTransaction();
     $affected = 0;
     try {
         $offset_date = date("c", time() - $flush_range * 24 * 60 * 60);
         /*
          * get event records that have creation date outdated
          */
         $c = new Criteria();
         $c->add(EtvaEventPeer::CREATED_AT, $offset_date, Criteria::LESS_THAN);
         $affected = EtvaEventPeer::doDelete($c, $con);
         $con->commit();
         $message = sprintf('Events Log - %d Record(s) deleted after %d day offset', $affected, $flush_range);
         $context->getEventDispatcher()->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $message)));
         $this->log('[INFO] ' . $message);
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
     $logger = new sfFileLogger($context->getEventDispatcher(), array('file' => sfConfig::get("sf_log_dir") . '/cron_status.log'));
     // log the message!
     $logger->log("[INFO] The events flush task ran!", 6);
 }
 public function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager(sfProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true));
     $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true);
     sfContext::createInstance($configuration);
     $conn = Doctrine_Manager::connection();
     // Récupération de toutes les notices.
     $noeuds = $conn->execute("SELECT id, name FROM ei_data_set_structure;");
     $this->log('Récupération des noeuds...OK');
     // Création de la requête permettant
     $this->log('Création de la requête de mise à jour...');
     $requeteToUpdate = "UPDATE ei_data_set_structure SET slug = #{NEW_SLUG} WHERE id = #{NODE_ID};";
     $requeteGlobale = array();
     foreach ($noeuds->fetchAll() as $noeud) {
         // Remplacement SLUG.
         $tmpRequete = str_replace("#{NEW_SLUG}", $conn->quote(MyFunction::sluggifyForXML($noeud["name"])), $requeteToUpdate);
         // Remplacement ID.
         $tmpRequete = str_replace("#{NODE_ID}", $noeud["id"], $tmpRequete);
         // Ajout dans la requête globale.
         $requeteGlobale[] = $tmpRequete;
     }
     // Préparation de la requête.
     $this->log("Préparation de la requête...");
     $requete = implode(" ", $requeteGlobale);
     try {
         // Exécution de la requête.
         $this->log("Exécution de la requête...");
         $conn->execute($requete);
         // Fin.
         $this->log("Processus terminé avec succès.");
     } catch (Exception $exc) {
         $this->log($exc->getMessage());
     }
 }
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     $applicationConfig = sfProjectConfiguration::getApplicationConfiguration('frontend', 'prod', true);
     $context = sfContext::createInstance($applicationConfig);
     ProjectConfiguration::registerCron();
     $quiet = (bool) $options['quiet'];
     $passed = array();
     $assigned = array();
     if ($arguments['subreddit'] == '%') {
         if (!$quiet) {
             echo "Advancing EpisodeAssignments for all Subreddits...";
         }
         SubredditTable::getInstance()->advanceEpisodeAssignments();
     } else {
         $subreddit = SubredditTable::getInstance()->findOneByName($arguments['subreddit']);
         if ($subreddit) {
             if (!$quiet) {
                 echo "Advancing EpisodeAssignments for {$subreddit} Subreddit...";
             }
             $subreddit->advanceEpisodeAssignments();
         } else {
             throw new sfException('Cannot find Subreddit: ' . $arguments['subreddit']);
         }
     }
     if (!$quiet) {
         echo "\n";
     }
 }
 protected function execute($arguments = array(), $options = array())
 {
     $context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', $options['env'], true));
     parent::execute($arguments, $options);
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     // add your code here
     $options_task_server_backup = array('location' => $arguments['location'], 'filepath' => $arguments['filepath']);
     if ($arguments['snapshot']) {
         $options_task_server_backup['snapshot'] = $arguments['snapshot'];
     }
     if ($arguments['newsnapshot']) {
         $options_task_server_backup['newsnapshot'] = $arguments['newsnapshot'];
     }
     if ($arguments['delete']) {
         $options_task_server_backup['deletesnapshot'] = $arguments['delete'];
     }
     if ($arguments['location']) {
         if ($arguments['do_not_generate_tar'] && $arguments['do_not_generate_tar'] != 'false') {
             $options_task_server_backup['do_not_generate_tar'] = true;
         }
     }
     $task_server_backup = new serverBackupTask($this->dispatcher, new sfFormatter());
     return $task_server_backup->run(array('serverid' => $arguments['serverid']), $options_task_server_backup);
 }
 /**
  * Executes the current task.
  *
  * @param array $arguments An array of arguments
  * @param array $options An array of options
  *
  * @return integer 0 if everything went fine, or an error code
  */
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager(sfProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true));
     $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true);
     sfContext::createInstance($configuration);
     $conn = Doctrine_Manager::connection();
     /** @var $parametres Récupération des paramètres à charger */
     $parametres = $conn->execute("\n            SELECT *\n            FROM ei_function_has_param, ei_fonction\n            WHERE param_type = 'OUT'\n            AND (param_id, ei_fonction.id) NOT IN (SELECT ei_param_function_id, ei_function_id FROM ei_param_block_function_mapping)\n            AND ei_function_has_param.function_ref = ei_fonction.function_ref\n            AND ei_function_has_param.function_id = ei_fonction.function_id\n        ");
     $this->log('Récupération des paramètres...OK');
     // Création de la requête permettant
     $this->log('Création de la requête d\'insertion...');
     $requeteToInsert = "INSERT INTO ei_param_block_function_mapping (ei_param_function_id, created_at, updated_at, ei_function_id) ";
     $requeteToInsert .= "VALUES(#{PARAM_ID}, now(), now(), #{FONCTION_ID});";
     $pile = array();
     foreach ($parametres->fetchAll() as $parametre) {
         // Remplacement PARAM ID.
         $tmpRequete = str_replace("#{PARAM_ID}", $parametre["param_id"], $requeteToInsert);
         // Remplacement FONCTION ID.
         $tmpRequete = str_replace("#{FONCTION_ID}", $parametre["id"], $tmpRequete);
         // Ajout dans la requête globale.
         $pile[] = $tmpRequete;
     }
     // Préparation de la requête.
     $this->log("Préparation de la requête...");
     $requete = implode(" ", $pile);
     try {
         // Exécution de la requête.
         $this->log("Exécution de la requête...");
         $conn->execute($requete);
         // Fin.
         $this->log("Processus terminé avec succès.");
     } catch (Exception $exc) {
         $this->log($exc->getMessage());
     }
 }
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     $applicationConfig = sfProjectConfiguration::getApplicationConfiguration('frontend', 'prod', true);
     $context = sfContext::createInstance($applicationConfig);
     $one_day_users = sfGuardUserTable::getInstance()->getOneDayEmailReminders();
     $one_week_users = sfGuardUserTable::getInstance()->getOneWeekEmailReminders();
     $quiet = (bool) $options['quiet'];
     if (!$quiet) {
         echo "Sending one-day reminder emails to  " . count($one_day_users) . " users...";
     }
     foreach ($one_day_users as $user) {
         $sf_user = $context->getUser();
         $sf_user->setApiUserId($user->getIncremented());
         $sf_user->sendMail('RegisterOneDay');
     }
     if (!$quiet) {
         echo "\nSending one-week reminder emails to " . count($one_week_users) . " users...";
     }
     foreach ($one_week_users as $user) {
         $sf_user = $context->getUser();
         $sf_user->setApiUserId($user->getIncremented());
         $sf_user->sendMail('RegisterOneWeek');
     }
     if (!$quiet) {
         echo "\n";
     }
 }
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     // need a scriptname otherwise it uses the symfony file
     if ($arguments['env'] != 'prod') {
         $_SERVER['SCRIPT_NAME'] = '/' . $arguments['application'] . '_' . $arguments['env'] . '.php';
     } else {
         $_SERVER['SCRIPT_NAME'] = '/index.php';
     }
     sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration($arguments['application'], $arguments['env'], true));
     $searchIndex = new zsSearchIndex($arguments['index']);
     //optimize to increase speed
     $searchIndex->optimize();
     //loop thru all models specified in this index and update all entries
     foreach ($searchIndex->getModels() as $model => $config) {
         $this->logSection('update', 'model: ' . $model);
         foreach (Doctrine::getTable($model)->findAll() as $object) {
             $searchIndex->updateIndex($object);
             echo '.';
         }
         echo "\n";
     }
     //re-optimize index
     $searchIndex->optimize();
 }
Beispiel #8
0
 protected function execute($arguments = array(), $options = array())
 {
     $context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', $options['env'], true));
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     // add your code here
     $nid = $arguments['id'];
     $this->log("[INFO] node check id={$nid}");
     if (!($etva_node = EtvaNodePeer::retrieveByPK($nid))) {
         $msg_i18n = $context->getI18N()->__(EtvaNodePeer::_ERR_NOTFOUND_ID_, array('%id%' => $nid));
         $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
         $this->log("[ERROR] " . $error['error']);
         return $error;
     } else {
         $etva_node_va = new EtvaNode_VA($etva_node);
         $response = $etva_node_va->checkState();
         if (!$response['success']) {
             $this->log("[ERROR] " . $response['error']);
         } else {
             $this->log("[INFO] " . $response['response']);
         }
         return $response;
     }
 }
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     $applicationConfig = sfProjectConfiguration::getApplicationConfiguration('frontend', 'prod', true);
     $context = sfContext::createInstance($applicationConfig);
     // Go to the Subreddit and obtain the past few keys.
     $reddit_location = $options['subreddit'];
     $reddit = new RedditObject($reddit_location);
     $quiet = (bool) $options['quiet'];
     if (!$quiet) {
         echo "Obtaining the most recent comments from {$reddit_location}...";
     }
     $reddit->appendData();
     $found_keys = count($reddit->getComments());
     if (!$quiet) {
         echo "\nFound {$found_keys} keys.  Updating keys in the database...";
     }
     ValidationTable::getInstance()->storeNewKeys($reddit->getComments());
     // Now that new keys are stored in the database we need to update all applicable users
     $users = sfGuardUserTable::getInstance()->getUsersToBeValidated();
     $updated = sfGuardUserTable::getInstance()->validateUsers($users);
     if (!$quiet) {
         echo "\nSending emails...";
     }
     foreach ($users as $user_id) {
         $sf_user = $context->getUser();
         $sf_user->setApiUserId($user_id);
         $sf_user->sendMail('RedditValidationSucceeded');
     }
     if (!$quiet) {
         echo "\n{$updated} users validated and email sent.\n";
     }
 }
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $con = $databaseManager->getDatabase($options['connection'])->getConnection();
     $context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', 'dev', true));
     if ($options['server'] !== null) {
         EtvaSettingPeer::updateSetting(EtvaSettingPeer::_SMTP_SERVER_, $options['server']);
     }
     if ($options['port'] !== null) {
         EtvaSettingPeer::updateSetting(EtvaSettingPeer::_SMTP_PORT_, $options['port']);
     }
     if ($options['security-type'] !== null) {
         EtvaSettingPeer::updateSetting(EtvaSettingPeer::_SMTP_SECURITY_, $options['security-type']);
     }
     if ($options['use-auth'] !== null) {
         EtvaSettingPeer::updateSetting(EtvaSettingPeer::_SMTP_USE_AUTH_, $options['use-auth']);
     }
     if ($options['username'] !== null) {
         EtvaSettingPeer::updateSetting(EtvaSettingPeer::_SMTP_USERNAME_, $options['username']);
     }
     if ($options['password'] !== null) {
         EtvaSettingPeer::updateSetting(EtvaSettingPeer::_SMTP_KEY_, $options['password']);
     }
     return;
 }
 protected function execute($arguments = array(), $options = array())
 {
     $context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', 'dev', true));
     parent::execute($arguments, $options);
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $con = $databaseManager->getDatabase($options['connection'])->getConnection();
     // add your code here
     $this->log('[INFO] Checking VirtAgents state...' . "\n");
     $offset = sfConfig::get('app_node_keepalive_update') + sfConfig::get('app_node_keepalive_update_offset');
     $total_nodes = EtvaNodePeer::doCount(new Criteria());
     if ($total_nodes > 0) {
         $con->beginTransaction();
         $affected = 0;
         try {
             $offset_date = date("c", time() - $offset);
             /*
              * get nodes that have last_keepalive field outdated
              */
             $c1 = new Criteria();
             $c1->add(EtvaNodePeer::LAST_KEEPALIVE, $offset_date, Criteria::LESS_THAN);
             $c1->add(EtvaNodePeer::STATE, EtvaNode::NODE_ACTIVE);
             // only active
             //update statement
             $c2 = new Criteria();
             $c2->add(EtvaNodePeer::STATE, EtvaNode::NODE_INACTIVE);
             $affected += BasePeer::doUpdate($c1, $c2, $con);
             // update maintenance and running to maintenance
             $c1 = new Criteria();
             $c1->add(EtvaNodePeer::LAST_KEEPALIVE, $offset_date, Criteria::LESS_THAN);
             $c1->add(EtvaNodePeer::STATE, EtvaNode::NODE_MAINTENANCE_UP);
             //update statement
             $c2 = new Criteria();
             $c2->add(EtvaNodePeer::STATE, EtvaNode::NODE_MAINTENANCE);
             $affected += BasePeer::doUpdate($c1, $c2, $con);
             // update fail and running to fail
             $c1 = new Criteria();
             $c1->add(EtvaNodePeer::LAST_KEEPALIVE, $offset_date, Criteria::LESS_THAN);
             $c1->add(EtvaNodePeer::STATE, EtvaNode::NODE_FAIL_UP);
             // only active
             //update statement
             $c2 = new Criteria();
             $c2->add(EtvaNodePeer::STATE, EtvaNode::NODE_FAIL);
             $affected += BasePeer::doUpdate($c1, $c2, $con);
             $con->commit();
             $message = sprintf('%d Node(s) NOT received update in time offset of %d seconds', $affected, $offset);
             if ($affected > 0) {
                 $context->getEventDispatcher()->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
             }
             $this->log('[INFO]' . $message);
         } catch (PropelException $e) {
             $con->rollBack();
             throw $e;
         }
     }
     $logger = new sfFileLogger($context->getEventDispatcher(), array('file' => sfConfig::get("sf_log_dir") . '/cron_status.log'));
     // log the message!
     $logger->log("[INFO] The check virtAgents task ran!", 6);
 }
 protected function execute($arguments = array(), $options = array())
 {
     $context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', $options['env'], true));
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     // add your code here
     // get parameters
     $lv = $arguments['name'];
     $size = $arguments['size'];
     $vg = $arguments['volumegroup'];
     $node_id = $options['node'];
     $format = $options['format'];
     $persnapshotusage = $options['persnapshotusage'];
     /*
      * check if lv is a file disk instead
      * if is a file disk check if special volume group exists. if not create
      */
     $is_DiskFile = $vg == sfConfig::get('app_volgroup_disk_flag') ? 1 : 0;
     // get etva_node
     $etva_node = EtvaNodePeer::getOrElectNodeFromArray(array_merge($options, $arguments));
     if (!$etva_node) {
         $msg_i18n = $context->getI18N()->__(EtvaNodePeer::_ERR_NOTFOUND_ID_, array('%id%' => $node_id));
         $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
         $this->log("[ERROR] " . $error['error']);
         return $error;
     }
     // get logical volume
     if ($etva_lv = $etva_node->retrieveLogicalvolumeByLv($lv)) {
         $msg_type = $is_DiskFile ? EtvaLogicalvolumePeer::_ERR_DISK_EXIST_ : EtvaLogicalvolumePeer::_ERR_LV_EXIST_;
         $msg = Etva::getLogMessage(array('name' => $lv), $msg_type);
         $msg_i18n = $context->getI18N()->__($msg_type, array('%name%' => $lv));
         $error = array('success' => false, 'agent' => $etva_node->getName(), 'error' => $msg_i18n, 'info' => $msg_i18n);
         $this->log("[ERROR] " . $error['error']);
         return $error;
     }
     if (!($etva_vg = $etva_node->retrieveVolumegroupByVg($vg))) {
         $msg = Etva::getLogMessage(array('name' => $vg), EtvaVolumegroupPeer::_ERR_NOTFOUND_);
         $msg_i18n = $context->getI18N()->__(EtvaVolumegroupPeer::_ERR_NOTFOUND_, array('%name%' => $vg));
         $error = array('success' => false, 'agent' => $etva_node->getName(), 'error' => $msg_i18n, 'info' => $msg_i18n);
         $this->log("[ERROR] " . $error['error']);
         return $error;
     }
     // prepare soap info....
     $etva_lv = new EtvaLogicalvolume();
     $etva_lv->setEtvaVolumegroup($etva_vg);
     $etva_lv->setLv($lv);
     $lv_va = new EtvaLogicalvolume_VA($etva_lv);
     $response = $lv_va->send_create($etva_node, $size, $format, $persnapshotusage);
     if (!$response['success']) {
         $this->log("[ERROR] " . $response['error']);
     } else {
         $this->log("[INFO] " . $response['response']);
     }
     return $response;
 }
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     //$databaseManager = new sfDatabaseManager($this->configuration);
     //$connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration($arguments['application'], $options['env'], true));
     $searchIndex = new zsSearchIndex($arguments['index']);
     //optimize to increase speed
     $searchIndex->optimize();
 }
 /**
  * Executes the current task.
  *
  * @param array $arguments An array of arguments
  * @param array $options An array of options
  *
  * @return integer 0 if everything went fine, or an error code
  */
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager(sfProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true));
     $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true);
     sfContext::createInstance($configuration);
     $conn = Doctrine_Manager::connection();
     $conn->execute("UPDATE ei_scenario_structure SET type = '" . EiScenarioStructure::$TYPE_BLOCK . "' WHERE type = 1");
     $this->log("Mise à jour des structures de scénarios de type " . EiScenarioStructure::$TYPE_BLOCK);
     $conn->execute("UPDATE ei_scenario_structure SET type = '" . EiScenarioStructure::$TYPE_PARAM . "' WHERE type = 2");
     $this->log("Mise à jour des structures de scénarios de type " . EiScenarioStructure::$TYPE_PARAM);
 }
 /**
  * Executes the current task.
  *
  * @param array $arguments An array of arguments
  * @param array $options An array of options
  *
  * @return integer 0 if everything went fine, or an error code
  */
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager(sfProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true));
     $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true);
     sfContext::createInstance($configuration);
     $this->connexion = Doctrine_Manager::connection();
     $initialStep = 1;
     do {
         $this->proceedStep($initialStep++);
     } while ($this->statutExec === true);
 }
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $con = $databaseManager->getDatabase($options['connection'])->getConnection();
     $this->log("[INFO] " . date("d/m/y : H:i:s", time()));
     $context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', 'dev', true));
     $response = diagnostic::getAgentFiles('diagnostic');
     $this->log("[INFO] " . date("d/m/y : H:i:s", time()));
     return;
 }
 protected function execute($arguments = array(), $options = array())
 {
     $context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', $options['env'], true));
     parent::execute($arguments, $options);
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $con = $databaseManager->getDatabase($options['connection'])->getConnection();
     // add your code here
     $this->log('[INFO]Checking node(s) virtual machines state...' . "\n");
     // get nodes active
     $updated_vm_state = array();
     $nodes = EtvaNodeQuery::create()->filterByState(EtvaNode::NODE_ACTIVE)->find();
     $affected = 0;
     foreach ($nodes as $node) {
         $response = $node->soapSend('domains_stats');
         $success = $response['success'];
         if ($success) {
             $returned_data = $response['response'];
             foreach ($returned_data as $i => $server) {
                 $server_data = (array) $server;
                 $etva_server = $node->retrieveServerByName($server_data['name']);
                 if ($etva_server) {
                     $server_id = $etva_server->getId();
                     // get server id
                     if ($etva_server->getVmState() !== EtvaServer::STATE_MIGRATING) {
                         // only if not in migrating mode
                         $etva_server->setVmState($server_data['state']);
                         $etva_server->save();
                     }
                     $updated_vm_state[$server_id] = $etva_server->getVmState();
                     // mark as updated
                 }
             }
         } else {
             $affected++;
             $errors[] = $response['error'];
         }
     }
     // change state as STOP for servers that are not in array
     EtvaServerQuery::create()->filterById(array_keys($updated_vm_state), Criteria::NOT_IN)->update(array('VmState' => EtvaServer::STATE_STOP));
     if ($nodes) {
         $message = sprintf('%d Node(s) could not be checked for virtual machines state', $affected);
         if ($affected > 0) {
             $context->getEventDispatcher()->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
         }
     }
     if (!empty($errors)) {
         $this->log('[INFO]' . $message);
     }
     $logger = new sfFileLogger($context->getEventDispatcher(), array('file' => sfConfig::get("sf_log_dir") . '/cron_status.log'));
     // log the message!
     $logger->log("The check virtual machines state task ran!", 6);
 }
 public function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager(sfProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true));
     $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true);
     sfContext::createInstance($configuration);
     $conn = Doctrine_Manager::connection();
     // Création de la requête permettant de mettre à jour les auteurs du test set.
     $titre = "Mise à jour des auteurs dans Test Set...";
     $this->log($titre . '[EN COURS]');
     try {
         $sql = "UPDATE ei_test_set ts SET author_id = COALESCE(\n(SELECT guard_id FROM ei_user, ei_log WHERE ei_log.ei_test_set_id = ts.id AND ref_id = ei_log.user_ref AND ei_user.user_id = ei_log.user_id GROUP BY ei_log.ei_test_set_id), NULL);";
         $conn->execute($sql);
         $this->log($titre . "[OK]");
     } catch (Exception $exc) {
         $this->log($titre . "[ECHEC]");
         $this->log($exc->getMessage());
     }
     // Création de la requête permettant de mettre à jour les modes d'exécution du test set.
     $titre = "Mise à jour des modes...";
     $this->log($titre . '[EN COURS]');
     try {
         $sql = "UPDATE ei_test_set SET mode = 'Campaign' WHERE id IN (SELECT ei_test_set_id FROM ei_campaign_execution_graph);";
         $conn->execute($sql);
         $this->log($titre . "[OK]");
     } catch (Exception $exc) {
         $this->log($titre . "[ECHEC]");
         $this->log($exc->getMessage());
     }
     // Mise à jour
     $titre = "Création des statuts...";
     $this->log($titre . "[EN COURS]");
     try {
         $sql = "SELECT ref_id, project_id FROM ei_projet WHERE (ref_id, project_id) NOT IN (SELECT project_ref, project_id FROM ei_test_set_state);";
         $sqlAdd = "INSERT INTO ei_test_set_state (name, color_code, state_code, project_id, project_ref, created_at, updated_at) VALUES ";
         $executes = array();
         $projets = $conn->execute($sql)->fetchAll();
         // On vérifie si des projets n'ont pas encore leurs statuts.
         if (count($projets) > 0) {
             /** @var Doctrine_Connection_Statement $statement Création du statement */
             $statement = $conn->prepare($sqlAdd);
             foreach ($projets as $projet) {
                 $executes[] = "('Success', '#58A155', 'OK', " . $projet["project_id"] . ", " . $projet["ref_id"] . ", now(), now())";
                 $executes[] = "('Failed', '#D8473D', 'KO', " . $projet["project_id"] . ", " . $projet["ref_id"] . ", now(), now())";
                 $executes[] = "('Aborted', '#B9B5AF', 'NA', " . $projet["project_id"] . ", " . $projet["ref_id"] . ", now(), now())";
             }
             $conn->execute($sqlAdd . implode(",", $executes) . ";");
         }
         $this->log($titre . "[OK]");
     } catch (Exception $exc) {
         $this->log($titre . "[ECHEC]");
         $this->log($exc->getMessage());
     }
 }
Beispiel #19
0
 protected function execute($arguments = array(), $options = array())
 {
     // Context
     $context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', $options['env'], true));
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     // add your code here
     // server id
     $server = $arguments['server'];
     $this->log("[INFO] Shutdown server with '{$server}'");
     $etva_server = EtvaServerPeer::retrieveByPK($server);
     if (!$etva_server) {
         $etva_server = EtvaServerPeer::retrieveByUuid($server);
     }
     if (!$etva_server) {
         $etva_server = EtvaServerPeer::retrieveByName($server);
     }
     if (!$etva_server) {
         $msg_i18n = $context->getI18N()->__(EtvaServerPeer::_ERR_NOTFOUND_, array('name' => $server));
         $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
         $this->log("[ERROR] " . $error['error']);
         return $error;
     } else {
         if ($nid = $options['node']) {
             $etva_node = EtvaNodePeer::retrieveByPK($nid);
         } else {
             $etva_node = $etva_server->getEtvaNode();
         }
         if (!$etva_node) {
             //notify event log
             $msg_i18n = Etva::makeNotifyLogMessage(sfConfig::get('config_acronym'), EtvaNodePeer::_ERR_NOTFOUND_ID_, array('id' => $nid), EtvaServerPeer::_ERR_STOP_, array('name' => $server));
             $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
             $this->log("[ERROR] " . $error['error']);
             return $error;
         }
         $destroy = $options['destroy'] ? 1 : 0;
         $force = $options['force'] ? 1 : 0;
         $extra = array('destroy' => $destroy, 'force' => $force);
         $server_va = new EtvaServer_VA($etva_server);
         $response = $server_va->send_stop($etva_node, $extra);
         if ($response['success']) {
             $this->log("[INFO] " . $response['response']);
         } else {
             $this->log("[ERROR] " . $response['error']);
         }
         return $response;
     }
 }
 protected function execute($arguments = array(), $options = array())
 {
     $context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', $options['env'], true));
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     // add your code here
     // get node
     $node_id = $options['node'];
     $etva_node = EtvaNodePeer::getOrElectNodeFromArray(array_merge($options, $arguments));
     if (!$etva_node) {
         $msg_i18n = $context->getI18N()->__(EtvaNodePeer::_ERR_NOTFOUND_ID_, array('%id%' => $node_id));
         $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
         $this->log("[ERROR] " . $error['error']);
         return $error;
     }
     // logical volume to clone
     $lv = $arguments['logicalvolume'];
     $vg = $options['volumegroup'];
     // check if a logical volume exists
     if (!($etva_lv = $etva_node->retrieveLogicalvolumeByAny($lv, $vg))) {
         $msg = Etva::getLogMessage(array('name' => $lv), EtvaLogicalvolumePeer::_ERR_NOTFOUND_);
         $msg_i18n = $context->getI18N()->__(EtvaLogicalvolumePeer::_ERR_NOTFOUND_, array('%name%' => $lv));
         $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
         $this->log("[ERROR] " . $error['error']);
         return $error;
     }
     // original logical volume
     $original_lv = $arguments['original'];
     $original_vg = $options['original-volumegroup'];
     // if cannot find logical volume
     if (!($etva_original_lv = $etva_node->retrieveLogicalvolumeByAny($original_lv, $original_vg))) {
         $msg = Etva::getLogMessage(array('name' => $original_lv), EtvaLogicalvolumePeer::_ERR_NOTFOUND_);
         $msg_i18n = $context->getI18N()->__(EtvaLogicalvolumePeer::_ERR_NOTFOUND_, array('%name%' => $original_lv));
         $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
         $this->log("[ERROR] " . $error['error']);
         return $error;
     }
     // prepare soap info....
     $lv_va = new EtvaLogicalvolume_VA($etva_lv);
     $response = $lv_va->send_clone($etva_node, $etva_original_lv);
     if (!$response['success']) {
         $this->log("[ERROR] " . $response['error']);
     } else {
         $this->log("[INFO] " . $response['response']);
     }
     return $response;
 }
 protected function execute($arguments = array(), $options = array())
 {
     // initialize default context
     sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('smint', 'dev', true));
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     // add your code here
     $tmpFilePath = smintUploadFileHelper::getUploadPath();
     $tmpfname = tempnam($tmpFilePath, "uploadscript.tmp");
     copy($options['filename'], $tmpfname);
     $newFile = new sfValidatedFile($options['filename'], "audio/mpeg", $tmpfname, null, $tmpFilePath);
     $fileInfo = smintUploadFileHelper::saveFile($newFile);
     //print_r($fileInfo);
     echo "originalFilename=" . urlencode($fileInfo["originalFilename"]) . "&existingUploadedFile=" . urlencode($fileInfo["filename"]) . "\n";
     unlink($tmpfname);
 }
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     //$databaseManager = new sfDatabaseManager($this->configuration);
     //$connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration($arguments['application'], $options['env'], true));
     $web_dir = sfConfig::get('sf_web_dir');
     $size = $arguments['size'];
     foreach ($arguments['path'] as $path) {
         $path = trim($path, '/');
         $files = sfFinder::type('file')->name('/\\.(jpg|jpeg|png|gif)/')->relative()->in($web_dir . DIRECTORY_SEPARATOR . $path);
         foreach ($files as $file) {
             $image = new zsThumb(array('path' => $path . DIRECTORY_SEPARATOR . $file, 'size' => $size));
             $image->cache();
             $this->logSection('file+', $image->getCachedPath());
         }
     }
 }
 protected function execute($arguments = array(), $options = array())
 {
     $context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', $options['env'], true));
     parent::execute($arguments, $options);
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     // add your code here
     $this->log('Refreshing Guest Agents Info...' . "\n");
     $nodes = EtvaNodeQuery::create()->filterByState(EtvaNode::NODE_ACTIVE)->find();
     foreach ($nodes as $node) {
         $node_va = new EtvaNode_VA($node);
         $this->log('Collecting info for node: ' . $node->getName() . "\n");
         $bulk_response_gas = $node_va->send_get_gas_info();
         //$this->log('The following servers info were updated: '.implode('; ', $bulk_response_gas));
         $message = 'The following servers info were updated: ' . implode('; ', $bulk_response_gas);
         $this->log($message);
         $context->getEventDispatcher()->notify(new sfEvent($node->getName(), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::INFO)));
     }
 }
 public function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager(sfProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true));
     $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true);
     sfContext::createInstance($configuration);
     $conn = Doctrine_Manager::connection();
     // Récupération de toutes les notices.
     $notices = $conn->execute("SELECT notice_ref, notice_id, version_notice_id, lang, description, expected, result FROM ei_version_notice;");
     $this->log('Récupération des notices...OK');
     // Création de la requête permettant
     $this->log('Création de la requête de mise à jour...');
     $requeteToUpdate = "UPDATE ei_version_notice SET description = DESC, expected = EXP, result = RES WHERE notice_ref = NOT_REF AND notice_id = NOT_ID AND version_notice_id = NOT_VE AND lang = 'NOT_LANG';";
     $requeteGlobale = array();
     foreach ($notices->fetchAll() as $notice) {
         // Remplacement description.
         $tmpRequete = str_replace("DESC", $conn->quote(html_entity_decode($notice["description"])), $requeteToUpdate);
         // Remplacement expected.
         $tmpRequete = str_replace("EXP", $conn->quote(html_entity_decode($notice["expected"])), $tmpRequete);
         // Remplacement result.
         $tmpRequete = str_replace("RES", $conn->quote(html_entity_decode($notice["result"])), $tmpRequete);
         // Remplacement des identifiants de la notice.
         $tmpRequete = str_replace("NOT_REF", $notice["notice_ref"], $tmpRequete);
         $tmpRequete = str_replace("NOT_ID", $notice["notice_id"], $tmpRequete);
         $tmpRequete = str_replace("NOT_VE", $notice["version_notice_id"], $tmpRequete);
         $tmpRequete = str_replace("NOT_LANG", $notice["lang"], $tmpRequete);
         // Ajout dans la requête globale.
         $requeteGlobale[] = $tmpRequete;
     }
     // Préparation de la requête.
     $this->log("Préparation de la requête...");
     $requete = implode(" ", $requeteGlobale);
     try {
         // Exécution de la requête.
         $this->log("Exécution de la requête...");
         $conn->execute($requete);
         // Fin.
         $this->log("Processus terminé avec succès.");
     } catch (Exception $exc) {
         $this->log($exc->getMessage());
     }
 }
Beispiel #25
0
 protected function execute($arguments = array(), $options = array())
 {
     $context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', $options['env'], true));
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     $apli = new Appliance();
     $serial = $apli->get_serial_number();
     $this->log('[INFO] Appliance backup...' . "\n");
     if ($serial) {
         $result = $apli->backup(true);
         if (!$result['success']) {
             if ($result['action'] == Appliance::LOGIN_BACKUP) {
                 $result['txt'] = 'Could not login!';
             }
             if ($result['action'] == Appliance::DB_BACKUP) {
                 $result['txt'] = 'DB backup error...';
             }
             if ($result['action'] == Appliance::MA_BACKUP) {
                 $result['txt'] = 'MA backup error...';
             }
             $reason = $result['info'];
             if ($result['txt']) {
                 $reason = $result['txt'];
             }
             $message = 'The backup failed, reason: ' . $reason;
             $context->getEventDispatcher()->notify(new sfEvent($this->name, 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
             $this->log('[ERR] ' . $message . "\n");
         } else {
             $message = 'The backup process run with success.';
             $context->getEventDispatcher()->notify(new sfEvent($this->name, 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::INFO)));
             $this->log('[INFO] ' . $message . "\n");
         }
     } else {
         $this->log('[INFO] Could not be possible to do the backup because the appliance is not registered!' . "\n");
     }
 }
<?php

/**
 *
 * Copyright (c) 2008 Yahoo! Inc.  All rights reserved.
 * The copyrights embodied in the content in this file are licensed
 * under the MIT open source license.
 *
 * For the full copyright and license information, please view the LICENSE.yahoo
 * file that was distributed with this source code.
 */
$sf_symfony_lib_dir = '/Users/dustin/projects/symfony/branch/1.1/lib';
$sf_root_dir = realpath(dirname(__FILE__) . '/../fixtures/project');
require_once $sf_root_dir . '/config/ProjectConfiguration.class.php';
$configuration = sfProjectConfiguration::getApplicationConfiguration('dimensions', 'test', true, $sf_root_dir);
sfContext::createInstance($configuration);
$sf_symfony_lib_dir = sfConfig::get('sf_symfony_lib_dir');
// remove all cache
sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir'));
// load lime
require_once $configuration->getSymfonyLibDir() . '/vendor/lime/lime.php';
$b = new sfTestBrowser();
$t = $b->test();
$c = $b->getContext()->getConfiguration();
$t->diag('checking default configuration dimensions');
$b->get('/test2')->isStatusCode(200)->checkResponseElement('title', '/symfony project/')->checkResponseElement('body', '/generic view/')->checkResponseElement('body', '/generic action/');
$t->is($c->getConfigPaths('config/app.yml'), array($sf_root_dir . '/apps/dimensions/config/app.yml', $sf_root_dir . '/apps/dimensions/config/sp1/app.yml'), '->getConfigPaths() returns correct module level configuration files given name');
$t->is($c->getTemplatePath('test', 'indexSuccess.php'), $sf_root_dir . '/apps/dimensions/modules/test/templates/indexSuccess.php', '->getTemplatePath() returns correct path to template given module name and template name');
$t->diag('checking backwards compatability by setting dimension null');
$c->setDimension(null);
$t->is($c->getTemplateDirs('test'), array($sf_root_dir . '/apps/dimensions/modules/test/templates', $sf_root_dir . '/plugins/ysfDimensionsTestPlugin/modules/test/templates', $sf_symfony_lib_dir . '/controller/test/templates', $sf_root_dir . '/cache/dimensions/test/modules/autoTest/templates'), '->getTemplateDirs() checking template path returns correct with out dimension');
 /**
  * Executes the current task.
  *
  * @param array $arguments An array of arguments
  * @param array $options An array of options
  *
  * @return integer 0 if everything went fine, or an error code
  */
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager(sfProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true));
     $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true);
     sfContext::createInstance($configuration);
     $conn = Doctrine_Manager::connection();
     // Création des roots.
     $sqlDrop = "DROP PROCEDURE IF EXISTS creerRootStructureDataSet;";
     $sqlCreate = "\n        CREATE PROCEDURE `creerRootStructureDataSet`()\n        BEGIN\n            DECLARE done INT DEFAULT 0;\n            DECLARE idScenario VARCHAR(64);\n            DECLARE idProject VARCHAR(64);\n            DECLARE refProject VARCHAR(64);\n            DECLARE curseurScenarios CURSOR FOR SELECT id, project_id, project_ref FROM ei_scenario WHERE id NOT IN (SELECT ei_scenario_id FROM ei_data_set_structure);\n            DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;\n\n            OPEN curseurScenarios;\n\n            REPEAT\n                FETCH curseurScenarios INTO idScenario, idProject, refProject;\n\n                IF done = 0 THEN\n                    INSERT INTO ei_data_set_structure(ei_scenario_id, ei_dataset_structure_parent_id, root_id, project_id, project_ref,\n                        type, name, description, created_at, updated_at, lft, rgt, level\n                    ) VALUES (idScenario, null, LAST_INSERT_ID(), idProject, refProject, 'NodeDataSet', 'Root', '', now(), now(), 1, 2, 0);\n\n                    UPDATE ei_data_set_structure SET root_id = LAST_INSERT_ID() WHERE id = LAST_INSERT_ID();\n                END IF;\n\n            UNTIL done\n            END REPEAT;\n        END;";
     $sqlCall = "CALL creerRootStructureDataSet();";
     // Copie de la structure du scénario dans la structure du jeu de données et mise à jour du data line.
     $sqlDropCopy = "DROP PROCEDURE IF EXISTS copyScenarioStructureToDataSetStructure;";
     $sqlCreateCopy = "\n            # Création de la procédure permettant de copier la structure du scénario dans la structure du jeu de données.\n            CREATE PROCEDURE `copyScenarioStructureToDataSetStructure`()\n            BEGIN\n                # Déclaration des variables utilisées.\n                # Variable permettant de vérifier que la boucle est terminée.\n                DECLARE done, nbElts, cpt, haveToDrop, cpt2, nbElts2 INT DEFAULT 0;\n                # Variable permettant de contenir le scénario courant.\n                DECLARE scenario_id BIGINT;\n\n                # Variable permettant de contenir l'ID de la structure du scénario parente.\n                DECLARE currentStrParentId BIGINT DEFAULT 0;\n                # Variable permettant de contenir l'ID de la structure jdd parente.\n                DECLARE currentDataSetStrParentId BIGINT DEFAULT 0;\n\n                DECLARE strId, strParentId, rootI, dsRootI, projectI, projectR, lastDsID, dlI, scenarioStrId, dlDsI BIGINT;\n                DECLARE strName, strType, dsStrType varchar(255);\n                DECLARE strDesc longtext;\n                DECLARE strUp, strCr datetime;\n                DECLARE strLft, strRgt int(11);\n                DECLARE strLvl smallint(6);\n\n                DECLARE scenario BIGINT DEFAULT 1;\n                DECLARE query longtext;\n\n                DECLARE curseurScenarios CURSOR FOR SELECT id FROM ei_scenario sc WHERE (SELECT COUNT(*) FROM ei_data_set_structure WHERE ei_scenario_id = sc.id) = 1;\n\n                DECLARE curseurStructure CURSOR FOR\n                    SELECT scstr.id, ei_scenario_structure_parent_id, scstr.root_id, scstr.project_id, scstr.project_ref, scstr.type, scstr.name, scstr.description,\n                                scstr.created_at, scstr.updated_at, scstr.lft, scstr.rgt, scstr.level, dsstr.root_id\n                    FROM ei_scenario_structure scstr, ei_data_set_structure dsstr\n                    WHERE scstr.ei_scenario_id = @scenario\n                    AND scstr.ei_scenario_id = dsstr.ei_scenario_id\n                    ORDER BY scstr.lft;\n\n                DECLARE curseurDataLines CURSOR FOR SELECT id FROM ei_data_line WHERE ei_data_set_structure_id = @strId\n                    AND id NOT IN (SELECT id FROM copy_scenario_structure_into_dataset_structure_data_line);\n\n                DECLARE curseurNotMatchedDataLines CURSOR FOR SELECT id, ei_data_set_structure_id FROM prod_v2_kalifast.ei_data_line\n                    WHERE ei_data_set_structure_id NOT IN (SELECT id FROM ei_data_set_structure);\n\n                DECLARE curseurMatchedDataSetDataLine CURSOR FOR SELECT id FROM ei_data_set_structure  WHERE ei_dataset_structure_parent_id IS NULL\n                    AND ei_scenario_id = (SELECT ei_scenario_id FROM ei_scenario_structure WHERE id = @scenarioStrId);\n\n                DECLARE curseurStructureChanges CURSOR FOR SELECT  FROM copy_scenario_structure_into_dataset_structure;\n\n                DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;\n\n                # Suppression des tables temporaires si elles existent déjà.\n                DROP TABLE IF EXISTS copy_scenario_structure_into_dataset_structure;\n                DROP TABLE IF EXISTS copy_scenario_structure_into_dataset_structure_data_line;\n\n                # Création d'une table temporaire permettant de recenser toutes les correspondances entre les structures de scénario et jeu de données.\n                CREATE TEMPORARY TABLE copy_scenario_structure_into_dataset_structure (\n                    `id` bigint(20) NOT NULL,\n                    `ei_scenario_id` bigint(20) NOT NULL,\n                    `ei_scenario_structure_parent_id` bigint(20) DEFAULT NULL,\n                    `root_id` bigint(20) DEFAULT NULL,\n                    `project_id` bigint(20) NOT NULL,\n                    `project_ref` bigint(20) NOT NULL,\n                    `type` varchar(255) NOT NULL,\n                    `name` varchar(255) NOT NULL,\n                    `description` longtext,\n                    `created_at` datetime NOT NULL,\n                    `updated_at` datetime NOT NULL,\n                    `lft` int(11) DEFAULT NULL,\n                    `rgt` int(11) DEFAULT NULL,\n                    `level` smallint(6) DEFAULT NULL,\n                    `data_set_structure_id` bigint(20) NOT NULL,\n                    `data_set_structure_parent_id` bigint(20),\n                    `data_set_structure_root_id` bigint(20) NOT NULL\n                ) DEFAULT CHARSET=utf8;\n\n                # Création de la table contenant les jeux de données traités.\n                CREATE TEMPORARY TABLE copy_scenario_structure_into_dataset_structure_data_line(\n                    `id` bigint(20) NOT NULL,\n                    `old`  bigint(20) NOT NULL,\n                    `new`  bigint(20) NOT NULL\n                ) DEFAULT CHARSET=utf8;\n\n                # TRANSACTION.\n                SET AUTOCOMMIT = 0;\n\n                START TRANSACTION;\n\n                # On regarde s'il y a besoin de créer la colonne dans ei_data_line.\n                SELECT count(*) FROM information_schema.COLUMNS c WHERE c.TABLE_SCHEMA = database()\n                    AND c.TABLE_NAME = 'ei_data_line' AND c.COLUMN_NAME = 'ei_data_set_structure_id' INTO haveToDrop;\n\n                IF haveToDrop = 0 THEN\n                    # Suppression de l'index et de la foreign key dans la table ei_data_line faisant référence à la structure du scénario.\n                    ALTER TABLE ei_data_line DROP FOREIGN KEY ei_data_line_ei_scenario_structure_id_ei_scenario_structure_id;\n                    ALTER TABLE ei_data_line DROP INDEX ei_scenario_structure_id_idx;\n\n                    # On renomme.\n                    ALTER TABLE ei_data_line CHANGE ei_scenario_structure_id ei_data_set_structure_id BIGINT;\n\n                    # Création de l'index.\n                    CREATE INDEX ei_data_set_structure_id_idx ON ei_data_line (ei_data_set_structure_id);\n                END IF;\n\n                # Parcours des scénarios.\n                OPEN curseurScenarios;\n\n                REPEAT\n                    # On récupère l'ID du scénario.\n                    FETCH curseurScenarios INTO scenario_id;\n\n                    IF done = 0 Then\n                        SET @scenario = scenario_id;\n\n                        # On parcours tous les éléments de la structure du scénario.\n                        OPEN curseurStructure;\n\n                        # On stocke le nombre de lignes dans le compteur.\n                        SELECT FOUND_ROWS() into nbElts;\n                        SET cpt = 1;\n\n                        # On récupère le premier élément qui doit être le root.\n                        FETCH NEXT FROM curseurStructure INTO strId, strParentId, rootI, projectI, projectR, strType, strName, strDesc, strCr, strUp, strLft, strRgt,\n                            strLvl, dsRootI;\n\n                        # Si l'élément capturé est bien le root, on met à jour le root de la structure du jeu de données\n                        # puis, on travaille à compléter la structure.\n                        IF strParentId IS NULL THEN\n                            SET @currentDataSetStrParentId = dsRootI;\n                            SET @currentStrParentId = strParentId;\n                            SET @dsStrType = 'NodeDataSet';\n                            SET @strId = strId;\n\n                            # On met à jour le champ right du noeud parent de la structure du jeu de données.\n                            UPDATE ei_data_set_structure SET rgt = strRgt WHERE id = @currentDataSetStrParentId;\n\n                            INSERT INTO copy_scenario_structure_into_dataset_structure VALUES (strId, @scenario, @currentStrParentId, rootI, projectI, projectR, @dsStrType,\n                                strName, strDesc, strCr, strUp, strLft, strRgt, strLvl, dsRootI, NULL, dsRootI\n                            );\n\n                            OPEN curseurDataLines;\n                                SELECT FOUND_ROWS() into nbElts2;\n\n                                IF nbElts2 = 1 THEN\n                                    FETCH NEXT FROM curseurDataLines INTO dlI;\n\n                                    # Répercussion sur les lignes des jeux de données.\n                                    UPDATE ei_data_line SET ei_data_set_structure_id = @lastDsID WHERE ei_data_set_structure_id = strId\n                                        AND id NOT IN (SELECT id FROM copy_scenario_structure_into_dataset_structure_data_line);\n\n                                    # Insertion dans la table temporaire.\n                                    INSERT INTO copy_scenario_structure_into_dataset_structure_data_line VALUES (dlI, strId, @lastDsID);\n                                END IF;\n                            CLOSE curseurDataLines;\n\n                            # Puis, on parcours les fils.\n                            WHILE ( cpt < nbElts) DO\n                                # On capture le nouvel élément.\n                                FETCH NEXT FROM curseurStructure INTO strId, strParentId, rootI, projectI, projectR, strType, strName, strDesc, strCr, strUp, strLft,\n                                    strRgt, strLvl, dsRootI;\n\n                                # On détermine le type de noeud en fonction du type d'élément.\n                                IF strType = 'BlockScenario' THEN\n                                    SET @dsStrType = 'NodeDataSet';\n                                ELSE\n                                    SET @dsStrType = 'LeafDataSet';\n                                END IF;\n\n                                SET @strId = strId;\n\n                                # On récupère l'ID de la structure parente.\n                                SELECT data_set_structure_id FROM copy_scenario_structure_into_dataset_structure WHERE id = strParentId INTO @currentDataSetStrParentId;\n\n                                # On insert l'élément dans la structure du jeu de données.\n                                INSERT INTO ei_data_set_structure (`ei_scenario_id`, `ei_dataset_structure_parent_id`, `root_id`, `project_id`, `project_ref`, `type`,\n                                    `name`, `description`, `created_at`, `updated_at`, `lft`, `rgt`, `level`) VALUES ( @scenario, @currentDataSetStrParentId, dsRootI,\n                                    projectI, projectR, @dsStrType, strName, strDesc, strCr, strUp, strLft, strRgt, strLvl\n                                );\n\n                                SET @lastDsID = LAST_INSERT_ID();\n\n                                # On insert l'élément de la structure du scénario avec les infos de l'élément de la structure du jeu de données lié.\n                                INSERT INTO copy_scenario_structure_into_dataset_structure VALUES (strId, @scenario, strParentId, rootI, projectI, projectR, @dsStrType,\n                                    strName, strDesc, strCr, strUp, strLft, strRgt, strLvl, @lastDsID, @currentDataSetStrParentId, dsRootI\n                                );\n\n                                # Parcours des lignes du jeu de données à convertir.\n                                OPEN curseurDataLines;\n                                    SET cpt2 = 1;\n                                    SELECT FOUND_ROWS() into nbElts2;\n\n                                    # Parcours des éléments.\n                                    WHILE (cpt2 <= nbElts2) DO\n                                        FETCH NEXT FROM curseurDataLines INTO dlI;\n\n                                        # Répercussion sur les lignes des jeux de données.\n                                        UPDATE ei_data_line SET ei_data_set_structure_id = @lastDsID WHERE ei_data_set_structure_id = strId\n                                            AND id NOT IN (SELECT id FROM copy_scenario_structure_into_dataset_structure_data_line);\n\n                                        # Insertion dans la table temporaire.\n                                        INSERT INTO copy_scenario_structure_into_dataset_structure_data_line VALUES (dlI, strId, @lastDsID);\n\n                                        # Incrémentation du compteur.\n                                        SET cpt2 = cpt2 + 1;\n                                    END WHILE;\n\n                                CLOSE curseurDataLines;\n\n                                # Incrémentation du compteur.\n                                SET cpt = cpt + 1;\n\n                            END WHILE;\n                        END IF;\n\n                        CLOSE curseurStructure;\n\n                    END IF;\n\n                UNTIL done\n                END REPEAT;\n\n                OPEN curseurNotMatchedDataLines;\n                    SET cpt2 = 1;\n                    SELECT FOUND_ROWS() into nbElts2;\n\n                    # Parcours des éléments.\n                    WHILE (cpt2 <= nbElts2) DO\n                        FETCH NEXT FROM curseurNotMatchedDataLines INTO dlI, dlDsI;\n\n                        SET @scenarioStrId = dlDsI;\n\n                        OPEN curseurMatchedDataSetDataLine;\n                            SELECT FOUND_ROWS() into nbElts;\n\n                            IF nbElts = 1 THEN\n                                FETCH NEXT FROM curseurMatchedDataSetDataLine INTO dlDsI;\n\n                                SET @dlDsI = dlDsI;\n\n                                # Répercussion sur les lignes des jeux de données.\n                                UPDATE ei_data_line SET ei_data_set_structure_id = @dlDsI WHERE ei_data_set_structure_id = @scenarioStrId\n                                    AND id NOT IN (SELECT id FROM copy_scenario_structure_into_dataset_structure_data_line);\n\n                                # Insertion dans la table temporaire.\n                                INSERT INTO copy_scenario_structure_into_dataset_structure_data_line VALUES (dlI, @scenarioStrId, @dlDsI);\n                            END IF;\n                        CLOSE curseurMatchedDataSetDataLine;\n\n                        # Incrémentation du compteur.\n                        SET cpt2 = cpt2 + 1;\n                    END WHILE;\n                CLOSE curseurNotMatchedDataLines;\n\n                IF haveToDrop = 0 THEN\n                    # Création du lien FK sur le champ ei_data_set_structure_id de la table ei_data_line.\n                    ALTER TABLE ei_data_line ADD CONSTRAINT FOREIGN KEY ei_data_line_ei_data_set_structure_id_ei_data_set_structure_id (ei_data_set_structure_id)\n                        REFERENCES ei_data_set_structure(id) ON UPDATE RESTRICT ON DELETE CASCADE;\n                END IF;\n\n                SELECT * FROM copy_scenario_structure_into_dataset_structure;\n                SELECT * FROM copy_scenario_structure_into_dataset_structure_data_line;\n\n                COMMIT;\n            END;\n        ";
     $sqlCallCopy = "CALL copyScenarioStructureToDataSetStructure();";
     try {
         $this->log("Create roots elements for data set structure.");
         $this->log("Drop old procedure if exists.");
         $conn->execute($sqlDrop);
         $this->log("Create procedure.");
         $conn->execute($sqlCreate);
         $this->log("Call procedure.");
         $conn->execute($sqlCall);
         $this->log("Drop procedure.");
         $conn->execute($sqlDrop);
         $this->log("done...");
         $this->log("Copy scenario structure into empties data set structure.");
         $this->log("Drop old procedure if exists.");
         $conn->execute($sqlDropCopy);
         $this->log("Create procedure.");
         $conn->execute($sqlCreateCopy);
         $this->log("Call procedure.");
         $conn->execute($sqlCallCopy);
         $this->log("Drop procedure.");
         $conn->execute($sqlDropCopy);
     } catch (Exception $exc) {
         $this->log($exc->getMessage());
     }
     /*
             $this->log('Récupération des paramètres...OK');
     
             // Création de la requête permettant
             $this->log('Création de la requête d\'insertion...');
     
             $requeteToInsert = "INSERT INTO ei_param_block_function_mapping (ei_param_function_id, created_at, updated_at, ei_function_id) ";
             $requeteToInsert.= "VALUES(#{PARAM_ID}, now(), now(), #{FONCTION_ID});";
             $pile = array();
     
             foreach( $parametres->fetchAll() as $parametre ){
                 // Remplacement PARAM ID.
                 $tmpRequete = str_replace("#{PARAM_ID}", $parametre["param_id"], $requeteToInsert);
                 // Remplacement FONCTION ID.
                 $tmpRequete = str_replace("#{FONCTION_ID}", $parametre["id"], $tmpRequete);
     
                 // Ajout dans la requête globale.
                 $pile[] = $tmpRequete;
             }
     
             // Préparation de la requête.
             $this->log("Préparation de la requête...");
     
             $requete = implode(" ",$pile);
     
             try{
                 // Exécution de la requête.
                 $this->log("Exécution de la requête...");
     
                 $conn->execute($requete);
     
                 // Fin.
                 $this->log("Processus terminé avec succès.");
             }
             catch( Exception $exc ){
                 $this->log($exc->getMessage());
             }
     */
 }
 protected function execute($arguments = array(), $options = array())
 {
     // Context
     $context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', $options['env'], true));
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     // add your code here
     // server id
     $server = $arguments['server'];
     $this->log("[INFO] Start server with '{$server}'");
     $etva_server = EtvaServerPeer::retrieveByPK($server);
     if (!$etva_server) {
         $etva_server = EtvaServerPeer::retrieveByUuid($server);
     }
     if (!$etva_server) {
         $etva_server = EtvaServerPeer::retrieveByName($server);
     }
     if (!$etva_server) {
         $msg_i18n = $context->getI18N()->__(EtvaServerPeer::_ERR_NOTFOUND_, array('name' => $server));
         $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
         $this->log("[ERROR] " . $error['error']);
         return $error;
     } else {
         if ($nid = $options['node']) {
             if (!($etva_node = EtvaNodePeer::retrieveByPK($nid))) {
                 //notify event log
                 $msg_i18n = Etva::makeNotifyLogMessage(sfConfig::get('config_acronym'), EtvaNodePeer::_ERR_NOTFOUND_ID_, array('id' => $nid), EtvaServerPeer::_ERR_START_, array('name' => $server));
                 $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
                 $this->log("[ERROR] " . $error['error']);
                 return $error;
             }
         } else {
             // get list of nodes that server can assign
             $nodes_toassign = $etva_server->listNodesAssignTo();
             if (count($nodes_toassign)) {
                 $etva_node = $nodes_toassign[0];
                 // get first
             } else {
                 //notify event log
                 $msg_i18n = Etva::makeNotifyLogMessage(sfConfig::get('config_acronym'), EtvaServerPeer::_ERR_NO_NODE_TO_ASSIGN_, array(), EtvaServerPeer::_ERR_START_, array('name' => $server));
                 $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
                 $this->log("[ERROR] " . $error['error']);
                 return $error;
             }
         }
         $server_va = new EtvaServer_VA($etva_server);
         if ($options['assign'] || $etva_server->getUnassigned()) {
             // Assign server to node
             $response = $server_va->send_assign($etva_node);
             if (!$response['success']) {
                 $this->log("[ERROR] " . $response['error']);
                 return $response;
             }
         }
         // start server
         $response = $server_va->send_start($etva_node);
         if ($response['success']) {
             // update GA Info
             $response_ga = $server_va->getGAInfo($etva_node);
             $this->log("[INFO] " . $response['response']);
         } else {
             $this->log("[ERROR] " . $response['error']);
         }
         return $response;
     }
 }
 protected function execute($arguments = array(), $options = array())
 {
     $context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', $options['env'], true));
     parent::execute($arguments, $options);
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     // add your code here
     $this->log('Checking shared storage cluster consistency...' . "\n");
     $ok = 1;
     $affected = 0;
     $errors = array();
     $clusters = EtvaClusterPeer::doSelect(new Criteria());
     foreach ($clusters as $cluster) {
         $bulk_response_lvs = $cluster->soapSend('getlvs_arr', array('force' => 1));
         $bulk_response_dtable = $cluster->soapSend('device_table');
         $lv_va = new EtvaLogicalvolume_VA();
         foreach ($bulk_response_lvs as $node_id => $node_response) {
             if ($node_response['success']) {
                 //response received ok
                 $lvs = (array) $node_response['response'];
                 $node = EtvaNodePeer::retrieveByPK($node_id);
                 //$consist = $lv_va->check_shared_consistency($node,$lvs);
                 $response_dtable = (array) $bulk_response_dtable[$node_id];
                 $dtable = array();
                 if ($response_dtable['success']) {
                     $dtable = (array) $response_dtable['response'];
                     //$consist_dtable = $lv_va->check_shared_devicetable_consistency($node,$dtable,$bulk_response_dtable);
                 }
                 $check_res = $lv_va->check_consistency($node, $lvs, $dtable, $bulk_response_dtable);
                 if (!$check_res['success']) {
                     $err = $check_res['errors'];
                     $msg = sfContext::getInstance()->getI18N()->__(EtvaLogicalvolumePeer::_ERR_INCONSISTENT_, array('%info%' => ''));
                     $err_msg = sprintf(" node with id=%s is not consistent: %s \n", $node_id, $msg);
                     $errors[] = array('message' => $err_msg, 'debug' => $err);
                     $affected++;
                     $node->setErrorMessage(EtvaLogicalvolume_VA::LVINIT);
                 } else {
                     $node->clearErrorMessage(EtvaLogicalvolume_VA::LVINIT);
                 }
                 /*if( !$consist || !$consist_dtable ){
                                     $errors = $lv_va->get_missing_lv_devices();
                                     $msg = $errors ? $errors['message'] :
                                                     sfContext::getInstance()->getI18N()->__(EtvaLogicalvolumePeer::_ERR_INCONSISTENT_,array('%info%'=>''));
                 
                                     $err_msg = sprintf( " node with id=%s is not consistent: %s \n", $node_id, $msg );
                                     $errors[] = array( 'message'=> $err_msg, 'debug'=>array( 'consist_lvs'=>$consist, 'consist_dtable'=>$consist_dtable ) );
                                     $affected++;
                                     $node->setErrorMessage(EtvaLogicalvolume_VA::LVINIT);
                                 } else {
                                     $node->clearErrorMessage(EtvaLogicalvolume_VA::LVINIT);
                                 }*/
             } else {
                 $errors[] = $node_response;
                 $affected++;
             }
         }
         $bulk_response_pvs = $cluster->soapSend('hash_phydisks', array('force' => 1));
         $pv_va = new EtvaPhysicalvolume_VA();
         foreach ($bulk_response_pvs as $node_id => $node_response) {
             if ($node_response['success']) {
                 //response received ok
                 $pvs = (array) $node_response['response'];
                 $node = EtvaNodePeer::retrieveByPK($node_id);
                 $check_res = $pv_va->check_consistency($node, $pvs);
                 if (!$check_res['success']) {
                     $err = $check_res['errors'];
                     $msg = sfContext::getInstance()->getI18N()->__(EtvaPhysicalvolumePeer::_ERR_INCONSISTENT_, array('%info%' => ''));
                     $err_msg = sprintf(" node with id=%s is not consistent: %s \n", $node_id, $msg);
                     $errors[] = array('message' => $err_msg, 'debug' => $err);
                     $affected++;
                     $node->setErrorMessage(EtvaPhysicalvolume_VA::PVINIT);
                 } else {
                     $node->clearErrorMessage(EtvaPhysicalvolume_VA::PVINIT);
                 }
             } else {
                 $errors[] = $node_response;
                 $affected++;
             }
         }
         $bulk_responses_vgs = $cluster->soapSend('getvgpvs', array('force' => 1));
         $vg_va = new EtvaVolumegroup_VA();
         foreach ($bulk_response_vgs as $node_id => $node_response) {
             if ($node_response['success']) {
                 //response received ok
                 $vgs = (array) $node_response['response'];
                 $node = EtvaNodePeer::retrieveByPK($node_id);
                 $check_res = $vg_va->check_consistency($node, $vgs);
                 if (!$check_res['success']) {
                     $err = $check_res['errors'];
                     $msg = sfContext::getInstance()->getI18N()->__(EtvaVolumegroupPeer::_ERR_INCONSISTENT_, array('%info%' => ''));
                     $err_msg = sprintf(" node with id=%s is not consistent: %s \n", $node_id, $msg);
                     $errors[] = array('message' => $err_msg, 'debug' => $err);
                     $affected++;
                     $node->setErrorMessage(EtvaVolumegroup_VA::VGINIT);
                 } else {
                     $node->clearErrorMessage(EtvaVolumegroup_VA::VGINIT);
                 }
             } else {
                 $errors[] = $node_response;
                 $affected++;
             }
         }
     }
     if (!empty($errors)) {
         $this->log($message);
     } else {
         // log the message!
         $this->log("The check shared storage cluster consistency task ran!", 6);
     }
 }
 protected function execute($arguments = array(), $options = array())
 {
     $context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', $options['env'], true));
     parent::execute($arguments, $options);
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $con = $databaseManager->getDatabase($options['connection'])->getConnection();
     // add your code here
     $this->log('[INFO] Checking Servers heartbeat...' . "\n");
     $servers_timeout = EtvaServerQuery::create()->filterByVmState(EtvaServer::RUNNING)->filterByGaState(EtvaServerPeer::_GA_RUNNING_)->filterByHasha(1)->where('hbtimeout>0 AND UNIX_TIMESTAMP(heartbeat) < (UNIX_TIMESTAMP(now()) - hbtimeout)')->useEtvaServerAssignQuery('ServerAssign', 'RIGHT JOIN')->useEtvaNodeQuery()->filterByState(EtvaNode::NODE_ACTIVE)->endUse()->endUse()->find();
     if (count($servers_timeout) > 0) {
         foreach ($servers_timeout as $etva_server) {
             $message = sprintf(' The server %s with id %s get heartbeat timed out (last heartbeat at %s and heartbeat timeout %s secods)', $etva_server->getName(), $etva_server->getId(), $etva_server->getHeartbeat(), $etva_server->getHbtimeout());
             $this->log($message);
             // add log message
             Etva::makeNotifyLogMessage($this->name, $message);
             $etva_node = $etva_server->getEtvaNode();
             $server_va = new EtvaServer_VA($etva_server);
             $response_ga = $etva_server->getGAInfo($etva_node);
             if (!$response_ga['success']) {
                 $msg = sprintf(' Something wrong with node %s agent, can\'t get GA state of the server %s with id %s run.', $etva_node->getName(), $etva_server->getName(), $etva_server->getId());
                 $this->log($msg);
                 // add log message
                 Etva::makeNotifyLogMessage($this->name, $msg);
                 $etva_server->setGaState(EtvaServerPeer::_GA_STOPPED_);
                 // mark GA as stopped
                 $etva_server->save();
             } else {
                 if ($reponse_ga['ga_state'] == EtvaServerPeer::_GA_RUNNING_) {
                     $message_ga = sprintf(' But the explicit check GA state of the server %s with id %s run with success.', $etva_server->getName(), $etva_server->getId());
                     $this->log($message_ga);
                     // add log message
                     Etva::makeNotifyLogMessage($this->name, $message_ga, array(), null, array(), EtvaEventLogger::INFO);
                 } else {
                     // go restart
                     $starttime = sfConfig::get('app_server_heartbeat_starttime');
                     $starttime_date = date("c", time() - $starttime);
                     if ($etva_server->getHblaststart() && $etva_server->getHblaststart() > $starttime_date) {
                         $msg = sprintf(' the server %s with id %s is in starttime.', $etva_server->getName(), $etva_server->getId());
                         $this->log($msg);
                         // add log message
                         Etva::makeNotifyLogMessage($this->name, $msg, array(), null, array(), EtvaEventLogger::INFO);
                     } else {
                         $last_nrestarts = $etva_server->getHbnrestarts();
                         if ($last_nrestarts >= sfConfig::get('app_server_heartbeat_number_of_restart')) {
                             $msg = sprintf(' the server %s with id %s exceed number of restart.', $etva_server->getName(), $etva_server->getId());
                             $this->log($msg);
                             // add log message
                             Etva::makeNotifyLogMessage($this->name, $msg);
                         } else {
                             $msg = sprintf(' the server %s with id %s is heartbeat out of date and will be restart.', $etva_server->getName(), $etva_server->getId());
                             $this->log($msg);
                             // add log message
                             Etva::makeNotifyLogMessage($this->name, $msg, array(), null, array(), EtvaEventLogger::INFO);
                             // force to stop
                             $response_stop = $server_va->send_stop($etva_node, array('force' => 1, 'destroy' => 1));
                             sleep(5);
                             // wait a few seconds
                             $response_start = $server_va->send_start($etva_node);
                             if (!$response_start['success']) {
                                 // start fail...
                                 sleep(10);
                                 // wait a few seconds
                                 $response_start = $server_va->send_start($etva_node);
                                 // start again
                             }
                             $etva_server->resetHeartbeat(EtvaServerPeer::_GA_STOPPED_);
                             // reset heartbeat and mark GA as stopped
                             $etva_server->setHbnrestarts($last_nrestarts + 1);
                             // inc number of restart
                             $etva_server->save();
                         }
                     }
                 }
             }
         }
     } else {
         $this->log("[INFO] No servers with heartbeat timed out.");
     }
     // log the message!
     $this->log("[INFO] The check servers heartbeat task ran!");
 }