Пример #1
0
/**
 * Creates or loads physical interface for port
 *
 * @param \Entities\SwitchPort $dbPort Port to create or load Physical interface
 * @param array                $port    Parsed port data from csv to check if is LAG or simple port
 * @param \Entities\Customer   $cust   Customer to get next monitor index
 * @param object               $em     Entity manager
 * @return \Entities\PhysicalInterface
 */
function createLoadPhysicalInterface($dbPort, $port, $cust, $em)
{
    $phInt = $dbPort->getPhysicalInterface();
    if (!$phInt) {
        $phInt = new \Entities\PhysicalInterface();
        $em->persist($phInt);
        $phInt->setStatus(\Entities\PhysicalInterface::STATUS_CONNECTED);
        $phInt->setDuplex('full');
        $phInt->setMonitorindex($em->getRepository("\\Entities\\PhysicalInterface")->getNextMonitorIndex($cust));
        $phInt->setSwitchPort($dbPort);
        $dbPort->setPhysicalInterface($phInt);
    }
    if ($port['port_type']) {
        $speed = split("base", strtolower($port['port_type']));
        switch ($speed[0]) {
            case '10gig':
                $phInt->setSpeed(10000);
                break;
            case '1000':
                $phInt->setSpeed(1000);
                break;
            case '100':
                $phInt->setSpeed(100);
                break;
            case '10':
                $phInt->setSpeed(10);
                break;
            default:
                echo "Uh oh: could not parse speed {$port['port_type']}\n";
                break;
        }
    } else {
        echo "Uh oh: no port type for switchport {$dbPort->getSwitcher()->getName()}:{$dbPort->getName()}\n";
    }
    return $phInt;
}
 /**
  *
  * @param IXP_Form_SwitchPort $form The form object
  * @param \Entities\SwitchPort $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->setSwitcher($this->getD2EM()->getRepository('\\Entities\\Switcher')->find($form->getElement('switchid')->getValue()));
     return true;
 }
 public function getMauAutoNegAdminState()
 {
     $this->__load();
     return parent::getMauAutoNegAdminState();
 }