[freeside-commits] freeside/FS/FS/part_export prizm.pm, 1.3, 1.3.2.1
Jeff Finucane,420,,
jeff at wavetail.420.am
Fri Jun 8 07:40:37 PDT 2007
Update of /home/cvs/cvsroot/freeside/FS/FS/part_export
In directory wavetail:/tmp/cvs-serv20872
Modified Files:
Tag: FREESIDE_1_7_BRANCH
prizm.pm
Log Message:
queue suspend, unsuspend, and delete (fixes #1657)
Index: prizm.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_export/prizm.pm,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -d -r1.3 -r1.3.2.1
--- prizm.pm 12 Jan 2007 23:27:09 -0000 1.3
+++ prizm.pm 8 Jun 2007 14:40:34 -0000 1.3.2.1
@@ -200,42 +200,7 @@
sub _export_delete {
my( $self, $svc ) = ( shift, shift );
-
- my $custnum = $svc->cust_svc->cust_pkg->cust_main->custnum;
-
- my $err_or_som = $self->prizm_command('NetworkIfService', 'getPrizmElements',
- ['MAC Address'],
- [$svc->mac_addr],
- ['='],
- );
- return $err_or_som
- unless ref($err_or_som);
-
- return "Can't find prizm element for " . $svc->mac_addr
- unless $err_or_som->result->[0];
-
- $err_or_som = $self->prizm_command('NetworkIfService',
- 'suspendNetworkElements',
- [$err_or_som->result->[0]->elementId],
- 1,
- 1,
- );
-
- return $err_or_som
- unless ref($err_or_som);
-
- $err_or_som = $self->prizm_command('CustomerIfService',
- 'removeElementFromCustomer',
- 0,
- $custnum,
- 0,
- $svc->mac_addr,
- );
-
- return $err_or_som
- unless ref($err_or_som);
-
- '';
+ $self->queue_statuschange('deleteElement', $svc);
}
sub _export_replace {
@@ -304,54 +269,62 @@
sub _export_suspend {
my( $self, $svc ) = ( shift, shift );
+ $self->queue_statuschange('suspendNetworkElements', $svc);
+}
- my $err_or_som = $self->prizm_command('NetworkIfService', 'getPrizmElements',
- [ 'MAC Address' ],
- [ $svc->mac_addr ],
- [ '=' ],
- );
- return $err_or_som
- unless ref($err_or_som);
-
- return "Can't find prizm element for " . $svc->mac_addr
- unless $err_or_som->result->[0];
-
- $err_or_som = $self->prizm_command('NetworkIfService',
- 'suspendNetworkElements',
- [ $err_or_som->result->[0]->elementId ],
- 1,
- 1,
- );
-
- return $err_or_som
- unless ref($err_or_som);
+sub _export_unsuspend {
+ my( $self, $svc ) = ( shift, shift );
+ $self->queue_statuschange('activateNetworkElements', $svc);
+}
- '';
+sub queue_statuschange {
+ my( $self, $method, $svc ) = @_;
+ my $queue = new FS::queue {
+ 'svcnum' => $svc->svcnum,
+ 'job' => 'FS::part_export::prizm::statuschange',
+ };
+ $queue->insert(
+ ( map { $self->option($_) }
+ qw( url user password ) ),
+ $method,
+ $svc->mac_addr,
+ );
}
-sub _export_unsuspend {
- my( $self, $svc ) = ( shift, shift );
+sub statuschange { # subroutine
+ my( $url, $user, $password, $method, $mac_addr ) = @_;
- my $err_or_som = $self->prizm_command('NetworkIfService', 'getPrizmElements',
- [ 'MAC Address' ],
- [ $svc->mac_addr ],
- [ '=' ],
- );
- return $err_or_som
+ eval "use Net::Prizm qw(CustomerInfo PrizmElement);";
+ die $@ if $@;
+
+ my $prizm = new Net::Prizm (
+ namespace => 'NetworkIfService',
+ url => $url,
+ user => $user,
+ password => $password,
+ );
+
+ my $err_or_som = $prizm->getPrizmElements( [ 'MAC Address' ],
+ [ $mac_addr ],
+ [ '=' ],
+ );
+ die $err_or_som
unless ref($err_or_som);
- return "Can't find prizm element for " . $svc->mac_addr
+ die "Can't find prizm element for " . $mac_addr
unless $err_or_som->result->[0];
- $err_or_som = $self->prizm_command('NetworkIfService',
- 'activateNetworkElements',
- [ $err_or_som->result->[0]->elementId ],
- 1,
- 1,
- );
+ my @args;
+ # yuck! should pass args in when we know 'em
+ if ($method =~ /suspendNetworkElements/ || $method =~ /activateNetworkElements/) {
+ @args = ( [ $err_or_som->result->[0]->elementId ], 1, 1);
+ }else{
+ @args = ( $err_or_som->result->[0]->elementId, 1);
+ }
+ $err_or_som = $prizm->$method( @args );
- return $err_or_som
+ die $err_or_som
unless ref($err_or_som);
'';
More information about the freeside-commits
mailing list