Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
2 replies Latest Post - ‏2013-09-26T19:16:52Z by DevM
DevM
DevM
9 Posts
ACCEPTED ANSWER

Pinned topic PERL API external Login Fails

‏2013-09-24T19:37:30Z |

Hello,

  I am writing a script to (at the moment) just to login to my synergy change 5.3 using the PERL API. This is what it looks like (code snippet):

 

use lib "/auto/synergy/Change/perl_modules/site_perl";
use lib "/local/ibm/change/change53_45/jetty/webapps/nswc/WEB-INF/perl/lib";
use lib "/local/ibm/change/change53_45/jetty/webapps/nswc/WEB-INF/perl/lib/perl5/5.8.6";
use lib "/local/ibm/change/change53_45/jetty/webapps/nswc/WEB-INF/perl/lib/perl5/site_perl/5.8.6";

use utf8;
use DBI;
use CGI qw/:standard/;
use Getopt::Long;
use Time::Local;
use ChangeSynergy::csapi;
use FileHandle;
use strict;

###### BEGIN USER CONFIG SECTION ######

# pull in parameters and declare rest
my $dbase    = shift;
my $port     = shift;
my $username = shift;
my $password = shift;

# Define System Globals
my $csapi = new ChangeSynergy::csapi(); # CS API object used to talk with CS server.

# Login information
my $host    = "arizona";
my $protocol= "http";
my $role    = "User";
my $db = "/auto/synergy/ccmdb/$dbase";
my $http = "http://138.109.248.240:$port";

#Declare Local Variables
my $keywords;
my $query;
my $result;
my $reportData;
my $attributeData;
my $dbi;
my $crid;
my $user="";
my $j;
my $sourceAttrs;
my $statusFile = "import.log"; # The name of the import log file

#########################################################################
#                      BEGIN MAIN EXECUTION                                        #
#########################################################################
# Establish our connection to Synergy
print "Connecting to SYNERGY/Change<BR>\n";
initialize();

$keywords = "problem_number|problem_synopsis";
$query = "cr_type = 'problem'";
$result = $csapi->QueryData($user, "Basic Summary", $query, undef, undef, undef, $keywords);

if ($result->getDataSize() > 0)
{
   $reportData = $result->getDataObject(0);

   # Loop for troubleshooting! CharranX
    my $printIt;
    for($j = 0; $j < $reportData->getDataSize(); $j++)
    {
        $attributeData = $reportData->getDataObject($j);
        $printIt = $attributeData->getValue();
    }
    print "Output: $printIt<BR>\n";
}



#########################################################################
#
# Basic script initialization to prepare for importing.  Open the log file, setup the connection parameters,
# login the user who is to perform the import operation.  This user must have the ccm_admin role.  And finally
# get the current list of source attributes.
#
sub initialize
{

  eval
    {
       openLogFile($statusFile);
       # Take input from Login screen

       $csapi->setUpConnection($http);
    
       if ($@) # Remove this!?!
       {
          printToLog($@, 1);
       }


          $user = $csapi->Login($username, $password, $role, $db);

 

#########End Snippet###########


 The code does continue but that is unimportant. I know it works up until it implements this Login call. Then the code errors out.

  The message I get in the Event Log is "Unable to establish connection with RDS".

Am I missing a path variable? Do I need to prep the RDS to accept my username/password. I believe I have my connection set up right since the error message is showing up in the right Event Log.

 

What am I missing?

Any help would be appreciated.

 

Thank You,

  DevM

  • jkrause
    jkrause
    11 Posts
    ACCEPTED ANSWER

    Re: PERL API external Login Fails

    ‏2013-09-25T16:08:19Z  in response to DevM

    DevM,

    First, a side note - this question might have been better posted in the "Enterprise Change Management with Rational Change" forum.

    The message "Unable to establish connection with RDS" indicates that the Change server is not able to connect with the RDS installation, which would cause all login attempts to fail.  Check that RDS is up and running and that you can login to Change using the same credentials from a browser.  

    Also, it looks like your declaration of $http  needs to have the context appended to it, e.g.

    my $http = "http://138.109.248.240:$port/change";  # use your context directory here if not the default

    I hope these suggestions help.

    Jeff

    • DevM
      DevM
      9 Posts
      ACCEPTED ANSWER

      Re: PERL API external Login Fails

      ‏2013-09-26T19:16:52Z  in response to jkrause

      Jeff,

        Thanks for the response. Good news it turned out to be operator error. They changed the database location without telling me. So my db string was pointing to the wrong thing. It's working fine now.

      Thanks,

        DevM