Ejemplo n.º 1
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);
         }
     }
 }
Ejemplo n.º 2
0
 public function retrievePhysicalvolumeByDevice($dev)
 {
     $criteria = new Criteria();
     $criteria->add(EtvaNodePhysicalvolumePeer::NODE_ID, $this->getId());
     $criteria->add(EtvaNodePhysicalvolumePeer::DEVICE, $dev);
     $criteria->addJoin(EtvaNodePhysicalvolumePeer::PHYSICALVOLUME_ID, EtvaPhysicalvolumePeer::ID);
     return EtvaPhysicalvolumePeer::doSelectOne($criteria);
 }
Ejemplo n.º 3
0
 /**
  * Return pre-formatted data for tree-column extjs
  *
  * $request may contain the following keys:
  * - nid: nid (virtAgent node ID)
  * @return array json array
  */
 public function executeJsonClusterVgsTree(sfWebRequest $request)
 {
     $cluster_id = $request->getParameter('cid');
     $criteria = new Criteria();
     $criteria->add(EtvaVolumeGroupPeer::CLUSTER_ID, $cluster_id);
     $criteria->addAnd(EtvaVolumeGroupPeer::STORAGE_TYPE, EtvaVolumeGroup::STORAGE_TYPE_LOCAL_MAP, Criteria::ALT_NOT_EQUAL);
     $cluster_vgs = EtvaVolumeGroupPeer::doSelect($criteria);
     //        $criteria->add(EtvaNodeVolumeGroupPeer::NODE_ID,$request->getParameter('nid'));
     //        $node_vgs = EtvaNodeVolumeGroupPeer::doSelectJoinEtvaVolumegroup($criteria);
     $volumes = array();
     foreach ($cluster_vgs as $vg) {
         //            $node_id = $data->getNodeId();
         //            $vg = $data->getEtvaVolumegroup();
         $pvs_tree = array();
         $etva_vp = $vg->getEtvaVolumePhysicals();
         foreach ($etva_vp as $vp) {
             $pv = $vp->getEtvaPhysicalvolume();
             if ($pv) {
                 $id = $pv->getId();
                 $c_criteria = new Criteria();
                 $c_criteria->add(EtvaPhysicalvolumePeer::ID, $id);
                 $c_criteria->add(EtvaPhysicalvolumePeer::CLUSTER_ID, $cluster_id);
                 $np = EtvaPhysicalvolumePeer::doSelectOne($c_criteria);
                 //                    $np = EtvaNodePhysicalvolumePeer::retrieveByPK($node_id, $id);
                 //AKII
                 $elem = $np->getDevice();
                 $pvdevice = $pv->getPv();
                 $pretty_size = $size = $pv->getPvsize();
                 $qtip = '';
                 $cls = 'dev-pv';
                 $pvs_tree[] = array('id' => $id, 'cls' => $cls, 'iconCls' => 'task', 'text' => $elem, 'pv' => $pvdevice, 'size' => $size, 'prettysize' => $pretty_size, 'singleClickExpand' => true, 'type' => 'dev-pv', 'qtip' => $qtip, 'leaf' => true);
             }
         }
         $id = $vg->getVg();
         $vgid = $vg->getId();
         $qtip = '';
         $cls = 'vg';
         $pretty_size = $size = $vg->getSize();
         $free_size = $vg->getFreesize();
         $expanded = empty($pvs_tree) ? true : false;
         $type = $vg->getStorageType();
         $is_DiskVG = $id == sfConfig::get('app_volgroup_disk_flag') ? 1 : 0;
         if ($is_DiskVG) {
             $type = 'file';
         }
         /* TODO improve this
          */
         if ($vg->getInconsistent()) {
             $qtip .= ' [INCONSISTENT]';
             $cls = 'vg-inc';
         }
         $inuse = $vg->hasLogicalVolumesInUse();
         $volumes[] = array('id' => $id, 'expanded' => $expanded, 'vgid' => $vgid, 'iconCls' => 'devices-folder', 'cls' => $cls, 'text' => $id, 'type' => $type, 'size' => $size, 'prettysize' => $pretty_size, 'freesize' => $free_size, 'singleClickExpand' => true, 'qtip' => $qtip, 'children' => $pvs_tree, 'inuse' => $inuse);
     }
     if (empty($volumes)) {
         $msg_i18n = $this->getContext()->getI18N()->__('No data found');
         $volumes[] = array('expanded' => true, 'text' => $msg_i18n, 'qtip' => $msg_i18n, 'leaf' => true);
     }
     $return = json_encode($volumes);
     $this->getResponse()->setHttpHeader('Content-type', 'application/json');
     return $this->renderText($return);
 }