Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 47e4b09

Browse files
committed
[IM] UI and tests for ability to exclude VLAN form IX-F export
* cast tinyints to bool for new columns * improve my old naming (result/vlansToExport) * exclude vlan interfaces attached to a non-exportable vlan * add networkinfo x 3 and additional non-exportable VLAN to CI test database * update known good CI test exports with the two exportable vlans * UI to prevent private and exportable being selected and to default to exportable when not private
1 parent 28fa382 commit 47e4b09

14 files changed

Lines changed: 216 additions & 22 deletions

app/Models/Aggregators/VlanAggregator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
* @property int $infrastructureid
4343
* @property int $peering_matrix
4444
* @property int $peering_manager
45+
* @property bool $export_to_ixf
4546
* @property string|null $config_name
4647
* @property \Illuminate\Support\Carbon|null $created_at
4748
* @property \Illuminate\Support\Carbon|null $updated_at
@@ -68,6 +69,7 @@
6869
* @method static \Illuminate\Database\Eloquent\Builder|VlanAggregator query()
6970
* @method static \Illuminate\Database\Eloquent\Builder|VlanAggregator whereConfigName($value)
7071
* @method static \Illuminate\Database\Eloquent\Builder|VlanAggregator whereCreatedAt($value)
72+
* @method static \Illuminate\Database\Eloquent\Builder|VlanAggregator whereExportToIxf($value)
7173
* @method static \Illuminate\Database\Eloquent\Builder|VlanAggregator whereId($value)
7274
* @method static \Illuminate\Database\Eloquent\Builder|VlanAggregator whereInfrastructureid($value)
7375
* @method static \Illuminate\Database\Eloquent\Builder|VlanAggregator whereName($value)

app/Models/Vlan.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
* @property int $infrastructureid
4444
* @property int $peering_matrix
4545
* @property int $peering_manager
46-
* @property int $export_to_ixf
46+
* @property bool $export_to_ixf
4747
* @property string|null $config_name
4848
* @property \Illuminate\Support\Carbon|null $created_at
4949
* @property \Illuminate\Support\Carbon|null $updated_at
@@ -70,6 +70,7 @@
7070
* @method static Builder|Vlan query()
7171
* @method static Builder|Vlan whereConfigName($value)
7272
* @method static Builder|Vlan whereCreatedAt($value)
73+
* @method static Builder|Vlan whereExportToIxf($value)
7374
* @method static Builder|Vlan whereId($value)
7475
* @method static Builder|Vlan whereInfrastructureid($value)
7576
* @method static Builder|Vlan whereName($value)
@@ -115,6 +116,7 @@ class Vlan extends Model
115116
*/
116117
protected $casts = [
117118
'private' => 'boolean',
119+
'export_to_ixf' => 'boolean',
118120
];
119121

120122
/**

app/Utils/Export/JsonSchema.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,13 @@ private function getIXPInfo( string $version ): array
195195

196196
$i['peering_policy_list'] = array_values( Customer::$PEERING_POLICIES);
197197

198-
$result = NetworkInfo::leftJoin( 'vlan', 'vlan.id', 'networkinfo.vlanid' )
198+
$vlansToExport = NetworkInfo::join( 'vlan', 'vlan.id', 'networkinfo.vlanid' )
199199
->where( 'vlan.infrastructureid', $infra->id )
200-
->where( 'vlan.export_to_ixf', 1 )
200+
->where( 'vlan.export_to_ixf', true )
201201
->get()->toArray();
202202

203203
$vlanentry = [];
204-
foreach( $result as $ni )
204+
foreach( $vlansToExport as $ni )
205205
{
206206
$id = $ni['id'];
207207
$vlanentry[$id]['id'] = $ni['id'];
@@ -403,7 +403,7 @@ private function getMemberInfo( string $version, bool $detailed, bool $tags ): a
403403

404404
$vlanentries = [];
405405
foreach( $vi->vlanInterfaces as $vli ) {
406-
if( $vli->vlan->private ) {
406+
if( $vli->vlan->private || !$vli->vlan->export_to_ixf ) {
407407
continue;
408408
}
409409

data/ci/ci_test_db.sql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1489,6 +1489,9 @@ CREATE TABLE `networkinfo` (
14891489

14901490
LOCK TABLES `networkinfo` WRITE;
14911491
/*!40000 ALTER TABLE `networkinfo` DISABLE KEYS */;
1492+
INSERT INTO `networkinfo` VALUES (1,1,4,'192.0.2.0',25,'192.0.2.8','192.0.2.9',NULL,NULL,NULL),(2,1,6,'2001:db8::',64,'2001:db8::8','2001:db8::9',NULL,NULL,NULL),
1493+
(3,2,4,'192.0.2.128',25,'192.0.2.136','192.0.2.137',NULL,NULL,NULL),(4,2,6,'2001:db8:0:2::',64,'2001:db8:0:2::8','2001:db8:0:2::9',NULL,NULL,NULL),
1494+
(5,3,4,'192.0.2.0',25,'192.0.2.8','192.0.2.9',NULL,NULL,NULL),(6,3,6,'2001:db8::',64,'2001:db8::8','2001:db8::9',NULL,NULL,NULL);
14921495
/*!40000 ALTER TABLE `networkinfo` ENABLE KEYS */;
14931496
UNLOCK TABLES;
14941497

@@ -2779,7 +2782,7 @@ CREATE TABLE `vlan` (
27792782

27802783
LOCK TABLES `vlan` WRITE;
27812784
/*!40000 ALTER TABLE `vlan` DISABLE KEYS */;
2782-
INSERT INTO `vlan` VALUES (1,1,'Peering LAN 1',1,0,'',1,1,1,NULL,NULL,NULL),(2,2,'Peering LAN 2',2,0,'',1,1,1,NULL,NULL,NULL);
2785+
INSERT INTO `vlan` VALUES (1,1,'Peering LAN 1',1,0,'',1,1,1,NULL,NULL,NULL),(2,2,'Peering LAN 2',2,0,'',1,1,1,NULL,NULL,NULL),(3,1,'Quarantine LAN 1',3,0,'',1,1,0,NULL,NULL,NULL);
27832786
/*!40000 ALTER TABLE `vlan` ENABLE KEYS */;
27842787
UNLOCK TABLES;
27852788

data/ci/known-good/api-v4-member-export-0.6-auth.json

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,20 @@
2626
"mandatory",
2727
"closed"
2828
],
29-
"vlan": [],
29+
"vlan": [
30+
{
31+
"id": 1,
32+
"name": "Peering LAN 1",
33+
"ipv4": {
34+
"prefix": "192.0.2.0",
35+
"mask_length": 25
36+
},
37+
"ipv6": {
38+
"prefix": "2001:db8::",
39+
"mask_length": 64
40+
}
41+
}
42+
],
3043
"switch": [
3144
{
3245
"id": 1,
@@ -60,7 +73,20 @@
6073
"mandatory",
6174
"closed"
6275
],
63-
"vlan": [],
76+
"vlan": [
77+
{
78+
"id": 2,
79+
"name": "Peering LAN 2",
80+
"ipv4": {
81+
"prefix": "192.0.2.128",
82+
"mask_length": 25
83+
},
84+
"ipv6": {
85+
"prefix": "2001:db8:0:2::",
86+
"mask_length": 64
87+
}
88+
}
89+
],
6490
"switch": [
6591
{
6692
"id": 2,

data/ci/known-good/api-v4-member-export-0.6-unauth.json

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,20 @@
2626
"mandatory",
2727
"closed"
2828
],
29-
"vlan": [],
29+
"vlan": [
30+
{
31+
"id": 1,
32+
"name": "Peering LAN 1",
33+
"ipv4": {
34+
"prefix": "192.0.2.0",
35+
"mask_length": 25
36+
},
37+
"ipv6": {
38+
"prefix": "2001:db8::",
39+
"mask_length": 64
40+
}
41+
}
42+
],
3043
"switch": [
3144
{
3245
"id": 1,
@@ -60,7 +73,20 @@
6073
"mandatory",
6174
"closed"
6275
],
63-
"vlan": [],
76+
"vlan": [
77+
{
78+
"id": 2,
79+
"name": "Peering LAN 2",
80+
"ipv4": {
81+
"prefix": "192.0.2.128",
82+
"mask_length": 25
83+
},
84+
"ipv6": {
85+
"prefix": "2001:db8:0:2::",
86+
"mask_length": 64
87+
}
88+
}
89+
],
6490
"switch": [
6591
{
6692
"id": 2,

data/ci/known-good/api-v4-member-export-0.7-auth.json

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,20 @@
2626
"mandatory",
2727
"closed"
2828
],
29-
"vlan": [],
29+
"vlan": [
30+
{
31+
"id": 1,
32+
"name": "Peering LAN 1",
33+
"ipv4": {
34+
"prefix": "192.0.2.0",
35+
"mask_length": 25
36+
},
37+
"ipv6": {
38+
"prefix": "2001:db8::",
39+
"mask_length": 64
40+
}
41+
}
42+
],
3043
"switch": [
3144
{
3245
"id": 1,
@@ -62,7 +75,20 @@
6275
"mandatory",
6376
"closed"
6477
],
65-
"vlan": [],
78+
"vlan": [
79+
{
80+
"id": 2,
81+
"name": "Peering LAN 2",
82+
"ipv4": {
83+
"prefix": "192.0.2.128",
84+
"mask_length": 25
85+
},
86+
"ipv6": {
87+
"prefix": "2001:db8:0:2::",
88+
"mask_length": 64
89+
}
90+
}
91+
],
6692
"switch": [
6793
{
6894
"id": 2,

data/ci/known-good/api-v4-member-export-0.7-unauth.json

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,20 @@
2626
"mandatory",
2727
"closed"
2828
],
29-
"vlan": [],
29+
"vlan": [
30+
{
31+
"id": 1,
32+
"name": "Peering LAN 1",
33+
"ipv4": {
34+
"prefix": "192.0.2.0",
35+
"mask_length": 25
36+
},
37+
"ipv6": {
38+
"prefix": "2001:db8::",
39+
"mask_length": 64
40+
}
41+
}
42+
],
3043
"switch": [
3144
{
3245
"id": 1,
@@ -62,7 +75,20 @@
6275
"mandatory",
6376
"closed"
6477
],
65-
"vlan": [],
78+
"vlan": [
79+
{
80+
"id": 2,
81+
"name": "Peering LAN 2",
82+
"ipv4": {
83+
"prefix": "192.0.2.128",
84+
"mask_length": 25
85+
},
86+
"ipv6": {
87+
"prefix": "2001:db8:0:2::",
88+
"mask_length": 64
89+
}
90+
}
91+
],
6692
"switch": [
6793
{
6894
"id": 2,

data/ci/known-good/api-v4-member-export-1.0-auth.json

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,20 @@
2626
"mandatory",
2727
"closed"
2828
],
29-
"vlan": [],
29+
"vlan": [
30+
{
31+
"id": 1,
32+
"name": "Peering LAN 1",
33+
"ipv4": {
34+
"prefix": "192.0.2.0",
35+
"mask_length": 25
36+
},
37+
"ipv6": {
38+
"prefix": "2001:db8::",
39+
"mask_length": 64
40+
}
41+
}
42+
],
3043
"switch": [
3144
{
3245
"id": 1,
@@ -63,7 +76,20 @@
6376
"mandatory",
6477
"closed"
6578
],
66-
"vlan": [],
79+
"vlan": [
80+
{
81+
"id": 2,
82+
"name": "Peering LAN 2",
83+
"ipv4": {
84+
"prefix": "192.0.2.128",
85+
"mask_length": 25
86+
},
87+
"ipv6": {
88+
"prefix": "2001:db8:0:2::",
89+
"mask_length": 64
90+
}
91+
}
92+
],
6793
"switch": [
6894
{
6995
"id": 2,

data/ci/known-good/api-v4-member-export-1.0-unauth.json

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,20 @@
2626
"mandatory",
2727
"closed"
2828
],
29-
"vlan": [],
29+
"vlan": [
30+
{
31+
"id": 1,
32+
"name": "Peering LAN 1",
33+
"ipv4": {
34+
"prefix": "192.0.2.0",
35+
"mask_length": 25
36+
},
37+
"ipv6": {
38+
"prefix": "2001:db8::",
39+
"mask_length": 64
40+
}
41+
}
42+
],
3043
"switch": [
3144
{
3245
"id": 1,
@@ -63,7 +76,20 @@
6376
"mandatory",
6477
"closed"
6578
],
66-
"vlan": [],
79+
"vlan": [
80+
{
81+
"id": 2,
82+
"name": "Peering LAN 2",
83+
"ipv4": {
84+
"prefix": "192.0.2.128",
85+
"mask_length": 25
86+
},
87+
"ipv6": {
88+
"prefix": "2001:db8:0:2::",
89+
"mask_length": 64
90+
}
91+
}
92+
],
6793
"switch": [
6894
{
6995
"id": 2,

0 commit comments

Comments
 (0)