/**
  * Function which can be over-ridden to perform any post-deletion tasks
  *
  * Database `flush()` has been successfully completed at this stage
  *
  * If you return with true, then the standard log message and OSS_Message
  * will be performed. If you want to override these, return false.
  *
  * NB: also calls `postFlush()`
  *
  * @param \Entities\PhysicalInterface $object The Doctrine2 entity to delete
  * @return bool Return false to stop / cancel standard log and OSS_Message
  */
 protected function postDelete($object)
 {
     if ($this->getParam('related', false) && $object->getRelatedInterface()) {
         $this->removeRelatedInterface($object);
         $this->getD2EM()->flush();
     }
     return $this->postFlush($object);
 }
Example #2
0
/**
 * Creates or updates physical interface for port
 *
 * @param \Entities\PhysicalInterface $phInt    Ports physical interface to get or create virtual interface
 * @param array                       $port     Parsed port data from csv to check if is LAG or simple port
 * @param \Entities\Switcher          $switcher Switch to look for port
 * @param \Entities\Customer          $cust     Customer to assign new virtual interface
 * @param object                      $em       Entity manager
 * @return \Entities\VirutalInterface
 */
function createUpdateVirtualInterface($phInt, $port, $switcher, $cust, $em)
{
    $viInt = $phInt->getVirtualInterface();
    if (!$viInt) {
        if ($port['pchan_master']) {
            foreach ($switcher->getPorts() as $sport) {
                if ($sport->getIfName() == $port['pchan_master']) {
                    $viInt = $sport->getPhysicalInterface()->getVirtualInterface();
                    break;
                }
            }
        }
        if (!$viInt) {
            $viInt = new \Entities\VirtualInterface();
            $em->persist($viInt);
            $viInt->setCustomer($cust);
            $cust->addVirtualInterface($viInt);
            $viInt->setMtu(0);
            $viInt->setTrunk(0);
            $viInt->setChannelgroup(0);
        }
        $phInt->setVirtualInterface($viInt);
        $viInt->addPhysicalInterface($phInt);
    }
    return $viInt;
}
 public function statusIsQuarantine()
 {
     $this->__load();
     return parent::statusIsQuarantine();
 }
Example #4
0
 /**
  * Removes related interface
  *
  * Removes a related interface and if it only has one physical interface, removes the virtual interface also
  *
  * @param \Entities\PhysicalInterface $pi Physical interface to remove related physical interface.
  * @return void
  */
 private function removeRelatedInterface($pi)
 {
     $pi->getRelatedInterface()->getSwitchPort()->setPhysicalInterface(null);
     if (count($pi->getRelatedInterface()->getVirtualInterface()->getPhysicalInterfaces()) == 1) {
         foreach ($pi->getRelatedInterface()->getVirtualInterface()->getVlanInterfaces() as $fnvi) {
             $this->getD2EM()->remove($fnvi);
         }
         foreach ($pi->getRelatedInterface()->getVirtualInterface()->getMACAddresses() as $mac) {
             $this->getD2EM()->remove($mac);
         }
         $this->getD2EM()->remove($pi->getRelatedInterface()->getVirtualInterface());
         $this->getD2EM()->remove($pi->getRelatedInterface());
     } else {
         $this->getD2EM()->remove($pi->getRelatedInterface());
     }
 }