This file is indexed.

/usr/lib/oar/oar_resources_add is in oar-server 2.5.6-2ubuntu1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#!/bin/bash

HOSTS=
CPUS=2
CORES=4
THREADS=1
HOST_PREFIX="node-"
YAML=""
CREATE_PROPERTIES=1
USE_THREADS=""

usage() {
  cat <<EOF
Usage:
    $0 -H <# of hosts> [other options]

    Generate commands to add new resources to OAR database

Options:
    -T, --use-threads           use the thread resource property
    -H, --hosts <#>             # of hosts
    -C, --cpus <#>              # of cpu per host
    -c, --cores <#>             # of core per cpu
    -t, --threads <#>           # of threads per core
    --host0 <#>                 first host id to use
    --cpu0 <#>                  first cpu id to use
    --core0 <#>                 first core id to use
    --thread0 <#>               first thread id to use
    --cpuset <#>                # of cpusets/host (default: cpus*cores*threads)
    --host-prefix <str>         hostname prefix (default: "node-")
    --host-suffix <str>         hostname suffix (e.g. ".domain")
    -a, --auto-offset           guess first host/cpu/core/thread ids
    -p, --no-create-properties  do not generate oarproperty commands
    -A, --append <str>          append a text string (extra properties)
    -o, --write-to <file>       write commands to file
    -Y, --yaml                  generate YAML output
    -h, --help                  display this message

EOF
}

die() {
  cat <<EOF 2>&1
Error: $1

EOF
  usage 2>&1
  exit 1
}

LONG_OPTS="hosts:,cpus:,cores:,threads:,host-prefix:,host-suffix:,host0:,cpu0:,core0:,thread0:,cpuset:,append:,use-threads,write-to:,auto-offset,yaml,no-create-properties,help"
SHORT_OPTS="H:C:c:t:P:S:A:o:TaYph"
args=$(getopt -l $LONG_OPTS -o $SHORT_OPTS -q -- "$@")
[ $? -gt 0 ] && die "Syntax error, $(getopt -l $LONG_OPTS -o $SHORT_OPTS -Q -- "$@" 2>&1)"

eval set -- "$args"

while [ $# -ge 1 ]; do
  case "$1" in
  --)
    # No more options left.
    shift
    break
    ;;
  -H|--hosts)
    HOSTS=$2
    shift
    ;;
  -C|--cpus)
    CPUS=$2
    shift
    ;;
  -c|--cores)
    CORES=$2
    shift
    ;;
  -t|--threads)
    THREADS=$2
    shift
    ;;
  -P|--host-prefix)
    HOST_PREFIX=$2
    shift
    ;;
  -S|--host-suffix)
    HOST_SUFFIX=$2
    shift
    ;;
  --host0)
    HOST0=$2
    shift
    ;;
  --cpu0)
    CPU0=$2
    shift
    ;;
  --core0)
    CORE0=$2
    shift
    ;;
  --thread0)
    THREAD0=$2
    shift
    ;;
  --cpuset)
    CPUSET=$2
    shift
    ;;
  -A|--append)
    APPEND=$2
    shift
    ;;
  -o|--write-to)
    WRITE_TO=$2
    shift
    ;;
  -T|--use-threads)
    USE_THREADS=1
    ;;
  -a|--auto-offset)
    AUTO_OFFSET=1
    ;;
  -p|--no-create-properties)
    CREATE_PROPERTIES=
    ;;
  -Y|--yaml)
    YAML=1
    ;;
  -h|--help)
    usage
    exit 0
    ;;
  *)
    usage
    exit 1
    ;;
  esac
  shift
done

[ -n "$HOSTS" ] && [ $HOSTS -gt 0 ] || die "Syntax error, need a # of host"

if [ -n "$WRITE_TO" ]; then
  if [ -e "$WRITE_TO" ]; then
    echo -n > $WRITE_TO
  fi
  exec 1> >(tee -a $WRITE_TO)
fi

CPUSET=${CPUSET:-$((CPUS*CORES*THREADS))}
if [ -n "$AUTO_OFFSET" ]; then
  [ -z "$HOST0" ] && echo "# Warning: guessing a new hostname is not really reliable because of a sort issue for non-numeric properties. Please double-check."
  HOST0=${HOST0:-$(($(oarnodesetting --last-property-value host | perl -pe 's/^[^\d]*(\d+).*/$1/') + 1))}
  CPU0=${CPU0:-$(($(oarnodesetting --last-property-value cpu) + 1))}
  CORE0=${CORE0:-$(($(oarnodesetting --last-property-value core) + 1))}
  if [ -n "$USE_THREADS" ]; then
    THREAD0=${THREAD0:-$(($(oarnodesetting --last-property-value thread) + 1))}
  fi
else
  HOST0=${HOST0:-1}
  CPU0=${CPU0:-0}
  CORE0=${CORE0:-0}
  THREAD0=${THREAD0:-0}
fi

host=1
thread=0
core=0
cpu=0

if [ -z "$USE_THREADS" ]; then
  # Force #threads=1 for the loop below to work. 
  THREADS=1
fi

if [ -n "$CREATE_PROPERTIES" -a -z "$YAML" ]; then
  cat <<EOF
oarproperty -c -a host || true
oarproperty -a cpu || true
oarproperty -a core || true
EOF
  if [ -n "$USE_THREADS" ]; then
    cat <<EOF
oarproperty -a thread || true
EOF
  fi
fi

if [ -n "$YAML" ]; then
  echo "---"
fi

while [ $host -le $HOSTS ]; do
  hostname="'$HOST_PREFIX$((host+HOST0-1))$HOST_SUFFIX'"
  cpuset=0
  while [ $cpu -lt $((CPUS * host)) ]; do
    while [ $core -lt $((CORES * (cpu+1))) ]; do
      while [ $thread -lt $((THREADS * (core+1))) ]; do
        if [ -n "$YAML" ]; then
          if [ -z "$USE_THREADS" ]; then
            cat <<EOF
- network_address: $hostname
  host: $hostname
  cpu: $((cpu+CPU0))
  core: $((core+CORE0))
  cpuset: $cpuset
EOF
            echo -ne "$APPEND"
          else
            cat <<EOF
- network_address: $hostname
  host: $hostname
  cpu: $((cpu+CPU0))
  core: $((core+CORE0))
  thread: $((thread+THREAD0))
  cpuset: $cpuset
EOF
            echo -ne "$APPEND"
          fi
        else
          if [ -z "$USE_THREADS" ]; then
            echo "oarnodesetting -a -h $hostname -p host=$hostname -p cpu=$((cpu+CPU0)) -p core=$((core+CORE0)) -p cpuset=$cpuset $APPEND"
          else
            echo "oarnodesetting -a -h $hostname -p host=$hostname -p cpu=$((cpu+CPU0)) -p core=$((core+CORE0)) -p thread=$((thread+THREAD0)) -p cpuset=$cpuset $APPEND"
          fi
        fi
        ((thread++))
        cpuset=$(((cpuset+1) % CPUSET))
      done
      ((core++))
    done
    ((cpu++))
  done
  ((host++))
done