Exemplo n.º 1
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())
 {
     $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);
 }
Exemplo n.º 3
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
     // 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;
 }
Exemplo n.º 4
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;
     }
 }
Exemplo n.º 5
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
     // 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;
 }
Exemplo n.º 6
0
 public function soapSend($method, $params = null, EtvaNode $except_node = null, $forceRequest = false, $rcv_timeout = 0, $all = false)
 {
     $c = new Criteria();
     if ($except_node) {
         $c->add(EtvaNodePeer::UUID, $except_node->getUuid(), Criteria::ALT_NOT_EQUAL);
     }
     if (!$all) {
         $c->add(EtvaNodePeer::INITIALIZE, EtvaNode::INITIALIZE_OK, Criteria::EQUAL);
     }
     $c->add(EtvaNodePeer::CLUSTER_ID, $this->getId());
     $all_nodes = EtvaNodePeer::doSelect($c);
     $responses = array();
     foreach ($all_nodes as $node) {
         $responses[$node->getId()] = $node->soapSend($method, $params, $forceRequest, $rcv_timeout);
     }
     return $responses;
 }
Exemplo n.º 7
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] 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;
     }
 }
Exemplo n.º 8
0
 public function check_all_see_it(EtvaNode $etva_node, $bulk_responses)
 {
     $errors = array();
     foreach ($bulk_responses as $node_id => $node_response) {
         if ($node_response['success']) {
             $node = EtvaNodePeer::retrieveByPK($node_id);
             $vgs = $node_response['response'];
             $found = false;
             foreach ($vgs as $vg => $vgInfo) {
                 $vg_info = (array) $vgInfo;
                 $vg_type = $vg_info[EtvaVolumegroup::STORAGE_TYPE_MAP];
                 $vg_name = $vg_info[EtvaVolumegroup::VG_MAP];
                 if ($vg_type == $this->etva_vg->getStorageType()) {
                     if ($vg_type == EtvaVolumegroup::STORAGE_TYPE_LOCAL_MAP) {
                         if ($vg_name == $this->etva_vg->getVg()) {
                             $found = true;
                         }
                     } else {
                         if (isset($vg_info[EtvaVolumegroup::UUID_MAP])) {
                             $vg_uuid = $vg_info[EtvaVolumegroup::UUID_MAP];
                             if ($vg_uuid == $this->etva_vg->getUuid()) {
                                 $found = true;
                             }
                         } else {
                             if ($vg_name == $this->etva_vg->getVg()) {
                                 $found = true;
                             }
                         }
                     }
                 }
                 if ($found) {
                     break;
                 }
             }
             if (!$found) {
                 $errors[$node_id] = array('node_id' => $node_id, 'uuid' => $this->etva_vg->getUuid(), 'vg' => $this->etva_vg->getVg(), 'found' => true);
             }
             /*$node_init = $this->initialize($node,(array) $node_response['response']);
             
                             if(!$node_init['success']){
                                 $errors[$node_id] = $node_init;
                             } else {
                                 //notify system log
                                 $message = Etva::getLogMessage(array(), EtvaVolumegroupPeer::_OK_SOAPREFRESH_);
                                 sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($node_response['agent'], 'event.log',array('message' => $message)));
                             }*/
         } else {
             /*$message = Etva::getLogMessage(array('info'=>$node_response['info']), EtvaVolumegroupPeer::_ERR_SOAPREFRESH_);
               sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($node_response['agent'], 'event.log',array('message' => $message,'priority'=>EtvaEventLogger::ERR)));*/
         }
     }
     if (!empty($errors)) {
         return array('success' => false, 'errors' => $errors);
     } else {
         return array('success' => 'true');
     }
 }
Exemplo n.º 9
0
 public function restore($backup_id)
 {
     //clear stage cache
     $this->delStage(self::RESTORE_STAGE);
     chdir(sfConfig::get('sf_root_dir'));
     /*
      * TELL VA to reset stuff
      */
     $node_list = EtvaNodePeer::doSelect(new Criteria());
     $node_num = count($node_list);
     if ($node_num != 1) {
         /*
          * ERROR should be only one element (standard ETVA release only)
          */
         $msg = "Sould only be one Virtualization Agent! {$node_num} found!";
         $data = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'info' => $msg, 'error' => $msg);
         return $data;
     }
     $node = $node_list[0];
     /*
      * check node state ok to comm with agent
      */
     if (!$node->getState()) {
         $node_name = $node->getName();
         $msg = sfContext::getInstance()->getI18N()->__(EtvaNodePeer::_STATE_DOWN_, array('%name%' => $node_name));
         $data = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'action' => 'check_nodes', 'info' => $msg, 'error' => $msg);
         return $data;
     }
     $this->disable();
     /*
      *
      * FIRST THING....CLEANUP DESTINATION FOLDER AND GET RESTORE ARCHIVE
      *
      */
     IOFile::unlinkRecursive($this->archive_base_dir, false);
     $full_path = $this->archive_base_dir . '/' . self::ARCHIVE_FILE;
     $this->setStage(self::RESTORE_STAGE, self::GET_RESTORE);
     $response = $this->getApplianceBackup($backup_id, $full_path);
     /*
      *
      * DECOMPRESS BACKUP ARCHIVE
      *
      */
     $this->setStage(self::RESTORE_STAGE, self::ARCHIVE_RESTORE);
     $create_gz = new gzip_file($full_path);
     $base_dir = $this->archive_base_dir;
     $create_gz->set_options(array('basedir' => $base_dir, 'overwrite' => 1));
     $create_gz->extract_files();
     /*
      * get DB file and put in tmp_db_filename
      */
     $db_filename = $base_dir . '/' . self::DB_FILE;
     if (!file_exists($db_filename)) {
         return array('success' => false, 'error' => 'no file');
     }
     // move DB backup to correct folder...
     rename($db_filename, $this->tmp_db_filename);
     /*
      *
      * CLEAN DB ????
      *
      */
     /*
      * delete tables and build again....
      */
     $command = "symfony propel:insert-sql --no-confirmation";
     $path = sfConfig::get('sf_root_dir') . DIRECTORY_SEPARATOR . "utils";
     ob_start();
     passthru('echo ' . $command . ' | sudo /usr/bin/php -f ' . $path . DIRECTORY_SEPARATOR . 'sudoexec.php', $return);
     $result = ob_get_contents();
     ob_end_clean();
     if ($result != 0 || $return != 0) {
         $msg = 'An error occurred while deleting DB. Aborted!' . $status;
         $data = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'action' => self::DB_RESTORE, 'info' => $msg, 'error' => $msg);
         return $data;
     }
     /*
      *
      * RESTORE CENTRAL MANAGEMENT BACKUP (DB)
      *
      *
      */
     $this->setStage(self::RESTORE_STAGE, self::DB_RESTORE);
     /*
      * load data to DB
      */
     //sfContext::getInstance()->getStorage()->regenerate(true);
     exec("symfony propel:data-load " . $this->tmp_db_filename, $output, $status);
     if ($status != 0) {
         // aconteceu erro
         $msg = 'An error occurred while generating DB dump. Aborted!' . $status;
         $data = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'action' => self::DB_RESTORE, 'info' => $msg, 'error' => $msg);
         return $data;
     }
     /*
      * 
      * generate session to stay logged in...
      *
      */
     sfContext::getInstance()->getStorage()->regenerate();
     $this->setStage(self::RESTORE_STAGE, self::VA_RESET);
     $node_va = new EtvaNode_VA($node);
     /*
      * get new uuid from DB
      */
     $backup_node = EtvaNodePeer::doSelectOne(new Criteria());
     $uuid = $backup_node->getUuid();
     $response = $node_va->send_change_uuid($uuid);
     if (!$response['success']) {
         return $response;
     }
     $response = array('success' => true);
     return $response;
 }
Exemplo n.º 10
0
 public static function getAgentFiles($method)
 {
     $apli = new Appliance();
     switch ($method) {
         case 'get_diagnostic_progress':
             $action = $apli->getStage(Appliance::BACKUP_STAGE);
             error_log("[ACTION] {$action}");
             switch ($action) {
                 case Appliance::DB_BACKUP:
                     $txt = 'Perfoming DB backup...';
                     $result = array('success' => true, 'txt' => $txt, 'action' => $action);
                     break;
                 case Appliance::ARCHIVE_BACKUP:
                     $txt = 'Creating compressed archive...';
                     $result = array('success' => true, 'txt' => $txt, 'action' => $action);
                     break;
                 default:
                     $result = array('success' => true, 'txt' => $action, 'action' => $action);
             }
             break;
         case 'diagnostic':
             #                $force = $request->getParameter('force');
             $result = $apli->backup(true, true);
             // generate tarball with logs
             $filepath = sfConfig::get("app_remote_log_file");
             $scriptfile = sfConfig::get("app_remote_log_script");
             #                putenv("ETVADIAGNOSTIC=symfony");
             $command = "/bin/bash {$scriptfile} {$filepath}";
             $node_list = EtvaNodePeer::doSelect(new Criteria());
             foreach ($node_list as $node) {
                 $name = $node->getName();
                 $ip = $node->getIp();
                 $port = $node->getPort();
                 $command .= " {$name} {$ip} {$port}";
             }
             $command .= ' 2>&1';
             error_log('[COMMAND]' . $command);
             $path = sfConfig::get('sf_root_dir') . DIRECTORY_SEPARATOR . "utils";
             error_log("[INFO] PATH TO SUDOEXEC" . $path . DIRECTORY_SEPARATOR);
             ob_start();
             passthru('echo ' . $command . ' | sudo /usr/bin/php -f ' . $path . DIRECTORY_SEPARATOR . 'sudoexec.php', $return);
             #$content_grabbed=ob_get_contents();
             ob_end_clean();
             #$output = shell_exec($command);
             error_log("[INFO] Script diagnostic_ball has exited.");
             error_log("[INFO] " . $return);
             if ($return != 0) {
                 $result['success'] = false;
             } else {
                 $mail_success = diagnostic::sendDiagnosticEmail();
                 if (!$mail_success) {
                     //$str = implode("\n", $mail_success);
                     $result['mail_errors'] = 'email errors';
                 }
             }
             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...';
                 }
             }
             break;
         default:
             $result = array('success' => true, 'data' => array());
             break;
     }
     return $result;
 }
 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);
     }
 }
Exemplo n.º 12
0
 public function executeJsonUnregister(sfWebRequest $request)
 {
     $msg_ok_type = EtvaLogicalvolumePeer::_OK_UNREGISTER_;
     $msg_err_type = EtvaLogicalvolumePeer::_ERR_UNREGISTER_;
     // get node id
     if (!($etva_node = EtvaNodePeer::retrieveByPK($request->getParameter('nid')))) {
         // ... or elect from cluster context
         $etva_node = EtvaNodePeer::getOrElectNode($request);
     }
     if (!$etva_node) {
         $msg_i18n = $this->getContext()->getI18N()->__(EtvaNodePeer::_ERR_NOTFOUND_ID_, array('%id%' => $nid));
         $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
         $node_log = Etva::getLogMessage(array('id' => $nid), EtvaNodePeer::_ERR_NOTFOUND_ID_);
         //notify system log
         $this->dispatcher->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $node_log, 'priority' => EtvaEventLogger::ERR)));
         // if is a CLI soap request return json encoded data
         if (sfConfig::get('sf_environment') == 'soap') {
             return json_encode($error);
         }
         // if is browser request return text renderer
         $error = $this->setJsonError($error);
         return $this->renderText($error);
     }
     $lv = $request->getParameter('lv');
     $vg = $request->getParameter('vg');
     $uuid = $request->getParameter('uuid');
     if (!($etva_logicalvolume = $etva_node->retrieveLogicalvolume($uuid, $vg, $lv))) {
         //lv is the logical volume name
         $msg = Etva::getLogMessage(array('name' => $lv), EtvaLogicalvolumePeer::_ERR_NOTFOUND_);
         $msg_i18n = $this->getContext()->getI18N()->__(EtvaLogicalvolumePeer::_ERR_NOTFOUND_, array('%name%' => $lv));
         $error = array('success' => false, 'agent' => $etva_node->getName(), 'error' => $msg_i18n, 'info' => $msg_i18n);
         //notify system log
         $message = Etva::getLogMessage(array('name' => $lv, 'info' => $msg), EtvaLogicalvolumePeer::_ERR_UNREGISTER_);
         $this->dispatcher->notify(new sfEvent($error['agent'], 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
         // if is a CLI soap request return json encoded data
         if (sfConfig::get('sf_environment') == 'soap') {
             return json_encode($error);
         }
         // if is browser request return text renderer
         $error = $this->setJsonError($error);
         return $this->renderText($error);
     }
     $etva_lv_va = new EtvaLogicalvolume_VA($etva_logicalvolume);
     $response = $etva_lv_va->unregister($etva_node);
     if (!$response['success']) {
         $msg_i18n = $this->getContext()->getI18N()->__($msg_err_type, array('%name%' => $lv));
         $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
         $node_log = Etva::getLogMessage(array('name' => $lv), $msg_err_type);
         //notify system log
         $this->dispatcher->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $node_log, 'priority' => EtvaEventLogger::ERR)));
         // if is a CLI soap request return json encoded data
         if (sfConfig::get('sf_environment') == 'soap') {
             return json_encode($error);
         }
         // if is browser request return text renderer
         $error = $this->setJsonError($error);
         return $this->renderText($error);
     }
     //notify system log
     $message = Etva::getLogMessage(array('name' => $lv), $msg_ok_type);
     $msg_i18n = sfContext::getInstance()->getI18N()->__($msg_ok_type, array('%name%' => $lv));
     sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($etva_node->getName(), 'event.log', array('message' => $message)));
     $result = array('success' => true, 'agent' => $etva_node->getName(), 'response' => $msg_i18n);
     $return = json_encode($result);
     if (sfConfig::get('sf_environment') == 'soap') {
         return $return;
     }
     $this->getResponse()->setHttpHeader('Content-type', 'application/json');
     return $this->renderText($return);
 }
Exemplo n.º 13
0
 public function executeJsonPermsWithGroupsUsers($request)
 {
     $isAjax = $request->isXmlHttpRequest();
     //        if(!$isAjax) return $this->redirect('@homepage');
     $level = $request->getParameter('level');
     $id = $request->getParameter('id');
     $p_permtype = $request->getParameter('permtype');
     $u = new Criteria();
     $g = new Criteria();
     $elements = array();
     $elements['id'] = 1;
     // if has node level, find clusterid
     if ($level == 'node') {
         $c = new Criteria();
         $c->add(EtvaNodePeer::ID, $id);
         $node = EtvaNodePeer::doSelectOne($c);
         $id = $node->getClusterId();
         $level = 'cluster';
     }
     if ($level == 'server') {
         $users = EtvaPermissionUserQuery::create()->useEtvaPermissionQuery()->filterByPermType($p_permtype)->useEtvaPermissionServerQuery()->filterByServerId($id)->endUse()->endUse()->find();
         foreach ($users as $user) {
             $elements['etva_permission_user_list'][] = $user->getUserId();
         }
         $groups = EtvaPermissionGroupQuery::create()->useEtvaPermissionQuery()->filterByPermType($p_permtype)->useEtvaPermissionServerQuery()->filterByServerId($id)->endUse()->endUse()->find();
         foreach ($groups as $group) {
             $elements['etva_permission_group_list'][] = $group->getGroupId();
         }
     } elseif ($level == 'cluster') {
         $users = EtvaPermissionUserQuery::create()->useEtvaPermissionQuery()->filterByPermType($p_permtype)->useEtvaPermissionClusterQuery()->filterByClusterId($id)->endUse()->endUse()->find();
         foreach ($users as $user) {
             $elements['etva_permission_user_list'][] = $user->getUserId();
         }
         $groups = EtvaPermissionGroupQuery::create()->useEtvaPermissionQuery()->filterByPermType($p_permtype)->useEtvaPermissionClusterQuery()->filterByClusterId($id)->endUse()->endUse()->find();
         foreach ($groups as $group) {
             $elements['etva_permission_group_list'][] = $group->getGroupId();
         }
     } else {
         $info = array('success' => false, 'error' => 'Wrong parameters');
         $error = $this->setJsonError($info);
         return $this->renderText($error);
     }
     $final = array('total' => 1, 'data' => $elements);
     $result = json_encode($final);
     $this->getResponse()->setHttpHeader('Content-type', 'application/json');
     return $this->renderText($result);
 }
Exemplo n.º 14
0
 public function initialize($data)
 {
     $uuid = $data['uuid'];
     $etva_data = Etva::getEtvaModelFile();
     if (!$etva_data) {
         $error_msg = 'Could not process etva-model.conf';
         $error = array('success' => false, 'error' => $error_msg);
         //notify system log
         $message = Etva::getLogMessage(array('name' => $data['name'], 'info' => $error_msg), EtvaNodePeer::_ERR_SOAPINIT_);
         sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
         return $error;
     }
     $etvamodel = $etva_data['model'];
     $c = new Criteria();
     $c->add(EtvaNodePeer::UUID, $uuid);
     $etva_node = EtvaNodePeer::doSelectOne($c);
     if ($etva_node) {
         if ($etva_node->getState() < EtvaNode::NODE_INACTIVE) {
             // dont touch
             //$data['state'] = $etva_node->getState();
             $data['state'] = $this->calcState($etva_node, EtvaNode::NODE_ACTIVE);
         }
         if (!isset($data['isSpareNode'])) {
             $data['isSpareNode'] = $etva_node->getIssparenode() ? 1 : 0;
         }
         if (!isset($data['fencingconf'])) {
             $data['fencingconf'] = $etva_node->getFencingconf();
         }
         $data['cluster_id'] = $etva_node->getClusterId();
         $node_initialize = $etva_node->getInitialize();
         $data['initialize'] = $node_initialize;
         if (empty($node_initialize)) {
             $data['initialize'] = self::INITIALIZE_PENDING;
         }
         if ($etvamodel == 'standard') {
             $data['initialize'] = self::INITIALIZE_OK;
         } else {
             if ($node_initialize != self::INITIALIZE_OK) {
                 return array('success' => true);
             }
         }
         $data['id'] = $etva_node->getId();
         /*
          * calculate free mem
          */
         $etva_node->setMemtotal($data['memtotal']);
         $etva_node->updateMemFree();
         $data['memfree'] = $etva_node->getMemfree();
         $uuid = $etva_node->getUuid();
         $form = new EtvaNodeForm($etva_node);
     } else {
         /*
          * add default cluster ID to node
          */
         if (!($default_cluster = EtvaClusterPeer::retrieveDefaultCluster())) {
             $error_msg = sprintf('Default Object etva_cluster does not exist ');
             $error = array('success' => false, 'error' => $error_msg);
             //notify system log
             $cluster_message = Etva::getLogMessage(array('info' => $error_msg), EtvaClusterPeer::_ERR_DEFAULT_CLUSTER_);
             $message = Etva::getLogMessage(array('name' => $data['name'], 'info' => $cluster_message), EtvaNodePeer::_ERR_SOAPINIT_);
             sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
             return $error;
         }
         $data['cluster_id'] = $default_cluster->getId();
         $form = new EtvaNodeForm();
         $uuid = EtvaNodePeer::generateUUID();
         $data['initialize'] = self::INITIALIZE_PENDING;
         if ($etvamodel == 'standard') {
             $data['initialize'] = self::INITIALIZE_OK;
         }
         /*
          * calculate free mem
          */
         $etva_node = new EtvaNode();
         $etva_node->setMemtotal($data['memtotal']);
         $etva_node->updateMemFree();
         $etva_node->setClusterId($default_cluster->getId());
         $data['memfree'] = $etva_node->getMemfree();
         $data['uuid'] = $uuid;
     }
     $this->clearLastMessage();
     $result = $this->processNodeForm($data, $form);
     if (!$result['success']) {
         return $result;
     }
     // reset guest agent info
     $this->reset_gas_info($etva_node);
     /*
      *
      * check if has restore to perform....
      */
     $apli = new Appliance();
     $action = $apli->getStage(Appliance::RESTORE_STAGE);
     if ($action) {
         $backup_url = $apli->get_backupconf_url(Appliance::VA_ARCHIVE_FILE, $uuid, 'VA');
         if ($backup_url) {
             $result['reset'] = 1;
             $result['backup_url'] = $backup_url;
             /*
              * send pvs, vgs, lvs
              */
             $node_devs = $etva_node->getEtvaNodePhysicalvolumesJoinEtvaPhysicalvolume();
             $devs_va = array();
             foreach ($node_devs as $data) {
                 $dev = $data->getEtvaPhysicalvolume();
                 $devs_va[] = $dev->_VA();
             }
             $result['pvs'] = $devs_va;
             $node_vgs = $etva_node->getEtvaNodeVolumegroupsJoinEtvaVolumegroup();
             $vgs_va = array();
             foreach ($node_vgs as $data) {
                 $vg = $data->getEtvaVolumegroup();
                 $vgs_va[] = $vg->_VA();
             }
             $result['vgs'] = $vgs_va;
             $node_lvs = $etva_node->getEtvaNodeLogicalvolumesJoinEtvaLogicalvolume();
             $lvs_va = array();
             foreach ($node_lvs as $data) {
                 $lv = $data->getEtvaLogicalvolume();
                 $lvs_va[] = $lv->_VA();
             }
             $result['lvs'] = $lvs_va;
         }
         $apli->setStage(Appliance::RESTORE_STAGE, Appliance::VA_INIT);
     }
     return $result;
 }
Exemplo n.º 15
0
 public function hasDatacenterCredential($credential, $useAnd = true)
 {
     if ($this->isSuperAdmin()) {
         return true;
     }
     $p_permtype = $credential[0];
     $p_user_id = $this->getId();
     //$p_cluster_id = $credential[1];
     if (is_array($credential[1])) {
         $p_type_credential = (array) $credential[1];
         if ($p_type_credential['node']) {
             error_log("MYUSER:[INFO]Node id: " . $p_type_credential['node']);
             $dc_c = new Criteria();
             $dc_c->add(EtvaNodePeer::ID, $p_type_credential['node']);
             $node = EtvaNodePeer::doSelectOne($dc_c);
             $p_cluster_id = $node->getClusterId();
         } elseif ($p_type_credential['server']) {
             error_log("MYUSER:[INFO]Server id: " . $p_type_credential['server']);
             $dc_c = new Criteria();
             $dc_c->add(EtvaServerPeer::ID, (int) $p_type_credential['server'], Criteria::EQUAL);
             $server = EtvaServerPeer::doSelectOne($dc_c);
             $p_cluster_id = $server->getClusterId();
         } elseif ($p_type_credential['cluster']) {
             error_log("MYUSER:[INFO]Cluster id: " . $p_type_credential['cluster']);
             $p_cluster_id = (int) $p_type_credential['cluster'];
         } else {
             error_log('MYUSER:[ERROR] hasDatacenterCredential invalid parameters');
             return false;
         }
     } else {
         $p_cluster_id = $credential[1];
     }
     // Check if user has permission
     $c = new Criteria();
     $c->add(EtvaPermissionUserPeer::USER_ID, $p_user_id, Criteria::EQUAL);
     $c->addJoin(EtvaPermissionUserPeer::ETVAPERM_ID, EtvaPermissionPeer::ID);
     $c->add(EtvaPermissionPeer::PERM_TYPE, $p_permtype, Criteria::EQUAL);
     $c->addJoin(EtvaPermissionPeer::ID, EtvaPermissionClusterPeer::ETVAPERM_ID);
     $c->add(EtvaPermissionClusterPeer::CLUSTER_ID, $p_cluster_id);
     //error_log($c->toString());
     $permission = EtvaPermissionUserPeer::doSelect($c);
     if ($permission) {
         return true;
     }
     // Check if user groups have permission
     $grps = $this->getGroups();
     foreach ($grps as $value) {
         foreach ($value->getEtvaPermissionGroups() as $relObj) {
             $perm = $relObj->getEtvaPermission();
             // validates the permission type
             if ($perm->getPermType() == $p_permtype) {
                 // check if user has permission on the cluster
                 foreach ($perm->getEtvaPermissionClusters() as $clusters) {
                     if ($clusters->getClusterId() == $p_cluster_id) {
                         error_log("Permission:  " . $clusters->getClusterId());
                         return true;
                     }
                 }
             }
         }
     }
     // Permission not found
     return false;
 }
Exemplo n.º 16
0
 /**
  * Moves an unaccepted node to the given cluster
  * @param sfWebRequest $request
  * json, cluster id (target) and node id
  * @return json, success
  */
 public function executeJsonMoveNode(sfWebRequest $request)
 {
     $cluster_id = $request->getParameter('to_cluster_id');
     $node_id = $request->getParameter('node_id');
     try {
         $c = new Criteria();
         $c->add(EtvaNodePeer::ID, $node_id, Criteria::EQUAL);
         if (EtvaNodePeer::doCount($c) == 1) {
             $etva_node = EtvaNodePeer::doSelectOne($c);
             $etva_node->setClusterId($cluster_id);
             $etva_node->save();
         } else {
             $msg_i18n = $this->getContext()->getI18N()->__(EtvaNodePeer::_ERR_NOTFOUND_ID_, array('%id%' => $node_id));
             $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
             // if is browser request return text renderer
             $error = json_encode($error);
             return $this->renderText($error);
         }
     } catch (Exception $e) {
         error_log("CLUSTER[ERROR] Move of node " . $node_id . " into cluster " . $cluster_id . " failed!");
         $error = array('success' => false, 'error' => array('cluster' => $e->getMessage()));
         $error = json_encode($error);
         return $this->renderText($error);
     }
     $msg_i18n = $this->getContext()->getI18N()->__('Node %name% moved successfully', array('%name%' => $etva_node->getName()));
     // EtvaServerPeer::_ERR_NOTFOUND_ID_,array('%id%'=>$sid));
     $return = array('agent' => sfConfig::get('config_acronym'), 'success' => true, 'info' => $msg_i18n);
     $result = json_encode($return);
     $this->getResponse()->setHttpHeader('Content-type', 'application/json');
     return $this->renderText($result);
 }
Exemplo n.º 17
0
 /**
  * process soap update requests of virtual machines
  *
  * $request['uuid'] //node uuid
  * $request['action'] // domains_stats (updates vms state) or domains_init (initializes agent servers)
  * $request['vms'] //list of virtual machines sent by VA
  *
  * @return array servers array on CM DB
  *
  */
 public function executeSoapUpdate(sfWebRequest $request)
 {
     if (sfConfig::get('sf_environment') == 'soap') {
         $action = $request->getParameter('action');
         $c = new Criteria();
         $c->add(EtvaNodePeer::UUID, $request->getParameter('uuid'));
         if (!($etva_node = EtvaNodePeer::doSelectOne($c))) {
             $error_msg = sprintf('Object etva_node does not exist (%s).', $request->getParameter('uuid'));
             $error = array('success' => false, 'error' => $error_msg);
             //notify event log
             $node_message = Etva::getLogMessage(array('name' => $request->getParameter('uuid')), EtvaNodePeer::_ERR_NOTFOUND_UUID_);
             $message = Etva::getLogMessage(array('info' => $node_message), EtvaServerPeer::_ERR_SOAPUPDATE_);
             $this->dispatcher->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
             return $error;
         }
         $node_initialize = $etva_node->getInitialize();
         if ($node_initialize != EtvaNode_VA::INITIALIZE_OK) {
             $error_msg = sprintf('Etva node initialize status: %s', $node_initialize);
             $error = array('success' => false, 'error' => $error_msg);
             return $error;
         }
         $querysrvs = EtvaServerQuery::create();
         $querysrvs->orderByPriorityHa('desc');
         $node_servers = $etva_node->getEtvaServers($querysrvs);
         switch ($action) {
             case 'domains_stats':
                 $vms = (array) $request->getParameter('vms');
                 $vms_uuids = array();
                 $vms = !empty($vms) ? (array) $vms : array();
                 $not_affected = 0;
                 foreach ($vms as $vm) {
                     $vms_uuids[$vm->uuid] = (array) $vm;
                 }
                 foreach ($node_servers as $node_server) {
                     //error_log(sprintf('node_servers id=%s name=%s priority_ha=%s',$node_server->getId(),$node_server->getName(),$node_server->getPriorityHa()));
                     $server_uuid = $node_server->getUuid();
                     if (!$node_server->getUnassigned()) {
                         // assigned only
                         // and is not migrating
                         if ($node_server->getVmState() !== EtvaServer::STATE_MIGRATING) {
                             if (isset($vms_uuids[$server_uuid])) {
                                 $node_server->setVmState($vms_uuids[$server_uuid]['state']);
                                 if (isset($vms_uuids[$server_uuid]['has_snapshots'])) {
                                     // set snapshots flags
                                     $node_server->setHassnapshots($vms_uuids[$server_uuid]['has_snapshots']);
                                 }
                                 $node_server->save();
                             } else {
                                 $message_s = sprintf('Node %s could not check state for virtual machine %s(%s)', $etva_node->getName(), $node_server->getName(), $server_uuid);
                                 $not_affected++;
                                 $this->dispatcher->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $message_s, 'priority' => EtvaEventLogger::ERR)));
                                 error_log($message_s);
                             }
                         } else {
                             $message_s = sprintf('Node %s could not check state for virtual machine %s(%s) beacuse is migrating', $etva_node->getName(), $node_server->getName(), $server_uuid);
                             error_log($message_s);
                         }
                     }
                 }
                 // update free memory
                 $etva_node->updateMemFree();
                 $etva_node->save();
                 //notify system log
                 if ($not_affected > 0) {
                     $message = sprintf('Node %s could not check for %d virtual machine(s) state', $etva_node->getName(), $not_affected);
                     $this->dispatcher->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
                     return array('success' => false, 'reason' => '_servers_inconsistency_');
                 }
                 return array('success' => true);
                 break;
             case 'domains_gainfo':
                 $vms = (array) $request->getParameter('vms');
                 $vms_uuids = array();
                 $vms = !empty($vms) ? (array) $vms : array();
                 foreach ($vms as $vm) {
                     $vms_uuids[$vm->uuid] = (array) $vm;
                 }
                 foreach ($node_servers as $node_server) {
                     $server_uuid = $node_server->getUuid();
                     if (!$node_server->getUnassigned()) {
                         // assigned only
                         if (isset($vms_uuids[$server_uuid])) {
                             //$str = json_encode($vms_uuids[$server_uuid]['msg']);
                             $str = $vms_uuids[$server_uuid]['msg'];
                             $obj = json_decode($str);
                             $node_server->mergeGaInfo($str);
                             // merge GA info
                             $node_server->resetHeartbeat(EtvaServerPeer::_GA_RUNNING_);
                             $node_server->setHbnrestarts(0);
                             // reset num of restarts
                             $node_server->save();
                             $message = sprintf('domains_gainfo guest agent info updated (id=%s name=%s type=%s hb=%s)', $node_server->getId(), $node_server->getName(), $obj->__name__, $node_server->getHeartbeat());
                             error_log($message);
                             /*$this->dispatcher->notify(
                               new sfEvent(sfConfig::get('config_acronym'), 'event.log',
                                   array('message' => $message,'priority'=>EtvaEventLogger::INFO)));*/
                         }
                     }
                 }
                 return array('success' => true);
                 break;
             case 'domains_sync':
                 $new_servers = array();
                 $vms = (array) $request->getParameter('vms');
                 $vms_uuids = array();
                 $vms = !empty($vms) ? (array) $vms : array();
                 $not_affected = 0;
                 foreach ($vms as $vm) {
                     if ($vm) {
                         $vms_uuids[$vm->uuid] = (array) $vm;
                     }
                 }
                 foreach ($node_servers as $node_server) {
                     error_log(sprintf('domains_sync server id=%s name=%s priority_ha=%s', $node_server->getId(), $node_server->getName(), $node_server->getPriorityHa()));
                     if (!$node_server->getUnassigned()) {
                         // ignore unassigned servers
                         $server_name = $node_server->getName();
                         $new_servers[$server_name] = $node_server->_VA();
                         $server_uuid = $node_server->getUuid();
                         if (isset($vms_uuids[$server_uuid])) {
                             if ($vms_uuids[$server_uuid]['state'] != EtvaServer::RUNNING && ($node_server->getVmState() == EtvaServer::RUNNING || $node_server->getAutostart())) {
                                 error_log(sprintf('domains_sync server id=%s name=%s should be running', $node_server->getId(), $node_server->getName()));
                                 $node_server->setHblaststart('NOW');
                                 // update hb last start
                                 $node_server->save();
                             }
                             unset($vms_uuids[$server_uuid]);
                         }
                     }
                 }
                 $servers_names = array_keys($new_servers);
                 $servers = implode(', ', $servers_names);
                 /*
                  * check if is an appliance restore operation...
                  */
                 $apli = new Appliance();
                 $action = $apli->getStage(Appliance::RESTORE_STAGE);
                 if ($action) {
                     $apli->setStage(Appliance::RESTORE_STAGE, Appliance::VA_UPDATE_VMS);
                 }
                 //notify system log
                 if ($new_servers) {
                     $this->dispatcher->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => Etva::getLogMessage(array('name' => $etva_node->getName(), 'info' => $servers), EtvaServerPeer::_OK_SOAPUPDATE_), 'priority' => EtvaEventLogger::INFO)));
                 }
                 $load_servers = count($new_servers) ? array_values($new_servers) : array();
                 $destroy_servers = count($vms_uuids) ? array_values($vms_uuids) : array();
                 $return = array('success' => true, 'load_servers' => $load_servers, 'destroy_servers' => $destroy_servers);
                 return $return;
                 break;
             default:
                 $new_servers = array();
                 foreach ($node_servers as $node_server) {
                     if (!$node_server->getUnassigned()) {
                         // ignore unassigned servers
                         $server_name = $node_server->getName();
                         $new_servers[$server_name] = $node_server->_VA();
                     }
                 }
                 $servers_names = array_keys($new_servers);
                 $servers = implode(', ', $servers_names);
                 /*
                  * check if is an appliance restore operation...
                  */
                 $apli = new Appliance();
                 $action = $apli->getStage(Appliance::RESTORE_STAGE);
                 if ($action) {
                     $apli->setStage(Appliance::RESTORE_STAGE, Appliance::VA_UPDATE_VMS);
                 }
                 //notify system log
                 if ($new_servers) {
                     $this->dispatcher->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => Etva::getLogMessage(array('name' => $etva_node->getName(), 'info' => $servers), EtvaServerPeer::_OK_SOAPUPDATE_), 'priority' => EtvaEventLogger::INFO)));
                 }
                 return $new_servers;
         }
     }
 }
Exemplo n.º 18
0
 function cli_serverstop($host, $server)
 {
     if (!($etva_node = EtvaNodePeer::retrieveByIp($host))) {
         $error = array('success' => false, 'error' => $host . ' : Virt agent not found');
         return json_encode($error);
     }
     $this->request->setParameter('nid', $etva_node->getId());
     $this->request->setParameter('server', $server);
     $action = $this->getAction('server', 'jsonStop');
     $result = $action->executeJsonStop($this->request);
     return $result;
 }
Exemplo n.º 19
0
 public function check_shared_devicetable_consistency($etva_node, $lvs_1stdtable, $bulk_response_dtable)
 {
     $node_id = $etva_node->getId();
     $etva_cluster = $etva_node->getEtvaCluster();
     // get shared LV
     $db_ = $etva_cluster->getSharedLvs();
     if (!$db_) {
         $db_ = array();
     }
     $shared_lvs_1stdtable = array();
     //filter LVs by shared
     foreach ($db_ as $data) {
         $lvdevice = $data->getLvdevice();
         $clvdev = $lvdevice;
         $clvdev = str_replace("/dev/", "", $clvdev);
         $clvdev = str_replace("-", "--", $clvdev);
         $clvdev = str_replace("/", "-", $clvdev);
         $re_clvdev = "/" . $clvdev . ":/";
         $lv_dtable_aux = preg_grep($re_clvdev, $lvs_1stdtable);
         // ignore snapshots
         $lv_dtable = preg_grep("/(?:(?! snapshot ).)/", $lv_dtable_aux);
         $shared_lvs_1stdtable = array_merge($shared_lvs_1stdtable, $lv_dtable);
     }
     $consistent = 0;
     $dt_errors = array();
     foreach ($bulk_response_dtable as $e_id => $e_response) {
         if ($e_response['success']) {
             //response received ok
             $node = EtvaNodePeer::retrieveByPK($e_id);
             $dtable = (array) $e_response['response'];
             $count_eq = 0;
             foreach ($dtable as $e_line) {
                 if (in_array($e_line, $shared_lvs_1stdtable)) {
                     $count_eq++;
                 }
             }
             if ($count_eq != count($shared_lvs_1stdtable)) {
                 foreach ($shared_lvs_1stdtable as $d) {
                     if (!in_array($d, $dtable)) {
                         $this->missing_dtable[$e_id]['devices'][] = $d;
                         $this->missing_dtable[$e_id]['name'] = $node->getName();
                     }
                 }
                 $missing_devices = $this->missing_dtable[$e_id]['devices'];
                 $err_msg = sprintf(" node_id=%s missing_devices=%s \n", $e_id, print_r($missing_devices, true));
                 $dt_errors[] = array('message' => $err_msg);
             }
         }
     }
     if (empty($dt_errors)) {
         $consistent = 1;
     }
     return $consistent;
 }
Exemplo n.º 20
0
 public function executeJsonFindSource(sfWebRequest $request)
 {
     /*$msg_ok_type = EtvaPoolPeer::_OK_FIND_SOURCE_;
       $msg_err_type = EtvaPoolPeer::_ERR_FIND_SOURCE_;*/
     // get node id from cluster context
     $etva_node = EtvaNodePeer::getOrElectNode($request);
     if (!$etva_node) {
         $msg_i18n = $this->getContext()->getI18N()->__(EtvaNodePeer::_ERR_NOTFOUND_ID_, array('%id%' => $nid));
         $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
         $node_log = Etva::getLogMessage(array('id' => $nid), EtvaNodePeer::_ERR_NOTFOUND_ID_);
         //notify system log
         $this->dispatcher->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $node_log, 'priority' => EtvaEventLogger::ERR)));
         // if is a CLI soap request return json encoded data
         if (sfConfig::get('sf_environment') == 'soap') {
             return json_encode($error);
         }
         // if is browser request return text renderer
         $error = $this->setJsonError($error);
         return $this->renderText($error);
     }
     $type = $request->getParameter('type');
     $source_host = $request->getParameter('source_host');
     // call find storage pool source
     $response = $etva_node->soapSend('find_storage_pool_source', array('type' => $type, 'source_host' => $source_host));
     if ($response['success']) {
         $return = json_encode($response);
         // if the request is made throught soap request...
         if (sfConfig::get('sf_environment') == 'soap') {
             return $return;
         }
         // if is browser request return text renderer
         $this->getResponse()->setHttpHeader('Content-type', 'application/json');
         return $this->renderText($return);
     } else {
         if (sfConfig::get('sf_environment') == 'soap') {
             return json_encode($response);
         }
         $return = $this->setJsonError($response);
         return $this->renderText($return);
     }
 }
Exemplo n.º 21
0
 public function executeJsonImport(sfWebRequest $request)
 {
     $nid = $request->getParameter('nid');
     $import_data = json_decode($request->getParameter('import'), true);
     $server = $import_data;
     $vnc_keymap = EtvaSettingPeer::retrieveByPk('vnc_keymap');
     $server['vnc_keymap'] = $vnc_keymap->getValue();
     $server['uuid'] = EtvaServerPeer::generateUUID();
     $server['name'] = $import_data['name'];
     $server['vm_type'] = $import_data['vm_type'];
     $server['ip'] = '000.000.000.000';
     $server['boot'] = 'filesystem';
     $import_data['uuid'] = $server['uuid'];
     $import_data['vnc_keymap'] = $server['vnc_keymap'];
     // import validation check
     $result = $this->jsonImportCheck($request);
     if (!$result['success']) {
         // if is a CLI soap request return json encoded data
         if (sfConfig::get('sf_environment') == 'soap') {
             return json_encode($result);
         }
         // if is browser request return text renderer
         $error = $this->setJsonError($result);
         return $this->renderText($error);
     }
     if (!($etva_node = EtvaNodePeer::retrieveByPK($nid))) {
         $msg_i18n = $this->getContext()->getI18N()->__(EtvaNodePeer::_ERR_NOTFOUND_ID_, array('%id%' => $nid));
         $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
         //notify event log
         $node_log = Etva::getLogMessage(array('id' => $nid), EtvaNodePeer::_ERR_NOTFOUND_ID_);
         $message = Etva::getLogMessage(array('info' => $node_log), OvfEnvelope_VA::_ERR_IMPORT_);
         $this->dispatcher->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
         // if is a CLI soap request return json encoded data
         if (sfConfig::get('sf_environment') == 'soap') {
             return json_encode($error);
         }
         // if is browser request return text renderer
         $error = $this->setJsonError($error);
         return $this->renderText($error);
     }
     $disks = $import_data['disks'];
     $collVgs = array();
     foreach ($disks as $id => $info) {
         $vg = $info['vg'];
         $lv = $info['lv'];
         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 = $this->getContext()->getI18N()->__($msg_type, array('%name%' => $lv));
             $error = array('success' => false, 'agent' => $etva_node->getName(), 'error' => $msg_i18n, 'info' => $msg_i18n);
             //notify system log
             $message = Etva::getLogMessage(array('name' => $lv, 'info' => $msg), OvfEnvelope_VA::_ERR_IMPORT_);
             $this->dispatcher->notify(new sfEvent($error['agent'], 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
             // if is a CLI soap request return json encoded data
             if (sfConfig::get('sf_environment') == 'soap') {
                 return json_encode($error);
             }
             // if is browser request return text renderer
             $error = $this->setJsonError($error);
             return $this->renderText($error);
         }
         if (!($etva_vg = $etva_node->retrieveVolumegroupByVg($vg))) {
             $msg = Etva::getLogMessage(array('name' => $vg), EtvaVolumegroupPeer::_ERR_NOTFOUND_);
             $msg_i18n = $this->getContext()->getI18N()->__(EtvaVolumegroupPeer::_ERR_NOTFOUND_, array('%name%' => $vg));
             $error = array('success' => false, 'agent' => $etva_node->getName(), 'error' => $msg_i18n, 'info' => $msg_i18n);
             //notify system log
             $message = Etva::getLogMessage(array('name' => $lv, 'info' => $msg), OvfEnvelope_VA::_ERR_IMPORT_);
             $this->dispatcher->notify(new sfEvent($error['agent'], 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
             // if is a CLI soap request return json encoded data
             if (sfConfig::get('sf_environment') == 'soap') {
                 return json_encode($error);
             }
             // if is browser request return text renderer
             $error = $this->setJsonError($error);
             return $this->renderText($error);
         }
         // fix lv path
         $is_DiskFile = $vg == sfConfig::get('app_volgroup_disk_flag') ? 1 : 0;
         $import_data['disks'][$id]['lv'] = $is_DiskFile ? $etva_node->getStoragedir() . '/' . $lv : $lv;
         $collVgs[$vg] = $etva_vg;
     }
     $networks = $import_data['networks'];
     $networks_va = $import_data['networks'];
     $collNetworks = array();
     $i = 0;
     // check if networks are available
     foreach ($networks as $network) {
         if ($etva_vlan = EtvaVlanPeer::retrieveByPk($network['vlan_id'])) {
             $import_data['networks'][$i]['network'] = $etva_vlan->getName();
             $import_data['networks'][$i]['macaddr'] = $network['mac'];
         }
         $etva_mac = EtvaMacPeer::retrieveByMac($network['mac']);
         /*
          * TODO improve this to add Mac Address to the pool
          */
         if (!$etva_mac || !$etva_vlan) {
             $msg = Etva::getLogMessage(array(), EtvaNetworkPeer::_ERR_);
             $msg_i18n = $this->getContext()->getI18N()->__(EtvaNetworkPeer::_ERR_, array());
             if (!$etva_mac) {
                 $msg = Etva::getLogMessage(array('%mac%' => $network['mac']), EtvaMacPeer::_ERR_INVALID_MAC_);
                 $msg_i18n = $this->getContext()->getI18N()->__(EtvaMacPeer::_ERR_INVALID_MAC_, array('%mac%' => $network['mac']));
             }
             $error = array('success' => false, 'agent' => $etva_node->getName(), 'error' => $msg_i18n, 'info' => $msg_i18n);
             //notify event log
             $message = Etva::getLogMessage(array('name' => $server['name'], 'info' => $msg), OvfEnvelope_VA::_ERR_IMPORT_);
             $this->dispatcher->notify(new sfEvent($error['agent'], 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
             // if is a CLI soap request return json encoded data
             if (sfConfig::get('sf_environment') == 'soap') {
                 return json_encode($error);
             }
             // if is browser request return text renderer
             $error = $this->setJsonError($error);
             return $this->renderText($error);
         }
         if ($etva_mac->getInUse()) {
             $msg = Etva::getLogMessage(array('%name%' => $etva_mac->getMac()), EtvaMacPeer::_ERR_ASSIGNED_);
             $msg_i18n = $this->getContext()->getI18N()->__(EtvaMacPeer::_ERR_ASSIGNED_, array('%name%' => $etva_mac->getMac()));
             $error = array('success' => false, 'agent' => $etva_node->getName(), 'info' => $msg_i18n, 'error' => $msg_i18n);
             //notify event log
             $message = Etva::getLogMessage(array('name' => $server['name'], 'info' => $msg), OvfEnvelope_VA::_ERR_IMPORT_);
             $this->dispatcher->notify(new sfEvent($error['agent'], 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
             // if is a CLI soap request return json encoded data
             if (sfConfig::get('sf_environment') == 'soap') {
                 return json_encode($error);
             }
             // if is browser request return text renderer
             $error = $this->setJsonError($error);
             return $this->renderText($error);
         }
         $etva_network = new EtvaNetwork();
         $etva_network->fromArray($network, BasePeer::TYPE_FIELDNAME);
         $collNetworks[] = $etva_network;
         $i++;
     }
     $env = new OvfEnvelope_VA();
     $env->fromArray($import_data);
     /* get server copy VA server representation */
     $params = $env->_VA();
     $method = 'vm_ovf_import_may_fork';
     $response = $etva_node->soapSend($method, $params);
     if (!$response['success']) {
         $error_decoded = $response['error'];
         $result = $response;
         $msg_i18n = $this->getContext()->getI18N()->__(EtvaServerPeer::_ERR_CREATE_, array('%name%' => $server['name'], '%info%' => $error_decoded));
         $result['error'] = $msg_i18n;
         //notify event log
         $message = Etva::getLogMessage(array('name' => $server['name'], 'info' => $response['info']), EtvaServerPeer::_ERR_CREATE_);
         $this->dispatcher->notify(new sfEvent($response['agent'], 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
         if (sfConfig::get('sf_environment') == 'soap') {
             return json_encode($result);
         }
         $return = $this->setJsonError($result);
         return $this->renderText($return);
     }
     $response_decoded = (array) $response['response'];
     $returned_object = (array) $response_decoded['_obj_'];
     $returned_lvs = (array) $returned_object['LVS'];
     $collLvs = array();
     foreach ($returned_lvs as $disk) {
         $disk_array = (array) $disk;
         $vg_info = (array) $disk_array[EtvaLogicalvolume::VOLUMEGROUP_MAP];
         $vg = $vg_info[EtvaVolumegroup::VG_MAP];
         $fake_lv_response = array('success' => true, 'response' => array('_obj_' => $disk_array));
         // create logical volume
         $etva_lv = new EtvaLogicalvolume();
         $etva_lv->setEtvaVolumegroup($collVgs[$vg]);
         $lv_va = new EtvaLogicalvolume_VA($etva_lv);
         $lv_response = $lv_va->processResponse($etva_node, $fake_lv_response, 'lvcreate');
         if (!$lv_response['success']) {
             $return = $this->setJsonError($lv_response);
             return $this->renderText($return);
         }
         $collLvs[] = $etva_lv;
     }
     $etva_server = new EtvaServer();
     $etva_server->fromArray($server, BasePeer::TYPE_FIELDNAME);
     $user_groups = $this->getUser()->getGroups();
     $server_sfgroup = array_shift($user_groups);
     //if user has group then put one of them otherwise put DEFAULT GROUP ID
     if ($server_sfgroup) {
         $etva_server->setsfGuardGroup($server_sfgroup);
     } else {
         $etva_server->setsfGuardGroup(sfGuardGroupPeer::getDefaultGroup());
     }
     foreach ($collNetworks as $coll) {
         $etva_server->addEtvaNetwork($coll);
     }
     $i = 0;
     foreach ($collLvs as $coll) {
         $server_disk = new EtvaServerLogical();
         $server_disk->setEtvaLogicalvolume($coll);
         $server_disk->setBootDisk($i);
         $etva_server->addEtvaServerLogical($server_disk);
         $i++;
     }
     //update some data from agent response
     $vm = (array) $returned_object['VM'];
     $etva_server->initData($vm);
     //$etva_server->setEtvaNode($etva_node);
     $etva_server->setEtvaCluster($etva_node->getEtvaCluster());
     try {
         $etva_server->save();
     } catch (Exception $e) {
         $msg = $e->getMessage();
         $result = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg, 'info' => $msg);
         $return = $this->setJsonError($result);
         return $this->renderText($return);
     }
     // assign To etva_node
     $etva_server->assignTo($etva_node);
     $msg_i18n = $this->getContext()->getI18N()->__(EtvaServerPeer::_OK_CREATE_, array('%name%' => $server['name']));
     $message = Etva::getLogMessage(array('name' => $server['name']), EtvaServerPeer::_OK_CREATE_);
     $this->dispatcher->notify(new sfEvent($etva_node->getName(), 'event.log', array('message' => $message)));
     $result = array('success' => true, 'agent' => $response['agent'], 'insert_id' => $etva_server->getId(), 'response' => $msg_i18n);
     $return = json_encode($result);
     $this->getResponse()->setHttpHeader('Content-type', 'application/json');
     // if is browser request return text renderer
     return $this->renderText($return);
 }
Exemplo n.º 22
0
 /**
  * Expanad the physical volume
  *
  * Expand size of physical volume,
  *
  * $request may contain the following keys:
  * - nid: virt agent node ID
  * - dev: device name Ex: /dev/sdb1
  *
  * Returns json array('success'=>true,'response'=>$resp) on success
  *  <br>or<br>
  * json array('success'=>false,'error'=>$error) on error
  *
  */
 public function executeJsonExpand(sfWebRequest $request)
 {
     $nid = $request->getParameter('nid');
     $dev = $request->getParameter('dev');
     $etva_node = EtvaNodePeer::getOrElectNode($request);
     if (!$etva_node) {
         $msg_i18n = $this->getContext()->getI18N()->__(EtvaNodePeer::_ERR_NOTFOUND_ID_, array('%id%' => $nid));
         $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
         //notify system log
         $node_log = Etva::getLogMessage(array('id' => $nid), EtvaNodePeer::_ERR_NOTFOUND_ID_);
         $message = Etva::getLogMessage(array('name' => $dev, 'info' => $node_log), EtvaPhysicalvolumePeer::_ERR_UNINIT_);
         $this->dispatcher->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
         // if is a CLI soap request return json encoded data
         if (sfConfig::get('sf_environment') == 'soap') {
             return json_encode($error);
         }
         // if is browser request return text renderer
         $error = $this->setJsonError($error);
         return $this->renderText($error);
     }
     // get DB info
     if (!($etva_pv = $etva_node->retrievePhysicalvolumeByDevice($dev))) {
         $msg = Etva::getLogMessage(array('name' => $etva_node->getName(), 'dev' => $dev), EtvaNodePeer::_ERR_NODEV_);
         $msg_i18n = $this->getContext()->getI18N()->__(EtvaNodePeer::_ERR_NODEV_, array('%name%' => $etva_node->getName(), '%dev%' => $dev));
         $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
         //notify system log
         $message = Etva::getLogMessage(array('name' => $dev, 'info' => $msg), EtvaPhysicalvolumePeer::_ERR_UNINIT_);
         $this->dispatcher->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
         // if is a CLI soap request return json encoded data
         if (sfConfig::get('sf_environment') == 'soap') {
             return json_encode($error);
         }
         $error = $this->setJsonError($error);
         return $this->renderText($error);
     }
     /*
      * send physical volume to VA
      */
     $pv_va = new EtvaPhysicalvolume_VA($etva_pv);
     $response = $pv_va->send_expand($etva_node);
     if ($response['success']) {
         $return = json_encode($response);
         // if the request is made throught soap request...
         if (sfConfig::get('sf_environment') == 'soap') {
             return $return;
         }
         // if is browser request return text renderer
         $this->getResponse()->setHttpHeader('Content-type', 'application/json');
         return $this->renderText($return);
     } else {
         if (sfConfig::get('sf_environment') == 'soap') {
             return json_encode($response);
         }
         $return = $this->setJsonError($response);
         return $this->renderText($return);
     }
 }
Exemplo n.º 23
0
 public static function getOrElectNodeFromArray($arguments)
 {
     // get parameters
     $nid = isset($arguments['node']) ? $arguments['node'] : null;
     $cid = isset($arguments['cluster']) ? $arguments['cluster'] : null;
     $level = isset($arguments['level']) ? $arguments['level'] : null;
     $vg = isset($arguments['volumegroup']) ? $arguments['volumegroup'] : null;
     $dev = isset($arguments['device']) ? $arguments['device'] : null;
     $lv = isset($arguments['logicalvolume']) ? $arguments['logicalvolume'] : null;
     // check level - back compatibility
     if (!$level) {
         $level = 'node';
     }
     if ($level == 'cluster') {
         $etva_cluster = EtvaClusterPeer::retrieveByPK($cid);
         return EtvaNode::getFirstActiveNode($etva_cluster);
     } elseif ($level == 'node') {
         $etva_node = EtvaNodePeer::retrieveByPK($nid);
         if ($lv) {
             $c = new Criteria();
             $c->add(EtvaLogicalvolumePeer::STORAGE_TYPE, EtvaLogicalvolume::STORAGE_TYPE_LOCAL_MAP, Criteria::ALT_NOT_EQUAL);
             $etva_lv = EtvaLogicalvolumePeer::retrieveByLv($lv, $c);
             return $etva_lv ? EtvaNodePeer::ElectNode($etva_node) : $etva_node;
         } elseif ($dev) {
             $c = new Criteria();
             $c->add(EtvaPhysicalvolumePeer::STORAGE_TYPE, EtvaPhysicalvolume::STORAGE_TYPE_LOCAL_MAP, Criteria::ALT_NOT_EQUAL);
             $etva_pv = EtvaPhysicalvolumePeer::retrieveByDevice($dev, $c);
             return $etva_pv ? EtvaNodePeer::ElectNode($etva_node) : $etva_node;
         } elseif ($vg) {
             $c = new Criteria();
             $c->add(EtvaVolumeGroupPeer::STORAGE_TYPE, EtvaVolumeGroup::STORAGE_TYPE_LOCAL_MAP, Criteria::ALT_NOT_EQUAL);
             $etva_vg = EtvaVolumegroupPeer::retrieveByVg($vg, $c);
             return $etva_vg ? EtvaNodePeer::ElectNode($etva_node) : $etva_node;
         } else {
             return $etva_node;
         }
     }
 }
Exemplo n.º 24
0
 public function executeView(sfWebRequest $request)
 {
     $this->node_form = new EtvaNodeForm();
     $this->node_tableMap = EtvaNodePeer::getTableMap();
     // parent extjs container id
     $this->containerId = $request->getParameter('containerId');
     // $this->request->setParameter('id', 1);
     // $this->request->setParameter('method', 'list_vms');
     //  $this->dispatcher->notify(new sfEvent($this, 'updatedsoap'));
     // $this->forward('node','soap');
     // WORKING!!!
     // CAN BE USED TO PERFORM EXTRA STUFF
     // $action = sfContext::getInstance()->getController()->getAction('node','soap');
     // $action = $this->getController()->getAction('node','soap');
     // $result = $action->executeSoap($this->request,1);
     // END WORKING
     // return sfView::SUCCESS;
     //sfContext::getInstance()->getController()->dispatch('somemodule', 'someaction');
 }
Exemplo n.º 25
0
 public function processResponse($etva_node, $response, $method, $params)
 {
     $etva_pool = $this->etva_pool;
     $pool_name = $etva_pool->getName();
     switch ($method) {
         case self::POOL_CREATE:
             $msg_ok_type = EtvaPoolPeer::_OK_CREATE_;
             $msg_err_type = EtvaPoolPeer::_ERR_CREATE_;
             break;
         case self::POOL_DESTROY:
             $msg_ok_type = EtvaPoolPeer::_OK_REMOVE_;
             $msg_err_type = EtvaPoolPeer::_ERR_REMOVE_;
             break;
         case self::POOL_RELOAD:
             $msg_ok_type = EtvaPoolPeer::_OK_RELOAD_;
             $msg_err_type = EtvaPoolPeer::_ERR_RELOAD_;
             break;
     }
     if (!$response['success']) {
         $result = $response;
         $message = Etva::getLogMessage(array('name' => $pool_name, 'info' => $response['info']), $msg_err_type);
         $msg_i18n = sfContext::getInstance()->getI18N()->__($msg_err_type, array('%name%' => $pool_name, '%info%' => $response['info']));
         $result['error'] = $msg_i18n;
         sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($response['agent'], 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
         return $result;
     }
     if ($method == self::POOL_CREATE) {
         // save object
         $etva_pool->save();
         // create relation to node
         $etva_nodepool = new EtvaNodePool();
         $etva_nodepool->setNodeId($etva_node->getId());
         $etva_nodepool->setPoolId($etva_pool->getId());
         $etva_nodepool->save();
     }
     $pool_id = $etva_pool->getId();
     $etva_cluster = $etva_node->getEtvaCluster();
     $error_messages = array();
     if ($etva_pool->getShared()) {
         // send call to all nodes
         $bulk_responses = $etva_cluster->soapSend($method, $params, $etva_node);
         //error_log(print_r($bulk_responses,true));
         foreach ($bulk_responses as $node_id => $node_response) {
             $node = EtvaNodePeer::retrieveByPK($node_id);
             if ($node_response['success']) {
                 if ($method == self::POOL_CREATE || $method == self::POOL_RELOAD) {
                     if (!EtvaNodePoolPeer::retrieveByPK($node_id, $pool_id)) {
                         // create relation to node
                         $etva_nodepool = new EtvaNodePool();
                         $etva_nodepool->setNodeId($node_id);
                         $etva_nodepool->setPoolId($pool_id);
                         $etva_nodepool->save();
                         $node->clearErrorMessage(self::POOL_CREATE);
                         if ($method == self::POOL_RELOAD) {
                             // clear error message for reload
                             $node->clearErrorMessage($method);
                         }
                     }
                 }
             } else {
                 $message = Etva::getLogMessage(array('name' => $pool_name, 'info' => $node_response['info']), $msg_err_type);
                 sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($node_response['agent'], 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
                 $msg_i18n = sfContext::getInstance()->getI18N()->__($msg_err_type, array('%name%' => $pool_name, '%info%' => $node_response['info']));
                 array_push($error_messages, array('success' => false, 'agent' => $node_response['agent'], 'response' => $msg_i18n));
                 // mark node with fail
                 $node->setErrorMessage($method, $msg_i18n);
             }
         }
     }
     if ($method == self::POOL_DESTROY) {
         // remove object
         $etva_pool->delete();
     }
     $response_decoded = (array) $response['response'];
     $returned_object = (array) $response_decoded['_obj_'];
     $message = Etva::getLogMessage(array('name' => $pool_name), $msg_ok_type);
     $msg_i18n = sfContext::getInstance()->getI18N()->__($msg_ok_type, array('%name%' => $pool_name));
     sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($response['agent'], 'event.log', array('message' => $message)));
     $result = array('success' => true, 'agent' => $etva_node->getName(), 'response' => $msg_i18n, 'errors' => $error_messages);
     return $result;
 }
Exemplo n.º 26
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] Check status of server '{$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));
                     $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);
                 $response = $server_va->getGAInfo($etva_node);   // update GA Info
                 */
         // TODO force check
         $response = array('success' => true, 'response' => 'check ok', 'agent' => sfConfig::get('config_acronym'));
         if ($etva_node) {
             $response['agent'] = $etva_node->getName();
         }
         if ($options['check']) {
             if (!$options['request_id']) {
                 $options['request_id'] = UUID::generate(UUID::UUID_RANDOM, UUID::FMT_STRING);
             }
             $response['_request_id'] = $options['request_id'];
             $response['_request_status'] = EtvaAsynchronousJob::PENDING;
             if ($etva_server->getVmState() == $options['check']) {
                 $response['_request_status'] = EtvaAsynchronousJob::FINISHED;
                 $msg_ok_type = '';
                 if ($options['check'] == EtvaServer::STATE_RUNNING) {
                     $msg_ok_type = EtvaServerPeer::_OK_START_;
                 } elseif ($options['check'] == EtvaServer::STATE_STOP) {
                     $msg_ok_type = EtvaServerPeer::_OK_STOP_;
                 }
                 if ($msg_ok_type) {
                     $response['response'] = Etva::makeNotifyLogMessage($response['agent'], $msg_ok_type, array('name' => $etva_server->getName()), null, array(), EtvaEventLogger::INFO);
                 }
             }
             //$this->log("[DEBUG] status=".$response['_request_status']." state=".$etva_server->getVmState()." == ".$options['check']);
         }
         if ($response['success']) {
             $this->log("[INFO] " . $response['response']);
             //$this->log("[DEBUG ".print_r($response,true));
         } else {
             $this->log("[ERROR] " . $response['error']);
         }
         return $response;
     }
 }
Exemplo n.º 27
0
 public static function getFirstActiveNode(EtvaCluster $cluster)
 {
     $c = new Criteria();
     $c->add(EtvaNodePeer::CLUSTER_ID, $cluster->getId(), Criteria::EQUAL);
     $c->addAnd(EtvaNodePeer::STATE, EtvaNode::NODE_ACTIVE, Criteria::EQUAL);
     $c->addDescendingOrderByColumn(EtvaNodePeer::ID);
     $c->setLimit(1);
     $etva_node = EtvaNodePeer::doSelectOne($c);
     return $etva_node;
 }
Exemplo n.º 28
0
 public function send_edit(EtvaNode $etva_node, $orig_server, $server_data)
 {
     $method = self::SERVER_EDIT;
     $etva_server = $this->etva_server;
     $etva_server->fromArray($server_data, BasePeer::TYPE_FIELDNAME);
     /*
      * process networks
      */
     $this->networks_changed = isset($server_data['networks']);
     if ($this->networks_changed) {
         $check_nics_available = $this->check_nics_availability($etva_node, $server_data['networks'], $method);
         if (!$check_nics_available['success']) {
             return $check_nics_available;
         }
     } else {
         /*
          * clone networks and add to server copy
          */
         $networks = $orig_server->getEtvaNetworks();
         foreach ($networks as $network) {
             $etva_server->addEtvaNetwork($network);
         }
     }
     /*
      * process devices
      */
     $devices_changed = isset($server_data['devices']);
     if ($devices_changed) {
         // ensure if devices are not attached to other vms
         $devs_in_use = EtvaNodePeer::getDevicesInUse($etva_node, $etva_server);
         $srv_name = $etva_server->getName();
         foreach ($server_data['devices'] as $k => $dev) {
             // check if device is already attached
             $testid = $dev['idvendor'] . $dev['idproduct'] . $dev['type'];
             foreach ($devs_in_use as $du) {
                 if ($du == $testid) {
                     //                            $msg_i18n = $this->getContext()->getI18N()->__(EtvaNodePeer::_ERR_DEVICE_ATTACHED_,array('%dev%'=>$dev['description']));
                     $error = EtvaNodePeer::_ERR_DEVICE_ATTACHED_;
                     $response = array('success' => False, 'error' => $error, 'agent' => $srv_name, 'dev' => $dev['description']);
                     return $response;
                 }
             }
         }
         //            $check_nics_available = $this->check_nics_availability($etva_node, $server_data['devices'],$method);
         //            if(!$check_nics_available['success']) return $check_nics_available;
         //
         $check_devs_available = $this->check_devices_availability($etva_node, $server_data['devices'], $method);
         if (!$check_devs_available['success']) {
             return $check_devs_available;
         }
         //
     } else {
         /*
          * clone devices and add to server copy
          */
         $devices = $orig_server->getDevices();
         $etva_server->setDevices($devices);
     }
     /*
      * process disks
      */
     $this->disks_changed = isset($server_data['disks']);
     $disks = $server_data['disks'];
     if ($this->disks_changed) {
         /*
          * create disks objects and add to server copy
          */
         $check_disks_available = $this->check_disks_availability($etva_node, $server_data['disks'], $method);
         //error processing parameters
         if (!$check_disks_available['success']) {
             return $check_disks_available;
         }
     } else {
         /*
          * clone disks and add to server copy
          */
         $disks = $orig_server->getEtvaServerLogicals();
         foreach ($disks as $disk) {
             $etva_server->addEtvaServerLogical($disk);
         }
     }
     $this->buildServer($method);
     $params = $etva_server->_VA();
     if ($etva_server->getVmState() == 'running') {
         $params['live'] = 1;
     }
     # if don't has snapshots and try to change name, send force_to_change_name= flag
     if (!$orig_server->getHassnapshots() && $orig_server->getName() != $etva_server->getName()) {
         $params['force_to_change_name'] = 1;
     }
     if (!$etva_server->getUnassigned()) {
         $response = $etva_node->soapSend($method, $params);
     } else {
         $response = array('success' => true);
     }
     $result = $this->processEditResponse($etva_node, $orig_server, $response);
     return $result;
 }
Exemplo n.º 29
0
 public function executeJsonTestFencing(sfWebRequest $request)
 {
     // create node entry
     $id = $request->getParameter('id');
     if (!($etva_node = EtvaNodePeer::retrieveByPk($id))) {
         return $this->_makeReturnErrorWithNotify(sfConfig::get('config_acronym'), EtvaNodePeer::_ERR_NOTFOUND_ID_, array('id' => $id));
     }
     $fencingconf = $request->getParameter('fencingconf');
     $fencingconf_cmd = $etva_node->getFencingconf_cmd('status', $fencingconf);
     error_log("getFencingconf_cmd " . print_r($fencingconf_cmd, true));
     $command = $fencingconf_cmd;
     error_log("fencingconf_cmd = " . $fencingconf_cmd);
     $path = sfConfig::get('sf_root_dir') . DIRECTORY_SEPARATOR . "utils";
     error_log("[INFO] PATH TO SUDOEXEC " . $path . DIRECTORY_SEPARATOR);
     ob_start();
     passthru('echo "' . $command . ' 2>&1 " | sudo /usr/bin/php -f ' . $path . DIRECTORY_SEPARATOR . 'sudoexec.php', $return);
     $result = ob_get_contents();
     # get message
     ob_end_clean();
     if ($return != 0) {
         return $this->_makeReturnErrorWithNotify(sfConfig::get('config_acronym'), 'You get an error executing fencing test with output: %debug%.', array('name' => $etva_node->getName(), 'conf' => $fencingconf, 'cmd' => print_r($fencingconf_cmd, true), 'debug' => $result));
     } else {
         return $this->_makeReturnOKWithNotify($etva_node->getName(), 'Node %name% successfully tested.', array('name' => $etva_node->getName(), 'conf' => $fencingconf, 'cmd' => print_r($fencingconf_cmd, true)));
     }
 }
Exemplo n.º 30
0
 function updateVirtAgentLogs($node_uuid, $data)
 {
     $c = new Criteria();
     $c->add(EtvaNodePeer::UUID, $node_uuid);
     $return = 0;
     $etva_node = EtvaNodePeer::doSelectOne($c);
     if (!($etva_node = EtvaNodePeer::doSelectOne($c))) {
         $error_msg = sprintf('Object etva_node does not exist (%s).', $node_uuid);
         $error = array('success' => false, 'error' => $error_msg);
         return $error;
     }
     $node_initialize = $etva_node->getInitialize();
     if ($node_initialize != EtvaNode_VA::INITIALIZE_OK) {
         $error_msg = sprintf('Etva node initialize status: %s', $node_initialize);
         $error = array('success' => false, 'error' => $error_msg);
         return $error;
     }
     $node_uuid = $etva_node->getUuid();
     $cpu_load = $data->load;
     $cpu_load_sort = array($cpu_load->onemin, $cpu_load->fivemin, $cpu_load->fifteenmin);
     $cpu_load = new NodeLoadRRA($node_uuid);
     $cpu_load->update($cpu_load_sort);
     $virtServers = $data->virtualmachines;
     if ($virtServers) {
         foreach ($virtServers as $server_name => $server_data) {
             if ($etva_server = $etva_node->retrieveServerByName($server_name)) {
                 if (isset($server_data->network)) {
                     /*
                      * store network info in RRA file
                      */
                     $server_network_data = $server_data->network;
                     /*
                      * create file per network device
                      */
                     foreach ($server_network_data as $intfname => $intfdata) {
                         $macaddr = $intfdata->macaddr;
                         $etva_network = $etva_server->retrieveByMac($macaddr);
                         if ($etva_network) {
                             $target = $etva_network->getTarget();
                             // if target not in network table of the DB
                             if ($target != $intfname) {
                                 $etva_network->updateTarget($intfname);
                             }
                             $tx = $intfdata->tx_bytes;
                             $rx = $intfdata->rx_bytes;
                             $intf_sort = array($rx, $tx);
                             $mac_strip = str_replace(':', '', $macaddr);
                             // create log file
                             $server_network_rra = new ServerNetworkRRA($node_uuid, $etva_server->getUuid(), $mac_strip);
                             //send/update file information
                             $return = $server_network_rra->update($intf_sort);
                         }
                     }
                 }
                 // end server networks
                 /*
                  * disk stuff
                  */
                 if (isset($server_data->disk)) {
                     $server_disk_data = $server_data->disk;
                     foreach ($server_disk_data as $disk => $diskdata) {
                         $diskname = $diskdata->name;
                         $read_b = $diskdata->rd_bytes;
                         $write_b = $diskdata->wr_bytes;
                         $disk_sort = array($read_b, $write_b);
                         // create log file
                         $server_disk_rw_log = new ServerDisk_rwRRA($node_uuid, $etva_server->getUuid(), $diskname);
                         //send/update file information
                         $return = $server_disk_rw_log->update($disk_sort);
                         /*
                          * DISK SPACE RRA NOT USED ANYMORE
                          */
                         //$size = $diskdata->size;
                         //$freesize = $diskdata->freesize;
                         //$disk_space = array($size,$freesize);
                         //$server_disk_spaceRRA = new ServerDiskSpaceRRA($node_uuid,$etva_server->getUuid(),$diskname);
                         //$return = $server_disk_spaceRRA->update($disk_space);
                     }
                     // end server disk
                 }
                 // store cpu utilization
                 $server_cpu_data = $server_data->cpu;
                 $server_cpu_per = array($server_cpu_data->cpu_per);
                 //      $logger->log("cpu ".$server_cpu_data->cpu_per);
                 // create log file
                 $server_cpu_per_rra = new ServerCpuUsageRRA($node_uuid, $etva_server->getUuid());
                 //send/update file information
                 $return = $server_cpu_per_rra->update($server_cpu_per);
                 /*
                  * store memory info
                  */
                 // store memory utilization
                 $server_memory_data = $server_data->memory;
                 $server_memory_per = array($server_memory_data->mem_per);
                 // create log file
                 $server_memory_per_rra = new ServerMemoryUsageRRA($node_uuid, $etva_server->getUuid());
                 //send/update file information
                 $return = $server_memory_per_rra->update($server_memory_per);
                 $server_memory_sort = array($server_memory_data->mem_m, $server_memory_data->mem_v);
                 $server_memory = new ServerMemoryRRA($node_uuid, $etva_server->getUuid());
                 $server_memory->update($server_memory_sort);
             }
             // end virtualmachine stuff
         }
     }
     //  $this->updateVirtAgentLogs_($node_uuid,$data);
     $all_params = array('request' => array('uuid' => $etva_node->getUuid(), 'data' => $data, 'method' => 'updateVirtAgentLogs'), 'response' => $return);
     // log function called
     $dispatcher = sfContext::getInstance()->getEventDispatcher();
     $dispatcher->notify(new sfEvent($this, sfConfig::get('app_virtsoap_log'), $all_params));
     return $return;
 }