Skip to main content

Using the Python (PyLXCA) toolkit

You can use the Lenovo XClarity Administrator Python (PyLXCA) toolkit from the Python shell, interactive shell, or as a Python script.

Python shell

You can run any of the PyLXCA commands from the Python shell.

To start the Python shell, run the lxca_shell command. When you are in the Python shell, the prompt changes to PyLXCA >>.
joe@joe_vm:~# lxca_shell
--------------------------------------------------
Welcome to LXCA Command Shell
Type "help" at any time for a list of commands.
Use "lxca_shell --api" to enable Interactive Python LXCA Shell
--------------------------------------------------

PyLXCA >> connect --url https://192.0.2.0 --user USER1 -noverify true

For information about each PyLXCA command, see PyLXCA commands reference.

Interactive shell

When you use the interactive Python XClarity Administrator shell, you can use built-in Python functions in addition to PyLXCA commands.

To start the interactive shell, run the pyshell --api command. When you are in the interactive shell, the prompt changes to >>>.
joe@joe_vm:~#lxca_shell --api
Interactive Python Shell for Lenovo XClarity Administrator
Type "dir()" or "help(lxca command object)" for more information.
>>>
>>> con1 = connect("https://192.0.2.0","USER1","password","true")

To get detailed help for the PyLXCA functions, use the python help(command_name) function. For example, help(connect) returns help for the connect function.

Python scripts

Just like the Python shell, when you create the Python scripts, you can use built-in Python functions in addition to PyLXCA APIs

Note
At the beginning of your script, you must import PyLXCA and connect to the XClarity Administrator instance, for example:
#!/usr/bin/env python 
from pylxca. import *
con1 = connect("https://192.0.2.0","USER1","password","True")