The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

HTCondor::Queue::Parser

SYNOPSIS

  my $cparser = HTCondor::Queue::Parser->new();
  
  my @condor_q =  read_file( 't/input.txt' ) ; # Text file with condor_q -global or condor_q output
  
  my %schedds_map = $cparser->load_schedds_xml(\@condor_q);
  
  foreach my $schedd (keys %schedds_map) {
        # This allows you to have simplified XMLs per schedd, that won't break XML parsers.
        # Default condor_q -global -l -xml does not outputs an 
        my $simple_xml = $schedds_map{$schedd}{'xml'};
        
  }

INITIAL RELEASE WARNING

This is the first 'working' version that was decent enough to upload to CPAN. You might find problems as it was not fully reviewed or tested by other people. Reviews and bug reports are welcome at :

        https://github.com/samircury/HTCondor--Queue--Parser/issues 
 

DESCRIPTION

Outputs condor queue's jobs different ways : Simpler XML per schedds, JSON

HTCondor's default output looks like :

  <c>
     <a n="MyType"><s>Job</s></a>
     <a n="TargetType"><s>Machine</s></a>
     <a n="PeriodicRemove"><b v="f"/></a>
     <a n="CommittedSlotTime"><i>0</i></a>
     <a n="Out"><s>_condor_stdout</s></a>
  </c> # Fake line -- truncated for the example
   

Converted, simpler XML from this module looks like more :

  <?xml version="1.0"?>
  <classads>
    <c>
      <MyType> Job </MyType>
      <TargetType> Machine </TargetType>
      <ClusterId> 790960 </ClusterId>
      <QDate> 1312487190 </QDate>
      <CompletionDate> 0 </CompletionDate>
      <Owner> uscmsPool1639 </Owner>
      <LocalUserCpu> 0.000000000000000E+00 </LocalUserCpu>
      <LocalSysCpu> 0.000000000000000E+00 </LocalSysCpu>
      <ExitStatus> 0 </ExitStatus>
      <NumCkpts_RAW> 0 </NumCkpts_RAW>
      <NumCkpts> 0 </NumCkpts>
      <NumRestarts> 0 </NumRestarts>
      <NumSystemHolds> 0 </NumSystemHolds>
      <CommittedTime> 0 </CommittedTime>
    </c> # Fake line -- truncated for the example
  </classads> # Fake line -- truncated for example

METHODS

new

        # This will only create the object then you can play with it later (see other methods)
        my $cparser = Condor::QueueParser->new();
        

load_schedds_xml

        # Here one should load the RAW output from $(condor_q -global -l -xml) it will spit a non-XML format and be converted later.
        $cparser->load_schedds_xml(\@condor_q);
        # What it does under the hood, is to get REAL XML for each schedd that the condor_q will present.
        # $cparser->{'schedds_map'}  will be then loaded with a key per schedd, which contains the {'xml'} already

convert_to_compatible_xml

Before this method runs, {xml} will contain the standard condor XML :

        <classads><c>   <a n="MyType"><s>Job</s></a>  

Afterwards, it will contain what I call "more compatible" XML :

        <classads>  <c> <MyType> Job </MyType> <TargetType> Machine </TargetType> 

xml_to_hrefs

This one should get the content of $self->{'schedds_map'}{$schedd}{'xml'} and populate $self->{'schedds_map'}{$schedd}{'href'} with a Perl equivalent multilevel hash, which will be the native format to Perl information, and you can use it in your application

schedd_json

Maybe the most useful way to use it is :

        foreach my $schedd (keys %{$cparser->{'schedds_map'}}) {
                my $json = $cparser->schedd_json($schedd);
                # do something with $json;
        }

SUPPORT

You will have more luck at https://github.com/samircury/HTCondor--Queue--Parser/issues

The CPAN's tracking system is also an option.

AUTHOR

Copyright 2014 Samir Cury.