コード例 #1
0
 public function removeMACAddresse(\Entities\MACAddress $mACAddresses)
 {
     $this->__load();
     return parent::removeMACAddresse($mACAddresses);
 }
コード例 #2
0
ファイル: port-sync.php プロジェクト: E-Poludnie/IXP-Manager
/**
 * Creates or updates virtual interface for port
 *
 * @param \Entities\VirtualInterface  $virtInt VirtualInterface for add or load vlan interface
 * @param \Entities\Vlan              $vlan    Vlan for IP addresses and to assign vlan interface.
 * @param array                       $port     Parsed port data from csv file
 * @param object                      $em       Entity manager
 * @return void
 */
function createUpdateVlanInterface($virtInt, $vlan, $port, $em)
{
    $ip4 = loadIPv4($port, $vlan, $em);
    if (!$ip4) {
        echo "ERROR: ip {$port['ipv4addr']} does not exist in Vlan {$vlan->getName()}";
        return false;
    }
    $ip6 = createLoadIPv6($port, $vlan, $em);
    $vlInt = false;
    foreach ($virtInt->getVlanInterfaces() as $vint) {
        if ($vint->getIPv4Address() == $ip4) {
            $vlInt = $vint;
            break;
        }
    }
    if (!$vlInt) {
        $vlInt = new \Entities\VlanInterface();
        $em->persist($vlInt);
        $vlInt->setVirtualInterface($virtInt);
        $virtInt->addVlanInterface($vlInt);
        $vlInt->setVlan($vlan);
        $vlan->addVlanInterface($vlInt);
        $vlInt->setIPv4Address($ip4);
        $vlInt->setIpv4enabled(1);
        $vlInt->setRsclient(0);
        $vlInt->setMaxbgpprefix(100);
    }
    $vlInt->setIpv4hostname($port['ipv4_ptr']);
    if ($port['ipv4_mcast']) {
        $vlInt->setMcastenabled(1);
    } else {
        $vlInt->setMcastenabled(0);
    }
    if ($ip6) {
        $vlInt->setIPv6Address($ip6);
        $vlInt->setIpv6enabled(1);
        $vlInt->setIpv6hostname($port['ipv6_ptr']);
    } else {
        $vlInt->setIPv6Address(null);
        $vlInt->setIpv6enabled(0);
        $vlInt->setIpv6hostname(null);
    }
}
コード例 #3
0
 /**
  * @param IXP_Form_Interface_Virtual $form The form object
  * @param \Entities\VirtualInterface $object The Doctrine2 entity (being edited or blank for add)
  * @param bool $isEdit True of we are editing an object, false otherwise
  * @return void
  */
 protected function addPostValidate($form, $object, $isEdit)
 {
     $object->setCustomer($this->getD2EM()->getRepository('\\Entities\\Customer')->find($form->getElement('custid')->getValue()));
     return true;
 }
コード例 #4
0
ファイル: Interfaces.php プロジェクト: E-Poludnie/IXP-Manager
 /**
  * Links peering and fanout physical interfaces.
  *
  * If *link with fanout port* is checked in the form, then this function:
  *
  * * checks if the necessary fields are set;
  * * loads the selected SwitchPort;
  * * creates/loads this SwitchPort's physical interface;
  * * creates a link between the fanout and peering physical interfaces.
  *
  * If *link with fanout port* is not checked then this function checks
  * if the peering port has a related interface and, if so, removes the relation.
  *
  * @param IXP_Form                     $form Form to get fanout data (one of _Interface_AddWizard or _Interface_Physical)
  * @param \Entities\PhysicalInterface  $pi   Peering physical interface to related with fanout physical interface (port).
  * @param \Entities\VirtualInterface   $vi   Virtual interface of peering physical intreface
  * @return bool
  */
 protected function processFanoutPhysicalInterface($form, $pi, $vi)
 {
     if (!$form->getValue('fanout')) {
         if ($pi->getRelatedInterface()) {
             // if *link with fanout port* is unchecked and the physical interace
             // has a related fanout interface, we need to remove it
             $this->removeRelatedInterface($pi);
             $pi->setFanoutPhysicalInterface(null);
         }
         return true;
     }
     // from here on, we assume $form->getValue( 'fanout' ) is true
     if (!$form->getValue('fn_switchid')) {
         $form->getElement('fn_switchid')->setErrorMessages(['Please select a switch'])->markAsError();
         $form->getElement('fn_switchportid')->setErrorMessages(['Please select a switchport'])->markAsError();
         return false;
     }
     if (!$form->getValue('fn_switchportid')) {
         $form->getElement('fn_switchportid')->setErrorMessages(['Please select a switchport'])->markAsError();
         return false;
     }
     if ($form->getElement('fn_monitorindex')) {
         if (!$form->getValue('fn_monitorindex')) {
             $form->getElement('fn_monitorindex')->setErrorMessages(['This value can not be empty.'])->markAsError();
             return false;
         }
         $monitorIdx = $form->getValue('fn_monitorindex');
     } else {
         $monitorIdx = $this->getD2EM()->getRepository('\\Entities\\PhysicalInterface')->getNextMonitorIndex($vi->getCustomer()->getReseller());
     }
     $fnsp = $this->getD2R('\\Entities\\SwitchPort')->find($form->getElement('fn_switchportid')->getValue());
     $fnsp->setType(\Entities\SwitchPort::TYPE_FANOUT);
     // if switchport does not have a physical interface then create one for it
     if (!$fnsp->getPhysicalInterface()) {
         $fnphi = new \Entities\PhysicalInterface();
         $fnphi->setSwitchPort($fnsp);
         $fnsp->setPhysicalInterface($fnphi);
         $fnphi->setMonitorindex($monitorIdx);
         $this->getD2EM()->persist($fnphi);
     } else {
         $fnphi = $fnsp->getPhysicalInterface();
         // checking if the fanout port already has physical interface and it is not this one
         if ($fnsp->getPhysicalInterface()->getRelatedInterface() && $fnsp->getPhysicalInterface()->getRelatedInterface()->getId() != $pi->getId()) {
             $this->addMesssage("Selected fanout port already has a related physical interface.", OSS_Message::ERROR);
             return false;
         }
     }
     // if the physical interace already has a related physical interface and it's not the same as the fanout physical interface
     if ($pi->getRelatedInterface() && $pi->getRelatedInterface()->getId() != $fnphi->getId()) {
         // if fanout does not have a virtual interface, relate it with old fanout port virtual interface.
         if (!$fnphi->getVirtualInterface()) {
             $pi->getRelatedInterface()->getVirtualInterface()->addPhysicalInterface($fnphi);
             $fnphi->setVirtualInterface($pi->getRelatedInterface()->getVirtualInterface());
         }
         $this->removeRelatedInterface($pi);
     } else {
         if (!$fnphi->getVirtualInterface()) {
             // creating virtual interface for fanout physical interface if it doesn't have one
             $fnvi = new \Entities\VirtualInterface();
             $fnvi->setCustomer($vi->getCustomer()->getReseller());
             $fnvi->addPhysicalInterface($fnphi);
             $fnphi->setVirtualInterface($fnvi);
             $this->getD2EM()->persist($fnvi);
         }
     }
     $pi->setFanoutPhysicalInterface($fnphi);
     $fnphi->setPeeringPhysicalInterface($pi);
     return true;
 }