public function getCustomers() { $this->__load(); return parent::getCustomers(); }
/** * Utility function to slurp all peering VLAN interfaces ports from the database and * arrange them in arrays for use by the Nagios config templates * * @param \Entities\IXP $ixp */ private function genMemberConf_getVlanInterfaces($ixp) { $custs = []; $switches = []; $cabinets = []; $locations = []; $ipv4hosts = []; $ipv6hosts = []; foreach ($ixp->getCustomers() as $c) { if (!$c->isTypeFull() || $c->hasLeft() || $c->getStatus() != \Entities\Customer::STATUS_NORMAL) { continue; } $custs[$c->getId()]['shortname'] = $c->getShortname(); $custs[$c->getId()]['name'] = $c->getAbbreviatedName(); $custs[$c->getId()]['hostnames'] = []; $custs[$c->getId()]['vints'] = []; foreach ($c->getVirtualInterfaces() as $vi) { // make sure we have a phsyical connection $haveConnection = false; foreach ($vi->getPhysicalInterfaces() as $pi) { if ($pi->getStatus() == \Entities\PhysicalInterface::STATUS_CONNECTED) { $haveConnection = true; } } if (!$haveConnection) { continue; } foreach ($vi->getVlanInterfaces() as $vli) { if ($vli->getVlan()->getPrivate()) { continue; } foreach (['v4', 'v6'] as $proto) { $getIpEnabled = "getIp{$proto}enabled"; $getIpCanping = "getIp{$proto}canping"; $getIpAddress = "getIP{$proto}Address"; $getIpMonBGP = "getIp{$proto}monitorrcbgp"; if ($vli->{$getIpEnabled}() && $vli->{$getIpCanping}()) { if (!$vli->{$getIpAddress}()) { continue; } $hn = "{$c->getShortname()}-ip{$proto}-vlan{$vli->getVlan()->getNumber()}-{$vli->getId()}"; $custs[$c->getId()]['hostnames'][] = $hn; $custs[$c->getId()]['vints'][$vli->getId()][$proto]['hostname'] = $hn; $custs[$c->getId()]['vints'][$vli->getId()][$proto]['address'] = $vli->{$getIpAddress}()->getAddress(); $custs[$c->getId()]['vints'][$vli->getId()][$proto]['canping'] = $vli->{$getIpCanping}(); $custs[$c->getId()]['vints'][$vli->getId()][$proto]['monrc'] = $vli->{$getIpMonBGP}(); $custs[$c->getId()]['vints'][$vli->getId()][$proto]['vlan'] = $vli->getVlan()->getName(); $custs[$c->getId()]['vints'][$vli->getId()][$proto]['busyhost'] = $vli->getBusyhost(); $pi = $vi->getPhysicalInterfaces()[0]; $sw = $pi->getSwitchPort()->getSwitcher(); if (!isset($switches[$sw->getName()]) || !in_array($hn, $switches[$sw->getName()])) { $switches[$sw->getName()][] = $hn; } if (!isset($cabinets[$sw->getCabinet()->getName()]) || !in_array($hn, $cabinets[$sw->getCabinet()->getName()])) { $cabinets[$sw->getCabinet()->getName()][] = $hn; } if (!isset($locations[$sw->getCabinet()->getLocation()->getShortname()]) || !in_array($hn, $locations[$sw->getCabinet()->getLocation()->getShortname()])) { $locations[$sw->getCabinet()->getLocation()->getShortname()][] = $hn; } if ($proto == 'v4') { $ipv4hosts[] = $hn; } else { $ipv6hosts[] = $hn; } if (!isset($custs[$c->getId()]['vints'][$vli->getId()]['phys'])) { $custs[$c->getId()]['vints'][$vli->getId()]['phys']['switch'] = $sw->getName(); $custs[$c->getId()]['vints'][$vli->getId()]['phys']['port'] = $pi->getSwitchPort()->getName(); $custs[$c->getId()]['vints'][$vli->getId()]['phys']['lag'] = count($vi->getPhysicalInterfaces()) - 1; } } } } } } $this->view->custs = $custs; $this->view->switches = $switches; $this->view->cabinets = $cabinets; $this->view->locations = $locations; $this->view->ipv4hosts = $ipv4hosts; $this->view->ipv6hosts = $ipv6hosts; }