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

NAME

Slurm::Sacctmgr::Account;

SYNOPSIS

  use Slurm::Sacctmgr::Account;
  use Slurm::Sacctmgr;

  my $sacctmgr = new Slurm::Sacctmgr;
  my $list = Slurm::Sacctmgr::Account->sacctmgr_list($sacctmgr);

  #List all accounts known to sacctmgr
  foreach $account (@$list)
  {     #account is a Slurm::Sacctmgr::Account object
        $name = $account->account;
        $desc = $account->description;
        $org = $account->organization;
        print "$name ($org) [$desc]\n";
  }

  #Get a single account 
  $name = 'test-account';
  $account = Slurm::Sacctmgr::Account->new_from_sacctmgr_by_name($sacctmgr,$name);
  $desc = $account->description;
  print "Description for account '$name' is '$desc'\n";

  #Set cpumin limit and zero usage on an account
  $cluster='test-cluster';
  $cpumin = 4*1000*60; #4 kSU
  #Old, deprecated way
  Slurm::Sacctmgr::Account->set_cpumin_limit_on_account_cluster($sacctmgr,$name, $cluster, $cpumin);
  #New way 
  Slurm::Sacctmgr::Account->set_grptresmin_on_account_cluster($sacctmgr,$name, $cluster, { cpu => $cpumin} );
  Slurm::Sacctmgr::Account->zero_usage_on_account_cluster($sacctmgr,$name, $cluster);

  ...

DESCRIPTION

Represents a Account entity in Slurm::Sacctmgr. Together with an instance of Slurm::Sacctmgr, this class allows one to issue commands to the Slurm sacctmgr command to add, delete, list, show, and modify sacctmgr entities of type "account".

The Slurm::Sacctmgr class provides a Perlish wrapper around the actual Slurm sacctmgr command, thus the methods provided by this class largely map quite straightforwardly onto sacctmgr commands. When using the sacctmgr_list method for this class, the results from the sacctmgr command is automatically parsed and presented as objects of this class.

Objects of this class contain the following data members:

account: the accountname of the account/allocation.
organization: the organization the account/allocation belongs to.
description: the description of the account/allocation.

and these are the fields that will be set by the sacctmgr_list and similar methods. When filtering results, you can use any fields recognized by the sacctmgr command, and when adding/modifying records you can provide any fields recognized by the command.

Most functionality is provided via the base classes,

Slurm::Sacctmgr::EntityBaseRW
Slurm::Sacctmgr::EntityBaseListable
Slurm::Sacctmgr::EntityBaseModifiable
Slurm::Sacctmgr::EntityBaseAddDel
Slurm::Sacctmgr::EntityBase

As a result, the whole Slurm::Sacctmgr::* family (for different entity types) all have a very similar account interface (basically the differences are what operations sacctmgr allows on different entity types, and how the results of list/show operations get parsed).

The remainder of this page briefly discusses the more commonly used methods for this class, but the base classes above contain fuller documentation. In all that follows, the variable $sacctmgr is a required instance of Slurm::Sacctmgr, and the invocant is not explicitly shown.

The following special class methods are defined in this class; the invocant can be either the class name or an instance of this class.

set_cpumin_limit_on_account_cluster($sacctmgr, $name, $cluster, $cpumin)

This is DEPRECATED in favor of set_grptresmin_on_account_cluster. It is currently just an alias for the latter.

set_grptresmin_on_account_cluster($sacctmgr, $name, $cluster, $tresmin)

This sets the GrpTresMin limits on a specific account/cluster as specified in $tresmin. $tresmin should be a hash ref with TRES names as keys and the corresponding limit as the value. TRES names which are not listed will be unchanged; use a value of -1 to remove an existing limit. $tresmin can also be a scalar TRES string, e.g. "cpu=100000,mem=500", etc. If $tresmin is a non-reference scalar that looks like a number, it will be convertedto the hash { cpu => $tresmin } to provide backwards compatibility with the old set_cpumin_limit_on_account_cluster method.

This method will automatically adapt the resulting sacctmgr command for the version of Slurm being run; i.e. on versions of Slurm before TRES was implemented, only the cpu TRES will be considered and its value will be used to set GrpCPUMins (and any other TRES fields will result in a warning).

zero_usage_on_account_cluster($sacctmgr, $name, $cluster)

This will modify the sacctmgr record assocation with account $name in cluster $cluster, setting RawUsage to 0.

The following class methods are available: these will take either an instance of Slurm::Sacctmgr::Account or the "Slurm::Sacctmgr::Account" class name as the invocant.

sacctmgr_list($sacctmgr, %where)

This will return a list reference of all objects of entity type "account" matching the "where" clause. The "where" clause is a list of zero or more key => value pairs specifying the conditions. Only exact matching is supported, and keys cannot be usefully repeated (the "where" clause is treated as a hash, so later keys simply overwrite earlier keys). You can use any parameter the Slurm sacctmgr command allows you to filter on. If no key => value pairs are given, all entities of this type are returned.

new_from_sacctmgr_by_name($sacctmgr, $accountname)

This looks up in sacctmgr the account entity with the specified accountname, and returns the corresponding Slurm::Sacctmgr::Account object. If no entity with specified accountname was found, returns undef.

sacctmgr_add($sacctmgr,%fields)

This method adds a new account entity to sacctmgr's databases. The entity to add will be defined by the "%fields" list of key => value pairs; valid keys are any parameters sacctmgr allows you to set when adding accounts. In addition, the "pseudofield" --ok-if-previously-exists can be given, and if true the method will not complain at attempts to add an entity which already exists.

sacctmgr_delete($sacctmgr, %where)

This method will delete one or more account entities matching the "where" clause. The where clause behaves as discussed in sacctmgr_list.

sacctmgr_modify($sacctmgr, $where, $update)

This will update the account entities matching the "where" clause as indicated by the "update" clause. Both $where and $update are list references of key => value pairs. The where clause behaves as in sacctmgr_list (except that it is a array reference, not a list), and similarly the update clause behaves as in sacctmgr_add.

The following instance methods are available, which require an instance of Slurm::Sacctmgr::Account as the invocant. With the exception of sacctmgr_save_me, they basically correspond to the class methods above, except will take basic parameters from the invocant.

sacctmgr_list_me($sacctmgr)

This will look up in the Slurm database and return the corresponding Slurm::Sacctmgr::Account instance for the account in the Slurm database with the same account name as the invocant. I.e., it returns what Slurm thinks the current Account object should be.

sacctmgr_add_me($sacctmgr,%extra_fields)

This will add the to the Slurm database the account corresponding to the invocant. Any key => value pairs in extra fields will also be supplied to the sacctmgr add command.

sacctmgr_delete_me($sacctmgr)

This will delete from the Slurm database the account with the same name as the invocant.

sacctmgr_modify_me($sacctmgr,%fields)

This will invoke a sacctmgr modify command on the account matching the name in the invocant, setting the fields in %fields.

sacctmgr_save_me($sacctmgr,%fields)

This is sort of a combination of sacctmgr_list_me, sacctmgr_add_me and sacctmgr_modify_me. First, sacctmgr_list_me is invoked to determine if the invocant exists in the Slurm database, and if so what is stored there for it. If it does not exist, it is sacctmgr_add_me-ed, with the extra data in %fields. If it already exists in the Slurm databases, the values stored there are compared to those of the invocant, and a sacctmgr_modify_me command will be invoked to bring the database in line with the invocant (as well as providing the extra arguments from %fields). If no extra %fields are given, and the invocant is already in the Slurm database and no data members differ, no seconds sacctmgr command is called.

EXPORT

Nothing. Pure OO interface.

SEE ALSO

Slurm::Sacctmgr::EntityBase
Slurm::Sacctmgr::EntityBaseListable
Slurm::Sacctmgr::EntityBaseAddDel
Slurm::Sacctmgr::EntityBaseModifiable
Slurm::Sacctmgr::EntityBaseRW
sacctmgr man page

AUTHOR

Tom Payerle, payerle@umd.edu

COPYRIGHT AND LICENSE

Copyright (C) 2014-2016 by the University of Maryland.

This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:

http://www.perlfoundation.org/artistic_license_2_0

Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.

If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.

This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.

This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.

Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.