[rt-users] Applying the RTIR_FindIP.pm when changing queues instead of On Create
Kevin Falcone
falcone at bestpractical.com
Thu Jun 27 15:55:35 EDT 2013
On Wed, Jun 26, 2013 at 09:59:43AM -0700, Landon wrote:
> Hello RT Users,
> We have a *ton* of tickets in a queue from another instance of RT in our instance of RTIR
> (RT4/RTIR3). I've been able to modify the Lifecycles so that I can move tickets to the
> "Incident Reports" queue now (thanks Kevin for your advice with that). I'd like tickets moved
> to that queue treated like new Incident Report tickets in RTIR but hitting some snags.
> The condition for On Queue Change itself isn't a problem since that part is pretty straight
> forward (either using the built in "On Queue Change" or a user defined condition).
> The problem is that the provided "SetIPFromContent" (which presumably is the RTIR_FindIP.pm)
> doesn't work when using "On Queue Change" as a condition. This is probably because the content
> of the transaction is that of a queue change and does not contain any correspondence-style
> content and it's not something you can run against the action. What I need however is
> something that will run against each part (attachment?) of this already existing ticket.
> I attempted to do this using a simple loop over each of the transactions but it's kind of
> hacked up and the loop doesn't even seem to run once (as if there are no transactions with
> attachments).
rt-crontool has the --transaction all argument for exactly this usage.
Move your tickets, run rt-crontool (search or condition to find the
tickets) --action FindIP --transaction all
RT will scrap the complete history of those tickets running them
through IP extractor (so all Create/Comment/Correspond would be
checked).
http://bestpractical.com/rt/docs/latest/rt-crontool.html
-kevin
> NAME: OnQueueChange Find IPs
> Condition: On Queue Change
> Action: User Defined
> Template: Blank
> Stage: Transaction Create
> Condition and Preperation: "return 1;"
> Cleanup Code:
> use Regexp::Common qw(net);
> use NetAddr::IP;
> use Data::Validate::IP qw(is_ipv4 is_ipv6);
> my $attachments = $self->TransactionObj->Attachments;
> my @ourips = RT->Config->Get('OurIPs');
> my $CF_Obj = RT::CustomField->new($RT::SystemUser);
> $CF_Obj->LoadByName( Name => "URL" ); # *** See note
> my @inserted;
> # Loop over each attachment in the TransactionObj and trap IPv4 and IPv6 addresses.
> # Insert those into the "IP" CustomField.
> # *** Note - For testing I've changed it to URL and I'm trying to simply write \
> # *** - the word "TEST" instead.
> # *** - URL is a valid CF and this AddValueForObject works outside the \
> # *** - while loop below.
> #
> while (my $message = $attachments->Next) {
> next unless $message->ContentType =~ m!^(text/html|text/plain|message|text$)!i;
> my $content = $message->Content;
> my @lines = split(/\n/,$content);
> foreach my $line (@lines) {
> if ($line =~ /($RE{net}{IPv4}|$RE{net}{IPv6})/g) {
> $CF_Obj->AddValueForObject( Object => $self->TicketObj, Content => "TEST" )
> unless grep($1, at inserted); # *** See note
> push(@inserted,$ipaddr);
> }
> }
> }
> I've been banging my head against this for a few hours now and can't get the loop to work it
> seems let alone find a way to do this more natively with RTIR_FindIP.pm.
> Thanks for reading!
> --
> Landon Stewart <LandonStewart at Gmail.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 235 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20130627/d5d943d5/attachment.sig>
More information about the rt-users
mailing list