Example #1
0
 public function send_create(EtvaNode $etva_node, $pool_data)
 {
     $method = self::POOL_CREATE;
     $etva_pool = $this->etva_pool;
     $etva_pool->fromArray($pool_data, BasePeer::TYPE_FIELDNAME);
     $etva_pool->setUuid(EtvaPoolPeer::generateUUID());
     $params = $etva_pool->_VA();
     $response = $etva_node->soapSend($method, $params);
     $result = $this->processResponse($etva_node, $response, $method, $params);
     return $result;
 }
Example #2
0
 public function executeJsonReload(sfWebRequest $request)
 {
     $msg_ok_type = EtvaPoolPeer::_OK_RELOAD_;
     $msg_err_type = EtvaPoolPeer::_ERR_RELOAD_;
     // 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);
     }
     $id = $request->getParameter('id');
     $uuid = $request->getParameter('uuid');
     $name = $request->getParameter('name');
     if ($id) {
         $etva_pool = EtvaPoolPeer::retrieveByPK($id);
     } else {
         if ($uuid) {
             $etva_pool = EtvaPoolPeer::retrieveByUUID($uuid);
         } else {
             if ($name) {
                 $etva_pool = EtvaPoolPeer::retrieveByName($name);
             }
         }
     }
     if (!$etva_pool) {
         $msg = Etva::getLogMessage(array('name' => $name), EtvaPoolPeer::_ERR_NOTFOUND_);
         $msg_i18n = $this->getContext()->getI18N()->__(EtvaPoolPeer::_ERR_NOTFOUND_, array('%name%' => $name));
         $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n);
         //notify system log
         $message = Etva::getLogMessage(array('name' => $name, 'info' => $msg), $msg_err_type);
         $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);
     }
     $name = $etva_pool->getName();
     // do reload
     $etva_pool_va = new EtvaPool_VA($etva_pool);
     $response = $etva_pool_va->send_reload($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);
     }
 }