@@ -217,20 +217,31 @@ public function getCustomers( $vid, $protocol, $forceDb = false )
217217 }
218218
219219 /**
220- * Tempory INEX function until I have a better way of doing this. Used by the
221- * `PeeringManagerController`. FIXME.
220+ * Find all VLANs marked for inclusion in the peering manager.
221+ *
222+ * @return Entities\Vlan[]
222223 */
223- public function getPeeringVLANs ()
224+ public function getPeeringManagerVLANs ()
224225 {
225226 return $ this ->getEntityManager ()->createQuery (
226- "SELECT v
227-
228- FROM \\Entities \\Vlan v
229-
227+ "SELECT v FROM \\Entities \\Vlan v
230228 WHERE
229+ v.peering_manager = 1
230+ ORDER BY v.number ASC "
231+ )
232+ ->getResult ();
233+ }
231234
232- v.number IN ( 10, 12 )
233-
235+ /**
236+ * Find all VLANs marked for inclusion in the peering matrices.
237+ *
238+ * @return Entities\Vlan[]
239+ */
240+ public function getPeeringMatrixVLANs ()
241+ {
242+ return $ this ->getEntityManager ()->createQuery (
243+ "SELECT v FROM \\Entities \\Vlan v
244+ WHERE v.peering_matrix = 1
234245 ORDER BY v.number ASC "
235246 )
236247 ->getResult ();
@@ -284,17 +295,17 @@ public function getPrivateVlanDetails( $infra = null )
284295 WHERE
285296
286297 v.private = 1 " ;
287-
298+
288299 if ( $ infra )
289300 $ q .= ' AND i = :infra ' ;
290301
291302 $ q .= 'ORDER BY v.number ASC ' ;
292-
303+
293304 $ q = $ this ->getEntityManager ()->createQuery ( $ q );
294-
305+
295306 if ( $ infra )
296307 $ q ->setParameter ( 'infra ' , $ infra );
297-
308+
298309 $ vlans = $ q ->getArrayResult ();
299310
300311 if ( !$ vlans || !count ( $ vlans ) )
@@ -335,7 +346,7 @@ public function getPrivateVlanDetails( $infra = null )
335346 return $ pvs ;
336347 }
337348
338-
349+
339350 /**
340351 * Utility function to provide an array of all VLAN interface IP addresses
341352 * and hostnames on a given VLAN for a given protocol for the purpose of generating
@@ -359,22 +370,22 @@ public function getArpaDetails( $vlan, $proto, $useResultCache = true )
359370 {
360371 if ( !in_array ( $ proto , [ 4 , 6 ] ) )
361372 throw new \IXP_Exception ( 'Invalid protocol specified ' );
362-
363-
373+
374+
364375 $ qstr = "SELECT vli.ipv {$ proto }enabled AS enabled, addr.address AS address,
365376 vli.ipv {$ proto }hostname AS hostname
366377 FROM Entities \\VlanInterface vli
367378 JOIN vli.IPv {$ proto }Address addr
368379 JOIN vli.Vlan v
369380 WHERE
370381 v = :vlan " ;
371-
382+
372383 $ qstr .= " ORDER BY addr.address ASC " ;
373-
384+
374385 $ q = $ this ->getEntityManager ()->createQuery ( $ qstr );
375386 $ q ->setParameter ( 'vlan ' , $ vlan );
376387 $ q ->useResultCache ( $ useResultCache , 3600 );
377388 return $ q ->getArrayResult ();
378389 }
379-
390+
380391}
0 commit comments