[freeside-commits] freeside/FS/FS Conf.pm, 1.243, 1.244 Schema.pm, 1.110, 1.111 addr_block.pm, 1.9, 1.10 svc_broadband.pm, 1.15, 1.16

Jeff Finucane,420,, jeff at wavetail.420.am
Fri Sep 26 20:01:45 PDT 2008


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

Modified Files:
	Conf.pm Schema.pm addr_block.pm svc_broadband.pm 
Log Message:
per address block ip auto assignment and auto router selection

Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -d -r1.110 -r1.111
--- Schema.pm	26 Sep 2008 03:54:25 -0000	1.110
+++ Schema.pm	27 Sep 2008 03:01:43 -0000	1.111
@@ -1586,6 +1586,7 @@
         'ip_gateway', 'varchar', '', 15, '', '', 
         'ip_netmask', 'int', '', '', '', '', 
         'agentnum',   'int', 'NULL', '', '', '', 
+        'manual_flag', 'char', 'NULL', 1, '', '', 
       ],
       'primary_key' => 'blocknum',
       'unique'      => [ [ 'blocknum', 'routernum' ] ],

Index: Conf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Conf.pm,v
retrieving revision 1.243
retrieving revision 1.244
diff -u -d -r1.243 -r1.244
--- Conf.pm	12 Sep 2008 07:58:33 -0000	1.243
+++ Conf.pm	27 Sep 2008 03:01:43 -0000	1.244
@@ -731,6 +731,13 @@
   },
   
   {
+    'key'         => 'auto_router',
+    'section'     => '',
+    'description' => 'Automatically choose the correct router/block based on supplied ip address when possible while provisioning broadband services',
+    'type'        => 'checkbox',
+  },
+  
+  {
     'key'         => 'hidecancelledpackages',
     'section'     => 'UI',
     'description' => 'Prevent cancelled packages from showing up in listings (though they will still be in the database)',

Index: addr_block.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/addr_block.pm,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- addr_block.pm	3 Sep 2008 19:08:27 -0000	1.9
+++ addr_block.pm	27 Sep 2008 03:01:43 -0000	1.10
@@ -48,6 +48,8 @@
 
 =item ip_netmask - the netmask of the block, expressed as an integer.
 
+=item manual_flag - prohibit automatic ip assignment from this block when true. 
+
 =item agentnum - optional agent number (see L<FS::agent>)
 
 =back
@@ -124,6 +126,7 @@
     $self->ut_number('routernum')
     || $self->ut_ip('ip_gateway')
     || $self->ut_number('ip_netmask')
+    || $self->ut_enum('manual_flag', [ '', 'Y' ])
     || $self->ut_agentnum_acl('agentnum', 'Broadband global configuration')
   ;
   return $error if $error;
@@ -202,13 +205,16 @@
 
 Returns a NetAddr::IP object corresponding to the first unassigned address 
 in the block (other than the network, broadcast, or gateway address).  If 
-there are no free addresses, returns false.
+there are no free addresses, returns false.  There are never free addresses
+when manual_flag is true.
 
 =cut
 
 sub next_free_addr {
   my $self = shift;
 
+  return '' if $self->manual_flag;
+
   my $conf = new FS::Conf;
   my @excludeaddr = $conf->config('exclude_ip_addr');
   

Index: svc_broadband.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_broadband.pm,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- svc_broadband.pm	28 Jun 2008 19:25:23 -0000	1.15
+++ svc_broadband.pm	27 Sep 2008 03:01:43 -0000	1.16
@@ -203,7 +203,7 @@
 
   my $error =
     $self->ut_numbern('svcnum')
-    || $self->ut_foreign_key('blocknum', 'addr_block', 'blocknum')
+    || $self->ut_numbern('blocknum')
     || $self->ut_textn('description')
     || $self->ut_number('speed_up')
     || $self->ut_number('speed_down')
@@ -231,7 +231,12 @@
     return "Invalid pkgnum" unless $cust_pkg;
   }
     
-  if ($cust_pkg) {
+  if ($self->blocknum) {
+    $error = $self->ut_foreign_key('blocknum', 'addr_block', 'blocknum');
+    return $error if $error;
+  }
+
+  if ($cust_pkg && $self->blocknum) {
     my $addr_agentnum = $self->addr_block->agentnum;
     if ($addr_agentnum && $addr_agentnum != $cust_pkg->cust_main->agentnum) {
       return "Address block does not service this customer";
@@ -239,6 +244,8 @@
   }
 
   if (not($self->ip_addr) or $self->ip_addr eq '0.0.0.0') {
+    return "Must supply either address or block"
+      unless $self->blocknum;
     my $next_addr = $self->addr_block->next_free_addr;
     if ($next_addr) {
       $self->ip_addr($next_addr->addr);
@@ -247,6 +254,19 @@
     }
   }
 
+  if (not($self->blocknum)) {
+    return "Must supply either address or block"
+      unless ($self->ip_addr and $self->ip_addr ne '0.0.0.0');
+    my @block = grep { $_->NetAddr->contains($self->NetAddr) }
+                 map { $_->addr_block }
+                 $self->allowed_routers;
+    if (scalar(@block)) {
+      $self->blocknum($block[0]->blocknum);
+    }else{
+      return "Address not with available block.";
+    }
+  }
+
   # This should catch errors in the ip_addr.  If it doesn't,
   # they'll almost certainly not map into the block anyway.
   my $self_addr = $self->NetAddr; #netmask is /32



More information about the freeside-commits mailing list