OLT ONT Implementation Devices
Snmp Version

Devicetypes:
Olt Flag
This commit is contained in:
Spitzer_Daniel
2023-07-04 18:19:30 +02:00
parent ebcccafb82
commit 81ba7c633c
8 changed files with 1087 additions and 9 deletions

View File

@@ -43,8 +43,16 @@ class DeviceController extends mfBaseController
$this->layout()->setTemplate("Device/Detail");
$devicesconfig = DeviceModel::getconifg($id);
$devices = DeviceModel::getOne($id);
if ($devices->devicetype->olt == "1") {
$customer = DeviceModel::getOltCustomer($device->ip);
} else {
$customer = [];
}
$this->layout()->set("devicesconfig", $devicesconfig);
$this->layout()->set("devices", $devices);
$this->layout()->set("customer", $customer);
}
@@ -122,6 +130,11 @@ class DeviceController extends mfBaseController
$data['ip'] = $r->ip;
$data['mac'] = $r->mac;
$data['serial'] = $r->serial;
if ($r->snmp_version) {
$data['snmp_version'] = $r->snmp_version;
} else {
$data['snmp_version'] = NULL;
}
if (empty(trim($r->price))) {
$data['price'] = "0.00";
} else {
@@ -212,14 +225,17 @@ class DeviceController extends mfBaseController
protected function apiAction()
{
if (!$this->me->is(["Admin"])) {
$this->redirect("Dashboard");
$return = false;
}
$do = $this->request->do;
$format = $this->request->format;
$filename = $this->request->filename;
$id = $this->request->id;
$ip = $this->request->ip;
$portid = $this->request->portid;
$ports = $this->request->ports;
$adv = $this->request->adv;
$ont = $this->request->ont;
$data = [];
switch ($do) {
@@ -229,6 +245,15 @@ class DeviceController extends mfBaseController
case "createconfig":
$return = $this->createConfig($ip);
break;
case "getoltinfo":
$return = $this->getoltInfo($ip, $portid, $adv);
break;
case "getontinfo":
$return = $this->getontInfo($ip, $portid, $ont);
break;
case "changeoltsplitter":
$return = $this->changeoltSplitter($id, $portid, $ports);
break;
default:
$return = false;
}
@@ -279,4 +304,29 @@ class DeviceController extends mfBaseController
return $this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker);
}
private function changeoltSplitter($id, $portid, $ports)
{
$changeOltSplitter = DeviceModel::changeoltSplitter($id, $portid, $ports);
echo json_encode($changeOltSplitter);
exit;
}
private function getoltInfo($ip, $portid, $adv)
{
$r = $this->request;
$id = $r->id;
$getOltInfo = DeviceModel::getoltInfo($ip, $portid, $adv);
echo json_encode($getOltInfo);
exit;
}
private function getontInfo($ip, $portid, $ont)
{
$r = $this->request;
$id = $r->id;
$getOntInfo = DeviceModel::getontInfo($ip, $portid, $ont);
echo json_encode($getOntInfo);
exit;
}
}

View File

@@ -17,6 +17,7 @@ class DeviceModel
public $addr_city = null;
public $gps_long = null;
public $create_by = null;
public $snmp_version = null;
public $edit_by = null;
public $create = null;
public $edit = null;
@@ -137,6 +138,49 @@ class DeviceModel
return $where;
}
public static function getOltCustomer($ip)
{
$items = [];
$db = FronkDB::singleton();
// $sql = "SELECT Patching.id,lastname,firstname,customer_number,company,device_name,device_port FROM `Patching`
//LEFT JOIN OrderProduct ON (Patching.termination_id=OrderProduct.termination_id)
//LEFT JOIN `Order` ON (`Order`.id=OrderProduct.order_id)
//LEFT JOIN Address ON Address.id=`Order`.owner_id
//WHERE Patching.`device_name` LIKE '".$ip."%'";
// $res = $db->query($sql);
// if ($db->num_rows($res)) {
// while ($data = $db->fetch_array($res)) {
// $devicePort = str_replace($ip, "", $data['device_name']);
// $devicePort=trim($devicePort);
// $devicePort=ltrim($devicePort,"/");
// $devicePort=ltrim($devicePort,"-");
// $devicePort=$devicePort."/".$data['device_port'];
// $devicePort=str_replace("/","-",$devicePort);
// $devicePort=rtrim($devicePort,"-");
// $items[$devicePort] = $data;
//
//
// }
// }
$sql = "Select Patching.id,lastname,firstname,customer_number,company,device_name,device_port,value_string FROM Workflowvalue
LEFT JOIN Termination ON Termination.id=Workflowvalue.object_id
LEFT JOIN Patching ON Termination.id = Patching.termination_id
LEFT JOIN OrderProduct ON (Patching.termination_id=OrderProduct.termination_id)
LEFT JOIN `Order` ON (`Order`.id=OrderProduct.order_id)
LEFT JOIN Address ON Address.id=`Order`.owner_id
WHERE `item_id` = '55'";
$res = $db->query($sql);
if ($db->num_rows($res)) {
while ($data = $db->fetch_array($res)) {
$ontSn=$data['value_string'];
$ontSn= str_replace("HWTC","48575443",$ontSn);
$items[$ontSn] = $data;
}
}
return $items;
}
public static function getconifg($id)
{
$response = "";
@@ -215,4 +259,92 @@ class DeviceModel
endif;
return json_decode($response);
}
public static function getoltInfo($ip, $portid = '', $adv = '')
{
if ($portid) {
$portid = "/" . $portid;
}
if ($adv) {
$adv = "/" . $adv;
}
$url = TT_MBI_API_URL . TT_MBI_API_VERSION . '/deviceoltinfo/' . $ip . $portid . $adv;
$response = "";
if (TT_MBI_API_ENABLE) :
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer ' . TT_MBI_API_KEY),
));
$response = curl_exec($curl);
curl_close($curl);
endif;
return json_decode($response);
}
public static function getontInfo($ip, $portid = '', $ont = '')
{
$portid = "/" . $portid;
$ont = "/ont/" . $ont;
$url = TT_MBI_API_URL . TT_MBI_API_VERSION . '/deviceoltinfo/' . $ip . $portid . $ont;
$response = "";
if (TT_MBI_API_ENABLE) :
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer ' . TT_MBI_API_KEY),
));
$response = curl_exec($curl);
curl_close($curl);
endif;
return json_decode($response);
}
public static function changeoltSplitter($id, $portid, $ports)
{
$url = TT_MBI_API_URL . TT_MBI_API_VERSION . '/deviceoltsetsplitter/' . $id . "/" . $portid . "/" . $ports;
$response = "";
if (TT_MBI_API_ENABLE) :
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer ' . TT_MBI_API_KEY),
));
$response = curl_exec($curl);
curl_close($curl);
endif;
return json_decode($response);
}
}