package FS::part_export::prizm;
-use vars qw(@ISA %info %options $DEBUG);
+use vars qw(@ISA %info %options $DEBUG $me);
use Tie::IxHash;
use FS::Record qw(fields dbh);
use FS::part_export;
@ISA = qw(FS::part_export);
-$DEBUG = 1;
+$DEBUG = 0;
+$me = '[' . __PACKAGE__ . ']';
tie %options, 'Tie::IxHash',
'url' => { label => 'Northbound url', default=>'https://localhost:8443/prizm/nbi' },
sub prizm_command {
my ($self,$namespace,$method) = (shift,shift,shift);
- eval "use Net::Prizm qw(CustomerInfo PrizmElement);";
+ eval "use Net::Prizm 0.04 qw(CustomerInfo PrizmElement);";
die $@ if $@;
my $prizm = new Net::Prizm (
sub queued_prizm_command { # subroutine
my( $url, $user, $password, $namespace, $method, @args ) = @_;
- eval "use Net::Prizm qw(CustomerInfo PrizmElement);";
+ eval "use Net::Prizm 0.04 qw(CustomerInfo PrizmElement);";
die $@ if $@;
my $prizm = new Net::Prizm (
sub _export_insert {
my( $self, $svc ) = ( shift, shift );
+ warn "$me: _export_insert called for export ". $self->exportnum.
+ " on service ". $svc->svcnum. "\n"
+ if $DEBUG;
my $cust_main = $svc->cust_svc->cust_pkg->cust_main;
my $pcustomer;
if ($err_or_som->result->[0]) {
$pcustomer = $err_or_som->result->[0]->customerId;
+ warn "$me: found customer $pcustomer in prizm\n" if $DEBUG;
}else{
my $chashref = $cust_main->hashref;
my $customerinfo = {
unless ref($err_or_som);
$pcustomer = $err_or_som->result;
+ warn "$me: added customer $pcustomer to prizm\n" if $DEBUG;
}
warn "multiple prizm customers found for $cust_main->custnum"
if scalar(@$pcustomer) > 1;
# }
# }
+# here we cope with a problem of prizm failing to insert for reason
+# of duplicate mac addr, but doing so inconsistently... a race in prizm?
+
+ $self->prizm_command( 'CustomerIfService', 'removeElementFromCustomer',
+ 0,
+ $cust_main->custnum,
+ 0,
+ $svc->mac_addr,
+ );
+
+ $err_or_som = $self->prizm_command( 'NetworkIfService', 'getPrizmElements',
+ [ 'MAC Address' ],
+ [ $svc->mac_addr ],
+ [ '=' ],
+ );
+ if ( ref($err_or_som) && $err_or_som->result->[0] ) { # ignore errors
+ $self->prizm_command( 'NetworkIfService', 'deleteElement',
+ $err_or_som->result->[0],
+ 1,
+ );
+ }
+# end of coping
+
+ my $performance_profile = $svc->performance_profile;
+ $performance_profile ||= $svc->cust_svc->cust_pkg->part_pkg->pkg;
+
my $element_name_length = 50;
$element_name_length = $1
if $self->option('element_name_length') =~ /^\s*(\d+)\s*$/;
0, $element_name_length),
$location,
$contact,
- sprintf("%032X", $svc->authkey),
- $svc->cust_svc->cust_pkg->part_pkg->pkg,
+ sprintf("%032X", $svc->authkey || 0),
+ $performance_profile,
$svc->vlan_profile,
($self->option('ems') ? 1 : 0 ),
);
return $err_or_som
unless ref($err_or_som);
+ warn "$me: added provisioned element to prizm\n" if $DEBUG;
my (@names) = ('Management IP',
'GPS Latitude',
);
return $err_or_som
unless ref($err_or_som);
+ warn "$me: set element configuration\n" if $DEBUG;
$err_or_som = $self->prizm_command('NetworkIfService', 'setElementConfigSet',
[ $element ],
);
return $err_or_som
unless ref($err_or_som);
+ warn "$me: set element vlan profile\n" if $DEBUG;
$err_or_som = $self->prizm_command('NetworkIfService', 'setElementConfigSet',
[ $element ],
- $svc->cust_svc->cust_pkg->part_pkg->pkg,
+ $performance_profile,
0,
1,
);
return $err_or_som
unless ref($err_or_som);
+ warn "$me: set element configset (performance profile)\n" if $DEBUG;
$err_or_som = $self->prizm_command('NetworkIfService',
'activateNetworkElements',
return $err_or_som
unless ref($err_or_som);
+ warn "$me: activated element\n" if $DEBUG;
$err_or_som = $self->prizm_command('CustomerIfService',
'addElementToCustomer',
return $err_or_som
unless ref($err_or_som);
+ warn "$me: added element to customer\n" if $DEBUG;
'';
}
return $err_or_som
unless ref($err_or_som);
+ my $performance_profile = $new->performance_profile;
+ $performance_profile ||= $new->cust_svc->cust_pkg->part_pkg->pkg;
+
+ $err_or_som = $self->prizm_command('NetworkIfService', 'setElementConfigSet',
+ [ $element ],
+ $performance_profile,
+ 0,
+ 1,
+ );
+ return $err_or_som
+ unless ref($err_or_som);
+
'';
}
'';
}
+sub export_links {
+ my( $self, $svc, $arrayref ) = ( shift, shift, shift );
+
+ push @$arrayref,
+ '<A HREF="http://'. $svc->ip_addr. '" target="_blank">SM</A>';
+
+ '';
+}
+
sub queue_statuschange {
my( $self, $method, $jobs, $svc, @args ) = @_;
sub statuschange { # subroutine
my( $url, $user, $password, $method, $mac_addr, @args) = @_;
- eval "use Net::Prizm qw(CustomerInfo PrizmElement);";
+ eval "use Net::Prizm 0.04 qw(CustomerInfo PrizmElement);";
die $@ if $@;
my $prizm = new Net::Prizm (