[freeside-commits] freeside/FS/FS Schema.pm, 1.330, 1.331 nas.pm, 1.9, 1.10

Ivan,,, ivan at wavetail.420.am
Fri Oct 14 01:56:06 PDT 2011


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv13344/FS/FS

Modified Files:
	Schema.pm nas.pm 
Log Message:
maintain freeradius nas table, RT#14697

Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.330
retrieving revision 1.331
diff -u -w -d -r1.330 -r1.331
--- Schema.pm	6 Oct 2011 20:44:17 -0000	1.330
+++ Schema.pm	14 Oct 2011 08:56:03 -0000	1.331
@@ -2240,28 +2240,30 @@
     'nas' => {
       'columns' => [
         'nasnum',   'serial',     '',    '', '', '', 
-        'nas',      'varchar', '',    $char_d, '', '', 
-        'nasip',    'varchar', '',    15, '', '', 
-        'nasfqdn',  'varchar', '',    $char_d, '', '', 
-        'last',     'int',     '',    '', '', '', 
+        'nasname',     'varchar',     '', 128,              '', '',
+        'shortname',   'varchar', 'NULL',  32,              '', '',
+        'type',        'varchar',     '',  30,         'other', '',
+        'ports',           'int', 'NULL',  '',              '', '',
+        'secret',      'varchar',     '',  60,        'secret', '',
+        'server',      'varchar', 'NULL',  64,              '', '',
+        'community',   'varchar', 'NULL',  50,              '', '',
+        'description', 'varchar',     '', 200, 'RADIUS Client', '',
       ],
       'primary_key' => 'nasnum',
-      'unique'      => [ [ 'nas' ], [ 'nasip' ] ],
-      'index'       => [ [ 'last' ] ],
+      'unique'      => [ [ 'nasname' ], ],
+      'index'       => [],
     },
 
-#    'session' => {
-#      'columns' => [
-#        'sessionnum', 'serial',       '',   '', '', '', 
-#        'portnum',    'int',       '',   '', '', '', 
-#        'svcnum',     'int',       '',   '', '', '', 
-#        'login',      @date_type, '', '', 
-#        'logout',     @date_type, '', '', 
-#      ],
-#      'primary_key' => 'sessionnum',
-#      'unique'      => [],
-#      'index'       => [ [ 'portnum' ] ],
-#    },
+    'export_nas' => {
+      'columns' => [
+        'exportnasnum', 'serial', '', '', '', '', 
+        'exportnum',       'int', '', '', '', '', 
+        'nasnum',          'int', '', '', '', '', 
+      ],
+      'primary_key' => 'exportnasnum',
+      'unique'      => [ [ 'exportnum', 'nasnum' ] ],
+      'index'       => [ [ 'exportnum' ], [ 'nasnum' ] ],
+    },
 
     'queue' => {
       'columns' => [

Index: nas.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/nas.pm,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -w -d -r1.9 -r1.10
--- nas.pm	18 Feb 2006 02:11:44 -0000	1.9
+++ nas.pm	14 Oct 2011 08:56:03 -0000	1.10
@@ -1,11 +1,8 @@
 package FS::nas;
 
 use strict;
-use vars qw( @ISA );
-use FS::Record qw(qsearchs); #qsearch);
-use FS::UID qw( dbh );
-
- at ISA = qw(FS::Record);
+use base qw( FS::Record );
+use FS::Record qw( qsearch qsearchs );
 
 =head1 NAME
 
@@ -16,11 +13,7 @@
   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 @@
 
   $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
 
-=item nas - NAS name
+primary key
 
-=item nasip - NAS ip address
+=item nasname
 
-=item nasfqdn - NAS fully-qualified domain name
+nasname
+
+=item shortname
+
+shortname
+
+=item type
+
+type
+
+=item ports
+
+ports
+
+=item secret
+
+secret
+
+=item server
+
+server
+
+=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
 
@@ -110,36 +126,26 @@
 sub check {
   my $self = shift;
 
+  my $error = 
   $self->ut_numbern('nasnum')
-    || $self->ut_text('nas')
-    || $self->ut_ip('nasip')
-    || $self->ut_domain('nasfqdn')
-    || $self->ut_numbern('last')
-    || $self->SUPER::check
+    || $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')
     ;
-}
-
-=item heartbeat TIMESTAMP
-
-Updates the timestamp for this nas
-
-=cut
+  return $error if $error;
 
-sub heartbeat {
-  my($self, $timestamp) = @_;
-  my $dbh = dbh;
-  my $sth =
-    $dbh->prepare("UPDATE nas SET last = ? WHERE nasnum = ? AND last < ?");
-  $sth->execute($timestamp, $self->nasnum, $timestamp) or die $sth->errstr;
-  $self->last($timestamp);
+  $self->SUPER::check;
 }
 
 =back
 
 =head1 BUGS
 
-heartbeat method uses SQL directly and doesn't update history tables.
-
 =head1 SEE ALSO
 
 L<FS::Record>, schema.html from the base documentation.



More information about the freeside-commits mailing list