Beispiel #1
0
 function MakePath()
 {
     $this->MakeSafe();
     //reset PathError
     $this->PathError = 0;
     //check devices/ports
     $device = new Device();
     $device->DeviceID = $this->devID1;
     if (!$device->GetDevice()) {
         $this->PathError = 1;
         //dev1 does not exist
         return false;
     }
     $devType1 = $device->DeviceType;
     if ($device->DeviceType == "Patch Panel") {
         $this->PathError = 2;
         //dev1 is a Patch Pannel
         return false;
     }
     $port1 = new DevicePorts();
     $port1->DeviceID = $this->devID1;
     $port1->PortNumber = $this->port1;
     if (!$port1->getPort()) {
         $this->PathError = 3;
         //dev1,port1 is missing
         return False;
     }
     if ($port1->ConnectedDeviceID > 0 && $port1->ConnectedPort > 0) {
         $this->PathError = 4;
         //dev1,port1 is connected
         return False;
     }
     $device->DeviceID = $this->devID2;
     if (!$device->GetDevice()) {
         $this->PathError = 5;
         //dev2 does not exist
         return false;
     }
     $devType2 = $device->DeviceType;
     if ($device->DeviceType == "Patch Panel") {
         $this->PathError = 6;
         //dev2 is a Patch Pannel
         return false;
     }
     $port2 = new DevicePorts();
     $port2->DeviceID = $this->devID2;
     $port2->PortNumber = $this->port2;
     if (!$port2->getPort()) {
         $this->PathError = 7;
         //dev2,port2 is missing
         return False;
     }
     if ($port2->ConnectedDeviceID > 0 && $port2->ConnectedPort > 0) {
         $this->PathError = 8;
         //dev2,port2 is connected
         return False;
     }
     //get dev2 info
     $this->cab2 = $device->GetDeviceCabinetID();
     //cab2
     $cabinet = new Cabinet();
     $cabinet->CabinetID = $this->cab2;
     $cabinet->GetCabinet();
     $this->row2 = $cabinet->CabRowID;
     //row2
     //if dev2 is panel protected device (connected to rear connection of a panel)
     $this->espejo2 = $port2->ConnectedDeviceID > 0 && $port2->ConnectedPort < 0;
     @unlink('ppath.log');
     $this->escribe_log("**** NEW PATH ****");
     $this->escribe_log("DEV1: ID=" . $this->devID1 . "  PORT=" . $this->port1);
     $this->escribe_log("DEV2: ID=" . $this->devID2 . "  PORT=" . $this->port2 . "  CAB_ID=" . $this->cab2 . "  ROW_ID=" . $this->row2);
     $this->escribe_log("-------------------");
     //reset Path
     $this->ClearPath();
     //initiate list with device1, port1, weitgh=0, prev_dev=0, prev_port=0
     $this->AddNodeToList($this->devID1, $this->port1, 0, 0, 0);
     while ($this->SelectNode()) {
         if ($this->DeviceID == $this->devID2) {
             $this->escribe_log("Target found. Making the PATH...");
             //make the path
             $i = 1;
             while ($this->DeviceID > 0) {
                 $dev = $this->DeviceID;
                 $port = $this->PortNumber;
                 $Path[$i]["DeviceID"] = $dev;
                 $Path[$i]["PortNumber"] = $port;
                 $this->DeviceID = $this->nodes[$dev][$port]["prev_dev"];
                 $this->PortNumber = $this->nodes[$dev][$port]["prev_port"];
                 $i++;
             }
             for ($j = 1; $j < $i; $j++) {
                 $this->Path[$j]["DeviceID"] = $Path[$i - $j]["DeviceID"];
                 $this->Path[$j]["PortNumber"] = $Path[$i - $j]["PortNumber"];
             }
             $this->escribe_log("PATH created.");
             $this->escribe_log("");
             return true;
         }
         $this->UpdateList();
     }
     $this->PathError = 9;
     //not found
     return false;
 }
Beispiel #2
0
                $lastreading = $pdu->GetLastReading();
                $LastWattage = $lastreading ? $lastreading->Wattage : 0;
                $LastRead = $lastreading ? strftime("%c", strtotime($lastreading->LastRead)) : "Never";
            }
        }
        if ($dev->ChassisSlots > 0 || $dev->RearChassisSlots > 0) {
            $childList = $dev->GetDeviceChildren();
        }
        if ($dev->ParentDevice > 0) {
            $pDev = new Device();
            $pDev->DeviceID = $dev->ParentDevice;
            $pDev->GetDevice();
            $parentList = $pDev->GetParentDevices();
            //$cab->CabinetID=$pDev->Cabinet;
            //JMGA: changed for multichassis
            $cab->CabinetID = $pDev->GetDeviceCabinetID();
            $cab->GetCabinet();
            $chassis = "Chassis";
            // This is a child device and if the action of new is set let's assume the
            // departmental Owner, primary contact, etc are the same as the parent
            if (isset($_POST['action']) && $_POST['action'] == 'Child') {
                $dev->Owner = $pDev->Owner;
                $dev->EscalationTimeID = $pDev->EscalationTimeID;
                $dev->EscalationID = $pDev->EscalationID;
                $dev->PrimaryContact = $pDev->PrimaryContact;
            }
        }
    }
    $cab->CabinetID = $dev->Cabinet;
    $cab->GetCabinet();
} else {