/**
  * Update OUI database from named file or IEEE website - for issue #87
  *
  * Typically called as:
  *
  *     bin/ixptool.php -a oui-cli.update-database
  *
  * which will create / update the OUI database directly from the latest IEEE file from their website.
  *
  * A specific file can be passed via the `fromfile` parameter. You can also force a
  * database reset (drop all OUI entries and re-populate) via the `refresh` parameter.
  *
  * Neither of these options are typically necessary:
  *
  *     bin/ixptool.php -a oui-cli.update-database -p fromfile=/path/to/oui.txt,refresh=1
  *
  * Note that we bundle a recent OUI file in `date/oui` also.
  * 
  * @return null
  */
 public function updateDatabaseAction()
 {
     $ouitool = new IXP_OUI($this->getParam('fromfile', false));
     $ouiRepo = $this->getD2R('\\Entities\\OUI');
     if ($refresh = $this->getParam('refresh', false)) {
         $this->verbose("Deleted " . $ouiRepo->clear() . " OUI entries during refresh");
     }
     $cnt = 0;
     foreach ($ouitool->loadList()->processRawData() as $oui => $organisation) {
         if ($cnt++ >= 1000) {
             $this->getD2EM()->flush();
             $this->verbose('.', false);
             $cnt = 0;
         }
         if (!$refresh && ($o = $ouiRepo->findOneBy(['oui' => $oui]))) {
             if ($o->getOrganisation() != $organisation) {
                 $o->setOrganisation($organisation);
             }
             continue;
         }
         $o = new \Entities\OUI();
         $o->setOui($oui);
         $o->setOrganisation($organisation);
         $this->getD2EM()->persist($o);
     }
     $this->getD2EM()->flush();
     $this->verbose("");
 }
Example #2
0
 public function testDownloadDefault()
 {
     $oui = new IXP_OUI();
     $this->assertInstanceOf('IXP_OUI', $oui->loadList());
 }