public function getId()
 {
     if ($this->__isInitialized__ === false) {
         return (int) $this->_identifier["id"];
     }
     $this->__load();
     return parent::getId();
 }
Example #2
0
/**
 * Updates vlan interface
 *
 * Script looks for vlan interface by IPv4 or IPv6 found in parsed data from CFG file.
 * If vlan interface is founded then its rsclient field is set to true. If $row[4] is set
 * then maxbgprefix field is set to $row[4] value.
 *
 * @param array          $row  Data row parsed form cfg file.
 * @param \Entities\Vlan $vlan Vlan for IP addresses and vlan interface search
 * @param object         $em   Entity manager
 * @return
 */
function updateVlanInterface($row, $vlan, $em)
{
    if (strpos($row[0], ":")) {
        $ip4 = false;
    } elseif (strpos($row[0], ".")) {
        $ip4 = true;
    } else {
        return false;
    }
    $vlInt = false;
    if ($ip4) {
        $ip = $em->getRepository("\\Entities\\IPv4Address")->findOneBy(['Vlan' => $vlan->getId(), 'address' => $row[0]]);
        if ($ip) {
            $vlInt = $em->getRepository("\\Entities\\VlanInterface")->findOneBy(['Vlan' => $vlan->getId(), 'IPv4Address' => $ip]);
        }
    } else {
        $ip = $em->getRepository("\\Entities\\IPv6Address")->findOneBy(['Vlan' => $vlan->getId(), 'address' => strtolower($row[0])]);
        if ($ip) {
            $vlInt = $em->getRepository("\\Entities\\VlanInterface")->findOneBy(['Vlan' => $vlan->getId(), 'IPv6Address' => $ip]);
        }
    }
    if ($vlInt) {
        $vlInt->setRsclient(1);
        if (isset($row[4])) {
            $vlInt->setMaxbgpprefix($row[4]);
        }
        return true;
    } else {
        return false;
    }
}