fix svc_broadband upgrade issues, #14698
authorMark Wells <mark@freeside.biz>
Fri, 2 Mar 2012 21:05:52 +0000 (13:05 -0800)
committerMark Wells <mark@freeside.biz>
Fri, 2 Mar 2012 21:05:52 +0000 (13:05 -0800)
FS/FS/svc_broadband.pm
httemplate/docs/man/FS/part_export/.cvs_is_on_crack [deleted file]

index 7606ad7..18b7036 100755 (executable)
@@ -101,15 +101,15 @@ sub table_info {
       'description' => 'Descriptive label for this particular device',
       'speed_down'  => 'Maximum download speed for this service in Kbps.  0 denotes unlimited.',
       'speed_up'    => 'Maximum upload speed for this service in Kbps.  0 denotes unlimited.',
-      #'ip_addr'     => 'IP address.  Leave blank for automatic assignment.',
-      #'blocknum'    => 
-      #{ 'label' => 'Address block',
-      #                   'type'  => 'select',
-      #                   'select_table' => 'addr_block',
-      #                    'select_key'   => 'blocknum',
-      #                   'select_label' => 'cidr',
-      #                   'disable_inventory' => 1,
-      #                 },
+      'ip_addr'     => 'IP address.  Leave blank for automatic assignment.',
+      'blocknum'    => 
+      { 'label' => 'Address block',
+                         'type'  => 'select',
+                         'select_table' => 'addr_block',
+                          'select_key'   => 'blocknum',
+                         'select_label' => 'cidr',
+                         'disable_inventory' => 1,
+                       },
      'plan_id' => 'Service Plan Id',
      'performance_profile' => 'Peformance Profile',
      'authkey'      => 'Authentication key',
@@ -418,8 +418,11 @@ sub check {
       if $router->agentnum and $router->agentnum != $agentnum;
 
     if ( $router->auto_addr ) {
-      my $error = $self->assign_ip_addr;
-      return $error if $error;
+      my $addr_block = $self->addr_block;
+      unless ( $addr_block and $addr_block->manual_flag ) {
+        my $error = $self->assign_ip_addr;
+        return $error if $error;
+      }
     }
     else {
       $self->blocknum('');
@@ -578,9 +581,6 @@ sub mac_addr_formatted {
   join( $delim || '', $addr =~ /../g );
 }
 
-=back
-
-
 #class method
 sub _upgrade_data {
   my $class = shift;
@@ -591,9 +591,20 @@ sub _upgrade_data {
       routernum => ''
     })) {
     my $addr_block = $self->addr_block;
-    if ( my $routernum = $addr_block->routernum ) {
+    my $ip_addr = $self->ip_addr;
+    my $routernum = $addr_block->routernum;
+    if ( $routernum ) {
       $self->set(routernum => $routernum);
-      my $error = $self->replace;
+      my $error = $self->check;
+      # sanity check: don't allow this to change IP address or block
+      # (other than setting blocknum to null for a non-auto-assigned router)
+      if ( $self->ip_addr ne $ip_addr 
+        or ($self->blocknum and $self->blocknum != $addr_block->blocknum)) {
+        die "Upgrading service ".$self->svcnum." would change its block/address.\n\nCheck your router and address block configuration.\n";
+        next;
+      }
+
+      $error ||= $self->replace;
       die "error assigning routernum $routernum to service ".$self->svcnum.
           ":\n$error\n"
         if $error;
@@ -606,6 +617,8 @@ sub _upgrade_data {
   '';
 }
 
+=back
+
 =head1 BUGS
 
 The business with sb_field has been 'fixed', in a manner of speaking.
diff --git a/httemplate/docs/man/FS/part_export/.cvs_is_on_crack b/httemplate/docs/man/FS/part_export/.cvs_is_on_crack
deleted file mode 100644 (file)
index e69de29..0000000