#!/bin/bash

################################################################################
################################################################################
# Copyright 2023-2025 by NI SP Software GmbH, All rights reserved.
# Copyright 1999-2023 by Nice, srl., All rights reserved.
#
# This software includes confidential and proprietary information
# of NI SP Software GmbH ("Confidential Information").
# You shall not disclose such Confidential Information
# and shall use it only in accordance with the terms of
# the license agreement you entered into with NI SP Software.
################################################################################
################################################################################

. "${EF_ROOT}/plugins/ef/lib/utils"
. "${EF_ROOT}/plugins/lsf/bin/lsf.commands"

_my_awk=`ef_find_awk`

${EF_LSF_BQUEUES} -l | ${_my_awk} \
    -f "${EF_ROOT}/plugins/ef/lib/awk/utils.awk" \
    -f <( echo '
/\r$/              { gsub("\r$","") } # change Windows newlines to Unix
BEGIN          { first = 1;
                     print "<grid:queue-list type=\"lsf\" xmlns:grid=\"http://www.enginframe.com/2000/GRID\">" ;
                     FS=" "; getline }
END            { if (!first) print "  </grid:queue>";
                     print "</grid:queue-list>" ; }
/^QUEUE:/          { if (!first) print "  </grid:queue>";
                first = 0;
                     print "  <grid:queue> ";
                     print "    <grid:name>" escapeXmlContent($2) "</grid:name>";
                   }
/^ADMINISTRATORS:/ {  print "    <grid:administrators>" escapeXmlContent($2) "</grid:administrators>";
                   } ')




