예제 #1
0
 public function send_migrate(EtvaNode $from_etva_node, EtvaNode $to_etva_node)
 {
     $method = self::SERVER_MIGRATE;
     $params = array('daddr' => $to_etva_node->getIp(), 'dagentname' => $to_etva_node->getName(), 'uuid' => $this->etva_server->getUuid(), 'live' => true);
     // do migrate in live mode
     $preCond = $this->preSend($method, $from_etva_node, $to_etva_node);
     if (!$preCond['success']) {
         return $preCond;
     }
     // mark state as migrating...
     $etva_server = $this->etva_server;
     $bkp_server_state = $etva_server->getVmState();
     $etva_server->setVmState(EtvaServer::STATE_MIGRATING);
     $etva_server->save();
     $response = $from_etva_node->soapSend($method, $params);
     $result = $this->processMigrateResponse($from_etva_node, $to_etva_node, $response, $method);
     if ($result['success']) {
         // update free memory on source
         $cur_avail = $from_etva_node->getMemfree();
         $cur_free = $cur_avail + Etva::MB_to_Byteconvert($this->etva_server->getMem());
         $from_etva_node->setMemfree($cur_free);
         $from_etva_node->save();
     } else {
         // if not success
         // rollback state
         // TODO improve this...
         $etva_server->setVmState($bkp_server_state);
         $etva_server->save();
     }
     return $result;
 }