This project implements an SDK for the iControl® REST interface for BIG-IP®. Use this library to use python to automate a BIG-IP® via its REST API.
Please see the project documentation on Read the Docs: http://f5-sdk.readthedocs.io.
$ pip install f5-sdk
Note
If you are using a pre-release version you must use the --pre
option for the pip
command.
from f5.bigip import ManagementRoot
# Connect to the BIG-IP
mgmt = ManagementRoot("bigip.example.com", "admin", "somepassword")
# Get a list of all pools on the BigIP and print their name and their
# members' name
pools = mgmt.tm.ltm.pools.get_collection()
for pool in pools:
print pool.name
for member in pool.members_s.get_collection():
print member.name
# Create a new pool on the BigIP
mypool = mgmt.tm.ltm.pools.pool.create(name='mypool', partition='Common')
# Load an existing pool and update its description
pool_a = mgmt.tm.ltm.pools.pool.load(name='mypool', partition='Common')
pool_a.description = "New description"
pool_a.update()
# Delete a pool if it exists
if mgmt.tm.ltm.pools.pool.exists(name='mypool', partition='Common'):
pool_b = mgmt.tm.ltm.pools.pool.load(name='mypool', partition='Common')
pool_b.delete()
Python API for configuring objects on a BIG-IP® device and gathering information from the device via the REST API.
See the Issues section of Contributing.
See Contributing
Before you open a pull request, your code must have passing pytest unit tests. In addition, you should include a set of functional tests written to use a real BIG-IP device for testing. Information on how to run our set of tests is included below.
We use pytest for our unit tests.
If you haven't already, install the required test packages listed in requirements.test.txt in your virtual environment.
$ pip install -r requirements.test.txt
Run the tests and produce a coverage report. The
--cov-report=html
will create ahtmlcov/
directory that you can view in your browser to see the missing lines of code.py.test --cov ./icontrol --cov-report=html open htmlcov/index.html
We use the hacking module for our style checks (installed as part of step 1 in the Unit Test section).
$ flake8 ./
Copyright 2014-2016 F5 Networks Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Individuals or business entities who contribute to this project must have completed and submitted the F5 Contributor License Agreement to [email protected] prior to their code submission being included in this project.