Using ->DeleteCustomFieldValue() on the 'IP' CF does not work like ->AddCustomFieldValue()?

Hello RTIR,

I’ve borrowed the code from RTIR_FindIP.pm and modified it so I can specify
the ticket object to Add and Delete IP addresses. This is so I can iterate
through child tickets of an Incident and perform the same action on them.
I can add IP addresses to CF.{IP} but not delete IP addresses though. I’m
stumped. Any clues about how to delete an IP address from the IP custom
field?

This works: (%existing is a hash where each key is an IP address already
in the CF)

$self->AddIP( Ticket => $ticket, IP => $ipaddr, CustomField => $cf, Skip =>
%existing );
sub AddIP {
my $self = shift;
my %arg = ( CustomField => undef, IP => undef, Skip => {}, @_ );
return 0 if !$arg{‘IP’} || $arg{‘Skip’}->{ $arg{‘IP’} }++ ||
$arg{‘Skip’}->{ $arg{‘IP’} .‘-’. $arg{‘IP’} }++;
my $t = $arg{‘Ticket’};
my ($status, $msg) = $t->AddCustomFieldValue( Value => $arg{‘IP’},
Field => $arg{‘CustomField’}, );
RT->Logger->error(“Couldn’t add IP address: $msg”) unless $status;

return 1;

}

The code that errors out: (%keep is a hash where each key is a list of IP
addresses not to delete)
$spots_left += $self->RemIP( Ticket => $ticket, IP => $, CustomField =>
$cf, Skip => %keep );
sub RemIP {
my $self = shift;
my %arg = ( CustomField => undef, IP => undef, Skip => {}, @
);
return 0 if !$arg{‘IP’} || $arg{‘Skip’}->{ $arg{‘IP’} }++ ||
$arg{‘Skip’}->{ $arg{‘IP’} .‘-’. $arg{‘IP’} }++;
my $t = $arg{‘Ticket’};
my ($status, $msg) = $t->DeleteCustomFieldValue( Value => $arg{‘IP’},
Field => $arg{‘CustomField’}, );
RT->Logger->error(“Couldn’t remove IP address: $msg”) unless $status;

return 1;

}

The error:
RT::CustomField::ParseIPRange Unimplemented in RT::ObjectCustomFieldValue.
(/opt/rt4/bin/…/lib/RT/ObjectCustomFieldValue.pm line 169)

Commenting out DeleteCustomFieldValue() line and the logger line make the
error not happen so I’m sure that line is the problem one.

Thank you for reading!

Landon Stewart :: lstewart@iweb.com
Lead Specialist, Abuse and Security Management
Spécialiste principal, gestion des abus et sécurité
http://iweb.com :: +1 (888) 909-4932

Hello RTIR,

I’ve borrowed the code from RTIR_FindIP.pm and modified it so I can specify the
ticket object to Add and Delete IP addresses. This is so I can iterate through
child tickets of an Incident and perform the same action on them. I can add IP
addresses to CF.{IP} but not delete IP addresses though. I’m stumped. Any
clues about how to delete an IP address from the IP custom field?

Your line numbers don’t line up with the current RT release, so
debugging this is kind of impossible

Please provide your RT release, your RTIR release, local modifications
made and enable Stacktraces to better highlight your error.
http://bestpractical.com/docs/rt/latest/RT_Config.html#LogStackTraces

-kevin

Hi Kevin,

Thanks for replying to me. See below for the information you mentioned in
your post.

Hello RTIR,

I’ve borrowed the code from RTIR_FindIP.pm and modified it so I can
specify the
ticket object to Add and Delete IP addresses. This is so I can iterate
through
child tickets of an Incident and perform the same action on them. I can
add IP
addresses to CF.{IP} but not delete IP addresses though. I’m stumped.
Any
clues about how to delete an IP address from the IP custom field?

Your line numbers don’t line up with the current RT release, so
debugging this is kind of impossible

rt/lib/RT/ObjectCustomFieldValue.pm at stable · bestpractical/rt · GitHub

Sorry - I’m using RT v4.0.17 with RTIR v3.0.0rc1. Nothing in the release
of either RT or RTIR was modified but new modules have been added. The one
I’m dealing with right now is called
local/plugins/RT-IR/lib/RT/Action/RTIR_UpdatePF.pm

I’ve pasted my code at http://pastebin.com/raw.php?i=APb1ZEPz with some
modifications (the external database call to grab customer data has been
removed).

Please provide your RT release, your RTIR release, local modifications
made and enable Stacktraces to better highlight your error.
RT Config - RT 5.0.5 Documentation - Best Practical

I’ve enabled $StackTraces with a value of 5 now. Not sure if this provides
enough information since it doesn’t really indicate what the error might be.

The resulting log entries after running this via:
/opt/rt4/bin/rt-crontool --search RT::Search::FromSQL --action
RT::Action::RTIR_iWebUpdatePF --transaction first --search-arg “id =
16735422”

*Are: *(xx.x05.127.6 purposely obfuscated)
[Mon Aug 11 17:08:46 2014] [critical]: RT::CustomField::ParseIPRange
Unimplemented in RT::ObjectCustomFieldValue.
(/opt/rt4/bin/…/lib/RT/ObjectCustomFieldValue.pm line 169)
(/opt/rt4/bin/…/lib/RT.pm:400)
Trace begun at /opt/rt4/bin/…/lib/RT.pm line 294
Log::Dispatch::crit(‘Log::Dispatch=HASH(0x40eaaf0)’,
‘RT::CustomField::ParseIPRange Unimplemented in RT::ObjectCustomFieldValue.
(/opt/rt4/bin/…/lib/RT/ObjectCustomFieldValue.pm line 169) ^J’) called at
/opt/rt4/bin/…/lib/RT.pm line 400
RT::ANON(‘RT::CustomField::ParseIPRange Unimplemented in
RT::ObjectCustomFieldValue.
(/opt/rt4/bin/…/lib/RT/ObjectCustomFieldValue.pm line 169) ^J’) called at
/usr/share/perl5/DBIx/SearchBuilder/Record.pm line 494
DBIx::SearchBuilder::Record::AUTOLOAD(‘RT::CustomField=HASH(0x822b700)’,
xx.x05.127.6) called at /opt/rt4/bin/…/lib/RT/ObjectCustomFieldValue.pm
line 169
RT::ObjectCustomFieldValue::LoadByCols(‘RT::ObjectCustomFieldValue=HASH(0x8228228)’,
‘Content’, xx.x05.127.6, ‘CustomField’, 68, ‘ObjectType’, ‘RT::Ticket’,
‘ObjectId’, 16735422, ‘Disabled’, 0) called at
/opt/rt4/bin/…/lib/RT/ObjectCustomFieldValue.pm line 217
RT::ObjectCustomFieldValue::LoadByObjectContentAndCustomField(‘RT::ObjectCustomFieldValue=HASH(0x8228228)’,
‘Object’, ‘RT::Ticket=HASH(0x805fdd8)’, ‘Content’, xx.x05.127.6,
‘CustomField’, 68) called at /opt/rt4/bin/…/lib/RT/CustomField.pm line 1654
RT::CustomField::DeleteValueForObject(‘RT::CustomField=HASH(0x822a1e8)’,
‘Object’, ‘RT::Ticket=HASH(0x805fdd8)’, ‘Id’, undef, ‘Content’,
xx.x05.127.6) called at /opt/rt4/bin/…/lib/RT/Record.pm line 1857
RT::Record::DeleteCustomFieldValue(‘RT::Ticket=HASH(0x805fdd8)’, ‘Value’,
xx.x05.127.6, ‘Field’, ‘RT::CustomField=HASH(0x81eed50)’) called at
/opt/rt4/local/plugins/RT-IR/lib/RT/Action/RTIR_UpdatePF.pm line 83
RT::Action::RTIR_UpdatePF::RemIP(‘RT::Action::RTIR_UpdatePF=HASH(0x8072dd0)’,
‘Ticket’, ‘RT::Ticket=HASH(0x805fdd8)’, ‘IP’, xx.x05.127.6, ‘CustomField’,
‘RT::CustomField=HASH(0x81eed50)’, ‘Skip’, ‘HASH(0x804ef98)’) called at
/opt/rt4/local/plugins/RT-IR/lib/RT/Action/RTIR_UpdatePF.pm line 46
RT::Action::RTIR_UpdatePF::Commit(‘RT::Action::RTIR_UpdatePF=HASH(0x8072dd0)’)
called at /opt/rt4/bin/rt-crontool line 227X
main::process(‘RT::Ticket=HASH(0x805fdd8)’,
‘RT::Transaction=HASH(0x8077500)’, undef) called at
/opt/rt4/bin/rt-crontool line 176

Landon Stewart :: lstewart@iweb.com
Lead Specialist, Abuse and Security Management
Spécialiste principal, gestion des abus et sécurité
http://iweb.com :: +1 (888) 909-4932

Sorry - I’m using RT v4.0.17 with RTIR v3.0.0rc1. Nothing in the release of
either RT or RTIR was modified but new modules have been added. The one I’m
dealing with right now is called local/plugins/RT-IR/lib/RT/Action/
RTIR_UpdatePF.pm

Ok, I’m going to stop here.

RTIR 3.0.0rc1 was an incredibly buggy pre-release that never should
have been shipped.

Your RT was released in August of 2013, your RTIR was released in
December of 2011.

Please try again with the current release of RTIR 3.0.2 which contains
almost 200 additional commits (most of which are bugfixes).

It’s still possible that there is a bug here, but I can’t chase it
against a broken pre-release.

You likely also want to examine how RT deletes IPs when changing
something in the UI, which is in _ProcessObjectCustomFieldUpdates in
RT::Interface::Web

-kevin

‎I am also using 3.0. Didn’t upgrade because there are specific instructions to this type of upgrade I mean from RTIR 3.0 to 3.0.2.

Atte
Gonzalo

Enviado desde BlackBerry
Mensaje original De: Kevin Falcone
Enviado: miércoles, 13 de agosto de 2014 11:14 a.m.
Para: rtir@lists.bestpractical.com
Responder a: rtir@lists.bestpractical.com
Asunto: Re: [Rtir] Using ->DeleteCustomFieldValue() on the ‘IP’ CF does not work like ->AddCustomFieldValue() ?

Sorry - I’m using RT v4.0.17 with RTIR v3.0.0rc1. Nothing in the release of
either RT or RTIR was modified but new modules have been added. The one I’m
dealing with right now is called local/plugins/RT-IR/lib/RT/Action/
RTIR_UpdatePF.pm

Ok, I’m going to stop here.

RTIR 3.0.0rc1 was an incredibly buggy pre-release that never should
have been shipped.

Your RT was released in August of 2013, your RTIR was released in
December of 2011.

Please try again with the current release of RTIR 3.0.2 which contains
almost 200 additional commits (most of which are bugfixes).

It’s still possible that there is a bug here, but I can’t chase it
against a broken pre-release.

You likely also want to examine how RT deletes IPs when changing
something in the UI, which is in _ProcessObjectCustomFieldUpdates in
RT::Interface::Web

-kevin

I am also using 3.0. Didn’t upgrade because there are specific instructions to this type of upgrade I mean from RTIR 3.0 to 3.0.2.

I’m afraid I don’t understand this sentence.

You’re running pre-release software with a ton of known bugs that have
been fixed, and you won’t upgrade?

RTIR ships with a README which refers to UPGRADING which refers to
version specific UPGRADING-3.0, all of which are available on
http://bestpractical.com/docs/rtir/3.0/

-kevin