Remove reference to "native" VLAN in code and replace with "untagged"

This commit is contained in:
Oliver Gorwits
2014-01-10 19:36:08 +00:00
parent 7547937194
commit 134b7a7646
7 changed files with 48 additions and 61 deletions

View File

@@ -1,5 +1,10 @@
2.021001 2.021001
[ENHANCEMENTS]
* [#66] Remove reference to "native" VLAN in code and replace with "untagged"
* [#66] DB Schema update to add "native" column to PK of device_port_vlan table
[BUG FIXES] [BUG FIXES]
* Correct is_discoverable check in Undiscovered Neighbors report * Correct is_discoverable check in Undiscovered Neighbors report

View File

@@ -84,8 +84,8 @@ __PACKAGE__->belongs_to( device => 'App::Netdisco::DB::Result::Device', 'ip' );
Returns the set of C<device_port_vlan> entries associated with this Port. Returns the set of C<device_port_vlan> entries associated with this Port.
These will be both native and non-native (tagged). See also These will be both tagged and untagged. See also C<port_vlans_tagged> and
C<port_vlans_tagged> and C<tagged_vlans>. C<tagged_vlans>.
=cut =cut
@@ -190,13 +190,19 @@ port, where the VLANs are all tagged.
=cut =cut
__PACKAGE__->has_many( port_vlans_tagged => 'App::Netdisco::DB::Result::Virtual::DevicePortVlanTagged', __PACKAGE__->has_many( port_vlans_tagged => 'App::Netdisco::DB::Result::DevicePortVlan',
{ sub {
'foreign.ip' => 'self.ip', my $args = shift;
'foreign.port' => 'self.port', return {
"$args->{foreign_alias}.ip" => { -ident => "$args->{self_alias}.ip" },
"$args->{foreign_alias}.port" => { -ident => "$args->{self_alias}.port" },
-not_bool => "$args->{foreign_alias}.native",
};
},
{
join_type => 'LEFT',
cascade_copy => 0, cascade_update => 0, cascade_delete => 0,
}, },
{ join_type => 'LEFT',
cascade_copy => 0, cascade_update => 0, cascade_delete => 0 },
); );
=head2 tagged_vlans =head2 tagged_vlans

View File

@@ -35,7 +35,7 @@ __PACKAGE__->add_columns(
"vlantype", "vlantype",
{ data_type => "text", is_nullable => 1 }, { data_type => "text", is_nullable => 1 },
); );
__PACKAGE__->set_primary_key("ip", "port", "vlan"); __PACKAGE__->set_primary_key("ip", "port", "vlan", "native");
# Created by DBIx::Class::Schema::Loader v0.07015 @ 2012-01-07 14:20:02 # Created by DBIx::Class::Schema::Loader v0.07015 @ 2012-01-07 14:20:02

View File

@@ -49,23 +49,37 @@ __PACKAGE__->belongs_to( device => 'App::Netdisco::DB::Result::Device', 'ip' );
=head2 port_vlans_tagged =head2 port_vlans_tagged
Link relationship for C<tagging_ports>, see below. Link relationship for C<tagged_ports>, see below.
=cut =cut
__PACKAGE__->has_many( port_vlans_tagged => 'App::Netdisco::DB::Result::Virtual::DevicePortVlanTagged', __PACKAGE__->has_many( port_vlans_tagged => 'App::Netdisco::DB::Result::DevicePortVlan',
{ 'foreign.ip' => 'self.ip', 'foreign.vlan' => 'self.vlan' }, sub {
my $args = shift;
return {
"$args->{foreign_alias}.ip" => { -ident => "$args->{self_alias}.ip" },
"$args->{foreign_alias}.vlan" => { -ident => "$args->{self_alias}.vlan" },
-not_bool => "$args->{foreign_alias}.native",
};
},
{ cascade_copy => 0, cascade_update => 0, cascade_delete => 0 } { cascade_copy => 0, cascade_update => 0, cascade_delete => 0 }
); );
=head2 port_vlans_native =head2 port_vlans_untagged
Link relationship to support C<native_ports>, see below. Link relationship to support C<untagged_ports>, see below.
=cut =cut
__PACKAGE__->has_many( port_vlans_native => 'App::Netdisco::DB::Result::Virtual::DevicePortVlanNative', __PACKAGE__->has_many( port_vlans_untagged => 'App::Netdisco::DB::Result::DevicePortVlan',
{ 'foreign.ip' => 'self.ip', 'foreign.vlan' => 'self.vlan' }, sub {
my $args = shift;
return {
"$args->{foreign_alias}.ip" => { -ident => "$args->{self_alias}.ip" },
"$args->{foreign_alias}.vlan" => { -ident => "$args->{self_alias}.vlan" },
-bool => "$args->{foreign_alias}.native",
};
},
{ cascade_copy => 0, cascade_update => 0, cascade_delete => 0 } { cascade_copy => 0, cascade_update => 0, cascade_delete => 0 }
); );
@@ -80,21 +94,20 @@ __PACKAGE__->has_many( ports => 'App::Netdisco::DB::Result::DevicePortVlan',
{ cascade_copy => 0, cascade_update => 0, cascade_delete => 0 } { cascade_copy => 0, cascade_update => 0, cascade_delete => 0 }
); );
=head2 tagging_ports =head2 tagged_ports
Returns the set of Device Ports on which this VLAN is configured to be tagged. Returns the set of Device Ports on which this VLAN is configured to be tagged.
=cut =cut
__PACKAGE__->many_to_many( tagging_ports => 'port_vlans_tagged', 'port' ); __PACKAGE__->many_to_many( tagged_ports => 'port_vlans_tagged', 'port' );
=head2 native_ports =head2 untagged_ports
Returns the set of Device Ports on which this VLAN is the native VLAN (that Returns the set of Device Ports on which this VLAN is an untagged VLAN.
is, untagged).
=cut =cut
__PACKAGE__->many_to_many( native_ports => 'port_vlans_native', 'port' ); __PACKAGE__->many_to_many( untagged_ports => 'port_vlans_untagged', 'port' );
1; 1;

View File

@@ -1,19 +0,0 @@
use utf8;
package App::Netdisco::DB::Result::Virtual::DevicePortVlanNative;
use strict;
use warnings;
use base 'App::Netdisco::DB::Result::DevicePortVlan';
__PACKAGE__->load_components('Helper::Row::SubClass');
__PACKAGE__->subclass;
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
__PACKAGE__->table("device_port_vlan_native");
__PACKAGE__->result_source_instance->is_virtual(1);
__PACKAGE__->result_source_instance->view_definition(q{
SELECT * FROM device_port_vlan WHERE native
});
1;

View File

@@ -1,19 +0,0 @@
use utf8;
package App::Netdisco::DB::Result::Virtual::DevicePortVlanTagged;
use strict;
use warnings;
use base 'App::Netdisco::DB::Result::DevicePortVlan';
__PACKAGE__->load_components('Helper::Row::SubClass');
__PACKAGE__->subclass;
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
__PACKAGE__->table("device_port_vlan_tagged");
__PACKAGE__->result_source_instance->is_virtual(1);
__PACKAGE__->result_source_instance->view_definition(q{
SELECT * FROM device_port_vlan WHERE NOT native
});
1;

View File

@@ -125,11 +125,12 @@ sub with_vlan_count {
->search({}, ->search({},
{ {
'+columns' => { tagged_vlans_count => '+columns' => { tagged_vlans_count =>
$rs->result_source->schema->resultset('Virtual::DevicePortVlanTagged') $rs->result_source->schema->resultset('DevicePortVlan')
->search( ->search(
{ {
'dpvt.ip' => { -ident => 'me.ip' }, 'dpvt.ip' => { -ident => 'me.ip' },
'dpvt.port' => { -ident => 'me.port' }, 'dpvt.port' => { -ident => 'me.port' },
-not_bool => { -ident => 'dpvt.native' },
}, },
{ alias => 'dpvt' } { alias => 'dpvt' }
)->count_rs->as_query )->count_rs->as_query