Пример #1
0
 public function check_consistency(EtvaNode $etva_node, $sync_node_vgs)
 {
     $errors = array();
     $etva_node->getId();
     $etva_cluster = $etva_node->getEtvaCluster();
     // get node database VGs
     $node_vgs = $etva_node->getEtvaNodeVolumegroups();
     // get shared database VGs
     $shared_vgs = $etva_cluster->getSharedVgs();
     $node_inconsistent = 0;
     foreach ($node_vgs as $rvg) {
         $vg = $rvg->getEtvaVolumegroup();
         $error = array();
         $uuid = $vg->getUuid();
         $vgname = $vg->getVg();
         // init
         $inconsistent = 0;
         // look at volume groups list
         $found_lvm = 0;
         foreach ($sync_node_vgs as $hvg) {
             $arr_hvg = (array) $hvg;
             if ($arr_hvg[EtvaVolumegroup::STORAGE_TYPE_MAP] == $vg->getStorageType()) {
                 if (isset($arr_hvg[EtvaVolumegroup::UUID_MAP])) {
                     if ($arr_hvg[EtvaVolumegroup::UUID_MAP] == $uuid) {
                         $found_lvm = 1;
                     }
                 } else {
                     if ($arr_hvg[EtvaVolumegroup::VG_MAP] == $vgname) {
                         $found_lvm = 1;
                     }
                 }
             }
         }
         $inconsistent = $inconsistent || !$found_lvm;
         if (!$found_lvm) {
             $error['not_found_lvm'] = 1;
         }
         $found_shared_lvm = 0;
         $inconsistent_shared_vgs = 0;
         foreach ($shared_vgs as $s_vg) {
             $s_uuid = $s_vg->getUuid();
             if ($s_uuid == $uuid) {
                 if ($s_vg->getStorageType() != $vg->getStorageType()) {
                     $inconsistent_shared_vgs = 1;
                 } else {
                     $found_shared_lvm = 1;
                 }
             } else {
                 if ($s_vg->getStorageType() == $vg->getStorageType()) {
                     if ($arr_hvg[EtvaVolumegroup::VG_MAP] == $vgname) {
                         $found_shared_lvm = 1;
                     }
                 }
             }
         }
         if ($vg->getStorageType() != EtvaVolumegroup::STORAGE_TYPE_LOCAL_MAP) {
             $inconsistent = $inconsistent || !$found_shared_lvm;
             if (!$found_shared_lvm) {
                 $error['not_found_shared_lvm'] = 1;
             }
         }
         $inconsistent = $inconsistent || $inconsistent_shared_vgs;
         if ($inconsistent_shared_vgs) {
             $error['diff_storage_type'] = 1;
         }
         // update data-base
         $etva_volumegroup = EtvaVolumegroupPeer::retrieveByNodeTypeUUIDVg($etva_node->getId(), $vg->getStorageType(), $vg->getUuid(), $vg->getVg());
         if ($etva_volumegroup) {
             $etva_volumegroup->setInconsistent($inconsistent);
             $etva_volumegroup->save();
         }
         $etva_node_volumegroup = EtvaNodeVolumegroupPeer::retrieveByPK($etva_node->getId(), $vg->getId());
         if ($etva_node_volumegroup) {
             $etva_node_volumegroup->setInconsistent($inconsistent);
             $etva_node_volumegroup->save();
         }
         if ($inconsistent) {
             $message = sfContext::getInstance()->getI18N()->__(EtvaVolumegroupPeer::_ERR_INCONSISTENT_, array('%info%' => sprintf('volume group "%s" with uuid "%s"', $vg->getVg(), $vg->getUuid())));
             if ($error['not_found_shared_lvm'] || $error['diff_storage_type']) {
                 $message = sfContext::getInstance()->getI18N()->__(EtvaVolumegroupPeer::_ERR_SHARED_INCONSISTENT_, array('%info%' => sprintf('volume group "%s" with uuid "%s"', $vg->getVg(), $vg->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['volumegroup'] = $vg->getVg();
             $error['uuid'] = $vg->getUuid();
             $error['message'] = $message;
         }
         if (!empty($error)) {
             $errors[] = $error;
         }
         $node_inconsistent = $node_inconsistent || $inconsistent;
     }
     // check consistency for shared Volume groups
     foreach ($shared_vgs as $vg) {
         $error = array();
         $uuid = $vg->getUuid();
         $vgname = $vg->getVg();
         // init
         $inconsistent = 0;
         // look at physical volumes list
         $found_lvm = 0;
         foreach ($sync_node_vgs as $hvg) {
             $arr_hvg = (array) $hvg;
             if ($arr_hvg[EtvaVolumegroup::STORAGE_TYPE_MAP] == $vg->getStorageType()) {
                 if (isset($arr_hvg[EtvaVolumegroup::UUID_MAP])) {
                     if ($arr_hvg[EtvaVolumegroup::UUID_MAP] == $uuid) {
                         $found_lvm = 1;
                     }
                 } else {
                     if ($arr_hvg[EtvaVolumegroup::VG_MAP] == $vgname) {
                         $found_lvm = 1;
                     }
                 }
             }
         }
         $inconsistent = $inconsistent || !$found_lvm;
         if (!$found_lvm) {
             $error['not_found_lvm'] = 1;
         }
         // update data-base
         $etva_volumegroup = EtvaVolumegroupPeer::retrieveByNodeTypeUUIDVg($etva_node->getId(), $vg->getStorageType(), $vg->getUuid(), $vg->getVg());
         if ($etva_volumegroup) {
             $etva_volumegroup->setInconsistent($inconsistent);
             $etva_volumegroup->save();
         }
         $etva_node_volumegroup = EtvaNodeVolumegroupPeer::retrieveByPK($etva_node->getId(), $vg->getId());
         if ($etva_node_volumegroup) {
             $etva_node_volumegroup->setInconsistent($inconsistent);
             $etva_node_volumegroup->save();
         }
         if ($inconsistent) {
             $message = sfContext::getInstance()->getI18N()->__(EtvaVolumegroupPeer::_ERR_SHARED_INCONSISTENT_, array('%info%' => sprintf('volumegroup "%s" with uuid "%s"', $vg->getVg(), $vg->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['volumegroup'] = $vg->getVg();
             $error['uuid'] = $vg->getUuid();
             $error['message'] = $message;
         }
         if (!empty($error)) {
             $errors[] = $error;
         }
         $node_inconsistent = $node_inconsistent || $inconsistent;
     }
     $return = array();
     if ($node_inconsistent) {
         $etva_node->setErrorMessage(self::VGINIT);
         $return = array('success' => false, 'errors' => $errors);
     } else {
         $etva_node->clearErrorMessage(self::VGINIT);
         $return = array('success' => true);
     }
     return $return;
 }
Пример #2
0
 public function preDelete(PropelPDO $con = null)
 {
     /*
      * delete lvs that are not shared....numVgs=1 only
      *
      */
     $criteria = new Criteria();
     $criteria->add(EtvaLogicalvolumePeer::CLUSTER_ID, $this->getClusterId());
     $criteria->addGroupByColumn(EtvaNodeLogicalvolumePeer::LOGICALVOLUME_ID);
     $criteria->addAsColumn('numLvs', 'COUNT(' . EtvaNodeLogicalvolumePeer::LOGICALVOLUME_ID . ')');
     $criteria->addHaving($criteria->getNewCriterion(EtvaNodeLogicalvolumePeer::LOGICALVOLUME_ID, 'numLvs=1', Criteria::CUSTOM));
     $records = EtvaNodeLogicalvolumePeer::doSelectJoinEtvaLogicalvolume($criteria);
     foreach ($records as $record) {
         $etva_lv = $record->getEtvaLogicalvolume();
         if ($record->getNodeId() == $this->getId()) {
             $etva_lv->delete();
         }
     }
     /*
      * delete vgs that are not shared....numVgs=1 only
      *
      */
     $criteria = new Criteria();
     $criteria->add(EtvaVolumegroupPeer::CLUSTER_ID, $this->getClusterId());
     $criteria->addGroupByColumn(EtvaNodeVolumegroupPeer::VOLUMEGROUP_ID);
     $criteria->addAsColumn('numVgs', 'COUNT(' . EtvaNodeVolumegroupPeer::VOLUMEGROUP_ID . ')');
     $criteria->addHaving($criteria->getNewCriterion(EtvaNodeVolumegroupPeer::VOLUMEGROUP_ID, 'numVgs=1', Criteria::CUSTOM));
     $records = EtvaNodeVolumegroupPeer::doSelectJoinEtvaVolumegroup($criteria);
     foreach ($records as $record) {
         $etva_vg = $record->getEtvaVolumegroup();
         if ($record->getNodeId() == $this->getId()) {
             $etva_vg->delete();
         }
     }
     /*
      * delete pvs that are not shared....numVgs=1 only
      *
      */
     $criteria = new Criteria();
     $criteria->add(EtvaPhysicalvolumePeer::CLUSTER_ID, $this->getClusterId());
     $criteria->addGroupByColumn(EtvaNodePhysicalvolumePeer::PHYSICALVOLUME_ID);
     $criteria->addAsColumn('numPvs', 'COUNT(' . EtvaNodePhysicalvolumePeer::PHYSICALVOLUME_ID . ')');
     $criteria->addHaving($criteria->getNewCriterion(EtvaNodePhysicalvolumePeer::PHYSICALVOLUME_ID, 'numPvs=1', Criteria::CUSTOM));
     $records = EtvaNodePhysicalvolumePeer::doSelectJoinEtvaPhysicalvolume($criteria);
     foreach ($records as $record) {
         $etva_pv = $record->getEtvaPhysicalvolume();
         if ($record->getNodeId() == $this->getId()) {
             $etva_pv->delete();
         }
     }
     // delete rra node dir and cpu load rrd
     $this->deleteRRAFiles();
     return true;
 }
Пример #3
0
 public function get_sync_volumegroups($force_sync = false, $sharedonly = false)
 {
     $elements = array();
     $criteria = new Criteria();
     $criteria->add(EtvaNodeVolumegroupPeer::NODE_ID, $this->etva_node->getId());
     $db_node_vgs = EtvaNodeVolumegroupPeer::doSelectJoinEtvaVolumegroup($criteria);
     $force_flag = $force_sync ? 1 : 0;
     $response_vgpvs = $this->etva_node->soapSend(EtvaVolumegroup_VA::GET_SYNC_VOLUMEGROUPS, array('force' => $force_flag));
     if ($response_vgpvs['success']) {
         $vgpvs = $response_vgpvs['response'];
         foreach ($vgpvs as $k => $e) {
             $vgpv = (array) $e;
             if (!$sharedonly || $vgpv[EtvaVolumegroup::STORAGE_TYPE_MAP] != EtvaVolumegroup::STORAGE_TYPE_LOCAL_MAP) {
                 $found = false;
                 foreach ($db_node_vgs as $data) {
                     $vg = $data->getEtvaVolumegroup();
                     if ($vgpv[EtvaVolumegroup::STORAGE_TYPE_MAP] == $vg->getStorageType()) {
                         if ($vg->getUuid() && $vgpv[EtvaVolumegroup::UUID_MAP]) {
                             if ($vg->getUuid() == $vgpv[EtvaVolumegroup::UUID_MAP]) {
                                 $found = true;
                             }
                         } else {
                             if ($vg->getVg() == $vgpv[EtvaVolumegroup::VG_MAP]) {
                                 $found = true;
                             }
                         }
                     }
                 }
                 $etva_vg = new EtvaVolumegroup();
                 $etva_vg->initData($vgpv);
                 $arr_e = $etva_vg->_VA();
                 $arr_e['registered'] = $found;
                 $elements[] = $arr_e;
             }
         }
     }
     foreach ($db_node_vgpvs as $data) {
         $vg = $data->getEtvaVolumegroup();
         if (!$sharedonly || $vg->getStorageType() != EtvaVolumegroup::STORAGE_TYPE_LOCAL_MAP) {
             $found = false;
             foreach ($vgpvs as $k => $e) {
                 $vgpv = (array) $e;
                 if ($vgpv[EtvaVolumegroup::STORAGE_TYPE_MAP] == $vg->getStorageType()) {
                     if ($vg->getUuid() && $vgpv[EtvaVolumegroup::UUID_MAP]) {
                         if ($vg->getUuid() == $vgpv[EtvaVolumegroup::UUID_MAP]) {
                             $found = true;
                         }
                     } else {
                         if ($vg->getVg() == $vgpv[EtvaVolumegroup::VG_MAP]) {
                             $found = true;
                         }
                     }
                 }
             }
             if (!$found) {
                 $arr_e = $vg->_VA();
                 $arr_e['inconsistent'] = true;
                 $arr_e['registered'] = true;
                 $elements[] = $arr_e;
             }
         }
     }
     return $elements;
 }