add device ports into mac "node" search
This commit is contained in:
		| @@ -49,9 +49,9 @@ __PACKAGE__->set_primary_key("mac", "switch", "port"); | ||||
| # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:sGGyKEfUkoIFVtmj1wnH7A | ||||
|  | ||||
| __PACKAGE__->belongs_to( device => 'Netdisco::DB::Result::Device', | ||||
|   { 'foreign.ip' => 'self.switch' } ); | ||||
|   { 'foreign.ip' => 'self.switch' }, { join_type => 'LEFT' } ); | ||||
| __PACKAGE__->belongs_to( device_port => 'Netdisco::DB::Result::DevicePort', | ||||
|   { 'foreign.ip' => 'self.switch', 'foreign.port' => 'self.port' } ); | ||||
|   { 'foreign.ip' => 'self.switch', 'foreign.port' => 'self.port' }, { join_type => 'LEFT' } ); | ||||
| __PACKAGE__->has_many( ips => 'Netdisco::DB::Result::NodeIp', | ||||
|   { 'foreign.mac' => 'self.mac' } ); | ||||
|  | ||||
|   | ||||
							
								
								
									
										25
									
								
								Netdisco/lib/Netdisco/DB/ResultSet/DevicePort.pm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								Netdisco/lib/Netdisco/DB/ResultSet/DevicePort.pm
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| package Netdisco::DB::ResultSet::DevicePort; | ||||
| use base 'DBIx::Class::ResultSet'; | ||||
|  | ||||
| sub by_mac { | ||||
|     my ($set, $mac) = @_; | ||||
|     return $set unless $mac; | ||||
|  | ||||
|     return $set->search( | ||||
|       { | ||||
|         'me.mac' => $mac, | ||||
|       }, | ||||
|       { | ||||
|         order_by => {'-desc' => 'me.creation'}, | ||||
|         columns => [qw/ ip port device.dns /], | ||||
|         '+select' => [ | ||||
|           \"to_char(me.creation, 'YYYY-MM-DD HH24:MI')", | ||||
|         ], | ||||
|         '+as' => [qw/ creation /], | ||||
|         join => 'device', | ||||
|       }, | ||||
|     ); | ||||
| } | ||||
|  | ||||
| 1; | ||||
|  | ||||
| @@ -49,11 +49,15 @@ ajax '/ajax/content/search/node' => sub { | ||||
|           ->by_mac(param('archived'), $mac->as_IEEE); | ||||
|         return unless $ips->count; | ||||
|  | ||||
|         my $ports = schema('netdisco')->resultset('Node') | ||||
|         my $sightings = schema('netdisco')->resultset('Node') | ||||
|           ->by_mac(param('archived'), $mac->as_IEEE); | ||||
|  | ||||
|         my $ports = schema('netdisco')->resultset('DevicePort') | ||||
|           ->by_mac($mac->as_IEEE); | ||||
|  | ||||
|         template 'ajax/node_by_mac.tt', { | ||||
|           ips => $ips, | ||||
|           sightings => $sightings, | ||||
|           ports => $ports, | ||||
|         }, { layout => undef }; | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user