From a1274b49a8d9ac174bc260e7c113d6069f6234f3 Mon Sep 17 00:00:00 2001 From: David Dorion Date: Tue, 7 Jul 2020 11:24:22 -0400 Subject: [PATCH 1/4] Make multiple rear connections --- misc.inc.php | 1 + rear_connection.php | 498 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 499 insertions(+) create mode 100644 rear_connection.php diff --git a/misc.inc.php b/misc.inc.php index c8d82ae4e..ceb2a519f 100644 --- a/misc.inc.php +++ b/misc.inc.php @@ -1009,6 +1009,7 @@ function buildnavmenu($ma,&$tl){ $samenu[__("Power Management")][]=''.__("Edit Power Panels").''; $samenu[__("Path Connections")][]=''.__("View Path Connection").''; $samenu[__("Path Connections")][]=''.__("Make Path Connection").''; + $samenu[__("Path Connections")][]=''.__("Make Rear Connection").''; $samenu[]=''.__("Edit Configuration").''; } if( AUTHENTICATION == "LDAP" ) { diff --git a/rear_connection.php b/rear_connection.php new file mode 100644 index 000000000..d21982b3d --- /dev/null +++ b/rear_connection.php @@ -0,0 +1,498 @@ +GetDCList(); + $idnum=''; + + if(!is_null($id)){ + if($id=="dc-front"){ + $idnum=1; + }elseif($id=="dc-rear"){ + $idnum=2; + } + $id=" name=\"$id\" id=\"$id\""; + } + + $dcpicklist=""; + $selected = "selected"; + foreach($dcList as $d){ + $dcpicklist.=""; + $selected = ""; + } + $dcpicklist.=''; + + return $dcpicklist; + } + + function portNumberIsInPortArray($portNumber, $array){ + foreach($array as $port){ + if($port->PortNumber == $portNumber){ + return true; + } + } + return false; + } + + // AJAX - Start + + function displayjson($array){ + header('Content-Type: application/json'); + echo json_encode($array); + exit; + } + + if(isset($_POST['dc'])){ + $cab=new Cabinet(); + $cab->DataCenterID=$_POST['dc']; + + displayjson($cab->ListCabinetsByDC()); + } + + if(isset($_POST['cab'])){ + $dev=new Device(); + $dev->Cabinet=$_POST['cab']; + + // Filter devices by rights and only show the Patch Panel + $devs=array(); + foreach($dev->ViewDevicesByCabinet(true) as $d){ + if($d->Rights=="Write" && $d->DeviceType=="Patch Panel"){ + $devs[]=$d; + } + } + displayjson($devs); + } + + if(isset($_POST['dev'])){ + $dp=new DevicePorts(); + $dp->DeviceID=$_POST['dev']; + $dev=new Device(); + $dev->DeviceID=$dp->DeviceID; + $dev->GetDevice(); + $ports=($dev->Rights=="Write")?$dp->getAvailableRearPorts():array(); + displayjson($ports); + } + + if(isset($_POST['actionValidation'])){ + $status = array(); + if(!(isset($_POST['devid1']) && $_POST['devid1']!=0)){ + $status[]=__("Initial device unspecified"); + } + if(!isset($_POST['port1']) || $_POST['port1']==''){ + $status[]=__("Initial device port unspecified"); + } + if(!(isset($_POST['devid2']) && $_POST['devid2']!=0)){ + $status[]=__("Final device unspecified"); + } + if(!isset($_POST['port2']) || $_POST['port2']==''){ + $status[]=__("Final device unspecified"); + } + if(!isset($_POST['numberOfPorts']) || $_POST['numberOfPorts']==''){ + $status[]=__("Number of ports not specified"); + } + if(empty($status)){ + //Getting number of connection to make + $numberOfPath = $_POST['numberOfPorts']; + $port1Number = intval($_POST['port1']); + $port2Number = intval($_POST['port2']); + + //INITIAL DEVICE + $dev=new Device(); + $dev->DeviceID=intval($_POST['devid1']); + $dev->GetDevice(); + + //FINAL DEVICE + $finDev=new Device(); + $finDev->DeviceID=intval($_POST['devid2']); + $finDev->GetDevice(); + + $dp=new DevicePorts(); + $dp->DeviceID=$dev->DeviceID; + + $portsDevArray = $dp->getAvailableRearPorts(); + + $dp->DeviceID = $finDev->DeviceID; + + $portsFinDevArray = $dp->getAvailableRearPorts(); + + $port1=new DevicePorts(); + $port2=new DevicePorts(); + + $port1->DeviceID=$dev->DeviceID; + $port2->DeviceID=$finDev->DeviceID; + + $port1NumberOfRearPorts = $port1->getNumberOfRearPorts(); + $port2NumberOfRearPorts = $port2->getNumberOfRearPorts(); + + //Temp port to do the testings of overriding ports + $tempPort1 = $port1Number; + $tempPort2 = $port2Number; + + $hasExceedInit = false; + $hasExceedFinal = false; + //Validate if we override used ports or if we exceed the port number. + for($i = 0; $i < $numberOfPath; $i++){ + + if($hasExceedInit = abs($tempPort1) == $port1NumberOfRearPorts + 1){ + $status[] = "Exceed initial"; + + } + if($hasExceedFinal = abs($tempPort2) == $port2NumberOfRearPorts + 1){ + $status[] = "Exceed final"; + } + + if($hasExceedFinal || $hasExceedInit){ + break; + } + + if(!portNumberIsInPortArray($tempPort1, $portsDevArray)){ + $status[] = "Override init"; + } + if(!portNumberIsInPortArray($tempPort2, $portsFinDevArray)){ + $status[] = "Override final"; + } + + $tempPort1--; + $tempPort2--; + } + + } + + //Return the error code. + displayjson($status); + } + + // AJAX - End + + if(!$person->SiteAdmin){ + // No soup for you. + header('Location: '.redirect()); + exit; + } + + //This is executed after the validation, but it is always good to do a double validation of the requiered fields. + if(isset($_POST['create_connection_after_validation'])){ + if((isset($_POST['devid1']) && $_POST['devid1']!=0) + && isset($_POST['port1']) && $_POST['port1']!='' + && (isset($_POST['devid2']) && $_POST['devid2']!=0) + && (isset($_POST['port2']) && $_POST['port2']!='') + && isset($_POST['numberOfPorts']) && $_POST['numberOfPorts']!=''){ + + //Getting number of connection to make + $numberOfPath = $_POST['numberOfPorts']; + $port1Number = intval($_POST['port1']); + $port2Number = intval($_POST['port2']); + + //INITIAL DEVICE + $dev=new Device(); + $dev->DeviceID=intval($_POST['devid1']); + + //FINAL DEVICE + $finDev=new Device(); + $finDev->DeviceID=intval($_POST['devid2']); + + $connectionMaker = new RearConnectionMaker($dev->DeviceID, $finDev->DeviceID, $port1Number, $port2Number, $numberOfPath); + $connectionMaker->MakeConnections(); + $additionalInfo = $connectionMaker->GetTable(); + + } else { + if(!(isset($_POST['devid1']) && $_POST['devid1']!=0)){ + $status=__("Initial device unspecified"); + }elseif(!isset($_POST['port1']) || $_POST['port1']==''){ + $status=__("Initial device port unspecified"); + }elseif(!(isset($_POST['devid2']) && $_POST['devid2']!=0)){ + $status=__("Final device unspecified"); + }elseif(!isset($_POST['port2']) || $_POST['port2']==''){ + $status=__("Final device port unspecified"); + }elseif(!isset($_POST['numberOfPorts']) || $_POST['numberOfPorts']==''){ + $status=__("Number of ports not specified"); + }else{ + $status=__("Unknown Error"); + } + } + } + + //We send the output table we want to show to JQuery so we can show it without refreshing the page. + if(isset($_POST['create_connection_after_validation'])){ + displayjson($additionalInfo); + } +?> + + + + + + + + openDCIM Data Center Inventory + + + + + + + + + + + +
+ +

',$status,'

+
+
+ + + +
+
+ '.__("Initial device").' +
+
+
+
'.builddclist('dc-front').'
+
+
+
+
      +
+ '.__("Final device").' +
+
+
+
'.builddclist('dc-rear').'
+
+
+
+
'; +echo '
'; +echo '
'; +echo '
'; +?> +
+

'; +echo '[ ',__("Return to Main Menu"),' ]'; ?> +
+
+ + + From 91e06e5f7a2a7844d2ce8d83eda000374f108145 Mon Sep 17 00:00:00 2001 From: David Dorion <55026996+Comraddde@users.noreply.github.com> Date: Tue, 7 Jul 2020 11:46:14 -0400 Subject: [PATCH 2/4] Delete rear_connection.php --- rear_connection.php | 498 -------------------------------------------- 1 file changed, 498 deletions(-) delete mode 100644 rear_connection.php diff --git a/rear_connection.php b/rear_connection.php deleted file mode 100644 index d21982b3d..000000000 --- a/rear_connection.php +++ /dev/null @@ -1,498 +0,0 @@ -GetDCList(); - $idnum=''; - - if(!is_null($id)){ - if($id=="dc-front"){ - $idnum=1; - }elseif($id=="dc-rear"){ - $idnum=2; - } - $id=" name=\"$id\" id=\"$id\""; - } - - $dcpicklist=""; - $selected = "selected"; - foreach($dcList as $d){ - $dcpicklist.=""; - $selected = ""; - } - $dcpicklist.=''; - - return $dcpicklist; - } - - function portNumberIsInPortArray($portNumber, $array){ - foreach($array as $port){ - if($port->PortNumber == $portNumber){ - return true; - } - } - return false; - } - - // AJAX - Start - - function displayjson($array){ - header('Content-Type: application/json'); - echo json_encode($array); - exit; - } - - if(isset($_POST['dc'])){ - $cab=new Cabinet(); - $cab->DataCenterID=$_POST['dc']; - - displayjson($cab->ListCabinetsByDC()); - } - - if(isset($_POST['cab'])){ - $dev=new Device(); - $dev->Cabinet=$_POST['cab']; - - // Filter devices by rights and only show the Patch Panel - $devs=array(); - foreach($dev->ViewDevicesByCabinet(true) as $d){ - if($d->Rights=="Write" && $d->DeviceType=="Patch Panel"){ - $devs[]=$d; - } - } - displayjson($devs); - } - - if(isset($_POST['dev'])){ - $dp=new DevicePorts(); - $dp->DeviceID=$_POST['dev']; - $dev=new Device(); - $dev->DeviceID=$dp->DeviceID; - $dev->GetDevice(); - $ports=($dev->Rights=="Write")?$dp->getAvailableRearPorts():array(); - displayjson($ports); - } - - if(isset($_POST['actionValidation'])){ - $status = array(); - if(!(isset($_POST['devid1']) && $_POST['devid1']!=0)){ - $status[]=__("Initial device unspecified"); - } - if(!isset($_POST['port1']) || $_POST['port1']==''){ - $status[]=__("Initial device port unspecified"); - } - if(!(isset($_POST['devid2']) && $_POST['devid2']!=0)){ - $status[]=__("Final device unspecified"); - } - if(!isset($_POST['port2']) || $_POST['port2']==''){ - $status[]=__("Final device unspecified"); - } - if(!isset($_POST['numberOfPorts']) || $_POST['numberOfPorts']==''){ - $status[]=__("Number of ports not specified"); - } - if(empty($status)){ - //Getting number of connection to make - $numberOfPath = $_POST['numberOfPorts']; - $port1Number = intval($_POST['port1']); - $port2Number = intval($_POST['port2']); - - //INITIAL DEVICE - $dev=new Device(); - $dev->DeviceID=intval($_POST['devid1']); - $dev->GetDevice(); - - //FINAL DEVICE - $finDev=new Device(); - $finDev->DeviceID=intval($_POST['devid2']); - $finDev->GetDevice(); - - $dp=new DevicePorts(); - $dp->DeviceID=$dev->DeviceID; - - $portsDevArray = $dp->getAvailableRearPorts(); - - $dp->DeviceID = $finDev->DeviceID; - - $portsFinDevArray = $dp->getAvailableRearPorts(); - - $port1=new DevicePorts(); - $port2=new DevicePorts(); - - $port1->DeviceID=$dev->DeviceID; - $port2->DeviceID=$finDev->DeviceID; - - $port1NumberOfRearPorts = $port1->getNumberOfRearPorts(); - $port2NumberOfRearPorts = $port2->getNumberOfRearPorts(); - - //Temp port to do the testings of overriding ports - $tempPort1 = $port1Number; - $tempPort2 = $port2Number; - - $hasExceedInit = false; - $hasExceedFinal = false; - //Validate if we override used ports or if we exceed the port number. - for($i = 0; $i < $numberOfPath; $i++){ - - if($hasExceedInit = abs($tempPort1) == $port1NumberOfRearPorts + 1){ - $status[] = "Exceed initial"; - - } - if($hasExceedFinal = abs($tempPort2) == $port2NumberOfRearPorts + 1){ - $status[] = "Exceed final"; - } - - if($hasExceedFinal || $hasExceedInit){ - break; - } - - if(!portNumberIsInPortArray($tempPort1, $portsDevArray)){ - $status[] = "Override init"; - } - if(!portNumberIsInPortArray($tempPort2, $portsFinDevArray)){ - $status[] = "Override final"; - } - - $tempPort1--; - $tempPort2--; - } - - } - - //Return the error code. - displayjson($status); - } - - // AJAX - End - - if(!$person->SiteAdmin){ - // No soup for you. - header('Location: '.redirect()); - exit; - } - - //This is executed after the validation, but it is always good to do a double validation of the requiered fields. - if(isset($_POST['create_connection_after_validation'])){ - if((isset($_POST['devid1']) && $_POST['devid1']!=0) - && isset($_POST['port1']) && $_POST['port1']!='' - && (isset($_POST['devid2']) && $_POST['devid2']!=0) - && (isset($_POST['port2']) && $_POST['port2']!='') - && isset($_POST['numberOfPorts']) && $_POST['numberOfPorts']!=''){ - - //Getting number of connection to make - $numberOfPath = $_POST['numberOfPorts']; - $port1Number = intval($_POST['port1']); - $port2Number = intval($_POST['port2']); - - //INITIAL DEVICE - $dev=new Device(); - $dev->DeviceID=intval($_POST['devid1']); - - //FINAL DEVICE - $finDev=new Device(); - $finDev->DeviceID=intval($_POST['devid2']); - - $connectionMaker = new RearConnectionMaker($dev->DeviceID, $finDev->DeviceID, $port1Number, $port2Number, $numberOfPath); - $connectionMaker->MakeConnections(); - $additionalInfo = $connectionMaker->GetTable(); - - } else { - if(!(isset($_POST['devid1']) && $_POST['devid1']!=0)){ - $status=__("Initial device unspecified"); - }elseif(!isset($_POST['port1']) || $_POST['port1']==''){ - $status=__("Initial device port unspecified"); - }elseif(!(isset($_POST['devid2']) && $_POST['devid2']!=0)){ - $status=__("Final device unspecified"); - }elseif(!isset($_POST['port2']) || $_POST['port2']==''){ - $status=__("Final device port unspecified"); - }elseif(!isset($_POST['numberOfPorts']) || $_POST['numberOfPorts']==''){ - $status=__("Number of ports not specified"); - }else{ - $status=__("Unknown Error"); - } - } - } - - //We send the output table we want to show to JQuery so we can show it without refreshing the page. - if(isset($_POST['create_connection_after_validation'])){ - displayjson($additionalInfo); - } -?> - - - - - - - - openDCIM Data Center Inventory - - - - - - - - - - - -
- -

',$status,'

-
-
- - - -
-
- '.__("Initial device").' -
-
-
-
'.builddclist('dc-front').'
-
-
-
-
      -
- '.__("Final device").' -
-
-
-
'.builddclist('dc-rear').'
-
-
-
-
'; -echo '
'; -echo '
'; -echo '
'; -?> -
-

'; -echo '[ ',__("Return to Main Menu"),' ]'; ?> -
-
- - - From 5cb33d769d278194bb568c62023e33ade2031607 Mon Sep 17 00:00:00 2001 From: David Dorion <55026996+Comraddde@users.noreply.github.com> Date: Tue, 7 Jul 2020 11:47:30 -0400 Subject: [PATCH 3/4] Update misc.inc.php --- misc.inc.php | 1 - 1 file changed, 1 deletion(-) diff --git a/misc.inc.php b/misc.inc.php index ceb2a519f..c8d82ae4e 100644 --- a/misc.inc.php +++ b/misc.inc.php @@ -1009,7 +1009,6 @@ function buildnavmenu($ma,&$tl){ $samenu[__("Power Management")][]=''.__("Edit Power Panels").''; $samenu[__("Path Connections")][]=''.__("View Path Connection").''; $samenu[__("Path Connections")][]=''.__("Make Path Connection").''; - $samenu[__("Path Connections")][]=''.__("Make Rear Connection").''; $samenu[]=''.__("Edit Configuration").''; } if( AUTHENTICATION == "LDAP" ) { From da6083b7ae8a260d384905b7f67c7f9e1145b7bf Mon Sep 17 00:00:00 2001 From: David Dorion Date: Wed, 8 Jul 2020 10:27:21 -0400 Subject: [PATCH 4/4] Multi path maker adding --- misc.inc.php | 1 + multipathmaker.php | 857 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 858 insertions(+) create mode 100644 multipathmaker.php diff --git a/misc.inc.php b/misc.inc.php index c8d82ae4e..28acf52b0 100644 --- a/misc.inc.php +++ b/misc.inc.php @@ -1009,6 +1009,7 @@ function buildnavmenu($ma,&$tl){ $samenu[__("Power Management")][]=''.__("Edit Power Panels").''; $samenu[__("Path Connections")][]=''.__("View Path Connection").''; $samenu[__("Path Connections")][]=''.__("Make Path Connection").''; + $samenu[__("Path Connections")][]=''.__("Make Multiple Path Connection").''; $samenu[]=''.__("Edit Configuration").''; } if( AUTHENTICATION == "LDAP" ) { diff --git a/multipathmaker.php b/multipathmaker.php new file mode 100644 index 000000000..488d84746 --- /dev/null +++ b/multipathmaker.php @@ -0,0 +1,857 @@ +GetDCList(); + $idnum=''; + + if(!is_null($id)){ + if($id=="dc-front"){ + $idnum=1; + }elseif($id=="dc-rear"){ + $idnum=2; + } + $id=" name=\"$id\" id=\"$id\""; + } + + $dcpicklist=""; + foreach($dcList as $d){ + $dcpicklist.=""; + } + $dcpicklist.=''; + + return $dcpicklist; + } + + // AJAX - Start + + function displayjson($array){ + header('Content-Type: application/json'); + echo json_encode($array); + exit; + } + + if(isset($_POST['dc'])){ + $cab=new Cabinet(); + $cab->DataCenterID=$_POST['dc']; + + displayjson($cab->ListCabinetsByDC()); + } + + if(isset($_POST['cab'])){ + $dev=new Device(); + $dev->Cabinet=$_POST['cab']; + + // Filter devices by rights + $devs=array(); + foreach($dev->ViewDevicesByCabinet(true) as $d){ + if($d->Rights=="Write" && $d->DeviceType != 'Patch Panel'){ + $devs[]=$d; + } + } + displayjson($devs); + } + + if(isset($_POST['dev'])){ + $dp=new DevicePorts(); + $dp->DeviceID=$_POST['dev']; + $dev=new Device(); + $dev->DeviceID=$dp->DeviceID; + $dev->GetDevice(); + $ports= array(); + if ($dev->Rights=="Write") { + $parent = new Device($dev->ParentDevice); + $parent->GetDevice(); + $ports = $dp->getAvailableFrontPorts(); + } + displayjson($ports); + } + + // AJAX - End + + if(!$person->SiteAdmin){ + // No soup for you. + header('Location: '.redirect()); + exit; + } + + if(isset($_POST['action_implement'])){ + if(isset($_POST['list'])){ + $list = $_POST['list']; + $listOfPaths = array(); + for($index = 0; $index < count($list); $index++){ + $status = ""; + $dcFrontID = $list[$index]['dc_front']; + $dcRearID = $list[$index]['dc_rear']; + + $devFrontID = $list[$index]['dev_front']; + $devRearID = $list[$index]['dev_rear']; + + $portFrontNumber = $list[$index]['port_front']; + $portRearNumber = $list[$index]['port_rear']; + //INITIAL DEVICE (Front) + + //Search device + $dev=new Device(); + $dev->DeviceID=intval($devFrontID); + + if ($dev->GetDevice()){ + $pp=new PlannedPath(); + $pp->devID1=$dev->DeviceID; + $pp->port1=intval($portFrontNumber); + $label1=$dev->Label; + } + + //FINAL DEVICE (Rear) + + //Search device + $dev=new Device(); + $dev->DeviceID=intval($devRearID); + + if ($dev->GetDevice() && isset($pp)){ + $port2=new DevicePorts(); + $port2->DeviceID = $dev->DeviceID; + $port2->PortNumber = $portRearNumber; + $port2->getPort(); + + while ($port2->ConnectedPort != null){ + if($pp->devID1 == $port2->DeviceID || $port2->DeviceID == $port2->ConnectedDeviceID ) { + $status = 'Device already connected'; + break; + } + + error_log("Device with dev_id " . $port2->DeviceID . " and port " . $port2->PortNumber . " already connected to device with id " . $port2->ConnectedDeviceID . " on port " . $port2->ConnectedPort); + $port2->DeviceID = $port2->ConnectedDeviceID; + #Once we switch to the other device, we look for the corresponding front or rear port + $port2->PortNumber = -1 * $port2->ConnectedPort; + $port2->getPort(); + } + $pp->devID2=$port2->DeviceID; + $pp->port2=$port2->PortNumber; + $label2=$dev->Label; + } + + $pp->MakePath(); + $pp->GotoHeadDevice(); + + for ($i=1;$i < count($pp->Path);$i++){ + error_log("Port : " . $pp->Path[$i]["PortNumber"]); + #if ($pp->Path[$i]["PortNumber"] > 0 && $pp->Path[$i + 1]["PortNumber"] < 0) { + $port1=new DevicePorts(); + $port1->DeviceID = $pp->Path[$i]["DeviceID"]; + $port1->PortNumber = $pp->Path[$i]["PortNumber"]; + $port1->getPort(); + if(isset($_POST['notes'][$index]) and $_POST['notes'][$index] != "") { + $port1->Notes=($_POST['notes'][$index]); + } + + $port2=new DevicePorts(); + $port2->DeviceID = $pp->Path[$i + 1]["DeviceID"]; + $port2->PortNumber = -$pp->Path[$i + 1]["PortNumber"]; + $port2->getPort(); + if(isset($_POST['notes'][$index]) and $_POST['notes'][$index] != "") { + $port2->Notes=($_POST['notes'][$index]); + } + + DevicePorts::makeConnection($port1,$port2); + #} + } + } + displayjson("All connections implemented"); + } + } + + if(isset($_POST['action_validate'])){ + if(isset($_POST['list'])){ + $list = $_POST['list']; + $listOfPaths = array(); + $fakelyUsedNodes = array(); + for($index = 0; $index < count($list); $index++){ + $status = ""; + $dcFrontID = $list[$index]['dc_front']; + $dcRearID = $list[$index]['dc_rear']; + + $devFrontID = $list[$index]['dev_front']; + $devRearID = $list[$index]['dev_rear']; + + $portFrontNumber = $list[$index]['port_front']; + $portRearNumber = $list[$index]['port_rear']; + //INITIAL DEVICE (Front) + + //Search device + $dev=new Device(); + $dev->DeviceID=intval($devFrontID); + + if ($dev->GetDevice()){ + $pp=new PlannedPath(); + $pp->devID1=$dev->DeviceID; + $pp->port1=intval($portFrontNumber); + $label1=$dev->Label; + } + + //FINAL DEVICE (Rear) + + //Search device + $dev=new Device(); + $dev->DeviceID=intval($devRearID); + + if ($dev->GetDevice() && isset($pp)){ + $port2=new DevicePorts(); + $port2->DeviceID = $dev->DeviceID; + $port2->PortNumber = $portRearNumber; + $port2->getPort(); + + while ($port2->ConnectedPort != null){ + if($pp->devID1 == $port2->DeviceID || $port2->DeviceID == $port2->ConnectedDeviceID) { + $status = 'Device already connected'; + break; + } + + error_log("Device with dev_id " . $port2->DeviceID . " and port " . $port2->PortNumber . " already connected to device with id " . $port2->ConnectedDeviceID . " on port " . $port2->ConnectedPort); + $port2->DeviceID = $port2->ConnectedDeviceID; + #Once we switch to the other device, we look for the corresponding front or rear port + $port2->PortNumber = -1 * $port2->ConnectedPort; + $port2->getPort(); + } + $pp->devID2=$port2->DeviceID; + $pp->port2=$port2->PortNumber; + $label2=$dev->Label; + } + + $pathid=$label1."[".$pp->port1."]---".$label2."[".$pp->port2."]"; + + //make path + if ($pp->MakePath($fakelyUsedNodes)){ + //Go to initial device on Path + if (!$pp->GotoHeadDevice()){ + $status="Error: ".__("Path not initialized").""; + } + } else { + switch ($pp->PathError){ + case 1: + $status="Error: ".__("Error getting initial device data").""; + break; + case 2: + $status="Error: ".__("Error: initial device is a panel").""; + break; + case 3: + $status="Error: ".__("Error getting initial device port data").""; + break; + case 4: + $status="Error: ".__("Error: initial device port is already connected").""; + break; + case 5: + $status="Error: ".__("Error getting final device data").""; + break; + case 6: + $status="Error: ".__("Error: final device is a panel").""; + break; + case 7: + $status="Error: ".__("Error getting final device port data").""; + break; + case 9: + $status="Error: ".__("Error: Path not found").""; + break; + } + } + + if ($status==""){ + $path="
"; + $path.="
".__("Connections")." $pathid
\n"; + + //Path Table + $path.="\n\t\n\t\t\n\t\n\t\n"; + $path.="\t\t\n\t\t"; + + if ($elem_path==1 || $dev->DeviceType=="Patch Panel"){ + //half hose + //Out connection type + $tipo_con=($pp->PortNumber>0)?"f":"r"; + + $path.="\n\t\t\n"; + } + //next device, if exist + if ($pp->GotoNextDevice()) { + $dev->DeviceID=$pp->DeviceID; + $dev->GetDevice(); + + //In connection type + $tipo_con=($pp->PortNumber>0)?"r":"f"; + + //half hose + $path.="\n\t\t\n"; + + //Out connection type + $tipo_con=($pp->PortNumber>0)?"f":"r"; + + //Can I follow? + if ($dev->DeviceType=="Patch Panel"){ + $path.="\n\t\t\n"; + $conex.="\t\t\n\t\n"; + } + else{ + $conex=""; + $path.="\n\t\t\n\t\t\n\t\n"; + + if ($pp->GotoNextDevice()) { + $tipo_con=($pp->PortNumber>0)?"r":"f"; //In connection type + + //row separation between patch rows: draw the connection between panels + $path.="\t\n\t\t\n"; + $path.="\t\t\n"; + $path.=$conex; + $path.="\n\n\t\t\n\t\t\n\t\t\n"; + $path.="\t\t\n"; + $path.=$conex; + $end=true; + } + }else { + //End of path + $path.="\n\t\t\n\t\t\n\t\t\n\t\n"; + $end=true; + } + $primero=false; + } + //key + $path.="\t\n\t\t\n\t"; + $path.="\t\n"; + $path.="\t\t\n"; + $path.="\t\t\n"; + $path.="\t\n"; + $path.="\t\n"; + $path.="\t\t\n"; + $path.="\t\t\n"; + $path.="\t\n"; + + //End of path table + $path.="\t\n\t\t\n\t
 
   "; + + $dev=new Device(); + $end=false; + $elem_path=0; + + while (!$end) { + //first device + //get the device + $dev->DeviceID=$pp->DeviceID; + $dev->GetDevice(); + $elem_path++; + + //I get device Lineage (for multi level chassis) + $devList=array(); + $devList=$dev->GetDeviceLineage(); + + //Device table + $path.="\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n"; + + //Lineage + $t=5; + for ($i=sizeof($devList); $i>1; $i--){ + $path.=str_repeat("\t",$t++)."\n"; + $path.=str_repeat("\t",$t--)."\n"; + $path.=str_repeat("\t",$t--)."
"; + + //cabinet + $cab=new Cabinet(); + $cab->CabinetID=$devList[sizeof($devList)]->Cabinet; + $cab->GetCabinet(); + $path.=__("Cabinet").": CabinetID\">$cab->Location"; + $path.="
U:{$devList[sizeof($devList)]->Position}\n"; + $path.=str_repeat("\t",$t++)."\n"; + $path.=str_repeat("\t",$t++)."\n"; + $path.=str_repeat("\t",$t--)."\n"; + $path.=str_repeat("\t",$t)."\n"; + $path.=str_repeat("\t",$t++)."\n"; + $path.=str_repeat("\t",$t)."\n"; + } + + //Device + $port1Label = new DevicePorts(); + $port1Label->PortNumber = abs($pp->PortNumber); + $port1Label->DeviceID = $pp->DeviceID; + $port1Label->getPort(); + + $path.=str_repeat("\t",$t--)."\n"; + $path.=str_repeat("\t",$t--)."\n"; + $path.=str_repeat("\t",$t--)."
"; + $path.="DeviceID}\">{$devList[$i]->Label}"; + $path.="
Slot:{$devList[$i-1]->Position}". + "DeviceID\">$dev->Label". + "
".__("Port").": ".$port1Label->Label."
\n"; + + //ending device table + for ($i=sizeof($devList); $i>1; $i--){ + $path.=str_repeat("\t",$t--)."
\n"; + } + + $path.="\t\t
"; + // I prepare row separation between patch rows + $conex="\t\t  
"; + } + + //I get device Lineage (for multi level chassis) + $devList=array(); + $devList=$dev->GetDeviceLineage(); + + //Device Table + $path.="\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n"; + + //lineage + $t=5; + for ($i=sizeof($devList); $i>1; $i--){ + $path.=str_repeat("\t",$t++)."\n"; + $path.=str_repeat("\t",$t--)."\n"; + } + + if ($pp->PortNumber>0){ + $t++; + $path.=str_repeat("\t",$t++)."\n"; + $path.=str_repeat("\t",$t)."\n"; + $path.=str_repeat("\t",$t--)."\n"; + } + $path.=str_repeat("\t",$t--)."
"; + + //cabinet + $cab=new Cabinet(); + $cab->CabinetID=$devList[sizeof($devList)]->Cabinet; + $cab->GetCabinet(); + $path.=__("Cabinet").": CabinetID\">$cab->Location"; + $path.="
U:{$devList[sizeof($devList)]->Position}\n"; + $path.=str_repeat("\t",$t++)."\n"; + $path.=str_repeat("\t",$t++)."\n"; + $path.=str_repeat("\t",$t--)."\n"; + $path.=str_repeat("\t",$t)."\n"; + $path.=str_repeat("\t",$t++)."\n"; + $path.=str_repeat("\t",$t)."\n"; + } + + $port2Label = new DevicePorts(); + $port2Label->PortNumber = abs($pp->PortNumber); + $port2Label->DeviceID = $pp->DeviceID; + $port2Label->getPort(); + //device + $path.=str_repeat("\t",$t--)."\n"; + $path.=str_repeat("\t",$t--)."\n"; + + //ending device table + for ($i=sizeof($devList); $i>1; $i--){ + $path.=str_repeat("\t",$t--)."
"; + $path.="DeviceID}\">{$devList[$i]->Label}"; + $path.="
Slot:{$devList[$i-1]->Position}". + "DeviceID\">$dev->Label". + "
".__("Port").": ".$port2Label->Label."
\n"; + $path.=str_repeat("\t",$t--)."
\n"; + $path.=str_repeat("\t",$t--)."
\n"; + + //ending row + $path.="\t\t
   
  
   "; + } else { + //End of path + $path.="\t
     
 
\"\"  ".__("Front Connection")."
\"\"  ".__("Rear Connection")."
 
"; + $path.="\t\n"; + $path.="\t\n"; + $path.= "
"; + array_push($listOfPaths, $path); + } else { + displayjson($status); + } + } + displayjson($listOfPaths); + } else { + displayjson("Error: No connections passed."); + } + } +?> + + + + + + + openDCIM Data Center Inventory + + + + + + + + + + + + +
+ +

',$status,'

+
+
+ + + + + +
+
+ '.__("Initial device").' + + + + + + + + + + + + + +
',__("Data Center"),'',__("Cabinet"),'',__("Device"),'',__("Port"),'
'.builddclist("dc-front").'
+
+
      +
+ '.__("Final device").' + + + + + + + + + + + + + +
',__("Data Center"),'',__("Cabinet"),'',__("Device"),'',__("Port"),'
'.builddclist("dc-rear").'
+
+
+ + + + + + + + + + + + +
',__("Initial Data Center"),'',__("Initial Cabinet"),'',__("Initial Device"),'',__("Initial Port"),'',__("|"),'',__("Final Data Center"),'',__("Final Cabinet"),'',__("Final Device"),'',__("Final Port"),'
'; + +echo '
'; +echo ''; +echo '

'; + +echo '
'; +?> +
+
",$path,"

"; +echo '[ ',__("Return to Main Menu"),' ]'; ?> +
+
+ + +