Source for file actions.class.php
Documentation is available at actions.class.php
* @subpackage physicalvol
* @version SVN: $Id: actions.class.php 12474 2008-10-31 10:41:27Z fabien $
* Initializes a physical device
* Params: array pv (mapping to db phpnames), nid (virtAgent node ID)
$criteria = new Criteria();
$pv = ($request->getParameter('pv')) ? json_decode($request->getParameter('pv'),true): array();
$pv_device = $pv['Device'];
// checks if an physical device matchs the physical volume we want to initialize
$error_msg = sprintf('Object EtvaPhysicalvolume does not exist (%s).', $pv);
$info = array('success'=> false,'errors'=> $error_msg);
return $this->renderText($error);
$etva_pv->fromArray($pv);
$result = array('success'=> true,'object'=> $etva_pv->toArray());
$this->getContext()->getResponse()->setHttpHeader("X-JSON", '()'); // set a header, (although it is empty, it is nicer than without a correct header. Filling the header with the result will not be parsed by extjs as far as I have seen).
return $this->renderText($result);
* Params: nid (virtAgent node ID)
* Used to return pre-formatted data for tree-column extjs
/* criteria to select only node ID column matching with nid
$criteria = new Criteria();
$criteria->clearSelectColumns();
$criteria->setDistinct();
// select distinct storage types
// foreach storage type....
while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$criteria = new Criteria();
foreach ($list as $elem){
$id = $elem->getDevice();
$qtip = 'Physical volume NOT initialized';
$pvsize = $elem->getPvsize();
$pretty_pvsize = $elem->getPvsize();
$pretty_size = $elem->getDevsize();
$size = $elem->getDevsize();
if($elem->getPvinit()){ $qtip = 'Physical volume initialized';
$children[] = array('id'=> $id,'uiProvider'=> 'col','iconCls'=> 'task','cls'=> $cls,'text'=> $tag,'size'=> $size,'prettysize'=> $pretty_size,'pvsize'=> $pvsize,'pretty-pvsize'=> $pretty_pvsize, 'singleClickExpand'=> true,'type'=> $type,'qtip'=> $qtip,'leaf'=> true);
$aux[] = array('id'=> $row[0],'uiProvider'=> 'col','iconCls'=> 'devices-folder','text'=> $storage_type, 'singleClickExpand'=> true,'children'=> $children);
$this->getResponse()->setHttpHeader("X-JSON", '()');
return $this->renderText($return);
* Params: nid (virtAgent node ID)
* Used to return pre-formatted data for the combo box of the vgcreate process (extjs)
* Returns data thas has allocatable==1 AND pvinit==1
$isAjax = $request->isXmlHttpRequest();
// If is not an Ajax Request redirect to homepage
if(!$isAjax) return $this->redirect('@homepage');
$criteria = new Criteria();
// Check if there are physical volumes available to create a new volume group
$info = array('success'=> false,'errors'=> 'No physical volumes available');
return $this->renderText($error);
foreach ($etva_pvs as $pv){
$device = $pv->getDevice();
$elements[] = array('value'=> $device,'name'=> $name);
$result = array('total' => count($elements),'data' => $elements);
$this->getResponse()->setHttpHeader("X-JSON", '()');
return $this->renderText($return);
* Params: device, nid (virtAgent node ID)
* Unsets the physical volume info
$isAjax = $request->isXmlHttpRequest();
if(!$isAjax) return $this->redirect('@homepage');
$criteria = new Criteria();
// get physical volume by device name
$error_msg = sprintf('Object EtvaPhysicalvolume does not exist (%s).', $request->getParameter('device'));
$info = array('success'=> false,'errors'=> $error_msg);
return $this->renderText($error);
$etva_pv->setPvfreesize('');
$etva_pv->setAllocatable(0);
$result = array('success'=> true);
$this->getResponse()->setHttpHeader("X-JSON", '()'); // set a header, (although it is empty, it is nicer than without a correct header. Filling the header with the result will not be parsed by extjs as far as I have seen).
return $this->renderText($result);
$this->getContext()->getResponse()->setStatusCode($statusCode);
$this->getContext()->getResponse()->setHttpHeader("X-JSON", '()');
* Used to process soap requests => updateVirtAgentDevices
* Updates physical volume/device info
* Params: uid (virtAgent uid), devs (object containing devices info)
* Check if the request is made via soapapi.php interface
if(SF_ENVIRONMENT == 'soap'){
$devs = $request->getParameter('devs');
// check node ID correspondig to the uid given
$error_msg = sprintf('Object etva_node does not exist (%s).', $request->getParameter('uid'));
$error = array('success'=> false,'errors'=> $error_msg);
//check physical volumes of the agent
$criteriaPV = new Criteria();
foreach($devs as $dev=> $devInfo){
* check if already in DB the data
* if not, insert it, otherwise update
$etva_physicalvol->setNodeId($etva_node->getId());
$etva_physicalvol->setName($dev);
$etva_physicalvol->setDevice($devInfo->device);
$etva_physicalvol->setDevsize($devInfo->size);
$etva_physicalvol->setPv($devInfo->pv);
$etva_physicalvol->setPvsize($devInfo->pvsize);
$etva_physicalvol->setPvfreesize($devInfo->pvfreesize);
$etva_physicalvol->setPvinit($devInfo->pvinit);
$etva_physicalvol->setStorageType($devInfo->type);
if(empty($devInfo->vg)) $etva_physicalvol->setAllocatable(1);
else $etva_physicalvol->setAllocatable(0);
$etva_physicalvol->save();
return array('success'=> true);
|