[freeside-commits] branch master updated. df1375c1ce6c844dd81afb0001bd0a4c1e96ca2f
Mark Wells
mark at 420.am
Sat Mar 24 16:32:14 PDT 2012
The branch, master has been updated
via df1375c1ce6c844dd81afb0001bd0a4c1e96ca2f (commit)
from ed4369640adc2e7c468ca384010729e8ec1f9074 (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 df1375c1ce6c844dd81afb0001bd0a4c1e96ca2f
Author: Mark Wells <mark at freeside.biz>
Date: Sat Mar 24 16:32:09 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 06a3001..2b6be2c 100755
--- a/FS/FS/svc_broadband.pm
+++ b/FS/FS/svc_broadband.pm
@@ -464,7 +464,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);
@@ -483,15 +483,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
@@ -668,6 +666,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