5 use FS::Record qw(qsearchs); #qsearch);
6 use FS::UID qw( dbh ); #to lock the tables for heartbeat; ugh, MySQL-specific
12 FS::nas - Object methods for nas records
18 $record = new FS::nas \%hash;
19 $record = new FS::nas {
21 'nasip' => '10.4.20.23',
22 'nasfqdn' => 'box1.brc.nv.us.example.net',
25 $error = $record->insert;
27 $error = $new_record->replace($old_record);
29 $error = $record->delete;
31 $error = $record->check;
33 $error = $record->heartbeat($timestamp);
37 An FS::nas object represents an Network Access Server on your network, such as
38 a terminal server or equivalent. FS::nas inherits from FS::Record. The
39 following fields are currently supported:
43 =item nasnum - primary key
47 =item nasip - NAS ip address
49 =item nasfqdn - NAS fully-qualified domain name
51 =item last - timestamp indicating the last instant the NAS was in a known
52 state (used by the session monitoring).
62 Creates a new NAS. To add the NAS to the database, see L<"insert">.
64 Note that this stores the hash reference, not a distinct copy of the hash it
65 points to. You can ask the object for a copy with the I<hash> method.
69 # the new method can be inherited from FS::Record, if a table method is defined
75 Adds this record to the database. If there is an error, returns the error,
76 otherwise returns false.
80 # the insert method can be inherited from FS::Record
84 Delete this record from the database.
88 # the delete method can be inherited from FS::Record
90 =item replace OLD_RECORD
92 Replaces the OLD_RECORD with this one in the database. If there is an error,
93 returns the error, otherwise returns false.
97 # the replace method can be inherited from FS::Record
101 Checks all fields to make sure this is a valid example. If there is
102 an error, returns the error, otherwise returns false. Called by the insert
107 # the check method should currently be supplied - FS::Record contains some
108 # data checking routines
113 $self->ut_numbern('nasnum')
114 || $self->ut_text('nas')
115 || $self->ut_ip('nasip')
116 || $self->ut_domain('nasfqdn')
117 || $self->ut_numbern('last');
120 =item heartbeat TIMESTAMP
122 Updates the timestamp for this nas
127 my($self, $timestamp) = @_;
129 my $sth = $dbh->prepare("LOCK TABLES nas WRITE");
130 $sth->execute or die $sth->errstr; #die?
131 my $lock_self = qsearchs('nas', { 'nasnum' => $self->nasnum } )
132 or die "can't find own record for $self nasnum ". $self->nasnum;
133 if ( $timestamp > $lock_self->last ) {
134 my $new_self = new FS::nas ( { $lock_self->hash } );
135 $new_self->last($timestamp);
136 #is there a reason to? #$self->last($timestamp);
137 $new_self->replace($lock_self);
139 $sth = $dbh->prepare("UNLOCK TABLES");
140 $sth->execute or die $sth->errstr; #die?
147 $Id: nas.pm,v 1.4 2001-02-21 01:45:37 ivan Exp $
151 The B<heartbeat> method is MySQL-specific. Yuck. It's also not quite
152 perfectly subclassable, which is much less yuck.
156 L<FS::Record>, schema.html from the base documentation.