Esempio n. 1
0
 public function getSharedPvs()
 {
     /*
      *
      * get shared pvs of defined cluster.         
      */
     $criteria = new Criteria();
     $criteria->add(EtvaClusterPeer::ID, $this->getId());
     $criteria->addJoin(EtvaPhysicalvolumePeer::CLUSTER_ID, EtvaClusterPeer::ID);
     $criteria->add(EtvaPhysicalvolumePeer::STORAGE_TYPE, EtvaPhysicalvolume::STORAGE_TYPE_LOCAL_MAP, Criteria::ALT_NOT_EQUAL);
     $etva_shared_pvs = EtvaPhysicalvolumePeer::doSelect($criteria);
     return $etva_shared_pvs;
 }
Esempio n. 2
0
 /**
  * Return pre-formatted data for tree-column extjs
  *
  * $request may contain the following keys:
  * - cid: cid (Cluster ID)
  * @return array json array
  */
 public function executeJsonClusterPhydiskTree(sfWebRequest $request)
 {
     /*
      * criteria to select only cluster ID column matching with incoming parameter
      *
      */
     $cluster_id = $request->getParameter('cid');
     $criteria = new Criteria();
     $criteria->add(EtvaPhysicalvolumePeer::CLUSTER_ID, $cluster_id, CRITERIA::EQUAL);
     $criteria->addAnd(EtvaPhysicalvolumePeer::STORAGE_TYPE, EtvaPhysicalvolume::STORAGE_TYPE_LOCAL_MAP, Criteria::ALT_NOT_EQUAL);
     //        $criteria->addAscendingOrderByColumn(EtvaPhysicalvolumePeer::STORAGE_TYPE);
     $cluster_devs = EtvaPhysicalvolumePeer::doSelect($criteria);
     //return;
     //        $node_devs = EtvaNodePhysicalVolumePeer::doSelectJoinEtvaPhysicalvolume($criteria);
     $storages = array();
     $storage_types = array();
     foreach ($cluster_devs as $dev) {
         //            $dev = $data->getEtvaPhysicalvolume();
         $storage_type = $dev->getStorageType();
         //            $dev = new EtvaPhysicalvolume();
         $id = $dev->getId();
         $device = $dev->getDevice();
         //            $device = $dev->get $data->getDevice();
         $tag = $device;
         $uuid = $dev->getUuid();
         $qtip_i18n = $this->getContext()->getI18N()->__(EtvaPhysicalvolumePeer::_PVUNINIT_, array('%name%' => $tag));
         $qtip = $qtip_i18n;
         $type = $cls = 'dev-pd';
         $pvsize = $dev->getPvsize();
         $pretty_pvsize = $dev->getPvsize();
         $size = $dev->getDevsize();
         $pretty_size = $dev->getDevsize();
         $devicesize = $size;
         $pretty_devicesize = $pretty_size;
         if ($dev->getPvinit()) {
             $qtip_i18n = $this->getContext()->getI18N()->__(EtvaPhysicalvolumePeer::_PVINIT_, array('%name%' => $tag));
             $qtip = $qtip_i18n;
             $type = 'dev-pv';
             $cls = 'dev-pv';
             $devicesize = $pvsize;
             $pretty_devicesize = $pretty_pvsize;
         }
         $qtip .= '<br>' . $uuid;
         /* TODO improve this
          */
         if ($dev->getInconsistent()) {
             $qtip .= ' [INCONSISTENT]';
             $type = 'dev-pv-inc';
             $cls = 'dev-pv-inc';
         }
         if (sfConfig::get('sf_environment') == 'soap') {
             $children = array('device' => $device, 'iconCls' => 'task', 'cls' => $cls, 'text' => $tag, 'size' => $size, 'storage_type' => $storage_type, 'prettysize' => $pretty_size, 'pvsize' => $pvsize, 'pretty-pvsize' => $pretty_pvsize, 'devicesize' => $devicesize, 'pretty-devicesize' => $pretty_devicesize, 'singleClickExpand' => true, 'type' => $type, 'qtip' => $qtip, 'leaf' => true);
         } else {
             $children = array('id' => $id, 'device' => $device, 'iconCls' => 'task', 'cls' => $cls, 'text' => $tag, 'size' => $size, 'storage_type' => $storage_type, 'prettysize' => $pretty_size, 'pvsize' => $pvsize, 'pretty-pvsize' => $pretty_pvsize, 'devicesize' => $devicesize, 'pretty-devicesize' => $pretty_devicesize, 'singleClickExpand' => true, 'type' => $type, 'qtip' => $qtip, 'uuid' => $uuid, 'leaf' => true);
         }
         $storage_types[$storage_type][] = $children;
     }
     foreach ($storage_types as $type => $data) {
         $storages[] = array('id' => $type, 'iconCls' => 'devices-folder', 'text' => $type, 'expanded' => true, 'singleClickExpand' => true, 'children' => $data);
     }
     if (empty($storages)) {
         $msg_i18n = $this->getContext()->getI18N()->__('No data found');
         $storages[] = array('expanded' => true, 'text' => $msg_i18n, 'qtip' => $msg_i18n, 'leaf' => true);
     }
     $return = json_encode($storages);
     if (sfConfig::get('sf_environment') == 'soap') {
         return $return;
     } else {
         $this->getResponse()->setHttpHeader('Content-type', 'application/json');
         return $this->renderText($return);
     }
 }