diff --git a/lib/App/Netdisco/DB.pm b/lib/App/Netdisco/DB.pm index 1aa424d3..e10990e2 100644 --- a/lib/App/Netdisco/DB.pm +++ b/lib/App/Netdisco/DB.pm @@ -11,7 +11,7 @@ __PACKAGE__->load_namespaces( ); our # try to hide from kwalitee - $VERSION = 65; # schema version used for upgrades, keep as integer + $VERSION = 66; # schema version used for upgrades, keep as integer use Path::Class; use File::ShareDir 'dist_dir'; diff --git a/lib/App/Netdisco/DB/Result/Device.pm b/lib/App/Netdisco/DB/Result/Device.pm index dbfce7f8..366e3f21 100644 --- a/lib/App/Netdisco/DB/Result/Device.pm +++ b/lib/App/Netdisco/DB/Result/Device.pm @@ -41,6 +41,8 @@ __PACKAGE__->add_columns( { data_type => "macaddr", is_nullable => 1 }, "serial", { data_type => "text", is_nullable => 1 }, + "chassis_id", + { data_type => "text", is_nullable => 1 }, "model", { data_type => "text", is_nullable => 1 }, "ps1_type", diff --git a/lib/App/Netdisco/DB/ResultSet/Device.pm b/lib/App/Netdisco/DB/ResultSet/Device.pm index 993733cf..547bbe80 100644 --- a/lib/App/Netdisco/DB/ResultSet/Device.pm +++ b/lib/App/Netdisco/DB/ResultSet/Device.pm @@ -358,6 +358,8 @@ The following fields are inspected for a match: =item serial +=item chassis_id + =item module serials (exact) =item location @@ -413,10 +415,11 @@ sub search_fuzzy { ->search( { -or => [ - 'me.contact' => { '-ilike' => $q }, - 'me.serial' => { '-ilike' => $q }, - 'me.location' => { '-ilike' => $q }, - 'me.name' => { '-ilike' => $q }, + 'me.contact' => { '-ilike' => $q }, + 'me.serial' => { '-ilike' => $q }, + 'me.chassis_id' => { '-ilike' => $q }, + 'me.location' => { '-ilike' => $q }, + 'me.name' => { '-ilike' => $q }, 'me.description' => { '-ilike' => $q }, 'me.ip' => { '-in' => $rs->search({ 'modules.serial' => $qc }, diff --git a/lib/App/Netdisco/Web/Plugin/Search/Device.pm b/lib/App/Netdisco/Web/Plugin/Search/Device.pm index 3ecdf2d8..afbe7567 100644 --- a/lib/App/Netdisco/Web/Plugin/Search/Device.pm +++ b/lib/App/Netdisco/Web/Plugin/Search/Device.pm @@ -15,7 +15,7 @@ register_search_tab({ api_endpoint => 1, api_parameters => [ q => { - description => 'Partial match of Device contact, serial, module serials, location, name, description, dns, or any IP alias', + description => 'Partial match of Device contact, serial, chassis ID, module serials, location, name, description, dns, or any IP alias', }, name => { description => 'Partial match of the Device name', @@ -67,7 +67,7 @@ get '/ajax/content/search/device' => require_login sub { if ($has_opt) { $rs = schema('netdisco')->resultset('Device')->columns( [ "ip", "dns", "name", - "location", "model", "os_ver", "serial" + "location", "model", "os_ver", "serial", "chassis_id" ] )->with_times->search_by_field( scalar params ); } @@ -77,7 +77,7 @@ get '/ajax/content/search/device' => require_login sub { $rs = schema('netdisco')->resultset('Device')->columns( [ "ip", "dns", "name", - "location", "model", "os_ver", "serial" + "location", "model", "os_ver", "serial", "chassis_id" ] )->with_times->search_fuzzy($q); } diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm index e7dc6ab1..c590174f 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm @@ -47,8 +47,10 @@ register_worker({ phase => 'early', driver => 'snmp' }, sub { (my $model = Encode::decode('UTF-8', ($snmp->model || ''))) =~ s/\s+$//; (my $serial = Encode::decode('UTF-8', ($snmp->serial || ''))) =~ s/\s+$//; + (my $chassis_id = Encode::decode('UTF-8', ($snmp->serial1 || ''))) =~ s/\s+$//; $device->set_column( model => $model ); $device->set_column( serial => $serial ); + $device->set_column( chassis_id => (($chassis_id ne $serial) ? $chassis_id : '') ); $device->set_column( contact => Encode::decode('UTF-8', $snmp->contact) ); $device->set_column( location => Encode::decode('UTF-8', $snmp->location) ); diff --git a/share/schema_versions/App-Netdisco-DB-65-66-PostgreSQL.sql b/share/schema_versions/App-Netdisco-DB-65-66-PostgreSQL.sql new file mode 100644 index 00000000..49bb90ad --- /dev/null +++ b/share/schema_versions/App-Netdisco-DB-65-66-PostgreSQL.sql @@ -0,0 +1,5 @@ +BEGIN; + +ALTER TABLE device ADD COLUMN "chassis_id" text; + +COMMIT; diff --git a/share/views/ajax/device/details.tt b/share/views/ajax/device/details.tt index 2577a00e..53644252 100644 --- a/share/views/ajax/device/details.tt +++ b/share/views/ajax/device/details.tt @@ -62,6 +62,10 @@