views:

209

answers:

2

Working from the Bugzilla API, I've written a quick Perl script to clone a Bugzilla Product (recreating all the Components under their new Product). The Bugzilla Perl API is quite easy to use from the command line. I could have just worked on the database directly, but I wanted a longer-term solution. Another option was the webservice, but I thought I'd try using the API directly this time.

The one problem I'm running into is authenticating as my Bz admin user so I can create the new components. Looking at Bugzilla's Bugzilla.pm file, I see that they just run login() from a Bugzilla::Auth object. I'm not sure how to get the username and password in there. I suppose I could just add the script to the Bugzilla admin interface...

Can any of you point me in the right direction?

+2  A: 

There's been some significant upgrades in the web services capabilities since 3.2, can you upgrade?

In 3.6 at least, check out contrib/bz_webservice_demo.pl for how to use the User.login method.

http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/User.html

David M
Upgrading is non-trivial due to some local customizations, but I'd like to do it someday. As I look at it, though my real problem using the web services is that I don't see any way to add new Products or Components.[1]: http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Product.html
Allan Anderson
+1  A: 

Oh, I'm being rather ignorant today, I focused on "web services" and didn't understand what you really wanted.

If you're just using the API to communicate with the database (as opposed to manipulating the database directly), do you really need to authenticate as any user at all?

In the 3.2 source tree, look at merge-users.pl for instance, which uses Bugzilla::User objects. Couldn't you do the same with Bugzilla::Component?

You should also look at sanitycheck.pl, which uses Bugzilla->set_user.

David M
Thank you; that's very helpful. I wound up just using Bugzilla->set_user() along with Bugzilla->usage_mode(Bugzilla::Constants::USAGE_MODE_CMDLINE), which let my script copy all the components I wanted.
Allan Anderson