X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fnas.pm;h=7fb7db5e511868a69198183bc04b6dea7b09149b;hb=b79a8cb932946c849328a3c117c35821d9d21e66;hp=53e0fbc34f7fa169a3522b87e5fd22caf53549d0;hpb=b90f8cdac9371c219a72dda16f8deecc7c44fc28;p=freeside.git diff --git a/FS/FS/nas.pm b/FS/FS/nas.pm index 53e0fbc34..7fb7db5e5 100644 --- a/FS/FS/nas.pm +++ b/FS/FS/nas.pm @@ -1,11 +1,8 @@ package FS::nas; use strict; -use vars qw( @ISA ); -use FS::Record qw(qsearchs); #qsearch); -use FS::UID qw( dbh ); #to lock the tables for heartbeat; ugh, MySQL-specific - -@ISA = qw(FS::Record); +use base qw( FS::Record ); +use FS::Record qw( qsearch qsearchs ); =head1 NAME @@ -16,11 +13,7 @@ FS::nas - Object methods for nas records use FS::nas; $record = new FS::nas \%hash; - $record = new FS::nas { - 'nasnum' => 1, - 'nasip' => '10.4.20.23', - 'nasfqdn' => 'box1.brc.nv.us.example.net', - }; + $record = new FS::nas { 'column' => 'value' }; $error = $record->insert; @@ -30,26 +23,49 @@ FS::nas - Object methods for nas records $error = $record->check; - $error = $record->heartbeat($timestamp); - =head1 DESCRIPTION -An FS::nas object represents an Network Access Server on your network, such as -a terminal server or equivalent. FS::nas inherits from FS::Record. The -following fields are currently supported: +An FS::nas object represents a RADIUS client. FS::nas inherits from +FS::Record. The following fields are currently supported: =over 4 -=item nasnum - primary key +=item nasnum + +primary key + +=item nasname + +nasname + +=item shortname + +shortname + +=item type + +type + +=item ports + +ports + +=item secret + +secret -=item nas - NAS name +=item server -=item nasip - NAS ip address +server -=item nasfqdn - NAS fully-qualified domain name +=item community + +community + +=item description + +description -=item last - timestamp indicating the last instant the NAS was in a known - state (used by the session monitoring). =back @@ -98,7 +114,7 @@ returns the error, otherwise returns false. =item check -Checks all fields to make sure this is a valid example. If there is +Checks all fields to make sure this is a valid NAS. If there is an error, returns the error, otherwise returns false. Called by the insert and replace methods. @@ -110,47 +126,26 @@ and replace methods. sub check { my $self = shift; - $self->ut_numbern('nasnum') - || $self->ut_text('nas') - || $self->ut_ip('nasip') - || $self->ut_domain('nasfqdn') - || $self->ut_numbern('last'); -} - -=sub heartbeat TIMESTAMP - -Updates the timestamp for this nas - -=cut - -sub heartbeat { - my($self, $timestamp) = @_; - my $dbh = dbh; - my $sth = $dbh->prepare("LOCK TABLES nas WRITE"); - $sth->execute or die $sth->errstr; #die? - my $lock_self = qsearchs('nas', { 'nasnum' => $self->nasnum } ) - or die "can't find own record for $self nasnum ". $self->nasnum; - if ( $timestamp > $lock_self->last ) { - my $new_self = new FS::nas ( { $lock_self->hash } ); - $new_self->last($timestamp); - #is there a reason to? #$self->last($timestamp); - $new_self->replace($lock_self); - }; - $sth = $dbh->prepare("UNLOCK TABLES"); - $sth->execute or die $sth->errstr; #die? + my $error = + $self->ut_numbern('nasnum') + || $self->ut_text('nasname') + || $self->ut_textn('shortname') + || $self->ut_text('type') + || $self->ut_numbern('ports') + || $self->ut_text('secret') + || $self->ut_textn('server') + || $self->ut_textn('community') + || $self->ut_text('description') + ; + return $error if $error; + + $self->SUPER::check; } =back -=head1 VERSION - -$Id: nas.pm,v 1.3 2000-12-03 20:25:20 ivan Exp $ - =head1 BUGS -The B method is MySQL-specific. Yuck. It's also not quite -perfectly subclassable, which is much less yuck. - =head1 SEE ALSO L, schema.html from the base documentation.