Exemple #1
0
 public function send_reload(EtvaNode $etva_node)
 {
     $method = self::POOL_RELOAD;
     $etva_pool = $this->etva_pool;
     $params = $etva_pool->_VA();
     $response = $etva_node->soapSend($method, $params);
     $result = $this->processResponse($etva_node, $response, $method, $params);
     return $result;
 }
 public function register(EtvaNode $etva_node, $vg_info = null)
 {
     $etva_cluster = $etva_node->getEtvaCluster();
     // check if volumegroup is shared
     $shared = $this->etva_vg->getStorageType() != EtvaVolumegroup::STORAGE_TYPE_LOCAL_MAP;
     // force to load volume groups
     $bulk_responses = array();
     if ($shared) {
         $bulk_responses = $etva_cluster->soapSend(self::GET_SYNC_VOLUMEGROUPS, array('force' => 1));
     } else {
         $node_id = $etva_node->getId();
         $bulk_responses[$node_id] = $etva_node->soapSend(self::GET_SYNC_VOLUMEGROUPS, array('force' => 1));
     }
     $vg_info_sync = $this->getVolumegroupInfo($etva_node, $bulk_responses);
     // merge vg info
     if ($vg_info_sync) {
         $vg_info = $vg_info ? array_merge($vg_info_sync, $vg_info) : $vg_info_sync;
     }
     // set vg info if needed
     if ($vg_info) {
         $this->etva_vg->initData($vg_info);
     }
     // for none local storage devices
     if ($shared) {
         // check if all nodes see that
         $check_res = $this->check_all_see_it($etva_node, $bulk_responses);
         if (!$check_res['success']) {
             return array('success' => false, 'errors' => $check_res['errors'], 'debug' => 'check_all_see_it');
         }
     }
     $etva_volgroup = $this->etva_vg;
     // set cluster
     $etva_cluster = $etva_node->getEtvaCluster();
     $etva_volgroup->setEtvaCluster($etva_cluster);
     // save it
     $etva_volgroup->save();
     // create relation node_volumegorup
     $etva_node_volgroup = new EtvaNodeVolumegroup();
     $etva_node_volgroup->setEtvaVolumegroup($etva_volgroup);
     $etva_node_volgroup->setEtvaNode($etva_node);
     $etva_node_volgroup->save();
     if ($vg_info) {
         /*
          * associate pvs with vg and update info
          */
         $pvs = isset($vg_info[EtvaVolumegroup::PHYSICALVOLUMES_MAP]) ? (array) $vg_info[EtvaVolumegroup::PHYSICALVOLUMES_MAP] : array();
         foreach ($pvs as $pv => $pvInfo) {
             $pv_info = (array) $pvInfo;
             $pv_type = $pv_info[EtvaPhysicalvolume::STORAGE_TYPE_MAP];
             $pv_uuid = isset($pv_info[EtvaPhysicalvolume::UUID_MAP]) ? $pv_info[EtvaPhysicalvolume::UUID_MAP] : '';
             $pv_device = $pv_info[EtvaPhysicalvolume::DEVICE_MAP];
             //error_log(sprintf("node name=%s id=%d device=%s uuid=%s type=%s",$etva_node->getName(),$etva_node->getId(),$pv_device,$pv_uuid,$pv_type));
             //get physical volume based on node, type, uuid and device
             $etva_physical = EtvaPhysicalvolumePeer::retrieveByNodeTypeUUIDDevice($etva_node->getId(), $pv_type, $pv_uuid, $pv_device);
             if (!$etva_physical) {
                 $etva_physical = new EtvaPhysicalvolume();
             }
             $etva_physical->setEtvaCluster($etva_cluster);
             $etva_physical->initData($pv_info);
             $etva_physical->save();
             $etva_node_physical = EtvaNodePhysicalvolumePeer::retrieveByPK($etva_node->getId(), $etva_physical->getId());
             if (!$etva_node_physical) {
                 $etva_node_physical = new EtvaNodePhysicalvolume();
             }
             $etva_node_physical->setEtvaPhysicalvolume($etva_physical);
             $etva_node_physical->setEtvaNode($etva_node);
             $etva_node_physical->setDevice($pv_device);
             $etva_node_physical->save();
             $etva_volgroup_physical = EtvaVolumePhysicalPeer::retrieveByPK($etva_volgroup->getId(), $etva_physical->getId());
             if (!$etva_volgroup_physical) {
                 $etva_volgroup_physical = new EtvaVolumePhysical();
             }
             $etva_volgroup_physical->setEtvaPhysicalvolume($etva_physical);
             $etva_volgroup_physical->setEtvaVolumegroup($etva_volgroup);
             $etva_volgroup_physical->save();
         }
     }
     // for no local storage type
     $errors = $this->sync_update($bulk_responses);
     if (!empty($errors)) {
         return array('success' => false, 'errors' => $errors);
     }
     // update logical volumes
     $lv_va = new EtvaLogicalvolume_VA();
     $lv_errors = $lv_va->send_update($etva_node, true, $shared);
     if (!empty($lv_errors)) {
         return array('success' => false, 'errors' => $lv_errors);
     }
     return array('success' => true);
 }
Exemple #3
0
 private function check_pvs(EtvaNode $etva_node)
 {
     $node_response = $etva_node->soapSend('getpvs_arr', array('force' => 1));
     if (!$node_response['success']) {
         $errors = $node_response['error'];
         Etva::getLogMessage(array('info' => ''), EtvaPhysicalvolumePeer::_ERR_INCONSISTENT_);
         //$etva_node->setErrorMessage(EtvaPhysicalvolume_VA::LVINIT);
         $message = $this->getContext()->getI18N()->__(EtvaPhysicalvolumePeer::_ERR_SOAPUPDATE_, array('%info%' => $node_response['info']));
         sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($etva_node->getName(), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
         $response = array('success' => false, 'error' => $message, 'agent' => $etva_node->getName());
         $return = $this->setJsonError($response);
         return $this->renderText($return);
     }
     //verify if cluster has any logical volume that belongs to another cluster...
     $cluster_id = $etva_node->getClusterId();
     $my_pvs = $node_response['response'];
     $my_pvs = (array) $my_pvs;
     foreach ($my_pvs as $my_pv) {
         $pv_info = (array) $my_pv;
         if ($pv_info['type'] == EtvaPhysicalvolume::STORAGE_TYPE_LOCAL_MAP) {
             continue;
         }
         $c_uuid = new criteria();
         $c_uuid->add(EtvaPhysicalvolumePeer::UUID, $pv_info['uuid']);
         $c_uuid->addAnd(EtvaPhysicalvolumePeer::CLUSTER_ID, $cluster_id, Criteria::NOT_EQUAL);
         $e_pv = EtvaPhysicalvolumePeer::doSelectOne($c_uuid);
         if ($e_pv) {
             $c_c = new Criteria();
             $c_c->add(EtvaClusterPeer::ID, $e_pv->getClusterId());
             $etva_cluster = EtvaClusterPeer::doSelectOne($c_c);
             $msg_i18n = $this->getContext()->getI18N()->__(EtvaPhysicalvolumePeer::_ERR_INIT_OTHER_CLUSTER_, array('%name%' => $etva_cluster->getName()));
             $response = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
             $return = $this->setJsonError($response);
             return $this->renderText($return);
         }
     }
 }
 public function send_expand(EtvaNode $etva_node)
 {
     $msg_ok_type = EtvaPhysicalvolumePeer::_OK_EXPAND_;
     $msg_err_type = EtvaPhysicalvolumePeer::_ERR_EXPAND_;
     $method = self::DEVICERESIZE;
     $etva_pv_uuid = $this->etva_pv->getUuid();
     $etva_pv_type = $this->etva_pv->getStorageType();
     $etva_pv_device = $this->etva_pv->getDevice();
     $params = array('device' => $etva_pv_device, 'uuid' => $etva_pv_uuid);
     // check if physical volume is shared
     $shared = $this->etva_pv->getStorageType() != EtvaPhysicalvolume::STORAGE_TYPE_LOCAL_MAP;
     $etva_cluster = $etva_node->getEtvaCluster();
     $bulk_responses = array();
     if ($shared) {
         // call resize at all nodes
         $bulk_responses = $etva_cluster->soapSend($method, $params);
     } else {
         $node_id = $etva_node->getId();
         // call resize
         $bulk_responses[$node_id] = $etva_node->soapSend($method, $params);
     }
     // sync physical volumes size
     $errors = $this->send_update($etva_node);
     if (!empty($errors)) {
         $result = array('success' => false, 'errors' => $errors);
         $msg_i18n = Etva::makeNotifyLogMessage($etva_node->getName(), $msg_err_type, array('name' => $this->etva_pv->getName(), 'info' => ''));
         $result['error'] = $msg_i18n;
         return $result;
     } else {
         //notify system log
         $message = Etva::getLogMessage(array('name' => $this->etva_pv->getName()), $msg_ok_type);
         $msg_i18n = sfContext::getInstance()->getI18N()->__($msg_ok_type, array('%name%' => $this->etva_pv->getName()));
         sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($etva_node->getName(), 'event.log', array('message' => $message)));
         $result = array('success' => true, 'agent' => $etva_node->getName(), 'response' => $msg_i18n);
         return $result;
     }
 }
 public function send_convertformat(EtvaNode $etva_node, $format)
 {
     $method = self::CONVERTFORMAT;
     $etva_lv = $this->etva_lv;
     // TODO testing can do convert
     // prepare soap info....
     $lvdevice = $etva_lv->getLvdevice();
     $params = array('olv' => $lvdevice, 'dlv' => $lvdevice, 'format' => $format);
     // send soap request
     $response = $etva_node->soapSend($method, $params);
     $result = $this->processCommonResponse($etva_node, $response, $method, EtvaLogicalvolumePeer::_OK_CONVERT_, EtvaLogicalvolumePeer::_ERR_CONVERT_, array('name' => $etva_lv->getLv()));
     if ($result['success']) {
         //update logical, volume group and physical sizes
         $etva_lv->setFormat($format);
         $etva_lv->save();
     }
     return $result;
 }
 public function remove_snapshot(EtvaNode $etva_node, $snapshot)
 {
     return $etva_node->soapSend(self::SERVER_REMOVE_SNAPSHOT, array('uuid' => $this->etva_server->getUuid(), 'name' => $this->etva_server->getName(), 'snapshot' => $snapshot));
 }