Re: [rt-users] Programmatically create queues

2014-09-12 Thread Karres, Dean
A list member clued me in off-line:  IMHO the RT::Queue "Create" docs leave a 
lot to be desired.  The argument in the title says "Args" but the description 
says "hash".  Due to the way the Create function actually interpolates the 
"Args" you can't pass a hash, as I understand the term.  You instead pass the 
key value pairs, a la:

$queue->Create(
Name=>"WWW",
Description=>"Web related issues",
CorrespondAddress=>"",
CommentAddress=>"",
InitialPriority=>"0",
FinalPriority=>"0",
DefaultDueIn=>"0"
);

Note, no curly braces.  





-Original Message-
From: rt-users [mailto:rt-users-boun...@lists.bestpractical.com] On Behalf Of 
Karres, Dean
Sent: Friday, September 12, 2014 1:26 PM
To: rt-users@lists.bestpractical.com
Subject: [rt-users] Programmatically create queues

Hi,

I am new to RT.  I have a test install of RT 4.2.6 on a RHEL 6.x platform.  It 
seems to work and I am newbie-lost in the universe of setting permissions -- 
but that is not currently my issue.

Our current helpdesk system has a bunch of queue-like things.  I don't want to 
have to click through the GUI to create them all.  I figured I would save time 
by writing a small script that could create them all quickly.  Apparently my 
newbie understanding of RT in general applies to trying to code scripts too.  I 
looked at the existing ...rt4/sbin/... scripts and the html RT module docs and 
came up with a one-liner (formatted over multi-lines for readability:

perl -e'use lib qw(/opt/rt4/lib);
use RT -init;
use RT::Queue;
use Data::Dumper;

 my $queue = RT::Queue->new( RT->SystemUser );
$queue->Load("Public Printing");
$queue->Create({
Name=>"WWW",
Description=>"Web related issues",
CorrespondAddress=>"",
CommentAddress=>"",
InitialPriority=>"0",
FinalPriority=>"0",
DefaultDueIn=>"0"
});'

However, when I run it I get:

[27849] [Fri Sep 12 17:56:10 2014] [warning]: Odd number of elements in hash 
assignment at /opt/rt4/lib/RT/Queue.pm line 160. (/opt/rt4/lib/RT/Queue.pm:160) 
[27849] [Fri Sep 12 17:56:10 2014] [warning]: Use of uninitialized value $name 
in length at /opt/rt4/lib/RT/Queue.pm line 317. (/opt/rt4/lib/RT/Queue.pm:317)

Looking in the /opt/rt4/lib/RT/Queue.pm file shows the "args" hash (line 160 in 
the 4.2.6 source) to have several more key tags available than the docs talk 
about.   Don't know if that is an issue.

What am I missing?  My guess is something trivial.

Dean...K...
--
RT Training - Boston, September 9-10
http://bestpractical.com/training
-- 
RT Training - Boston, September 9-10
http://bestpractical.com/training


Re: [rt-users] Programmatically create queues

2014-09-12 Thread Alex Peters
Check out also:

http://bestpractical.com/docs/rt/latest/initialdata.html

as this permits programmatic setup of a bunch of things, which might be
useful to slap into revision control/configuration management/etc.
On 13/09/2014 6:05 am, "Karres, Dean"  wrote:

> A list member clued me in off-line:  IMHO the RT::Queue "Create" docs
> leave a lot to be desired.  The argument in the title says "Args" but the
> description says "hash".  Due to the way the Create function actually
> interpolates the "Args" you can't pass a hash, as I understand the term.
> You instead pass the key value pairs, a la:
>
> $queue->Create(
> Name=>"WWW",
> Description=>"Web related issues",
> CorrespondAddress=>"",
> CommentAddress=>"",
> InitialPriority=>"0",
> FinalPriority=>"0",
> DefaultDueIn=>"0"
> );
>
> Note, no curly braces.
>
>
>
>
>
> -Original Message-
> From: rt-users [mailto:rt-users-boun...@lists.bestpractical.com] On
> Behalf Of Karres, Dean
> Sent: Friday, September 12, 2014 1:26 PM
> To: rt-users@lists.bestpractical.com
> Subject: [rt-users] Programmatically create queues
>
> Hi,
>
> I am new to RT.  I have a test install of RT 4.2.6 on a RHEL 6.x
> platform.  It seems to work and I am newbie-lost in the universe of setting
> permissions -- but that is not currently my issue.
>
> Our current helpdesk system has a bunch of queue-like things.  I don't
> want to have to click through the GUI to create them all.  I figured I
> would save time by writing a small script that could create them all
> quickly.  Apparently my newbie understanding of RT in general applies to
> trying to code scripts too.  I looked at the existing ...rt4/sbin/...
> scripts and the html RT module docs and came up with a one-liner (formatted
> over multi-lines for readability:
>
> perl -e'use lib qw(/opt/rt4/lib);
> use RT -init;
> use RT::Queue;
> use Data::Dumper;
>
>  my $queue = RT::Queue->new( RT->SystemUser );
> $queue->Load("Public Printing");
> $queue->Create({
> Name=>"WWW",
> Description=>"Web related issues",
> CorrespondAddress=>"",
> CommentAddress=>"",
> InitialPriority=>"0",
> FinalPriority=>"0",
> DefaultDueIn=>"0"
> });'
>
> However, when I run it I get:
>
> [27849] [Fri Sep 12 17:56:10 2014] [warning]: Odd number of elements in
> hash assignment at /opt/rt4/lib/RT/Queue.pm line 160.
> (/opt/rt4/lib/RT/Queue.pm:160) [27849] [Fri Sep 12 17:56:10 2014]
> [warning]: Use of uninitialized value $name in length at
> /opt/rt4/lib/RT/Queue.pm line 317. (/opt/rt4/lib/RT/Queue.pm:317)
>
> Looking in the /opt/rt4/lib/RT/Queue.pm file shows the "args" hash (line
> 160 in the 4.2.6 source) to have several more key tags available than the
> docs talk about.   Don't know if that is an issue.
>
> What am I missing?  My guess is something trivial.
>
> Dean...K...
> --
> RT Training - Boston, September 9-10
> http://bestpractical.com/training
> --
> RT Training - Boston, September 9-10
> http://bestpractical.com/training
>
-- 
RT Training - Boston, September 9-10
http://bestpractical.com/training