예제 #1
0
 usort($cabList, 'compareCab');
 // error_log( "Cabinet List:" . print_r( $cabList, true ));
 printf("<h2>%s</h2>", __("Power Outage Simulation Report"));
 if ($skipNormal) {
     printf("<h3>%s</h3>\n", __("Only listing systems which are down or unknown."));
 }
 echo "<table id=\"report\" class=\"display\">\n<thead>\n";
 foreach (array(__("Cabinet"), __("Device Name"), __("Status"), __("Position"), __("Primary Contact"), __("Owner")) as $header) {
     printf("<th>%s</th>\n", $header);
 }
 echo "</thead>\n<tbody>\n";
 foreach ($cabList as $cabRow) {
     $dev->Cabinet = $cabRow->CabinetID;
     // Check to see if all circuits to the cabinet are from the outage list - if so, the whole cabinet goes down
     $pdu->CabinetID = $cabRow->CabinetID;
     $cabPDUList = $pdu->GetPDUbyCabinet();
     $diversity = false;
     // If you can find one CDU for the Cabinet that is not in the list of down CDUs, then you have at least some diversity
     foreach ($cabPDUList as $cabPDU) {
         if (!objArraySearch($pduList, "DeviceID", $cabPDU->PDUID)) {
             $diversity = true;
             break;
         }
     }
     // Basic device selection based on the CabinetID
     // Filter out all reservations, devices with no power supplies, power strips, and chassis slot cards
     $sql = "SELECT * FROM fac_Device WHERE Reservation=0 AND PowerSupplyCount>0 AND DeviceType not in ('CDU','Patch Panel','Physical Infrastructure') AND ParentDevice=0 AND Cabinet=" . intval($cabRow->CabinetID);
     // If tags were added, only include devices with tags that are in the Include array
     if (sizeof($includeTags) > 0) {
         $sql .= " AND DeviceID in (select DeviceID from fac_DeviceTags a, fac_Tags b where a.TagID=b.TagID and b.Name in (";
         for ($n = 0; $n < sizeof($includeTags); $n++) {
예제 #2
0
 function DeleteCabinet()
 {
     global $dbh;
     /* Need to delete all devices and CDUs first */
     $tmpDev = new Device();
     $tmpCDU = new PowerDistribution();
     $tmpDev->Cabinet = $this->CabinetID;
     $devList = $tmpDev->ViewDevicesByCabinet();
     foreach ($devList as &$delDev) {
         $delDev->DeleteDevice();
     }
     $tmpCDU->CabinetID = $this->CabinetID;
     $cduList = $tmpCDU->GetPDUbyCabinet();
     foreach ($cduList as &$delCDU) {
         $delCDU->DeletePDU();
     }
     $sql = "DELETE FROM fac_Cabinet WHERE CabinetID={$this->CabinetID};";
     if (!$dbh->exec($sql)) {
         $info = $dbh->errorInfo();
         error_log("PDO Error::DeleteCabinet: {$info[2]} SQL={$sql}");
         return false;
     }
     class_exists('LogActions') ? LogActions::LogThis($this) : '';
     return true;
 }