(Click to open topic with navigation)
There are several ways of interacting with Moab Accounting Manager. Let's consider a simple usage charge in each of the different ways.
In this topic:
5.62.1 Using the Appropriate Command-line Client
From inside a script, or by invoking a system command, you can use a command-line client (one of the "g" commands in the bin directory).
Example 5-118: To issue a charge at the completion of job usage, you could use mam-charge:
mam-charge -J Moab.1234 -a chemistry -u amy -m colony -P 2 -t 3600
5.62.2 Using the Interactive Control Program
The interactive control program, mam-shell, will issue a charge for a job expressed in xml.
Example 5-119: To issue a charge you must invoke the Charge action on the Job object:
mam-shell UsageRecord Charge Data:="<UsageRecord><Instance>Moab.1234</Instance><Account>chemistry</Account><User>amy</User><Machine>colony</Machine><Processors>2</Processors><Duration>3600</Duration></UsageRecord>" Duration:=3600
The Perl API exposes the full functionality of Moab Accounting Manager. The client commands can be examined as sample code. Use perldoc on the modules in lib/mam for function documentation.
Example 5-120: To make a charge via this interface you might do something like:
use MAM;
my $request = new MAM::Request(object => "UsageRecord", action => "Charge");
my $usageRecord = new MAM::Datum("UsageRecord");
$usageRecord->setProperty("Instance", "Moab.1234");
$usageRecord->setProperty("Account", "chemistry");
$usageRecord->setProperty("User", "amy");
$usageRecord->setProperty("Machine", "colony");
$usageRecord->setProperty("Processors", "2");
$usageRecord->setProperty("Duration", "3600");
$request->addDatum($usageRecord);
$request->setOption("Duration", "3600");
my $response = $request->getResponse();
print $response->getStatus(), ": ", $response->getMessage(), "\n";
5.62.4 Use the Java API (no longer supported)
Beginning with Moab Accounting Manager 9.0, Java API is no longer supported, use Perl API instead.
5.62.5 Communicating via the SSSRMAP Protocol
Finally, it is possible to interact with Moab Accounting Manager by directly using the SSSRMAP Wire Protocol and Message Format over the network (see SSS Resource Management and Accounting documentation). This will entail building the request body in XML, appending an XML digital signature, combining these in an XML envelope framed in an HTTP POST, sending it to the server, and parsing the similarly formed response. The Moab Workload Manager communicates with Moab Accounting Manager via this method.
Example 5-121: The message might look something like:
POST /SSSRMAP HTTP/1.1
Content-Type: text/xml; charset="utf-8"
Transfer-Encoding: chunked
190
<?xml version="1.0" encoding="UTF-8"?>
<Envelope>
<Body>
<Request action="Charge" actor="scottmo">
<Object>UsageRecord</Object>
<Data>
<UsageRecord>
<Instance>Moab.1234</Instance>
<Account>chemistry</Account>
<User>amyh</User>
<Machine>colony</Machine>
<Processors>2</Processors>
<Duration>3600</Duration>
</UsageRecord>
</Data>
<Option name="Duration">3600</Option>
</Request>
<//Body>
<Signature>
<DigestValue>azu4obZswzBt89OgATukBeLyt6Y=</DigestValue>
<SignatureValue>YXE/C08XX3RX4PMU1bWju+5/E5M=</SignatureValue>
<SecurityToken type="Symmetric"></SecurityToken>
</Signature>
</Envelope>
0