Remove reference to "native" VLAN in code and replace with "untagged"
This commit is contained in:
		| @@ -1,5 +1,10 @@ | ||||
| 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] | ||||
|  | ||||
|   * Correct is_discoverable check in Undiscovered Neighbors report | ||||
|   | ||||
| @@ -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. | ||||
|  | ||||
| These will be both native and non-native (tagged). See also | ||||
| C<port_vlans_tagged> and C<tagged_vlans>. | ||||
| These will be both tagged and untagged. See also C<port_vlans_tagged> and | ||||
| C<tagged_vlans>. | ||||
|  | ||||
| =cut | ||||
|  | ||||
| @@ -190,13 +190,19 @@ port, where the VLANs are all tagged. | ||||
|  | ||||
| =cut | ||||
|  | ||||
| __PACKAGE__->has_many( port_vlans_tagged => 'App::Netdisco::DB::Result::Virtual::DevicePortVlanTagged', | ||||
|   { | ||||
|     'foreign.ip' => 'self.ip', | ||||
|     'foreign.port' => 'self.port', | ||||
| __PACKAGE__->has_many( port_vlans_tagged => 'App::Netdisco::DB::Result::DevicePortVlan', | ||||
|   sub { | ||||
|     my $args = shift; | ||||
|     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 | ||||
|   | ||||
| @@ -35,7 +35,7 @@ __PACKAGE__->add_columns( | ||||
|   "vlantype", | ||||
|   { 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 | ||||
|   | ||||
| @@ -49,23 +49,37 @@ __PACKAGE__->belongs_to( device => 'App::Netdisco::DB::Result::Device', 'ip' ); | ||||
|  | ||||
| =head2 port_vlans_tagged | ||||
|  | ||||
| Link relationship for C<tagging_ports>, see below. | ||||
| Link relationship for C<tagged_ports>, see below. | ||||
|  | ||||
| =cut | ||||
|  | ||||
| __PACKAGE__->has_many( port_vlans_tagged => 'App::Netdisco::DB::Result::Virtual::DevicePortVlanTagged', | ||||
|     { 'foreign.ip' => 'self.ip', 'foreign.vlan' => 'self.vlan' }, | ||||
| __PACKAGE__->has_many( port_vlans_tagged => 'App::Netdisco::DB::Result::DevicePortVlan', | ||||
|     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 } | ||||
| ); | ||||
|  | ||||
| =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 | ||||
|  | ||||
| __PACKAGE__->has_many( port_vlans_native => 'App::Netdisco::DB::Result::Virtual::DevicePortVlanNative', | ||||
|     { 'foreign.ip' => 'self.ip', 'foreign.vlan' => 'self.vlan' }, | ||||
| __PACKAGE__->has_many( port_vlans_untagged => 'App::Netdisco::DB::Result::DevicePortVlan', | ||||
|     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 } | ||||
| ); | ||||
|  | ||||
| @@ -80,21 +94,20 @@ __PACKAGE__->has_many( ports => 'App::Netdisco::DB::Result::DevicePortVlan', | ||||
|     { 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. | ||||
|  | ||||
| =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 | ||||
| is, untagged). | ||||
| Returns the set of Device Ports on which this VLAN is an untagged VLAN. | ||||
|  | ||||
| =cut | ||||
|  | ||||
| __PACKAGE__->many_to_many( native_ports  => 'port_vlans_native', 'port' ); | ||||
| __PACKAGE__->many_to_many( untagged_ports  => 'port_vlans_untagged', 'port' ); | ||||
|  | ||||
| 1; | ||||
|   | ||||
| @@ -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; | ||||
| @@ -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; | ||||
| @@ -125,11 +125,12 @@ sub with_vlan_count { | ||||
|     ->search({}, | ||||
|       { | ||||
|         '+columns' => { tagged_vlans_count => | ||||
|           $rs->result_source->schema->resultset('Virtual::DevicePortVlanTagged') | ||||
|           $rs->result_source->schema->resultset('DevicePortVlan') | ||||
|             ->search( | ||||
|               { | ||||
|                 'dpvt.ip' => { -ident => 'me.ip' }, | ||||
|                 'dpvt.port' => { -ident => 'me.port' }, | ||||
|                 -not_bool => { -ident => 'dpvt.native' }, | ||||
|               }, | ||||
|               { alias => 'dpvt' } | ||||
|             )->count_rs->as_query | ||||
|   | ||||
		Reference in New Issue
	
	Block a user