Really helpful thread! I managed to do the same for the slurm accounts;
class SlurmData
def self.accounts
username = Etc.getlogin
accounts = []
IO.popen 'sacctmgr -np show accounts withassoc format=account,user' do |io|
io.each do |line|
acc = line.split('|')
if acc[1] == username
accounts.append(acc[0])
end
end
end
return accounts
end
end
combined with
bc_account:
widget: "select"
label: "Project"
options: [<%= SlurmData.accounts.join(', ') %>]
(Note: I had to modify bc_account to allow it to specify a custom widget type, as it was hardcoded to text_field)
Edit: The use of the bracket list yml syntax here was to avoid errors if for some reason the list happened to be empty. An empty
options:
causes errors.