16Chapter 1 Using the CLI
response = json.loads(r.content)
print("Health = " + response['system'][0]['health'])
Using XML API output
The Management Controller provides access for monitoring and management via the SSH and Telnet protocols for command-
line interface semantics, or via the HTTP and HTTPS protocols for XML API request/response semantics.
You can use an XML parser, such as XML::Parser in Perl, to process the XML output and store this information as objects.
The output of each CLI command is composed of valid XML data until the CLI prompt (typically #) is encountered. The output
contains a valid XML header followed by the XML elements described in the following table.
Elements Description and attributes
RESPONSE The RESPONSE element is the top-level element, which contains all data output for the CLI command that was issued. The
response includes:
lA number of OBJECT elements, which varies by command.
lA status object that provides a message and return code. A return code of 0 indicates that the command succeeded. Any
other return code is an error code.
There is only one RESPONSE element per issued command.
OBJECT In general, an OBJECT element describes a storage system component such as a disk or a volume. An object has these
attributes:
lbasetype. This attribute allows output in brief mode to be correlated with metadata to reduce the overhead of each
command, as described in XML API optimization. This is also a good field to use to detect the type of the object (e.g., a
disk, a volume, etc.).
lname. The name of the object.
loid. The unique identifier for the object in the scope of the response.
The OBJECT element can contain PROPERTY elements.
PROPERTY APROPERTY element provides detail about the attributes of an OBJECT. A property has these attributes:
lname. The unique name for the property within the object.
ltype. The type of data represented by the element data.
lkey. Indicates whether this property is a key value to identify this object.
lsize. Typically the maximum size of the output. Usually only important if the console output is displayed in rows.
ldraw. Whether to show or hide this data in console mode.
lsort. The type of sorting that can be applied to this property.
ldisplay-name. The label for this data to show in user interfaces.
COMP ACOMP (composition) element associates nested objects, such as a task object within a schedule object. A composition
element has these attributes:
lG. The OID of the group component.
lP. The OID of the part component.
An alternative to using COMP elements is described in "XML API optimization" on page19.
ASC The association element provides a simple association description between two objects in the response.
lA. First object.
lB. Second object.
Table 1 XML API elements
Using JSON API output
The simplest mechanism to handle JSON output is by using either a JavaScript or a Python parser to interpret the data.
The JSON output is organized according to the basetypes defined for the system. All basetype objects are returned in an
array. The JSON object uses the same name for the key as the XML API uses in the name attribute. Objects can also be
embedded inside of other objects and are always presented as an array as well. This is different from the XML API where the