FBSNG Application
Programmer’s Interface
Reference Manual
Version
1.1
Jim Fromm, Krzysztof Genser, Tanya Levshina, Igor Mandrichenko
Farms and Clustered Systems Group
Fermi National Accelerator Laboratory
This document is a part of set of the FBSNG documentation. It describes functionality of Python version of FBSNG Application Programmer’s Interface (API). Description of FBSNG features is left beyond the scope of this document. Other parts of documentation should be consulted for more information on specific FBSNG features:
The FBSNG API provides access to FBSNG run-time and configuration information. It is organized as a set of classes divided into the following major groups:
FBSClient object creates objects of “informational” API classes such as FBSJobInfo, FBSSectionInfo, FBSProcessInfo, etc.
In order to submit a job using API, user must
For more information, refer to FBSJobDesc and FBSSectionDesc sections of this document.
Objects of all informational classes are created by FBSClient object or objects of other FBSNG API classes. API client application should not create objects of these classes directly.
Currently, only Python binding of FBSNG API is available.
Relationships between different API classes are shown on Fig. 1.

Figure 1. FBSNG API Classes
In order to use FBSNG API, client application must import all or only necessary names from FBS_API module using one of the following methods:
from FBS_API import * # import all names
from FBS_API import FBSClient, FBSJobDesc # import some names
import FBS_API # import only the module
If
first method is used, the following names will be imported: FBSClient,
FBSJobDesc, FBSSectionDesc and FBSError. If third method is used, class names
will have to be explicitly qualified with module name “FBS_API”. All examples
of Python code in this document are written assuming first or second method was
used.
Actual location of FBS_API.py module must be included into Python library search path defined by PYTHONPATH. FBSNG comes with necessary user environment set-up scripts that assign correct value to this and other environment variables. UPS users can use FBSNG API after issuing “setup fbsng” command. See FBSNG User’s Guide for more details on setting up user environment.
Many API methods return completion status information as a 2-tuple (status, reason). By convention, status 1 indicates successful completion, and status 0 indicates failure. On success, the reason field is either ‘OK’ or some warning message. On failure, the reason field of the tuple contains a specific explanation of what happened.
For example:
# Cancel or kill a section
from FBS_API import FBSClient
fc=FBSClient()
si = fc.getSection(‘123.MAIN’)
sts, reason = si.kill()
if sts:
if reason == ‘OK’:
print ‘Done’
else:
print ‘Warning: ‘, reason
else:
print ‘Failed: ‘, reason
Almost all methods of API classes described below generate standard Python KeyError