function deleteRackTablesData() { // delete racktables items data $query = 'delete from item_information;'; usePreparedExecuteBlade($query); // delete racktables object data $allObjects = scanRealmByText('object'); foreach ($allObjects as $object) { $racklist = getResidentRacksData($object["id"], FALSE); commitDeleteObject($object["id"]); foreach ($racklist as $rack_id) { usePreparedDeleteBlade('RackThumbnail', array('rack_id' => $rack_id)); } } // delete racktables rack data $allRacks = scanRealmByText('rack'); foreach ($allRacks as $rack) { releaseFiles('rack', $rack['id']); destroyTagsForEntity('rack', $rack['id']); usePreparedDeleteBlade('RackSpace', array('rack_id' => $rack['id'])); commitDeleteObject($rack['id']); resetRackSortOrder($rack['row_id']); } $query = 'delete from rack_position;'; usePreparedExecuteBlade($query); $query = 'delete from rack_airconditioner;'; usePreparedExecuteBlade($query); }
function deleteRack() { assertUIntArg('rack_id'); $rackData = spotEntity('rack', $_REQUEST['rack_id']); amplifyCell($rackData); if (count($rackData['mountedObjects'])) { showFuncMessage(__FUNCTION__, 'ERR1'); return; } releaseFiles('rack', $_REQUEST['rack_id']); destroyTagsForEntity('rack', $_REQUEST['rack_id']); usePreparedDeleteBlade('RackSpace', array('rack_id' => $_REQUEST['rack_id'])); commitDeleteObject($_REQUEST['rack_id']); resetRackSortOrder($rackData['row_id']); showFuncMessage(__FUNCTION__, 'OK', array($rackData['name'])); return buildRedirectURL('rackspace', 'default'); }
function deleteRack() { assertUIntArg('rack_id'); $rackData = spotEntity('rack', $_REQUEST['rack_id']); ############################################################################################### # delete zabbix group $result = deleteGroup($rackData["name"]); if (isset($result["error"])) { showError("Deleting zabbix group is failed. Error message:" . $result["error"]); } # END ############################################################################################### amplifyCell($rackData); if (count($rackData['mountedObjects'])) { showFuncMessage(__FUNCTION__, 'ERR1'); return; } releaseFiles('rack', $_REQUEST['rack_id']); destroyTagsForEntity('rack', $_REQUEST['rack_id']); usePreparedDeleteBlade('RackSpace', array('rack_id' => $_REQUEST['rack_id'])); commitDeleteObject($_REQUEST['rack_id']); resetRackSortOrder($rackData['row_id']); showFuncMessage(__FUNCTION__, 'OK', array($rackData['name'])); ############################################################################################## # delete position information from DB usePreparedDeleteBlade('rack_position', array('rack_id' => $_REQUEST["rack_id"])); # delete airconditioner information from DB usePreparedDeleteBlade('rack_airconditioner', array('rack_id' => $_REQUEST["rack_id"])); ############################################################################################## return buildRedirectURL('rackspace', 'default'); }
function commitUpdateRack($rack_id, $new_row_id, $new_name, $new_height, $new_has_problems, $new_asset_no, $new_comment) { // Can't shrink a rack if rows being deleted contain mounted objects $check_result = usePreparedSelectBlade('SELECT COUNT(*) AS count FROM RackSpace WHERE rack_id = ? AND unit_no > ?', array($rack_id, $new_height)); $check_row = $check_result->fetch(PDO::FETCH_ASSOC); unset($check_result); if ($check_row['count'] > 0) { throw new InvalidArgException('new_height', $new_height, 'Cannot shrink rack, objects are still mounted there'); } // Determine if the row changed $old_rack = spotEntity('rack', $rack_id); $old_row_id = $old_rack['row_id']; if ($old_row_id != $new_row_id) { // Move it to the specified row usePreparedUpdateBlade('EntityLink', array('parent_entity_id' => $new_row_id), array('child_entity_type' => 'rack', 'child_entity_id' => $rack_id)); // Set the sort_order attribute so it's placed at the end of the new row $rowInfo = getRowInfo($new_row_id); usePreparedUpdateBlade('AttributeValue', array('uint_value' => $rowInfo['count']), array('object_id' => $rack_id, 'attr_id' => 29)); // Reset the sort order of the old row resetRackSortOrder($old_row_id); } // Update the height commitUpdateAttrValue($rack_id, 27, $new_height); // Update the rack commitUpdateObject($rack_id, $new_name, NULL, $new_has_problems, $new_asset_no, $new_comment); recordObjectHistory($rack_id); }
function deleteRack() { assertUIntArg('rack_id'); $rackData = spotEntity('rack', $_REQUEST['rack_id']); amplifyCell($rackData); if (count($rackData['mountedObjects'])) { return showFuncMessage(__FUNCTION__, 'ERR1'); } commitDeleteObject($_REQUEST['rack_id']); resetRackSortOrder($rackData['row_id']); showFuncMessage(__FUNCTION__, 'OK', array($rackData['name'])); return buildRedirectURL('rackspace', 'default'); }
$id = getEntityIdByName("rack", $_REQUEST["name"]); if ($id < 0) { echo json_encode(array("error" => "In racktables the rack " . $_REQUEST["name"] . "is not existed.")); return; } $rack = spotEntity("rack", $id); amplifyCell($rack); if (count($rack["mountedObjects"])) { echo json_encode(array("error" => "There are mounted Objects in the rack " . $_REQUEST["name"] . ".")); return; } releaseFiles("rack", $rack["id"]); destroyTagsForEntity("rack", $rack['id']); usePreparedDeleteBlade("RackSpace", array("rack_id" => $rack["id"])); commitDeleteObject($rack["id"]); resetRackSortOrder($rack["row_id"]); # delete position information usePreparedDeleteBlade('rack_position', array('rack_id' => $id)); # delete airconditioner information usePreparedDeleteBlade('rack_airconditioner', array('rack_id' => $id)); echo json_encode(array("result" => $rack["id"])); return; // add_object // api.php?method=my_add_object&type=4&name=test&label=&asset_no=&taglist[]=&has_problems=no // add_object // api.php?method=my_add_object&type=4&name=test&label=&asset_no=&taglist[]=&has_problems=no case "my_add_object": require_once "inc/init.php"; $object_type_id = isset($_REQUEST["type"]) ? $_REQUEST["type"] : 4; $object_name = isset($_REQUEST["name"]) ? $_REQUEST["name"] : ""; $object_label = isset($_REQUEST["label"]) ? $_REQUEST["label"] : "";