Exemplo n.º 1
0
 public function getNodesCluster(Criteria $criteria)
 {
     if (!$criteria) {
         $criteria = new Criteria();
     }
     $criteria->add(EtvaNodePeer::CLUSTER_ID, $this->getClusterId());
     return EtvaNodePeer::doSelect($criteria);
 }
Exemplo n.º 2
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.º 3
0
 public function executeIndex(sfWebRequest $request)
 {
     //    if(update::checkDbVersion() == 0){
     //
     //    }else{
     //
     //    }
     $this->node_list = EtvaNodePeer::doSelect(new Criteria());
     $this->node_form = new EtvaNodeForm();
     $etva_data = Etva::getEtvaModelFile();
     $this->etvamodel = $etva_data['model'];
     if ($this->getUser()->isFirstRequest()) {
         $etva_data = Etva::getEtvaModelFile();
         $etvamodel = $etva_data['model'];
         // remove session macs for cleanup the wizard
         $this->getUser()->getAttributeHolder()->remove('etvamodel');
         // store the new mac back into the session
         $this->getUser()->setAttribute('etvamodel', $etvamodel);
         $this->getUser()->isFirstRequest(false);
     }
     //$action = $this->getController()->getAction('node','bulkUpdateState');
     //$result = $action->executeBulkUpdateState($this->request);
 }
Exemplo n.º 4
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.º 5
0
 public function executeJsonListCluster(sfWebRequest $request)
 {
     $filterBy = '';
     if ($request->hasParameter('sid')) {
         $filterBy = 'sid';
     }
     if ($request->hasParameter('cid')) {
         $filterBy = 'cid';
     }
     $cluster_nodes = array();
     $criteria = new Criteria();
     if ($request->hasParameter('initialize')) {
         // filter by initialized nodes only
         $criteria->add(EtvaNodePeer::INITIALIZE, 'ok', Criteria::EQUAL);
     }
     switch ($filterBy) {
         case 'sid':
             $value = $request->getParameter($filterBy);
             $server = EtvaServerPeer::retrieveByPK($value);
             $node = $server->getEtvaNode();
             $criteria->add(EtvaNodePeer::ID, $node->getId(), Criteria::NOT_EQUAL);
             $cluster_nodes = $node->getNodesCluster($criteria);
             break;
         case 'cid':
             $value = $request->getParameter($filterBy);
             if ($cluster = EtvaClusterPeer::retrieveByPK($value)) {
                 $criteria->add(EtvaNodePeer::CLUSTER_ID, $cluster->getId());
                 $cluster_nodes = EtvaNodePeer::doSelect($criteria);
             }
             break;
         default:
             $cluster_nodes = EtvaNodePeer::doSelect($criteria);
             break;
     }
     $elements = array();
     foreach ($cluster_nodes as $node) {
         $node_array = $node->toArray();
         // get max allocatable memory
         $node_array['maxmem'] = $node->getMaxmem();
         $elements[] = $node_array;
     }
     $result = array('success' => true, 'total' => count($elements), 'data' => $elements);
     $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.º 6
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;
 }
Exemplo n.º 7
0
 /**
  * Removes vlan
  *
  * Issues soap request to all nodes
  *
  * @return json array string
  *
  */
 public function executeJsonRemove(sfWebRequest $request)
 {
     // vlan name and cluster id...
     $netname = $request->getParameter('name');
     $clusterid = $request->getParameter('cluster_id');
     if (!$clusterid) {
         $defaultCluster = EtvaClusterPeer::retrieveDefaultCluster();
         $clusterid = $defaultCluster->getId();
     }
     $nodes_criteria = new Criteria();
     $nodes_criteria->add(EtvaNodePeer::CLUSTER_ID, $clusterid);
     $etva_nodes = EtvaNodePeer::doSelect($nodes_criteria);
     //        $etva_nodes = EtvaNodePeer::doSelect(new Criteria());
     $oks = array();
     $errors = array();
     $method = 'destroy_network';
     $params = array('name' => $netname);
     error_log("VLANREMOVE[INFO] Getting vlan " . $netname . " of cluster " . $clusterid);
     if (!($etva_vlan = EtvaVlanPeer::retrieveByClusterAndName($netname, $clusterid))) {
         $msg = "Network {$netname} not found!";
         $msg_i18n = $this->getContext()->getI18N()->__('Network %1% not found!', array('%1%' => $netname));
         $error = array('success' => false, 'ok' => $oks, 'error' => array($msg_i18n));
         //notify system log
         $this->dispatcher->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => Etva::getLogMessage(array('name' => $netname, 'info' => $msg), EtvaVlanPeer::_ERR_REMOVE_), 'priority' => EtvaEventLogger::CRIT)));
         // 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);
     }
     // check if is in use....
     $c = new Criteria();
     $c->add(EtvaNetworkPeer::VLAN_ID, $etva_vlan->getId());
     if ($etva_network = EtvaNetworkPeer::doSelectOne($c)) {
         $msg = "Network {$netname} in use!";
         $msg_i18n = $this->getContext()->getI18N()->__('Network %1% in use!', array('%1%' => $netname));
         $msg_array = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n);
         $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'ok' => $oks, 'error' => array($msg_array));
         //notify system log
         $this->dispatcher->notify(new sfEvent($error['agent'], 'event.log', array('message' => Etva::getLogMessage(array('name' => $netname, 'info' => $msg), EtvaVlanPeer::_ERR_REMOVE_), '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);
     }
     //        error_log(print_r($etva_vlan,true));
     $etva_vlan->delete();
     //notify system log
     $this->dispatcher->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => Etva::getLogMessage(array('name' => $netname), EtvaVlanPeer::_OK_REMOVE_))));
     // send soap request to all nodes (agents)
     foreach ($etva_nodes as $etva_node) {
         // send soap request
         $response = $etva_node->soapSend($method, $params);
         if ($response['success']) {
             $msg_i18n = $this->getContext()->getI18N()->__(EtvaVlanPeer::_OK_REMOVE_, array('%name%' => $netname));
             $response['info'] = $msg_i18n;
             $oks[] = $response;
             //notify system log
             $this->dispatcher->notify(new sfEvent($etva_node->getName(), 'event.log', array('message' => Etva::getLogMessage(array('name' => $netname), EtvaVlanPeer::_OK_REMOVE_))));
         } else {
             $info = $response['info'];
             $info_i18n = $this->getContext()->getI18N()->__($info);
             $response['info'] = $info_i18n;
             $errors[] = $response;
             //notify system log
             $this->dispatcher->notify(new sfEvent($etva_node->getName(), 'event.log', array('message' => Etva::getLogMessage(array('name' => $netname, 'info' => $info), EtvaVlanPeer::_ERR_REMOVE_), 'priority' => EtvaEventLogger::ERR)));
         }
     }
     if (!empty($errors)) {
         $result = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'ok' => $oks, 'error' => $errors);
         if (sfConfig::get('sf_environment') == 'soap') {
             return json_encode($result);
         }
         $return = $this->setJsonError($result);
         return $this->renderText($return);
     }
     $result = array('success' => true, 'agent' => sfConfig::get('config_acronym'), 'response' => $oks);
     $return = json_encode($result);
     // 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);
 }
Exemplo n.º 8
0
 /**
  * Perform update on table setting
  *
  * @param      string $param parameter name to perform operation
  * @param      string $value value for the $param
  *
  */
 public function executeJsonUpdateSetting(sfWebRequest $request)
 {
     $isAjax = $request->isXmlHttpRequest();
     if (!$isAjax) {
         return $this->redirect('@homepage');
     }
     $settings = $request->getParameter('settings');
     $settings_decoded = json_decode($settings, true);
     $force = $request->getParameter('force');
     $networks = $request->getParameter('networks');
     $network_decoded = json_decode($networks, true);
     if ($networks) {
         $etva_data = Etva::getEtvaModelFile();
         $etvamodel = $etva_data['model'];
         /*
          * get nodes....and call node agent script
          */
         $remote_errors = array();
         $change_networks = 0;
         $cm_networks = new SystemNetworkUtil();
         $interfaces_devices = sfConfig::get('app_device_interfaces');
         $devices = $interfaces_devices[$etvamodel];
         $cm_networks->loadCMNetworks($devices);
         $sys_networks = $cm_networks->getNetworks();
         if ($etvamodel == 'standard') {
             $local = $network_decoded['lan'];
             $remote = $network_decoded['cm_management'];
             $cm_ip = $remote['ip'];
             $local_net = new SystemNetwork();
             $local_net->fromArray($local);
             $remote_net = new SystemNetwork();
             $remote_net->fromArray($remote);
             $sys_lan_if = $devices['lan'];
             $sys_manag_if = $devices['cm_management'];
             $sys_lan_net = $sys_networks[$sys_lan_if];
             $sys_manag_net = $sys_networks[$sys_manag_if];
             if (!$local_net->equals($sys_lan_net) || !$remote_net->equals($sys_manag_net)) {
                 $change_networks = 1;
             }
         } else {
             $local = $network_decoded['cm_management'];
             $remote = array();
             $cm_ip = $local['ip'];
             $local_net = new SystemNetwork();
             $local_net->fromArray($local);
             $sys_manag_if = $devices['cm_management'];
             $sys_manag_net = $sys_networks[$sys_manag_if];
             if (!$local_net->equals($sys_manag_net)) {
                 $change_networks = 1;
             }
         }
         if ($change_networks) {
             $criteria = new Criteria();
             $etva_nodes = EtvaNodePeer::doSelect($criteria);
             if (!$force) {
                 // check for nodes state if not force
                 foreach ($etva_nodes as $etva_node) {
                     $node_state = $etva_node->getState();
                     if (!$node_state) {
                         $remote_errors[] = Etva::getLogMessage(array('agent' => $etva_node->getName(), 'msg' => 'Down'), Etva::_AGENT_MSG_);
                     }
                     /*
                      * check if servers has an MA and are down...send error
                      */
                     $etva_servers = $etva_node->getEtvaServers();
                     foreach ($etva_servers as $etva_server) {
                         $server_ma = $etva_server->getAgentTmpl();
                         $server_state = $etva_server->getState();
                         if (!$server_state && $server_ma) {
                             $remote_errors[] = Etva::getLogMessage(array('agent' => $etva_server->getName(), 'msg' => 'Down'), Etva::_AGENT_MSG_);
                         }
                     }
                 }
                 //end foreach
             }
             if ($remote_errors && !$force) {
                 $msg = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'action' => 'check_nodes', 'info' => implode('<br>', $remote_errors), 'error' => implode(' ', $remote_errors));
                 $error = $this->setJsonError($msg);
                 return $this->renderText($error);
             }
             if ($etvamodel != 'standard') {
                 // only if not standard version
                 /*
                  * 
                  * check ISO DIR in use
                  *
                  */
                 $isosdir = sfConfig::get("config_isos_dir");
                 $criteria = new Criteria();
                 $criteria->add(EtvaServerPeer::LOCATION, "%{$isosdir}%", Criteria::LIKE);
                 $criteria->add(EtvaServerPeer::VM_STATE, 'running');
                 $servers_running_iso = EtvaServerPeer::doSelect($criteria);
                 foreach ($servers_running_iso as $server) {
                     $remote_errors[] = $this->getContext()->getI18N()->__(EtvaServerPeer::_CDROM_INUSE_, array('%name%' => $server->getName()));
                 }
                 if ($remote_errors) {
                     $message = Etva::getLogMessage(array('info' => ETVA::_CDROM_INUSE_), ETVA::_ERR_ISODIR_INUSE_);
                     $this->dispatcher->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
                     $i18n_br_sep = implode('<br>', $remote_errors);
                     $i18n_sp_sep = implode(' ', $remote_errors);
                     //$iso_br_msg = Etva::getLogMessage(array('info'=>'<br>'.$br_sep), ETVA::_ERR_ISODIR_INUSE_);
                     $i18n_iso_br_msg = $this->getContext()->getI18N()->__(ETVA::_ERR_ISODIR_INUSE_, array('%info%' => '<br>' . $i18n_br_sep));
                     //$iso_sp_msg = Etva::getLogMessage(array('info'=>$sp_sep), ETVA::_ERR_ISODIR_INUSE_);
                     $i18n_iso_sp_msg = $this->getContext()->getI18N()->__(ETVA::_ERR_ISODIR_INUSE_, array('%info%' => $i18n_sp_sep));
                     $msg = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'info' => $i18n_iso_br_msg, 'error' => $i18n_iso_sp_msg);
                     $error = $this->setJsonError($msg);
                     return $this->renderText($error);
                 }
                 /*
                  * if all ok so far.....send nodes umount ISO DIR
                  */
                 foreach ($etva_nodes as $etva_node) {
                     $node_va = new EtvaNode_VA($etva_node);
                     $response = array('success' => true);
                     if ($force && $etva_node->getState()) {
                         $response = $node_va->send_umount_isosdir();
                     }
                     $success = $response['success'];
                     if (!$success) {
                         $node_msg = Etva::getLogMessage(array('name' => $response['agent'], 'info' => $response['error']), EtvaNodePeer::_ERR_ISODIR_UMOUNT_);
                         $remote_errors[] = $node_msg;
                         $message = Etva::getLogMessage(array('info' => $node_msg), EtvaSettingPeer::_ERR_SETTING_REMOTE_CONNECTIVITY_SAVE_);
                         $this->dispatcher->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
                     }
                 }
                 if (!empty($remote_errors)) {
                     $msg = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'info' => implode('<br>', $remote_errors), 'error' => implode(' ', $remote_errors));
                     $error = $this->setJsonError($msg);
                     return $this->renderText($error);
                 }
             }
             /*
              * update using local script
              */
             $local_updated = $this->localUpdate($local);
             if (!$local_updated) {
                 $intf = $local['if'];
                 $msg_i18n = $this->getContext()->getI18N()->__(SystemNetwork::_ERR_NOTFOUND_INTF_, array('%name%' => $intf, '%info%' => ''));
                 $info = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n);
                 $error = $this->setJsonError($info);
                 return $this->renderText($error);
             }
             if (empty($remote_errors)) {
                 foreach ($etva_nodes as $etva_node) {
                     // send update to nodes if force
                     $etva_node->setSoapTimeout(5);
                     $remote_updated = $this->remoteUpdate($etva_node, $remote, $cm_ip);
                     if ($remote_updated !== true) {
                         if ($remote_updated === false) {
                             $intf = $remote['intf'];
                             $msg_i18n = $this->getContext()->getI18N()->__(SystemNetwork::_ERR_NOTFOUND_INTF_, array('%name%' => $intf, '%info%' => ''));
                             $remote_errors[] = $msg_i18n;
                             //$error = array('success'=>false,'agent'=>sfConfig::get('config_acronym'),'error'=>$msg_i18n);
                         } else {
                             $agent_msg = Etva::getLogMessage(array('agent' => $remote_updated['agent'], 'msg' => $remote_updated['error']), Etva::_AGENT_MSG_);
                             $message = Etva::getLogMessage(array('info' => $agent_msg), EtvaSettingPeer::_ERR_SETTING_REMOTE_CONNECTIVITY_SAVE_);
                             $this->dispatcher->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
                             $remote_errors[] = $agent_msg;
                         }
                     }
                     /*
                      * update MA if any...
                      *
                      */
                     $etva_servers = $etva_node->getEtvaServers();
                     foreach ($etva_servers as $etva_server) {
                         $server_ma = $etva_server->getAgentTmpl();
                         $server_state = $etva_server->getState();
                         if ($server_state && $server_ma) {
                             $aux_ip = $etva_server->getIp();
                             $etva_server->setSoapTimeout(5);
                             $remote_updated = $this->remoteUpdate($etva_server, $remote, $cm_ip);
                             if ($remote_updated === false) {
                                 $intf = $remote['intf'];
                                 $msg_i18n = $this->getContext()->getI18N()->__(SystemNetwork::_ERR_NOTFOUND_INTF_, array('%name%' => $intf, '%info%' => ''));
                                 $remote_errors[] = $msg_i18n;
                                 //$error = array('success'=>false,'agent'=>sfConfig::get('config_acronym'),'error'=>$msg_i18n);
                             } else {
                                 $agent_msg = Etva::getLogMessage(array('agent' => $remote_updated['agent'], 'msg' => $remote_updated['error']), Etva::_AGENT_MSG_);
                                 $message = Etva::getLogMessage(array('info' => $agent_msg), EtvaSettingPeer::_ERR_SETTING_REMOTE_CONNECTIVITY_SAVE_);
                                 $this->dispatcher->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
                                 $remote_errors[] = $agent_msg;
                             }
                         }
                     }
                 }
             }
             if (!empty($remote_errors)) {
                 $msg = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'info' => implode('<br>', $remote_errors), 'error' => implode(' ', $remote_errors));
                 $error = $this->setJsonError($msg);
                 return $this->renderText($error);
             }
         }
         // end if changed networks
     }
     foreach ($settings_decoded as $data) {
         $param = $data['param'];
         $value = $data['value'];
         if (!($etva_setting = EtvaSettingPeer::retrieveByPk($param))) {
             $msg_i18n = $this->getContext()->getI18N()->__(EtvaSettingPeer::_ERR_NOTFOUND_PARAM_, array('%id%' => $param));
             $info = array('success' => false, 'error' => $msg_i18n);
             $error = $this->setJsonError($info);
             return $this->renderText($error);
         }
         $etva_setting->setValue($value);
         switch ($param) {
             case 'vnc_keymap':
                 if ($etva_setting->saveVNCkeymap()) {
                     //notify system log
                     $this->dispatcher->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => Etva::getLogMessage(array('name' => $etva_setting->getValue()), EtvaSettingPeer::_OK_VNCKEYMAP_CHANGE_))));
                 } else {
                     //notify system log
                     $this->dispatcher->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => Etva::getLogMessage(array('name' => $value), EtvaSettingPeer::_ERR_VNCKEYMAP_CHANGE_), 'priority' => EtvaEventLogger::ERR)));
                 }
                 break;
             default:
                 try {
                     $etva_setting->save();
                     //notify system log
                     $this->dispatcher->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => Etva::getLogMessage(array('name' => $etva_setting->getParam(), 'value' => $etva_setting->getValue()), EtvaSettingPeer::_OK_SETTING_CHANGE_))));
                 } catch (Exception $e) {
                     //notify system log
                     $this->dispatcher->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => Etva::getLogMessage(array('name' => $value), EtvaSettingPeer::_ERR_SETTING_CHANGE_), 'priority' => EtvaEventLogger::ERR)));
                 }
                 break;
         }
     }
     // end foreach
     $msg_i18n = $this->getContext()->getI18N()->__(EtvaSettingPeer::_OK_SETTING_CONNECTIVITY_SAVE_);
     $message = EtvaSettingPeer::_OK_SETTING_CONNECTIVITY_SAVE_;
     $this->dispatcher->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $message)));
     $info = array('success' => true, 'agent' => sfConfig::get('config_acronym'), 'response' => $msg_i18n);
     return $this->renderText(json_encode($info));
 }