Ejemplo n.º 1
0
 protected function processStartStop(EtvaNode $etva_node, $response, $method)
 {
     $etva_server = $this->etva_server;
     switch ($method) {
         case self::SERVER_START:
             $msg_ok_type = EtvaServerPeer::_OK_START_;
             $msg_err_type = EtvaServerPeer::_ERR_START_;
             break;
         case self::SERVER_STOP:
             $msg_ok_type = EtvaServerPeer::_OK_STOP_;
             $msg_err_type = EtvaServerPeer::_ERR_STOP_;
             break;
     }
     if (!$response['success']) {
         $result = $response;
         $msg_i18n = Etva::makeNotifyLogMessage($response['agent'], $response['info'], array(), $msg_err_type, array('name' => $etva_server->getName()));
         $result['error'] = $msg_i18n;
         return $result;
     }
     $response_decoded = (array) $response['response'];
     $returned_status = $response_decoded['_okmsg_'];
     $returned_object = (array) $response_decoded['_obj_'];
     // get some info from response...
     //update some server data from agent response
     $etva_server->initData($returned_object);
     $etva_server->setFirstBoot(0);
     if ($first_boot) {
         $etva_server->setBoot('filesystem');
     } else {
         $boot_field = $etva_server->getBoot();
         switch ($boot_field) {
             case 'filesystem':
             case 'pxe':
                 if (!$etva_server->getCdrom()) {
                     $etva_server->setLocation(null);
                 }
                 break;
         }
     }
     switch ($method) {
         case self::SERVER_START:
             $etva_server->setHblaststart('NOW');
             // update hb last start
             break;
     }
     $etva_server->save();
     // update free memory
     $etva_node->updateMemFree();
     $etva_node->save();
     //notify event log
     $msg_i18n = Etva::makeNotifyLogMessage($response['agent'], $msg_ok_type, array('name' => $etva_server->getName()), null, array(), EtvaEventLogger::INFO);
     $result = array('success' => true, 'agent' => $response['agent'], 'response' => $msg_i18n);
     return $result;
 }