CLM Python SDK
This section contains detailed information about the BMC Cloud Lifecycle Management Python-based Software Development Kit (SDK), which provides a simple way to perform task-based API operations in BMC Cloud Lifecycle Management. You do not need to interact directly with the BMC Cloud Lifecycle Management RESTful API. Instead, the SDK provides Python bindings to the full RESTful API, enabling you to use a Python command-line, code, or scripts to complete BMC Cloud Lifecycle Management operations with a simplified syntax.
This topic contains the following sections:
See also the following BMC Communities videos:
CLM Python SDK Install and Configure (6:56): https://youtu.be/YL8cTQqw69A
Exploring BMC Cloud Lifecycle Management Python SDK (8:40): https://youtu.be/2MkVxrQehsk (This video explores using the SDK to request a service offering instance, to perform a Day 2 operation such as adding a disk, and to combine two or more commands in a batch file.)
Prerequisites for installing the SDK
The SDK is installed as part of your BMC Cloud Lifecycle Management installation, and is located in the sdk folder of the Platform Manager. Alternatively, you can download the SDK from BMC Communities.
To use the SDK, you must first complete the following activities:
Download and install Python 2.7.x on the computer that you will use to run SDK commands. Visit www.python.org for the software and documentation. For example, https://www.python.org/downloads/release/python-278/ for Windows installer.
Add the C:\Python27 and C:\Python27\Lib directories to your
PATH
environment variable .Note
Python 2.7.x is only required on the computer from which you will run the SDK. The BMC Cloud Lifecycle Management server does not require Python.
If you will install Python on a Red Hat Enterprise Linux (RHEL) system, do not upgrade the existing Python version already installed on your RHEL system. Instead, install Python 2.7.x as a separate program.
To install Python 2.7.x as a separate program on a RHEL system:
- Ensure that you have the GNU Compiler Collection (GCC) installed.
For more information about GCC, see http://gcc.gnu.org. - Download Python 2.7.x
Run the following commands, where x is a number of the Python version you downloaded:
# tar -xzf Python-2.7.x.tgz # cd Python-2.7.x # ./configure # make altinstall
The
make altinstall
command installs Python 2.7.x in parallel with the existing Python version, and enables you to run the newer version using apython2.7
command.For Microsoft Windows system, you can install Python 2.7.x as a separate program without upgrading the existing Python version already installed on your Microsoft Windows system.
- Ensure that you have the GNU Compiler Collection (GCC) installed.
- Download and install Python Setup tools in your environment. For more information, see https://pypi.python.org/pypi/setuptools.
Download setuptools-xx.x.x.zip (for example, setuptools-38.6.0.zip) and extract it.
- Go to the extracted folder and run
python setup.py install
command. The script downloads the appropriate .egg file and installs it. - Once installation is complete, an
easy_install
script is available under the PythonScripts
subdirectory. - Add this directory to your
PATH
environment variable, if it is not already present.
Install pip (a package management system used to install and manage software packages written in Python) in your Python environment. Visit http://www.pip-installer.org/en/latest/installing.html for more information about pip. To install pip, you must go to C:\Python27\Scripts and execute
easy_install.exe pip
command.
You can verify whether pip installation is successful by using theC:\Python27>pip list
command.Note
Install pip only if you are using Python 2.7.8 or lower version. Pip is pre-installed for Python 2.7.9 and later versions.
Installing the SDK
- Copy the Platform_Manager/sdk/python-sdk-1.0-src.zip file from the Platform Manager server to the computer from which you will run SDK commands.
Consider using C:\sdk (for Windows) or /home/admin (for Linux) as a destination folder. - Extract the .zip file.
- Go to the directory where python-sdk-1.0-src file is present. For example, change directory to C:\sdk\python-sdk-1.0-src.
- Enter the following command:
python setup.py install
The SDK is installed in the C:\Python27\Lib\site-packages\bmc_csm_sdk-4.0-py2.7.egg folder. - Verify that the SDK was installed by entering the following command:
pip list
The SDK is installed ifbmc-csm-sdk
is listed in the output.
Executing an SDK API
The following table shows sample API commands:
Command | Description |
---|---|
C:\>clm login --url http://cloud-test:8080/csm --user cloudadmin --password password | Command for authenticating with BMC Cloud Lifecyle Management System |
clm pod-list -n | Lists the pods in the environment |
Configuring the CLM Python SDK to use SSL
If you are running BMC Cloud Lifecycle Management Platform Manager using Secure Sockets Layer (SSL), you must configure the SDK to use SSL.
Navigate to the csmconfig.ini file located under the C:\Users\LocalUser\csmsdk\ directory. This file (csmconfig.ini) is available only if you have executed the following SDK command successfully.
C:\>clm login --url http://cloud-test:8080/csm --user cloudadmin --password password
Comment the following lines for BMC Cloud Lifecycle Management 4.5 and later releases:
#key_file : C:\Users\LocalUser\csmsdk\key_file\RootCA.key #cert_file : C:\Users\LocalUser\csmsdk\key_file\mycert.pem #validate=true
Log in to BMC Cloud Lifecycle Management using the SDK
login
command, ensuring that you usehttps
instead ofhttp
in the--url
argument of the command. Ensure that the BMC Cloud Lifecycle Management Platform Manager is HTTPS enabled.
For example:C:\>clm login --url https://cloud-test:8080/csm --user cloudadmin --password password
Configuring the CLM Python SDK
Once you have run at least one command from the command line, an SDK configuration file called csmconfig.ini
is created in the csmsdk
and folder of your SDK installation. You can configure the following settings in the configuration file:
Setting | Description |
---|---|
locale | The locale of your SDK environment. |
waitFor | Time in seconds to wait for response from the server, otherwise the SDK returns the running task details. The default value is 300 seconds. Any |
enable | Whether SDK activity will be logged. The value can be true or false. |
logLevel | The level of logging. The values can be any of the following:
|
maxFileSizeInMegs | The maximum size (in MB) of the log file. The default size is 20 MB. |
maxBackupIndex | The maximum number of old log files to retain. The default value is 5. |
logFileName | The absolute path and name of the log file to use if SDK logging is enabled. The default value is:
|
key_file | The location of the SSL key file, if BMC Cloud Lifecycle Management Platform Manager is using SSL. The default value is:
|
cert_file | The location of the SSL certification file, if BMC Cloud Lifecycle Management Platform Manager is using SSL. The default value is:
|
Uninstalling the CLM Python SDK
If you want to uninstall the SDK from your BMC Cloud Lifecycle Management environment, complete the following steps:
- In a Python client, enter the following command:
pip list
The command returnsbmc-csm-sdk
. - Enter the following command:
pip uninstall bmc-csm-sdk
The SDK is uninstalled.
Related topics
CLM Python SDK syntax and usage
Summary of changes to the CLM Python SDK
CLM Python SDK reference
Related BMC Communities blog entry
The following link provides supplemental information available from a blog entry in BMC Cloud Lifecycle Management Communities:
The blog discusses how to use to stop services or servers in bulk by using the CLM Python SDK.
Comments
Log in or register to comment.