Database schema changes to support improved stp discovery and topology
This commit is contained in:
@@ -11,7 +11,7 @@ __PACKAGE__->load_namespaces(
|
||||
);
|
||||
|
||||
our # try to hide from kwalitee
|
||||
$VERSION = 39; # schema version used for upgrades, keep as integer
|
||||
$VERSION = 40; # schema version used for upgrades, keep as integer
|
||||
|
||||
use Path::Class;
|
||||
use File::Basename;
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
use utf8;
|
||||
package App::Netdisco::DB::Result::Device;
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader
|
||||
# DO NOT MODIFY THE FIRST PART OF THIS FILE
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
@@ -75,12 +72,13 @@ __PACKAGE__->add_columns(
|
||||
{ data_type => "timestamp", is_nullable => 1 },
|
||||
"last_arpnip",
|
||||
{ data_type => "timestamp", is_nullable => 1 },
|
||||
"stp_ver",
|
||||
{ data_type => "text", is_nullable => 1 },
|
||||
"b_mac",
|
||||
{ data_type => "macaddr", is_nullable => 1 },
|
||||
);
|
||||
__PACKAGE__->set_primary_key("ip");
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.07015 @ 2012-01-07 14:20:02
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:671/XuuvsO2aMB1+IRWFjg
|
||||
|
||||
=head1 RELATIONSHIPS
|
||||
|
||||
=head2 device_ips
|
||||
@@ -186,6 +184,29 @@ Returns the row from the community string table, if one exists.
|
||||
__PACKAGE__->might_have(
|
||||
community => 'App::Netdisco::DB::Result::Community', 'ip');
|
||||
|
||||
=head2 stp_instances
|
||||
|
||||
Returns the set of STP instances on this Device.
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->has_many(
|
||||
stp_instances => 'App::Netdisco::DB::Result::DeviceStp',
|
||||
'ip', { join_type => 'RIGHT' }
|
||||
);
|
||||
|
||||
=head2 stp_ports
|
||||
|
||||
Returns the set of STP instances known to be configured on Ports on this
|
||||
Device.
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->has_many(
|
||||
stp_ports => 'App::Netdisco::DB::Result::DevicePortStp',
|
||||
'ip', { join_type => 'RIGHT' }
|
||||
);
|
||||
|
||||
=head1 ADDITIONAL COLUMNS
|
||||
|
||||
=head2 port_count
|
||||
|
||||
51
Netdisco/lib/App/Netdisco/DB/Result/DevicePortStp.pm
Normal file
51
Netdisco/lib/App/Netdisco/DB/Result/DevicePortStp.pm
Normal file
@@ -0,0 +1,51 @@
|
||||
use utf8;
|
||||
package App::Netdisco::DB::Result::DevicePortStp;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'DBIx::Class::Core';
|
||||
__PACKAGE__->table("device_port_stp");
|
||||
__PACKAGE__->add_columns(
|
||||
"ip",
|
||||
{ data_type => "inet", is_nullable => 0 },
|
||||
"port",
|
||||
{ data_type => "text", is_nullable => 0 },
|
||||
"instance",
|
||||
{ data_type => "integer", is_nullable => 0 },
|
||||
"port_id",
|
||||
{ data_type => "integer", is_nullable => 0 },
|
||||
"des_bridge_mac",
|
||||
{ data_type => "macaddr", is_nullable => 1 },
|
||||
"des_port_id",
|
||||
{ data_type => "integer", is_nullable => 1 },
|
||||
"status",
|
||||
{ data_type => "text", is_nullable => 1 },
|
||||
);
|
||||
__PACKAGE__->set_primary_key("port", "ip", "instance");
|
||||
|
||||
|
||||
=head1 RELATIONSHIPS
|
||||
|
||||
=head2 port
|
||||
|
||||
Returns the entry from the C<port> table for which this Power entry applies.
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->belongs_to( port => 'App::Netdisco::DB::Result::DevicePort', {
|
||||
'foreign.ip' => 'self.ip', 'foreign.port' => 'self.port',
|
||||
});
|
||||
|
||||
=head2 stp_instance
|
||||
|
||||
Returns the entry from the C<device_stp> table for which this STP entry
|
||||
applies.
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->belongs_to( device_stp => 'App::Netdisco::DB::Result::DeviceStp', {
|
||||
'foreign.ip' => 'self.ip', 'foreign.instance' => 'self.instance',
|
||||
});
|
||||
|
||||
1;
|
||||
53
Netdisco/lib/App/Netdisco/DB/Result/DeviceStp.pm
Normal file
53
Netdisco/lib/App/Netdisco/DB/Result/DeviceStp.pm
Normal file
@@ -0,0 +1,53 @@
|
||||
use utf8;
|
||||
package App::Netdisco::DB::Result::DeviceStp;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'DBIx::Class::Core';
|
||||
__PACKAGE__->table("device_stp");
|
||||
__PACKAGE__->add_columns(
|
||||
"ip",
|
||||
{ data_type => "inet", is_nullable => 0 },
|
||||
"instance",
|
||||
{ data_type => "integer", is_nullable => 0 },
|
||||
"mac",
|
||||
{ data_type => "macaddr", is_nullable => 1 },
|
||||
"top_change",
|
||||
{ data_type => "integer", is_nullable => 1 },
|
||||
"top_lastchange",
|
||||
{ data_type => "bigint", is_nullable => 1 },
|
||||
"des_root_mac",
|
||||
{ data_type => "macaddr", is_nullable => 1 },
|
||||
"root_port",
|
||||
{ data_type => "text", is_nullable => 1 },
|
||||
);
|
||||
__PACKAGE__->set_primary_key("ip", "instance");
|
||||
|
||||
|
||||
=head1 RELATIONSHIPS
|
||||
|
||||
=head2 device
|
||||
|
||||
Returns the entry from the C<device> table to which this STP instance relates.
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->belongs_to( device => 'App::Netdisco::DB::Result::Device', 'ip' );
|
||||
|
||||
=head2 stp_ports
|
||||
|
||||
Returns the set of STP instances known to be configured on Ports on this
|
||||
Device.
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->has_many(
|
||||
ports => 'App::Netdisco::DB::Result::DevicePortStp',
|
||||
{
|
||||
'foreign.ip' => 'self.ip',
|
||||
'foreign.instance' => 'self.instance',
|
||||
},
|
||||
);
|
||||
|
||||
1;
|
||||
@@ -0,0 +1,46 @@
|
||||
BEGIN;
|
||||
|
||||
-- Add/Alter tables to support stp topology
|
||||
--
|
||||
-- Table: device_stp.
|
||||
--
|
||||
CREATE TABLE "device_stp" (
|
||||
"ip" inet NOT NULL,
|
||||
"instance" integer NOT NULL,
|
||||
"mac" macaddr,
|
||||
"top_change" integer,
|
||||
"top_lastchange" bigint,
|
||||
"des_root_mac" macaddr,
|
||||
"root_port" text,
|
||||
PRIMARY KEY ("ip", "instance")
|
||||
);
|
||||
CREATE INDEX "device_stp_idx_ip" on "device_stp" ("ip");
|
||||
CREATE INDEX "device_stp_idx_des_root_mac" on "device_stp" ("des_root_mac");
|
||||
|
||||
--
|
||||
-- Table: device_port_stp.
|
||||
--
|
||||
CREATE TABLE "device_port_stp" (
|
||||
"ip" inet NOT NULL,
|
||||
"port" text NOT NULL,
|
||||
"instance" integer NOT NULL,
|
||||
"port_id" integer NOT NULL,
|
||||
"des_bridge_mac" macaddr,
|
||||
"des_port_id" integer,
|
||||
"status" text,
|
||||
PRIMARY KEY ("ip", "port", "instance")
|
||||
);
|
||||
CREATE INDEX "device_port_stp_idx_ip_instance" on "device_port_stp" ("ip", "instance");
|
||||
CREATE INDEX "device_port_stp_idx_ip_port" on "device_port_stp" ("ip", "port");
|
||||
CREATE INDEX "device_port_stp_idx_port_id" on "device_port_stp" ("port_id");
|
||||
CREATE INDEX "device_port_stp_idx_mac" on "device_port_stp" ("des_bridge_mac");
|
||||
|
||||
--
|
||||
-- Alter Table: device
|
||||
--
|
||||
ALTER TABLE device ADD COLUMN "stp_ver" text;
|
||||
-- existing mac may not be the bridge base mac
|
||||
ALTER TABLE device ADD COLUMN "b_mac" macaddr;
|
||||
CREATE INDEX "device_idx_b_mac" on "device" ("b_mac");
|
||||
|
||||
COMMIT;
|
||||
Reference in New Issue
Block a user