diff options
author | Ivan Kohler <ivan@freeside.biz> | 2018-10-28 15:04:31 -0700 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2018-10-28 15:04:31 -0700 |
commit | 57dd3d1026aca4c963df83e4208c9767755680f1 (patch) | |
tree | c6fbf6ebd5185ddadcdfc49b72d0bbbb65b91819 /FS/FS/svc_hardware.pm | |
parent | 91367084a4d14bfc639d2675d20056377613ee4b (diff) |
svc_hardware uniqueness checks, RT#81534
Diffstat (limited to 'FS/FS/svc_hardware.pm')
-rw-r--r-- | FS/FS/svc_hardware.pm | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/FS/FS/svc_hardware.pm b/FS/FS/svc_hardware.pm index 019a564..69da0c7 100644 --- a/FS/FS/svc_hardware.pm +++ b/FS/FS/svc_hardware.pm @@ -214,6 +214,40 @@ sub check { $self->SUPER::check; } +#false laziness w/svc_cable +sub _check_duplicate { + my $self = shift; + + # Not reliable checks because the table isn't locked, but that's why we have + # unique indices. These are just to give friendlier error messages. + + if ( $self->hw_addr ) { + my @dup_mac; + @dup_mac = $self->find_duplicates('global', 'hw_addr'); + if ( @dup_mac ) { + return "MAC address in use (svcnum ".$dup_mac[0]->svcnum.")"; + } + } + + if ( $self->ip_addr ) { + my @dup_ip; + @dup_ip = $self->find_duplicates('global', 'ip_addr'); + if ( @dup_ip ) { + return "IP address in use (svcnum ".$dup_ip[0]->svcnum.")"; + } + } + + if ( $self->serialnum ) { + my @dup_serial; + @dup_serial = $self->find_duplicates('global', 'typenum', 'serialnum'); + if ( @dup_serial ) { + return "Serial number in use (svcnum ".$dup_serial[0]->svcnum.")"; + } + } + + ''; +} + =item hardware_type Returns the L<FS::hardware_type> object associated with this installation. |