Skip to content

Commit

Permalink
Merge branch 'nf-vlan-pm-switches'
Browse files Browse the repository at this point in the history
  • Loading branch information
barryo committed Nov 26, 2014
2 parents cef2616 + 16f6411 commit 4d565c0
Show file tree
Hide file tree
Showing 17 changed files with 423 additions and 228 deletions.
2 changes: 1 addition & 1 deletion application/Entities/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2113,4 +2113,4 @@ public function isUniqueMonitorIndex( $i )
}
return true;
}
}
}
2 changes: 1 addition & 1 deletion application/Entities/PhysicalInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,4 +368,4 @@ public function statusIsQuarantine()
{
return $this->getStatus() == self::STATUS_QUARANTINE;
}
}
}
2 changes: 1 addition & 1 deletion application/Entities/Switcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -795,4 +795,4 @@ public function getSerialNumber()
{
return $this->serialNumber;
}
}
}
70 changes: 63 additions & 7 deletions application/Entities/Vlan.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class Vlan

const PROTOCOL_IPv4 = 4;
const PROTOCOL_IPv6 = 6;


/**
* @var string $name
*/
Expand Down Expand Up @@ -321,7 +321,7 @@ public function getNetworkInfo()
{
return $this->NetworkInfo;
}

/**
* @var boolean
*/
Expand Down Expand Up @@ -828,7 +828,7 @@ private function _processKey($config, $key, $value)
public function setInfrastructure(\Entities\Infrastructure $infrastructure = null)
{
$this->Infrastructure = $infrastructure;

return $this;
}

Expand All @@ -851,7 +851,7 @@ public function getInfrastructure()
public function addIPv4Addresse(\Entities\IPv4Address $iPv4Addresses)
{
$this->IPv4Addresses[] = $iPv4Addresses;

return $this;
}

Expand All @@ -874,7 +874,7 @@ public function removeIPv4Addresse(\Entities\IPv4Address $iPv4Addresses)
public function addIPv6Addresse(\Entities\IPv6Address $iPv6Addresses)
{
$this->IPv6Addresses[] = $iPv6Addresses;

return $this;
}

Expand All @@ -887,4 +887,60 @@ public function removeIPv6Addresse(\Entities\IPv6Address $iPv6Addresses)
{
$this->IPv6Addresses->removeElement($iPv6Addresses);
}
}
/**
* @var boolean
*/
private $peering_matrix = 0;

/**
* @var boolean
*/
private $peering_manager = 0;


/**
* Set peering_matrix
*
* @param boolean $peeringMatrix
* @return Vlan
*/
public function setPeeringMatrix($peeringMatrix)
{
$this->peering_matrix = $peeringMatrix;

return $this;
}

/**
* Get peering_matrix
*
* @return boolean
*/
public function getPeeringMatrix()
{
return $this->peering_matrix;
}

/**
* Set peering_manager
*
* @param boolean $peeringManager
* @return Vlan
*/
public function setPeeringManager($peeringManager)
{
$this->peering_manager = $peeringManager;

return $this;
}

/**
* Get peering_manager
*
* @return boolean
*/
public function getPeeringManager()
{
return $this->peering_manager;
}
}
6 changes: 6 additions & 0 deletions application/Proxies/__CG__EntitiesCustomer.php
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,12 @@ public function statusIsSuspended()
return parent::statusIsSuspended();
}

public function isUniqueMonitorIndex($i)
{
$this->__load();
return parent::isUniqueMonitorIndex($i);
}


public function __sleep()
{
Expand Down
26 changes: 25 additions & 1 deletion application/Proxies/__CG__EntitiesVlan.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,34 @@ public function removeIPv6Addresse(\Entities\IPv6Address $iPv6Addresses)
return parent::removeIPv6Addresse($iPv6Addresses);
}

public function setPeeringMatrix($peeringMatrix)
{
$this->__load();
return parent::setPeeringMatrix($peeringMatrix);
}

public function getPeeringMatrix()
{
$this->__load();
return parent::getPeeringMatrix();
}

public function setPeeringManager($peeringManager)
{
$this->__load();
return parent::setPeeringManager($peeringManager);
}

public function getPeeringManager()
{
$this->__load();
return parent::getPeeringManager();
}


public function __sleep()
{
return array('__isInitialized__', 'name', 'number', 'rcvrfname', 'private', 'notes', 'id', 'NetInfo', 'VlanInterfaces', 'IPv4Addresses', 'IPv6Addresses', 'NetworkInfo', 'Infrastructure');
return array('__isInitialized__', 'name', 'number', 'rcvrfname', 'private', 'peering_matrix', 'peering_manager', 'notes', 'id', 'NetInfo', 'VlanInterfaces', 'IPv4Addresses', 'IPv6Addresses', 'NetworkInfo', 'Infrastructure');
}

public function __clone()
Expand Down
49 changes: 30 additions & 19 deletions application/Repositories/Vlan.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,20 +217,31 @@ public function getCustomers( $vid, $protocol, $forceDb = false )
}

/**
* Tempory INEX function until I have a better way of doing this. Used by the
* `PeeringManagerController`. FIXME.
* Find all VLANs marked for inclusion in the peering manager.
*
* @return Entities\Vlan[]
*/
public function getPeeringVLANs()
public function getPeeringManagerVLANs()
{
return $this->getEntityManager()->createQuery(
"SELECT v
FROM \\Entities\\Vlan v
"SELECT v FROM \\Entities\\Vlan v
WHERE
v.peering_manager = 1
ORDER BY v.number ASC"
)
->getResult();
}

v.number IN ( 10, 12 )
/**
* Find all VLANs marked for inclusion in the peering matrices.
*
* @return Entities\Vlan[]
*/
public function getPeeringMatrixVLANs()
{
return $this->getEntityManager()->createQuery(
"SELECT v FROM \\Entities\\Vlan v
WHERE v.peering_matrix = 1
ORDER BY v.number ASC"
)
->getResult();
Expand Down Expand Up @@ -284,17 +295,17 @@ public function getPrivateVlanDetails( $infra = null )
WHERE
v.private = 1 ";

if( $infra )
$q .= ' AND i = :infra ';

$q .= 'ORDER BY v.number ASC';

$q = $this->getEntityManager()->createQuery( $q );

if( $infra )
$q->setParameter( 'infra', $infra );

$vlans = $q->getArrayResult();

if( !$vlans || !count( $vlans ) )
Expand Down Expand Up @@ -335,7 +346,7 @@ public function getPrivateVlanDetails( $infra = null )
return $pvs;
}


/**
* Utility function to provide an array of all VLAN interface IP addresses
* and hostnames on a given VLAN for a given protocol for the purpose of generating
Expand All @@ -359,22 +370,22 @@ public function getArpaDetails( $vlan, $proto, $useResultCache = true )
{
if( !in_array( $proto, [ 4, 6 ] ) )
throw new \IXP_Exception( 'Invalid protocol specified' );


$qstr = "SELECT vli.ipv{$proto}enabled AS enabled, addr.address AS address,
vli.ipv{$proto}hostname AS hostname
FROM Entities\\VlanInterface vli
JOIN vli.IPv{$proto}Address addr
JOIN vli.Vlan v
WHERE
v = :vlan";

$qstr .= " ORDER BY addr.address ASC";

$q = $this->getEntityManager()->createQuery( $qstr );
$q->setParameter( 'vlan', $vlan );
$q->useResultCache( $useResultCache, 3600 );
return $q->getArrayResult();
}

}
Loading

0 comments on commit 4d565c0

Please sign in to comment.