public function preDelete(PropelPDO $con = null) { $server = $this->getEtvaServer(); $node = $server->getEtvaNode(); $logicalvol = $this->getEtvaLogicalvolume(); $lv = $logicalvol->getLv(); //remove disk RRA files $server_disk_rw = new ServerDisk_rwRRA($node->getUuid(), $server->getUuid(), $lv, false); $server_disk_rw->delete(); return true; }
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; }
function updateVirtAgentLogs($node_uuid, $data) { $c = new Criteria(); $c->add(EtvaNodePeer::UUID, $node_uuid); $return = 0; $etva_node = EtvaNodePeer::doSelectOne($c); if (!($etva_node = EtvaNodePeer::doSelectOne($c))) { $error_msg = sprintf('Object etva_node does not exist (%s).', $node_uuid); $error = array('success' => false, 'error' => $error_msg); return $error; } $node_initialize = $etva_node->getInitialize(); if ($node_initialize != EtvaNode_VA::INITIALIZE_OK) { $error_msg = sprintf('Etva node initialize status: %s', $node_initialize); $error = array('success' => false, 'error' => $error_msg); return $error; } $node_uuid = $etva_node->getUuid(); $cpu_load = $data->load; $cpu_load_sort = array($cpu_load->onemin, $cpu_load->fivemin, $cpu_load->fifteenmin); $cpu_load = new NodeLoadRRA($node_uuid); $cpu_load->update($cpu_load_sort); $virtServers = $data->virtualmachines; if ($virtServers) { foreach ($virtServers as $server_name => $server_data) { if ($etva_server = $etva_node->retrieveServerByName($server_name)) { if (isset($server_data->network)) { /* * store network info in RRA file */ $server_network_data = $server_data->network; /* * create file per network device */ foreach ($server_network_data as $intfname => $intfdata) { $macaddr = $intfdata->macaddr; $etva_network = $etva_server->retrieveByMac($macaddr); if ($etva_network) { $target = $etva_network->getTarget(); // if target not in network table of the DB if ($target != $intfname) { $etva_network->updateTarget($intfname); } $tx = $intfdata->tx_bytes; $rx = $intfdata->rx_bytes; $intf_sort = array($rx, $tx); $mac_strip = str_replace(':', '', $macaddr); // create log file $server_network_rra = new ServerNetworkRRA($node_uuid, $etva_server->getUuid(), $mac_strip); //send/update file information $return = $server_network_rra->update($intf_sort); } } } // end server networks /* * disk stuff */ if (isset($server_data->disk)) { $server_disk_data = $server_data->disk; foreach ($server_disk_data as $disk => $diskdata) { $diskname = $diskdata->name; $read_b = $diskdata->rd_bytes; $write_b = $diskdata->wr_bytes; $disk_sort = array($read_b, $write_b); // create log file $server_disk_rw_log = new ServerDisk_rwRRA($node_uuid, $etva_server->getUuid(), $diskname); //send/update file information $return = $server_disk_rw_log->update($disk_sort); /* * DISK SPACE RRA NOT USED ANYMORE */ //$size = $diskdata->size; //$freesize = $diskdata->freesize; //$disk_space = array($size,$freesize); //$server_disk_spaceRRA = new ServerDiskSpaceRRA($node_uuid,$etva_server->getUuid(),$diskname); //$return = $server_disk_spaceRRA->update($disk_space); } // end server disk } // store cpu utilization $server_cpu_data = $server_data->cpu; $server_cpu_per = array($server_cpu_data->cpu_per); // $logger->log("cpu ".$server_cpu_data->cpu_per); // create log file $server_cpu_per_rra = new ServerCpuUsageRRA($node_uuid, $etva_server->getUuid()); //send/update file information $return = $server_cpu_per_rra->update($server_cpu_per); /* * store memory info */ // store memory utilization $server_memory_data = $server_data->memory; $server_memory_per = array($server_memory_data->mem_per); // create log file $server_memory_per_rra = new ServerMemoryUsageRRA($node_uuid, $etva_server->getUuid()); //send/update file information $return = $server_memory_per_rra->update($server_memory_per); $server_memory_sort = array($server_memory_data->mem_m, $server_memory_data->mem_v); $server_memory = new ServerMemoryRRA($node_uuid, $etva_server->getUuid()); $server_memory->update($server_memory_sort); } // end virtualmachine stuff } } // $this->updateVirtAgentLogs_($node_uuid,$data); $all_params = array('request' => array('uuid' => $etva_node->getUuid(), 'data' => $data, 'method' => 'updateVirtAgentLogs'), 'response' => $return); // log function called $dispatcher = sfContext::getInstance()->getEventDispatcher(); $dispatcher->notify(new sfEvent($this, sfConfig::get('app_virtsoap_log'), $all_params)); return $return; }