Quick Start

Prerequisites

  • Python 3.7+, for installation see python download docs.

  • Python virtual environment, for details see python venv docs.

  • Optional: Specify the log level verbosity to see additional log messages during SDK usage. See the Troubleshooting section for more details.

  • Optional: Ignore untrusted TLS certificate warnings during HTTPS requests to BIG-IP. See the Troubleshooting section for more details.

Installation

pip install f5-sdk-python

Note

Typically, all that is required to use the SDK is a basic installation. For certain platforms or system configurations it may be simpler to get started in a container.

docker run --rm -it -v $(pwd):/f5sdk python:3.7 /bin/bash

Usage

This script uses the SDK to update BIG-IP L4-L7 configuration using AS3, provided via a local file.

For an example AS3 declaration, see the documentation here.

python example.py
""" Update BIG-IP L4-L7 configuration using AS3

Notes
-----
Set local environment variables first
"""

# export F5_SDK_HOST='192.0.2.10'
# export F5_SDK_USERNAME='admin'
# export F5_SDK_PWD='admin'
# export F5_SDK_AS3_DECL='./my_declaration.json'
# export F5_SDK_LOG_LEVEL='INFO'

import os

from f5sdk.bigip import ManagementClient
from f5sdk.bigip.extension import AS3Client
from f5sdk.logger import Logger

LOGGER = Logger(__name__).get_logger()


def run_example():
    """ Update AS3 configuration

    Notes
    -----
    Includes package installation, service check while
    maintaining idempotency
    """
    # create management client
    mgmt_client = ManagementClient(
        os.environ['F5_SDK_HOST'],
        user=os.environ['F5_SDK_USERNAME'],
        password=os.environ['F5_SDK_PWD'])

    # create extension client
    as3_client = AS3Client(mgmt_client)

    # Get installed package version info
    version_info = as3_client.package.is_installed()
    LOGGER.info(version_info['installed'])
    LOGGER.info(version_info['installed_version'])
    LOGGER.info(version_info['latest_version'])

    # install package
    if not version_info['installed']:
        as3_client.package.install()

    # ensure service is available
    as3_client.service.is_available()

    # configure AS3
    return as3_client.service.create(config_file=os.environ['F5_SDK_AS3_DECL'])


if __name__ == '__main__':
    LOGGER.info(run_example())

Note

The F5 SDK-Python is currently in early development and we want to hear from you! To provide feedback on F5 SDK-Python or this documentation, you can file a GitHub Issue.