From 49acca34ee28867699f02b9051fd13904e3a5cd1 Mon Sep 17 00:00:00 2001 From: Tim Raphael Date: Mon, 6 Apr 2020 22:47:02 +1000 Subject: [PATCH] Addition of a customvlantag field to the backend and interface wizard UI. --- .../Interfaces/VirtualInterfaceController.php | 1 + .../Interfaces/VlanInterfaceController.php | 2 ++ .../Requests/StoreVirtualInterfaceWizard.php | 1 + app/Http/Requests/StoreVlanInterface.php | 1 + .../Yaml/SwitchConfigurationGenerator.php | 2 +- database/Entities/VlanInterface.php | 28 +++++++++++++++ database/Repositories/VlanInterface.php | 1 + ...00_add_customvlantag_to_vlan_interface.php | 34 +++++++++++++++++++ database/xml/Entities.VlanInterface.dcm.xml | 1 + .../views/interfaces/virtual/add/vli.foil.php | 7 ++++ .../views/interfaces/virtual/wizard.foil.php | 5 +++ resources/views/interfaces/vlan/edit.foil.php | 5 +++ 12 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2020_04_06_205000_add_customvlantag_to_vlan_interface.php diff --git a/app/Http/Controllers/Interfaces/VirtualInterfaceController.php b/app/Http/Controllers/Interfaces/VirtualInterfaceController.php index 44babb9e0..37ac29602 100644 --- a/app/Http/Controllers/Interfaces/VirtualInterfaceController.php +++ b/app/Http/Controllers/Interfaces/VirtualInterfaceController.php @@ -316,6 +316,7 @@ public function storeWizard( StoreVirtualInterfaceWizard $request ): RedirectRes $vli->setRsclient( $request->input( 'rsclient', false ) ); $vli->setAs112client( $request->input( 'as112client', false ) ); $vli->setBusyhost( false ); + $vli->setCustomvlantag( $request->input( 'customvlantag', false ) ); if( !$this->setIp($request, $v, $vli, false ) || !$this->setIp($request, $v, $vli, true ) ) { return Redirect::to('virtualInterface/add-wizard' )->withInput( $request->all() ); diff --git a/app/Http/Controllers/Interfaces/VlanInterfaceController.php b/app/Http/Controllers/Interfaces/VlanInterfaceController.php index 59ba8bee3..8458ba0c5 100644 --- a/app/Http/Controllers/Interfaces/VlanInterfaceController.php +++ b/app/Http/Controllers/Interfaces/VlanInterfaceController.php @@ -144,6 +144,7 @@ public function edit( Request $request, int $id = null, int $viid = null, int $ 'rsmorespecifics' => $request->old( 'rsmorespecifics', ( $vli->getRsMoreSpecifics() ? 1 : 0 ) ), 'as112client' => $request->old( 'as112client', ( $vli->getAs112client() ? 1 : 0 ) ), 'busyhost' => $request->old( 'busyhost', ( $vli->getBusyhost() ? 1 : 0 ) ), + 'customvlantag' => $request->old( 'customvlantag', ( $vli->getCustomVlanTag() ? 1 : 0 ) ), 'ipv6-enabled' => $request->old( 'ipv6-enabled', ( $vli->getIpv6enabled() ? 1 : 0 ) ), 'ipv6-address' => $request->old( 'ipv6-address', ( $vli->getIPv6Address() ? $vli->getIPv6Address()->getId() : null ) ), @@ -215,6 +216,7 @@ public function store( StoreVlanInterface $request ): RedirectResponse $vli->setRsclient( $request->input( 'rsclient', false ) ); $vli->setAs112client( $request->input( 'as112client', false ) ); $vli->setBusyhost( $request->input( 'busyhost', false ) ); + $vli->setCustomvlantag( $request->input( 'customvlantag', false ) ); D2EM::flush(); // add a warning if we're filtering on irrdb but have not configured one for the customer diff --git a/app/Http/Requests/StoreVirtualInterfaceWizard.php b/app/Http/Requests/StoreVirtualInterfaceWizard.php index 5ba7a1a60..f34e7f1a8 100644 --- a/app/Http/Requests/StoreVirtualInterfaceWizard.php +++ b/app/Http/Requests/StoreVirtualInterfaceWizard.php @@ -57,6 +57,7 @@ public function rules() 'cust' => 'required|integer|exists:Entities\Customer,id', 'vlan' => 'required|integer|exists:Entities\Vlan,id', 'trunk' => 'boolean', + 'customvlantag' => 'integer', 'switch' => 'required|integer|exists:Entities\Switcher,id', 'switch-port' => 'required|integer|exists:Entities\SwitchPort,id', diff --git a/app/Http/Requests/StoreVlanInterface.php b/app/Http/Requests/StoreVlanInterface.php index 75904bd2b..33380ec0f 100644 --- a/app/Http/Requests/StoreVlanInterface.php +++ b/app/Http/Requests/StoreVlanInterface.php @@ -54,6 +54,7 @@ public function rules() 'maxbgpprefix' => 'integer|nullable', 'mcastenabled' => 'boolean', 'busyhost' => 'boolean', + 'customvlantag' => 'integer', 'rsclient' => 'boolean', 'irrdbfilter' => 'boolean', 'rsmorespecifics' => 'boolean', diff --git a/app/Tasks/Yaml/SwitchConfigurationGenerator.php b/app/Tasks/Yaml/SwitchConfigurationGenerator.php index 7de2fc5f0..c04045cf8 100644 --- a/app/Tasks/Yaml/SwitchConfigurationGenerator.php +++ b/app/Tasks/Yaml/SwitchConfigurationGenerator.php @@ -130,7 +130,7 @@ private function processVirtualInterface( VirtualInterfaceEntity $vi ): array { /** @var \Entities\VlanInterface $vli */ $v = []; $v[ 'number' ] = $vli->getVlan()->getNumber(); - + $v[ 'customVlanTag' ] = $vli->getCustomvlantag(); $v[ 'macaddresses' ] = []; foreach( $vli->getLayer2Addresses() as $mac ) { $v[ 'macaddresses' ][] = $mac->getMacFormattedWithColons(); diff --git a/database/Entities/VlanInterface.php b/database/Entities/VlanInterface.php index 1400c71ee..a73e51960 100644 --- a/database/Entities/VlanInterface.php +++ b/database/Entities/VlanInterface.php @@ -122,6 +122,11 @@ class VlanInterface */ protected $busyhost = false; + /** + * @var integer $customvlantag + */ + protected $customvlantag; + /** * @var string $notes */ @@ -572,6 +577,29 @@ public function getBusyhost() return $this->busyhost; } + /** + * Set customvlantag + * + * @param integer $customvlantag + * @return VlanInterface + */ + public function setCustomvlantag($customvlantag) + { + $this->customvlantag = $customvlantag; + + return $this; + } + + /** + * Get customvlantag + * + * @return integer $customvlantag + */ + public function getCustomvlantag() + { + return $this->customvlantag; + } + /** * Set notes * diff --git a/database/Repositories/VlanInterface.php b/database/Repositories/VlanInterface.php index c623f4595..dd5ba6fc1 100644 --- a/database/Repositories/VlanInterface.php +++ b/database/Repositories/VlanInterface.php @@ -120,6 +120,7 @@ public function getForProto( $vlan, $proto, $useResultCache = true, $pistatus = vli.as112client AS as112client, vli.rsclient AS rsclient, vli.busyhost AS busyhost, + vli.customvlantag AS customvlantag, vli.irrdbfilter AS irrdbfilter, vli.rsmorespecifics AS rsmorespecifics, vli.ipv{$proto}canping AS canping, diff --git a/database/migrations/2020_04_06_205000_add_customvlantag_to_vlan_interface.php b/database/migrations/2020_04_06_205000_add_customvlantag_to_vlan_interface.php new file mode 100644 index 000000000..c34b7e7cc --- /dev/null +++ b/database/migrations/2020_04_06_205000_add_customvlantag_to_vlan_interface.php @@ -0,0 +1,34 @@ +integer('customvlantag')->default(0)->nullable(); + // + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('vlaninterface', function (Blueprint $table) { + $table->dropColumn('customvlantag'); + // + }); + } +} \ No newline at end of file diff --git a/database/xml/Entities.VlanInterface.dcm.xml b/database/xml/Entities.VlanInterface.dcm.xml index 20925fb66..5b9662d3c 100644 --- a/database/xml/Entities.VlanInterface.dcm.xml +++ b/database/xml/Entities.VlanInterface.dcm.xml @@ -42,6 +42,7 @@ + diff --git a/resources/views/interfaces/virtual/add/vli.foil.php b/resources/views/interfaces/virtual/add/vli.foil.php index 11ac9374f..9aa3549ef 100644 --- a/resources/views/interfaces/virtual/add/vli.foil.php +++ b/resources/views/interfaces/virtual/add/vli.foil.php @@ -35,6 +35,9 @@ VLAN Tag + + Custom VLAN Tag + Configured MAC Address(es) @@ -63,6 +66,10 @@ ee( $vli->getVlan()->getNumber() )?> + + + ee( ($vli->getCustomvlantag() == 0) ? '(Untagged)' : "{$vli->getCustomvlantag()}" ) ?> + $vli->getId() ] )?> " > diff --git a/resources/views/interfaces/virtual/wizard.foil.php b/resources/views/interfaces/virtual/wizard.foil.php index 9d0b8a199..52c4a06f0 100644 --- a/resources/views/interfaces/virtual/wizard.foil.php +++ b/resources/views/interfaces/virtual/wizard.foil.php @@ -83,6 +83,11 @@ ->inline() ?> + label( 'Custom VLAN Tag' ) + ->blockHelp( 'The VLAN to translate to, if required. 0 signifies untagged '); + ?> + label(' ') ->text( 'IPv6 Enabled' ) diff --git a/resources/views/interfaces/vlan/edit.foil.php b/resources/views/interfaces/vlan/edit.foil.php index e6bc53741..e6e271478 100644 --- a/resources/views/interfaces/vlan/edit.foil.php +++ b/resources/views/interfaces/vlan/edit.foil.php @@ -92,6 +92,11 @@ ->blockHelp( 'Pick the VLAN for this VLAN interface. IP address dropdowns will automatically populate on change.' ); ?> + label( 'Custom VLAN Tag' ) + ->blockHelp( 'The VLAN to translate to, if required. 0 signifies untagged '); + ?> + label(' ') ->text( 'Multicast Enabled' )