Exemplo n.º 1
0
 /**
  * Used to process soap requests => updateVirtAgentLvs
  *
  * Updates logical volume info sent by virt Agent
  *
  * Replies with succcess
  *
  * $request may contain the following keys:
  * - uid: uid (virtAgent sending request uid)
  * - lvs (object containing logical volumes info)
  * @return array array(success=>true)
  */
 public function executeSoapUpdate(sfWebRequest $request)
 {
     /*
      * Check if the request is made via soapapi.php interface
      */
     if (sfConfig::get('sf_environment') == 'soap') {
         $lvs = $request->getParameter('lvs');
         $dtable = $request->getParameter('devicetable');
         // check node ID correspondig to the uid given
         $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 system log
             $node_message = Etva::getLogMessage(array('name' => $request->getParameter('uuid')), EtvaNodePeer::_ERR_NOTFOUND_UUID_);
             $message = Etva::getLogMessage(array('info' => $node_message), EtvaLogicalvolumePeer::_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;
         }
         /*
          * check node cluster ID
          */
         if (!($etva_cluster = $etva_node->getEtvaCluster())) {
             $error_msg = sprintf('Object etva_cluster does not exist for node %s', $etva_node->getName());
             $error = array('success' => false, 'error' => $error_msg);
             //notify system log
             $cluster_message = Etva::getLogMessage(array('info' => $error_msg), EtvaClusterPeer::_ERR_CLUSTER_);
             $message = Etva::getLogMessage(array('info' => $cluster_message), EtvaLogicalvolumePeer::_ERR_SOAPUPDATE_);
             $this->dispatcher->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
             return $error;
         }
         # bulk device table with timeout
         $bulk_response_dtable = $etva_cluster->soapSend('device_table', array(), $etva_node, false, 120);
         /*
          * send logical volume to VA
          */
         $lv_va = new EtvaLogicalvolume_VA();
         $response = $lv_va->initialize($etva_node, $lvs, $dtable, $bulk_response_dtable);
         return $response;
     }
     // end soap request
 }