From 55f470de060424b123c0689d22caa26b5f4035e5 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Mon, 31 Mar 2014 16:52:06 -0700 Subject: [PATCH] option to disable DID selection and provisioning, RT#27691 --- FS/FS/part_export/voip_innovations2.pm | 85 ++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 34 deletions(-) diff --git a/FS/FS/part_export/voip_innovations2.pm b/FS/FS/part_export/voip_innovations2.pm index af6825c0c..cca9c1571 100644 --- a/FS/FS/part_export/voip_innovations2.pm +++ b/FS/FS/part_export/voip_innovations2.pm @@ -16,6 +16,9 @@ tie my %options, 'Tie::IxHash', 'e911' => { label=>'Provision E911 data', type=>'checkbox', }, + 'no_provision_did' => { label=>'Disable DID provisioning', + type=>'checkbox', + }, 'dry_run' => { label=>"Test mode - don't actually provision", type=>'checkbox', }, @@ -35,7 +38,10 @@ END sub rebless { shift; } -sub can_get_dids { 1; } +sub can_get_dids { + my $self = shift; + ! $self->option('no_provision_did'); +} sub get_dids { my $self = shift; @@ -284,39 +290,43 @@ sub _export_insert { #we want to provision and catch errors now, not queue - ### - # reserveDID - ### + unless ( $self->option('no_provision_did') ) { - my $r = $self->gp_command('reserveDID', - 'did' => $svc_phone->phonenum, - 'minutes' => 1, - 'endpointgroup' => $self->option('endpointgroup'), - ); + ### + # reserveDID + ### - my $rdid = $r->{did}; + my $r = $self->gp_command('reserveDID', + 'did' => $svc_phone->phonenum, + 'minutes' => 1, + 'endpointgroup' => $self->option('endpointgroup'), + ); - if ( $rdid->{'statuscode'} != 100 ) { - return "Error running VoIP Innovations reserveDID: ". - $rdid->{'statuscode'}. ': '. $rdid->{'status'}; - } + my $rdid = $r->{did}; - ### - # assignDID - ### + if ( $rdid->{'statuscode'} != 100 ) { + return "Error running VoIP Innovations reserveDID: ". + $rdid->{'statuscode'}. ': '. $rdid->{'status'}; + } - my $a = $self->gp_command('assignDID', - 'did' => $svc_phone->phonenum, - 'endpointgroup' => $self->option('endpointgroup'), - #'rewrite' - #'cnam' - ); + ### + # assignDID + ### + + my $a = $self->gp_command('assignDID', + 'did' => $svc_phone->phonenum, + 'endpointgroup' => $self->option('endpointgroup'), + #'rewrite' + #'cnam' + ); - my $adid = $a->{did}; + my $adid = $a->{did}; + + if ( $adid->{'statuscode'} != 100 ) { + return "Error running VoIP Innovations assignDID: ". + $adid->{'statuscode'}. ': '. $adid->{'status'}; + } - if ( $adid->{'statuscode'} != 100 ) { - return "Error running VoIP Innovations assignDID: ". - $adid->{'statuscode'}. ': '. $adid->{'status'}; } ### @@ -398,18 +408,25 @@ sub _export_delete { #probably okay to queue the deletion...? #but hell, let's do it inline anyway, who wants phone numbers hanging around - my $r = $self->gp_command('releaseDID', - 'did' => $svc_phone->phonenum, - ); + unless ( $self->option('no_provision_did') ) { + + my $r = $self->gp_command('releaseDID', + 'did' => $svc_phone->phonenum, + ); - my $rdid = $r->{did}; + my $rdid = $r->{did}; + + if ( $rdid->{'statuscode'} != 100 ) { + return "Error running VoIP Innovations releaseDID: ". + $rdid->{'statuscode'}. ': '. $rdid->{'status'}; + } - if ( $rdid->{'statuscode'} != 100 ) { - return "Error running VoIP Innovations releaseDID: ". - $rdid->{'statuscode'}. ': '. $rdid->{'status'}; } #delete e911 information? assuming release clears all that + #if ( $self->option('e911') ) { + # # but need to handle the no_provision_did case + #} ''; } -- 2.11.0