Пример #1
0
 public function getEtvaLogicalvolumesSnapshots(Criteria $criteria = null)
 {
     if (!$criteria) {
         $criteria = new Criteria();
     }
     $criteria->add(EtvaLogicalvolumePeer::VOLUMEGROUP_ID, $this->getVolumegroupId());
     $criteria->add(EtvaLogicalvolumePeer::ORIGIN, $this->getLv());
     $criteria->add(EtvaLogicalvolumePeer::SNAPSHOT, 1);
     return EtvaLogicalvolumePeer::doSelect($criteria);
 }
Пример #2
0
 public function executeGraphDiskRWPNG(sfWebRequest $request)
 {
     $etva_lv = EtvaLogicalvolumePeer::retrieveByPK($request->getParameter('id'));
     $etva_server = $etva_lv->getEtvaServer();
     $etva_node = $etva_server->getEtvaNode();
     $graph_start = $request->getParameter('graph_start');
     $graph_end = $request->getParameter('graph_end');
     $disk_rra = new ServerDisk_rwRRA($etva_node->getUuid(), $etva_server->getUuid(), $etva_lv->getLv());
     $title = sprintf("%s :: %s", $etva_server->getName(), $etva_lv->getLv());
     $this->getResponse()->setContentType('image/png');
     $this->getResponse()->setHttpHeader('Content-Type', 'image/png', TRUE);
     $this->getResponse()->sendHttpHeaders();
     $this->getResponse()->setContent(print $disk_rra->getGraphImg($title, $graph_start, $graph_end));
     return sfView::HEADER_ONLY;
 }
Пример #3
0
 public function clearStorage()
 {
     $c = new Criteria();
     $c->add(EtvaNodeLogicalvolumePeer::NODE_ID, $this->getId());
     EtvaLogicalvolumePeer::doDelete($c);
     $c = new Criteria();
     $c->add(EtvaNodeVolumegroupPeer::NODE_ID, $this->getId());
     EtvaVolumegroupPeer::doDelete($c);
     $c = new Criteria();
     $c->add(EtvaNodePhysicalvolumePeer::NODE_ID, $this->getId());
     EtvaPhysicalvolumePeer::doDelete($c);
 }
Пример #4
0
 public static function getOrElectNodeFromArray($arguments)
 {
     // get parameters
     $nid = isset($arguments['node']) ? $arguments['node'] : null;
     $cid = isset($arguments['cluster']) ? $arguments['cluster'] : null;
     $level = isset($arguments['level']) ? $arguments['level'] : null;
     $vg = isset($arguments['volumegroup']) ? $arguments['volumegroup'] : null;
     $dev = isset($arguments['device']) ? $arguments['device'] : null;
     $lv = isset($arguments['logicalvolume']) ? $arguments['logicalvolume'] : null;
     // check level - back compatibility
     if (!$level) {
         $level = 'node';
     }
     if ($level == 'cluster') {
         $etva_cluster = EtvaClusterPeer::retrieveByPK($cid);
         return EtvaNode::getFirstActiveNode($etva_cluster);
     } elseif ($level == 'node') {
         $etva_node = EtvaNodePeer::retrieveByPK($nid);
         if ($lv) {
             $c = new Criteria();
             $c->add(EtvaLogicalvolumePeer::STORAGE_TYPE, EtvaLogicalvolume::STORAGE_TYPE_LOCAL_MAP, Criteria::ALT_NOT_EQUAL);
             $etva_lv = EtvaLogicalvolumePeer::retrieveByLv($lv, $c);
             return $etva_lv ? EtvaNodePeer::ElectNode($etva_node) : $etva_node;
         } elseif ($dev) {
             $c = new Criteria();
             $c->add(EtvaPhysicalvolumePeer::STORAGE_TYPE, EtvaPhysicalvolume::STORAGE_TYPE_LOCAL_MAP, Criteria::ALT_NOT_EQUAL);
             $etva_pv = EtvaPhysicalvolumePeer::retrieveByDevice($dev, $c);
             return $etva_pv ? EtvaNodePeer::ElectNode($etva_node) : $etva_node;
         } elseif ($vg) {
             $c = new Criteria();
             $c->add(EtvaVolumeGroupPeer::STORAGE_TYPE, EtvaVolumeGroup::STORAGE_TYPE_LOCAL_MAP, Criteria::ALT_NOT_EQUAL);
             $etva_vg = EtvaVolumegroupPeer::retrieveByVg($vg, $c);
             return $etva_vg ? EtvaNodePeer::ElectNode($etva_node) : $etva_node;
         } else {
             return $etva_node;
         }
     }
 }
Пример #5
0
 protected function check_lvs(EtvaNode $etva_node)
 {
     $node_response = $etva_node->soapSend('getlvs_arr', array('force' => 1));
     if (!$node_response['success']) {
         $errors = $node_response['error'];
         Etva::getLogMessage(array('info' => ''), EtvaLogicalvolumePeer::_ERR_INCONSISTENT_);
         $etva_node->setErrorMessage(EtvaLogicalvolume_VA::LVINIT);
         $message = Etva::getLogMessage(array('info' => $node_response['info']), EtvaLogicalvolumePeer::_ERR_SOAPUPDATE_);
         sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($etva_node->getName(), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
         $response = array('success' => false, 'error' => $errors);
         $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_lvs = $node_response['response'];
     $my_lvs = (array) $my_lvs;
     foreach ($my_lvs as $my_lv) {
         $lv_info = (array) $my_lv;
         if ($lv_info['type'] == EtvaLogicalvolume::STORAGE_TYPE_LOCAL_MAP) {
             continue;
         }
         $c_uuid = new criteria();
         $c_uuid->add(EtvaLogicalvolumePeer::UUID, $lv_info['uuid']);
         $c_uuid->addAnd(EtvaLogicalvolumePeer::CLUSTER_ID, $cluster_id, Criteria::NOT_EQUAL);
         $e_lv = EtvaLogicalvolumePeer::doSelectOne($c_uuid);
         if ($e_lv) {
             $c_c = new Criteria();
             $c_c->add(EtvaClusterPeer::ID, $e_lv->getClusterId());
             $etva_cluster = EtvaClusterPeer::doSelectOne($c_c);
             $msg_i18n = $this->getContext()->getI18N()->__(EtvaLogicalvolumePeer::_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);
         }
     }
 }
Пример #6
0
 public function check_consistency(EtvaNode $etva_node, $sync_node_lvs, $sync_node_dtable, $sync_bulk_dtable)
 {
     $errors = array();
     $etva_node->getId();
     $etva_cluster = $etva_node->getEtvaCluster();
     // get node database LVs
     $node_lvs = $etva_node->getEtvaLogicalvolumes();
     $node_inconsistent = 0;
     foreach ($node_lvs as $lv) {
         $error = array();
         $uuid = $lv->getUuid();
         $device = $lv->getLvdevice();
         $etva_vg = $lv->getEtvaVolumegroup();
         $vgname = $etva_vg->getVg();
         $is_FileDiskVG = $vgname == sfConfig::get('app_volgroup_disk_flag') ? true : false;
         // init
         $inconsistent = 0;
         // look at logical volumes list
         $found_lvm = 0;
         foreach ($sync_node_lvs as $hlv) {
             $arr_hlv = (array) $hlv;
             if ($arr_hlv[EtvaLogicalvolume::STORAGE_TYPE_MAP] == $lv->getStorageType()) {
                 if ($arr_hlv[EtvaLogicalvolume::UUID_MAP]) {
                     if ($arr_hlv[EtvaLogicalvolume::UUID_MAP] == $uuid) {
                         $found_lvm = 1;
                     }
                 } else {
                     if ($arr_hlv[EtvaLogicalvolume::LVDEVICE_MAP] == $device) {
                         $found_lvm = 1;
                     }
                 }
             }
         }
         $inconsistent = $inconsistent || !$found_lvm;
         if (!$found_lvm) {
             $error['not_found_lvm'] = 1;
         }
         if (!$is_FileDiskVG) {
             // if not file disk volume
             // look at devices table
             $clvdev = $device;
             $clvdev = str_replace("/dev/", "", $clvdev);
             $clvdev = str_replace("-", "--", $clvdev);
             $clvdev = str_replace("/", "-", $clvdev);
             $re_clvdev = "/" . $clvdev . ":/";
             // found device table of node
             $node_lv_dtable_aux = preg_grep($re_clvdev, $sync_node_dtable);
             // ignore snapshots
             $node_lv_dtable = preg_grep("/(?:(?! snapshot ).)/", $node_lv_dtable_aux);
             // check if found
             $found_node_dt = empty($node_lv_dtable) ? 0 : 1;
             $inconsistent = $inconsistent || !$found_node_dt;
             if (!$found_node_dt) {
                 $error['not_found_node_device_table'] = 1;
             }
         }
         // update data-base
         $etva_logicalvol = EtvaLogicalvolumePeer::retrieveByNodeTypeUUIDLv($etva_node->getId(), $lv->getStorageType(), $lv->getUuid(), $lv->getLv());
         if ($etva_logicalvol) {
             $etva_logicalvol->setInconsistent($inconsistent);
             $etva_logicalvol->save();
         }
         $etva_node_logicalvol = EtvaNodeLogicalvolumePeer::retrieveByPK($etva_node->getId(), $lv->getId());
         if ($etva_node_logicalvol) {
             $etva_node_logicalvol->setInconsistent($inconsistent);
             $etva_node_logicalvol->save();
         }
         if ($inconsistent) {
             $message = sfContext::getInstance()->getI18N()->__(EtvaLogicalvolumePeer::_ERR_INCONSISTENT_, array('%info%' => sprintf('device "%s" with uuid "%s"', $lv->getLvdevice(), $lv->getUuid())));
             sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($etva_node->getName(), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
             $error['node'] = array('name' => $etva_node->getName(), 'id' => $etva_node->getId(), 'uuid' => $etva_node->getUuid());
             $error['device'] = $lv->getLvdevice();
             $error['uuid'] = $lv->getUuid();
             $error['message'] = $message;
         }
         if (!empty($error)) {
             $errors[] = $error;
         }
         $node_inconsistent = $node_inconsistent || $inconsistent;
     }
     // get shared database LVs
     $shared_lvs = $etva_cluster->getSharedLvs();
     // check consistency for shared LVs
     foreach ($shared_lvs as $lv) {
         $error = array();
         $uuid = $lv->getUuid();
         $device = $lv->getLvdevice();
         $etva_vg = $lv->getEtvaVolumegroup();
         $vgname = $etva_vg->getVg();
         // init
         $inconsistent = 0;
         // look at logical volumes list
         $found_lvm = 0;
         foreach ($sync_node_lvs as $hlv) {
             $arr_hlv = (array) $hlv;
             if ($arr_hlv[EtvaLogicalvolume::STORAGE_TYPE_MAP] == $lv->getStorageType()) {
                 if (isset($arr_hlv[EtvaLogicalvolume::UUID_MAP])) {
                     if ($arr_hlv[EtvaLogicalvolume::UUID_MAP] == $uuid) {
                         $found_lvm = 1;
                     }
                 } else {
                     if ($arr_hlv[EtvaLogicalvolume::LVDEVICE_MAP] == $device) {
                         $found_lvm = 1;
                     }
                 }
             }
         }
         $inconsistent = $inconsistent || !$found_lvm;
         if (!$found_lvm) {
             $error['not_found_lvm'] = 1;
         }
         // look at devices table
         $clvdev = $device;
         $clvdev = str_replace("/dev/", "", $clvdev);
         $clvdev = str_replace("-", "--", $clvdev);
         $clvdev = str_replace("/", "-", $clvdev);
         $re_clvdev = "/" . $clvdev . ":/";
         // found device table of node
         $node_lv_dtable_aux = preg_grep($re_clvdev, $sync_node_dtable);
         // ignore snapshots
         $node_lv_dtable = preg_grep("/(?:(?! snapshot ).)/", $node_lv_dtable_aux);
         // check if found
         $found_node_dt = empty($node_lv_dtable) ? 0 : 1;
         $inconsistent = $inconsistent || !$found_node_dt;
         if (!$found_node_dt) {
             $error['not_found_node_device_table'] = 1;
         }
         // look at all nodes devices table
         $found_all_nodes_dt = 1;
         foreach ($sync_bulk_dtable as $e_id => $e_response) {
             if ($e_response['success']) {
                 //response received ok
                 $dtable = (array) $e_response['response'];
                 // found device table of node
                 $lv_dtable = preg_grep($re_clvdev, $dtable);
                 $found = empty($lv_dtable) ? 0 : 1;
                 $is_eq = count($lv_dtable) == count($node_lv_dtable) ? 1 : 0;
                 if ($is_eq) {
                     foreach ($lv_dtable as $e_line) {
                         // TODO fix this
                         if (!in_array($e_line, $node_lv_dtable)) {
                             $is_eq = 0;
                         }
                     }
                 }
                 $found_all_nodes_dt = $found_all_nodes_dt && $found && $is_eq;
             }
         }
         $inconsistent = $inconsistent || !$found_all_nodes_dt;
         if (!$found_all_nodes_dt) {
             $error['not_found_all_nodes_device_table'] = 1;
         }
         // update data-base
         $etva_logicalvol = EtvaLogicalvolumePeer::retrieveByNodeTypeUUIDLv($etva_node->getId(), $lv->getStorageType(), $lv->getUuid(), $lv->getLv());
         if ($etva_logicalvol) {
             $etva_logicalvol->setInconsistent($inconsistent);
             $etva_logicalvol->save();
         }
         $etva_node_logicalvol = EtvaNodeLogicalvolumePeer::retrieveByPK($etva_node->getId(), $lv->getId());
         if ($etva_node_logicalvol) {
             $etva_node_logicalvol->setInconsistent($inconsistent);
             $etva_node_logicalvol->save();
         }
         if ($inconsistent) {
             $message = sfContext::getInstance()->getI18N()->__(EtvaLogicalvolumePeer::_ERR_SHARED_INCONSISTENT_, array('%info%' => sprintf('device "%s" with uuid "%s"', $lv->getLvdevice(), $lv->getUuid())));
             sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($etva_node->getName(), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
             $error['node'] = array('name' => $etva_node->getName(), 'id' => $etva_node->getId(), 'uuid' => $etva_node->getUuid());
             $error['device'] = $lv->getLvdevice();
             $error['uuid'] = $lv->getUuid();
             $error['message'] = $message;
         }
         if (!empty($error)) {
             $errors[] = $error;
         }
         $node_inconsistent = $node_inconsistent || $inconsistent;
     }
     $return = array();
     if ($node_inconsistent) {
         $etva_node->setErrorMessage(self::LVINIT);
         $return = array('success' => false, 'errors' => $errors);
     } else {
         $etva_node->clearErrorMessage(self::LVINIT);
         $return = array('success' => true);
     }
     return $return;
 }
Пример #7
0
 public function check_disks_availability($etva_node, $disks, $method)
 {
     $etva_server = $this->etva_server;
     $collDisks = array();
     $i = 0;
     foreach ($disks as $disk) {
         if (!($etva_lv = EtvaLogicalvolumePeer::retrieveByPK($disk['id']))) {
             $msg = Etva::getLogMessage(array('id' => $disk['id']), EtvaLogicalvolumePeer::_ERR_NOTFOUND_ID_);
             $msg_i18n = sfContext::getInstance()->getI18N()->__(EtvaLogicalvolumePeer::_ERR_NOTFOUND_ID_, array('%id%' => $disk['id']));
             $error = array('success' => false, 'agent' => $etva_node->getName(), 'error' => $msg_i18n);
             //notify event log
             $message = Etva::getLogMessage(array('name' => $etva_server->getName(), 'info' => $msg), EtvaServerPeer::_ERR_CREATE_);
             sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($error['agent'], 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
             return $error;
         }
         $lv = $etva_lv->getLv();
         /*
          * check if is not system lv
          */
         if ($etva_lv->getMounted()) {
             $msg = Etva::getLogMessage(array('name' => $lv), EtvaLogicalvolumePeer::_ERR_SYSTEM_LV_);
             $msg_i18n = sfContext::getInstance()->getI18N()->__(EtvaLogicalvolumePeer::_ERR_SYSTEM_LV_, array('%name%' => $lv));
             $error = array('success' => false, 'agent' => $etva_node->getName(), 'error' => $msg_i18n, 'info' => $msg_i18n);
             //notify system log
             $message = Etva::getLogMessage(array('name' => $etva_server->getName(), 'info' => $msg), EtvaServerPeer::_ERR_CREATE_);
             sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($etva_node->getName(), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
             return $error;
         }
         //check if lv already marked as 'in use'
         if ($method == self::SERVER_CREATE && $etva_lv->getInUse()) {
             $lv_server = $etva_lv->getEtvaServer();
             $msg = Etva::getLogMessage(array('name' => $lv, 'server' => $lv_server->getName()), EtvaLogicalvolumePeer::_ERR_INUSE_);
             $msg_i18n = sfContext::getInstance()->getI18N()->__(EtvaLogicalvolumePeer::_ERR_INUSE_, array('%name%' => $lv, '%server%' => $lv_server->getName()));
             $error = array('success' => false, 'agent' => $etva_node->getName(), 'error' => $msg_i18n, 'info' => $msg_i18n);
             //notify event log
             $message = Etva::getLogMessage(array('name' => $etva_server->getName(), 'info' => $msg), EtvaServerPeer::_ERR_CREATE_);
             sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($error['agent'], 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
             return $error;
         }
         $etva_sl = new EtvaServerLogical();
         $etva_sl->setLogicalvolumeId($etva_lv->getId());
         $etva_sl->setDiskType($disk['disk_type']);
         $etva_sl->setBootDisk($i);
         $i++;
         $collDisks[] = $etva_sl;
     }
     // end each disk
     $this->collDisks = $collDisks;
     return array('success' => true);
 }
Пример #8
0
 public function getEtvaLogicalvolumes(Criteria $criteria = null)
 {
     if (!$criteria) {
         $criteria = new Criteria();
     }
     $criteria->add(EtvaServerLogicalPeer::SERVER_ID, $this->getId());
     $criteria->addJoin(EtvaLogicalvolumePeer::ID, EtvaServerLogicalPeer::LOGICALVOLUME_ID);
     return EtvaLogicalvolumePeer::doSelect($criteria);
 }