svc_hardware: better error messages for bad hw_addr when not validating as a MAC...
[freeside.git] / FS / FS / addr_status.pm
1 package FS::addr_status;
2 use base qw( FS::Record );
3
4 use strict;
5
6 =head1 NAME
7
8 FS::addr_status;
9
10 =head1 SYNOPSIS
11
12   use FS::addr_status;
13
14   $record = new FS::addr_status \%hash;
15   $record = new FS::addr_status { 'column' => 'value' };
16
17   $error = $record->insert;
18
19   $error = $new_record->replace($old_record);
20
21   $error = $record->delete;
22
23   $error = $record->check;
24
25 =head1 DESCRIPTION
26
27 An FS::addr_status object represents the last known status (up or down, and
28 the latency) of an IP address monitored by freeside-pingd.  FS::addr_status
29 inherits from FS::Record.  The following fields are currently supported:
30
31 =over 4
32
33 =item addrnum - primary key
34
35 =item ip_addr - the IP address (unique)
36
37 =item _date - the time the address was last scanned
38
39 =item up - 'Y' if the address responded to a ping
40
41 =item delay - the latency, in milliseconds
42
43 =back
44
45 =head1 METHODS
46
47 =over 4
48
49 =item new HASHREF
50
51 Creates a new status record.  To add the record to the database, see
52 L<"insert">.
53
54 Note that this stores the hash reference, not a distinct copy of the hash it
55 points to.  You can ask the object for a copy with the I<hash> method.
56
57 =cut
58
59 # the new method can be inherited from FS::Record, if a table method is defined
60
61 sub table { 'addr_status'; }
62
63 =item insert
64
65 Adds this record to the database.  If there is an error, returns the error,
66 otherwise returns false.
67
68 =item delete
69
70 =item replace OLD_RECORD
71
72 =item check
73
74 Checks all fields to make sure this is a valid status record.  If there is
75 an error, returns the error, otherwise returns false.  Called by the insert
76 and replace methods.
77
78 =cut
79
80 sub check {
81   my $self = shift;
82
83   my $error = 
84     $self->ut_numbern('addrnum')
85     || $self->ut_ip('ip_addr')
86     || $self->ut_number('_date')
87     || $self->ut_flag('up')
88     || $self->ut_numbern('delay')
89   ;
90
91   $self->SUPER::check;
92 }
93
94 =back
95
96 =head1 SEE ALSO
97
98 L<FS::Record>
99
100 =cut
101
102 1;
103