X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Fbroadband_snmp.pm;h=8ebc716e782a7907adc69dbf4be969d23a280d85;hb=ffa18709ee8a4d05e18d2d406cf73afe79e52524;hp=9afca08721660d79751e2e3345b89e607b72e441;hpb=a2a69f909cad813d7164bae805e87f5874a9fdae;p=freeside.git diff --git a/FS/FS/part_export/broadband_snmp.pm b/FS/FS/part_export/broadband_snmp.pm index 9afca0872..8ebc716e7 100644 --- a/FS/FS/part_export/broadband_snmp.pm +++ b/FS/FS/part_export/broadband_snmp.pm @@ -34,9 +34,10 @@ tie my %options, 'Tie::IxHash', }, 'community' => { label=>'Community', default=>'public' }, - 'action' => { multiple=>1 }, - 'oid' => { multiple=>1 }, - 'value' => { multiple=>1 }, + 'action' => { multiple=>1 }, + 'oid' => { multiple=>1 }, + 'value' => { multiple=>1 }, + 'datatype'=> { multiple=>1 }, 'ip_addr_change_to_new' => { label=>'Send IP address changes to new address', @@ -54,32 +55,34 @@ tie my %options, 'Tie::IxHash', 'weight' => 10, 'notes' => <<'END' Send one or more SNMP SET requests to the IP address registered to the service. -The value may interpolate fields from svc_broadband by prefixing the field -name with $, or $new_ and $old_ for replace operations. +The value may interpolate fields from svc_broadband, cust_location, or +cust_main by prefixing the field name with $. For replace operations, +svc_broadband fields may be prefixed with $new_ and $old_ +(e.g. "$old_mac_addr"). END ); -sub export_insert { +sub _export_insert { my $self = shift; $self->export_command('insert', @_); } -sub export_delete { +sub _export_delete { my $self = shift; $self->export_command('delete', @_); } -sub export_replace { +sub _export_replace { my $self = shift; $self->export_command('replace', @_); } -sub export_suspend { +sub _export_suspend { my $self = shift; $self->export_command('suspend', @_); } -sub export_unsuspend { +sub _export_unsuspend { my $self = shift; $self->export_command('unsuspend', @_); } @@ -158,6 +161,10 @@ sub substitute { # accepts old_ and new_ for replace actions, like shellcommands my $self = shift; my ($value, $svc_new, $svc_old) = @_; + + my $location = $svc_new->cust_svc->cust_pkg->cust_location; + my $cust_main = $location->cust_main; + foreach my $field ( $svc_new->fields ) { my $new_val = $svc_new->$field; $value =~ s/\$(new_)?$field/$new_val/g; @@ -166,6 +173,21 @@ sub substitute { $value =~ s/\$old_$field/$old_val/g; } } + + # we don't yet have export_relocate hooks in here, so there's no old/new + # cust_location. do cust_location before cust_main, since cust_main has + # a bunch of empty fields with the same names. + + foreach my $field ( $location->fields ) { + my $curr_val = $location->get($field); + $value =~ s/\$$field/$curr_val/g; + } + + foreach my $field ( $cust_main->fields ) { + my $curr_val = $cust_main->get($field); + $value =~ s/\$$field/$curr_val/g; + } + $value; }