X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fsvc_hardware.pm;h=16a5ea99c7e2ac8570b9f9bb8814ce5dff66cf0f;hb=b64599c894116623746b90d184ba708d67392c65;hp=af6865f12ab8d5a43b7beff1c15fe464d8a42610;hpb=69bf020f03918910e0e34260d6e5a9d984f0414d;p=freeside.git diff --git a/FS/FS/svc_hardware.pm b/FS/FS/svc_hardware.pm index af6865f12..16a5ea99c 100644 --- a/FS/FS/svc_hardware.pm +++ b/FS/FS/svc_hardware.pm @@ -1,10 +1,9 @@ package FS::svc_hardware; +use base qw( FS::svc_Common ); use strict; -use base qw( FS::svc_Common ); use vars qw( $conf ); -use FS::Record qw( qsearch qsearchs ); -use FS::hardware_type; +use FS::Record qw( qsearchs ); #qsearch qsearchs ); use FS::hardware_status; use FS::Conf; @@ -105,9 +104,13 @@ sub search_sql { my ($class, $string) = @_; my @where = (); - my $ip = NetAddr::IP->new($string); - if ( $ip ) { - push @where, $class->search_sql_field('ip_addr', $ip->addr); + if ( $string =~ /^[\d\.:]+$/ ) { + # if the string isn't an IP address, this will waste several seconds + # attempting a DNS lookup. so try to filter those out. + my $ip = NetAddr::IP->new($string); + if ( $ip ) { + push @where, $class->search_sql_field('ip_addr', $ip->addr); + } } if ( $string =~ /^(\w+)$/ ) { @@ -129,7 +132,17 @@ sub search_sql { sub label { my $self = shift; - $self->serial || $self->display_hw_addr; + my @label = (); + if (my $type = $self->hardware_type) { + push @label, 'Type:' . $type->description; + } + if (my $ser = $self->serial) { + push @label, 'Serial#' . $ser; + } + if (my $mac = $self->display_hw_addr) { + push @label, 'MAC:'. $mac; + } + return join(', ', @label); } =item insert @@ -164,7 +177,7 @@ sub check { return $x unless ref $x; my $hw_addr = $self->getfield('hw_addr'); - $hw_addr = join('', split(/\W/, $hw_addr)); + $hw_addr = join('', split(/[_\W]/, $hw_addr)); if ( $conf->exists('svc_hardware-check_mac_addr') ) { $hw_addr = uc($hw_addr); $hw_addr =~ /^[0-9A-F]{12}$/ @@ -196,13 +209,6 @@ sub check { Returns the L object associated with this installation. -=cut - -sub hardware_type { - my $self = shift; - return qsearchs('hardware_type', { 'typenum' => $self->typenum }); -} - =item status_label Returns the 'label' field of the L object associated