Getting started
4 minute read
Easily integrate CloudBolt OneFuse with Python to quickly automate and integrate into your business provisioning lifecycle.
The CloudBolt OneFuse integration platform offers integrations to services like Naming, IPAM, DNS, Microsoft Active Directory, Scripting, Ansible Tower and more.
Upstream providers like Ansible, Terraform, VMware vRealize Automation, CloudBolt CMP, ServiceNow and others are able to consume the same OneFuse integrations combined with organizational business logic for a standardized approach to automation across the enterprise.
Prerequisites
Identify a system to run the Python commands from. This could be your own desktop or a server in your environment. You will need to have Python 3 or greater installed on the system.
-
Verify Python is installed
python --versionPython 2 has sunset. If previously installed and on Python 2, upgrade to the latest Python.
- If Python is not installed (or upgrading), download the latest Python
-
Verify pip is installed
pip --version- Install pip if it does not exist
-
Review Python’s Installing Packages
OneFuse Python Module
GitHub Repo: OneFuse Python Module
Install OneFuse Python Package
OneFuse Python Module is distributed as a Python Package. Install the OneFuse Python Package using pip.
It is recommended to install the latest OneFuse Python Package that matches the OneFuse Appliance version.
If the OneFuse Python Module is already installed, skip to Upgrading the OneFuse Python Package.
- Open a Command Prompt or Terminal window
- Install OneFuse Python Package using instructions below:
Option 1. Installing the latest
pip install onefuse
Option 2. Installing a specific version
Optional: list available OneFuse Python package versions
# Run the following in a Command Prompt/Terminal
pip install onefuse==versions
# An output error message similar to the below is returned, listing available versions:
# ~ERROR: Could not find a version that satisfies the requirement onefuse==versions (from versions: <!! versions are listed here !!>)
# ~ERROR: No matching distribution found for onefuse==versions
Then, install with a specific version.
# Replace <version> in the command below with a specific version number (e.g. 1.4.0)
# Run the following in a Command Prompt/Terminal
pip install onefuse==<version>
# An output message similar to the below is returned, where <version> is replaced with the version number installed:
# ~Successfully installed onefuse-<version>
Upgrading the OneFuse Python Package
Upgrade to the latest OneFuse Python Package using pip.
-
Open a Command Prompt or Terminal window
-
Install OneFuse Python Package using the command below:
pip install --upgrade onefuse
Configure OneFuse Manager
Configure the connection to OneFuse with the OneFuse Manager from the OneFuse Python Package.
-
Open a Command Prompt or Terminal window
-
Enter the Python Console via command:
# Run the following in a Command Prompt/Terminal to enter the Python Console python -
Import the OneFuse Manager via command:
# Run the following in the Python Console from onefuse.admin import OneFuseManager -
Create a OneFuse Manager via command:
# Replace <username> in the command below with the OneFuse username # Replace <password> in the command below with the password for the OneFuse user # Replace <host> in the command below with the FQDN or IP Address of the OneFuse instance # Run the following in the Python Console ofm = OneFuseManager(<username>, <password>, <host>) # Example # ofm = OneFuseManager('admin', 'admin', 'onefuse.example.com')- Replace
<username>with the OneFuse username that has at least the Workspace Member role. - Replace
<password>with the password for the OneFuse user. - Replace
<host>with the OneFuse Instance FQDN or IP Address.
Accepted optional kwargs:
Key Value protocolDefaults to https. Specify a protocol:httpor a non-standard protocol.portDefaults to 443. Specify the port for the OneFuse Instance.verify_certsDefaults to false. Specify whether or not to verify OneFuse Certificates (trueorfalse).loggerDefaults to onefuse.logand to the console at theLOG_LEVELset inconfiguration.globals. Pass in logger information.sourceDefaults to PYTHON. Specify the source so that this class can be called by other Upstream Providers (Ansible, CloudBolt CMP, Terraform, ServiceNow, VMware vRealize Automation, etc). All OneFuse Jobs will show this value as the “Source” of the Job.Example using accepted optional kwargs:
# Pass in accepted optional kwargs comma separated in format <key>='<value>' # Run the following in the Python Console ofm = OneFuseManager(<username>, <password>, <host>, verify_certs='true') - Replace
-
Use the OneFuse Manager to make API calls to OneFuse.
From the example command above, the OneFuse Manager is instantiated in the Python variable
ofm.# Run the following in the Python Console # Run commands and OneFuse API calls against the created OneFuse Manager # Example below outputs the OneFuse Instance version for the created OneFuse Manager ofm.onefuse_version
Resources
- Learn about Python Modules.
- Visit our GitHub Repo: onefuse-examples
Troubleshooting
Update the OneFuse Manager’s Log Level and re-try the request:
# Pass in accepted optional kwargs comma separated in format <key>='<value>'
# Run the following in the Python Console
ofm = OneFuseManager(<username>, <password>, <host>, log_level='DEBUG')
Refer to Python’s Logging facility for Python.
Next steps
Start integrating with OneFuse Modules.