[freeside-commits] branch FREESIDE_2_3_BRANCH updated. 7fd2b8885728374bbee5459fadd2f712bd4d9ec0
Mark Wells
mark at 420.am
Sat Mar 24 16:32:51 PDT 2012
The branch, FREESIDE_2_3_BRANCH has been updated
via 7fd2b8885728374bbee5459fadd2f712bd4d9ec0 (commit)
from 69a47bd38e71ae6486b14d24d60dc60077cf09e9 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 7fd2b8885728374bbee5459fadd2f712bd4d9ec0
Author: Mark Wells <mark at freeside.biz>
Date: Sat Mar 24 16:32:45 2012 -0700
fix any missing blocknums during svc_broadband upgrade, #17091
diff --git a/FS/FS/svc_broadband.pm b/FS/FS/svc_broadband.pm
index 3a936a9..67b1ffd 100755
--- a/FS/FS/svc_broadband.pm
+++ b/FS/FS/svc_broadband.pm
@@ -463,7 +463,7 @@ sub assign_ip_addr {
my @blocks;
my $ip_addr;
- if ( $self->blocknum and $self->addr_block->routernum == $self->routernum ) {
+ if ( $self->addr_block and $self->addr_block->routernum == $self->routernum ) {
# simple case: user chose a block, find an address in that block
# (this overrides an existing IP address if it's not in the block)
@blocks = ($self->addr_block);
@@ -482,15 +482,13 @@ sub assign_ip_addr {
return '';
}
$ip_addr = $block->next_free_addr;
- last if $ip_addr;
- }
- if ( $ip_addr ) {
- $self->set(ip_addr => $ip_addr->addr);
- return '';
- }
- else {
- return 'No IP address available on this router';
+ if ( $ip_addr ) {
+ $self->set(ip_addr => $ip_addr->addr);
+ $self->set(blocknum => $block->blocknum);
+ return '';
+ }
}
+ return 'No IP address available on this router';
}
=item assign_router
@@ -667,6 +665,38 @@ sub _upgrade_data {
": no routernum in address block ".$addr_block->cidr.", skipped\n";
}
}
+
+ # assign blocknums to services that should have them
+ my @all_blocks = qsearch('addr_block', { });
+ SVC: foreach my $self (
+ qsearch({
+ 'select' => 'svc_broadband.*',
+ 'table' => 'svc_broadband',
+ 'addl_from' => 'JOIN router USING (routernum)',
+ 'hashref' => {},
+ 'extra_sql' => 'WHERE svc_broadband.blocknum IS NULL '.
+ 'AND router.manual_addr IS NULL',
+ })
+ ) {
+
+ next SVC if $self->ip_addr eq '';
+ my $NetAddr = $self->NetAddr;
+ # inefficient, but should only need to run once
+ foreach my $block (@all_blocks) {
+ if ($block->NetAddr->contains($NetAddr)) {
+ $self->set(blocknum => $block->blocknum);
+ my $error = $self->replace;
+ warn "WARNING: error assigning blocknum ".$block->blocknum.
+ " to service ".$self->svcnum."\n$error; skipped\n"
+ if $error;
+ next SVC;
+ }
+ }
+ warn "WARNING: no block found containing ".$NetAddr->addr." for service ".
+ $self->svcnum;
+ #next SVC;
+ }
+
'';
}
-----------------------------------------------------------------------
Summary of changes:
FS/FS/svc_broadband.pm | 48 +++++++++++++++++++++++++++++++++++++++---------
1 files changed, 39 insertions(+), 9 deletions(-)
More information about the freeside-commits
mailing list