7 Replies Latest reply on Oct 28, 2009 11:44 AM by Vinnie Lima

    Bug in RedHatRepositoryManager.jar for Linux VPC?

    Vinnie Lima

      Got a peculiar problem which I don't know if it's a VPC for linux or my own stupidity on my perl scripting abilities.

       

      I wrote a Perl wrapper to execute RedHatRepositoryManager.sh.  This wrapper takes inputs from the Job, determines what Red Hat Repository this job should run against, and then executes the command line via the "exec" function in Perl.

       

      The problem I am having is that the native RedHatRepositoryManager.nsh script (RedHatRepositoryManager.sh is just a wrapper that calls nsh) is stripping the first "/" slash from the path to the repository.  So jobs that runs end up having the following error:

       

      Info    Oct 26, 2009 5:34:55 PM    Started running the job 'Repository Update - RHEL-PRIMARY' on application server 'emda-nbp-uea21.corp.csa.ic.gov'(1)
      Info    Oct 26, 2009 5:34:56 PM    Executing work item NSH Script Job:Repository Update - RHEL-PRIMARY;  on application server: emda-nbp-uea21.corp.csa.ic.gov
      Info    Oct 26, 2009 5:34:57 PM    Checking default java version.... 1.5.0_20
      Info    Oct 26, 2009 5:34:58 PM    Loading the configuration file "/opt/bmc/bcas/patch/SupportFiles/RedHatRepositoryManager/configuration.properties"
      Info    Oct 26, 2009 5:34:58 PM    Initializing ...
      Info    Oct 26, 2009 5:34:58 PM    Directory /emda-nbp-uea21/opt/bmc/bcas/patch/rhel-repo does not exist or not a directory. Creating one....
      Info    Oct 26, 2009 5:34:58 PM    Could not create /emda-nbp-uea21/opt/bmc/bcas/patch/rhel-repo. Can not proceed...
      Info    Oct 26, 2009 5:34:58 PM    Exit Code 0
      Info    Oct 26, 2009 5:34:58 PM    The job 'Repository Update - RHEL-PRIMARY' has succeeded

       

       

      So I copied the whole NSH script (which is just a perl script) that is executed against this host, and I am running locally, and it still complains that "/emda-nbp-uea21/opt/bmc/bcas/patch/rhel-repo" doesnt exist. But because I am running as "root", it runs fine as it has the necessary privileges to create the directory (whereas via the job, it runs as bladmin and it doesn't).

       

      Here's what I validated so far:

      1. The exact command that is executed via the "exec" function is indeed making to the exec command in the proper form (e.g. I echo it out in the script while having the exec command commented off, and the two slashes are there).
      2. I've tested if escaping any "forward" slash before executed by "exec" makes any difference. It doesnt.
      3. I've tested running the command interactively, and the same problem occurs. Again, I never noticed before as I was running it as "root" thus the erroneous directory creation was done without much alarm:

        [root@emda-nbp-uea21 Work]# /opt/bmc/bcas/patch/SupportFiles/RedHatRepositoryManager/RedHatRepositoryManager.sh -command createUpdateRepo -channel rhel-x86_64-server-5 -yumRepo y -repoLocation //emda-nbp-uea21/opt/bmc/bcas/patch/rhel-repo

        Checking default java version.... 1.5.0_20
        Loading the configuration file "/opt/bmc/bcas/patch/SupportFiles/RedHatRepositoryManager/configuration.properties"
        Initializing ...
        Directory /emda-nbp-uea21/opt/bmc/bcas/patch/rhel-repo does not exist or not a directory. Creating one....
        "-yumRepo" or "-obsoleteYum" parameters are missing......considering values from "configuration.properties" file.
        Create Update Repository Channel label - rhel-x86_64-server-5 Repository path - //emda-nbp-uea21/opt/bmc/bcas/patch/rhel-repo.
        Previous cached credentials Found...
        Checking the packages available for channel rhel-x86_64-server-5 for downloading...

       

      Thanks for any input. You can run the below by doing:

       

      ./test.pl -r RHEL-PRIMARY -a UPDATE  (note, RHEL-PRIMARY translates to //emda-nbp-uea21/opt/bmc/bcas/patch/rhel-repo).

       

      <snip>

      #!/usr/bin/perl

       

      use Getopt::Std;
      use FileHandle;
      use Getopt::Std;
      use Cwd;

       

      getopts('r:a:f:');

       

      $REPO_NAME = $opt_r ;
      $ACTION = $opt_a ;
      $HOST = $opt_f ;

       

      $REPO_FILE="/opt/bmc/bcas/patch/linuxpu/Work/linuxrepo.conf" ;
      $RHDL_PATH="/opt/bmc/bcas/patch/SupportFiles/RedHatRepositoryManager" ;
      $COMMAND = "NOTSET" ;

       

      if ($ACTION =~ /YUMMIFY/)
      {
              $COMMAND = "yummifyRepo" ;
      }
      elsif ($ACTION =~ /UPDATE/)
      {
              $COMMAND = "createUpdateRepo -channel rhel-x86_64-server-5 -yumRepo y" ;
      }

       

      open REPOFILE, "<", $REPO_FILE ;

       

      while (<REPOFILE>)
      {
              s/#.*//;
              chomp;
              if ($_ =~ /$REPO_NAME/)
              {
                      ($junk, $repostring) = split(/=/, $_) ;
                      ($REPO_LOC, $junk2) = split(/,/, $repostring) ;

       

                      $REPO_LOC =~ s/\//\\\//g ;

       

                      $EXECUTE = "$RHDL_PATH/RedHatRepositoryManager.sh -command $COMMAND -repoLocation $REPO_LOC" ;

       

                      system($EXECUTE) ;
                      #print "$EXECUTE\n" ;
              }
      }

       

      </snip>

        • 1. Re: Bug in RedHatRepositoryManager.jar for Linux VPC?
          Vinnie Lima

          Fixed.  Bug in documentation and linuxrepo.conf.  Don't specify the NSH path to the system in linuxrepo.conf - it wont work. You need to specify the local directory e.g. /opt/bmc/bcas/patch/rhel-repo

           

          Thanks.

          • 2. Re: Bug in RedHatRepositoryManager.jar for Linux VPC?
            Bill Robinson

            linuxrepo.conf will take an nsh path, but you're saying that you can't use an nsh path for the repoLocation you pass to the RedHatRepositoryManager script?

            • 3. Re: Bug in RedHatRepositoryManager.jar for Linux VPC?
              Vinnie Lima

              linuxrepo.conf , and thus redhatrepositorymanager.sh (or .nsh), do not work with the NSH path (e.g. //servername/blah/path/to/repo).

               

              I've tried every possible combination. Once I changed the linuxrepo.conf to reference a regular directory (e.g. /blah/path/to/repo), it then worked.

              • 4. Re: Bug in RedHatRepositoryManager.jar for Linux VPC?
                Bill Robinson

                the repomanager doesn't read the linuxrepo.conf file.   you have to pass the path to the repo to the RedHatRepoManager.sh directly.  maybe there's a wrapper script that's calling the RedHatRepoManager.sh script that reads the linuxrepo.conf (i wrote one for you that did that).  that would need to strip out the //<server>.

                • 5. Re: Bug in RedHatRepositoryManager.jar for Linux VPC?
                  Vinnie Lima

                  Yes true the shell script doesn't read the linuxrepo.conf (my wrapper does) but if you execute the shell script directly and pass the "//" as repo location, it will automatically strip the first /.

                   

                  So, like I mentioned before, it seems that something internal to the JAR file is not able to handle NSH paths for the repo location:

                   

                  [root@emda-nbp-uea21 Work]# /opt/bmc/bcas/patch/SupportFiles/RedHatRepositoryManager/RedHatRepositoryManager.sh -command createUpdateRepo -channel rhel-x86_64-server-5 -yumRepo y -repoLocation //emda-nbp-uea21/opt/bmc/bcas/patch/rhel-repo

                   

                  Checking default java version.... 1.5.0_20
                  Loading the configuration file "/opt/bmc/bcas/patch/SupportFiles/RedHatRepositoryManager/configuration.properties"
                  Initializing ...
                  Directory /emda-nbp-uea21/opt/bmc/bcas/patch/rhel-repo does not exist or not a directory. Creating one....
                  "-yumRepo" or "-obsoleteYum" parameters are missing......considering values from "configuration.properties" file.
                  Create Update Repository Channel label - rhel-x86_64-server-5 Repository path - //emda-nbp-uea21/opt/bmc/bcas/patch/rhel-repo.
                  Previous cached credentials Found...
                  Checking the packages available for channel rhel-x86_64-server-5 for downloading..

                  • 6. Re: Bug in RedHatRepositoryManager.jar for Linux VPC?
                    Bill Robinson

                    The jar definately won't, and the underlying binaries that it calls (createrepo) don't know nsh either.  so you need to strip out the //<server> from the path in your wrapper before you pass it to the repomanager.

                    • 7. Re: Bug in RedHatRepositoryManager.jar for Linux VPC?
                      Vinnie Lima

                      Bill - thanks but already know that

                       

                      An official defect case ID was opened about this in either way.  Either documentation needs to be updated (even the linuxrepo.conf references NSH path for examples!) or the script needs to be updated to handle NSH paths.

                       

                      Thanks again for the help.