as3 Python module

Problem this snippet solves:

This is a python module to simplify using the F5 Networks AS3 utility.


Downloads, installs and uninstalls the AS3 package


https://clouddocs.f5.com/products/extensions/f5-appsvcs-extension/latest/userguide/installation.html


How to use this snippet:





Installation

Install using pip:

pip install as3


Example

#!/usr/bin/env python
import as3
t = as3.as3(host='1.1.1.1',username='admin',password='admin')
# Check whether AS3 is installed:
print (str(t.isInstalled()))
# Download the latest AS3 version from Github
print (str(t.retrieveVersion()))
# Install a specific version on a different host - if you leave out filename it will download the latest
t.installAS3(host='2.2.2.2',username='admin',password='admin',filename='f5-appsvcs-3.16.0-6.noarch.rpm')
# Uninstall it
t.uninstallAS3(host='2.2.2.2',username='admin',password='admin')


Methods

  • as3([debug,host,username,password,port,usetoken]) - initialise an AS3 object
  • isInstalled([version,host,username,password,usetoken,port]) - Checks whether AS3 is installed. Returns version dict, True or False
  • retrieveVersion([release]) - Downloads a specific release or the latest release of the RPM package
  • installAS3([version,filename,host,username,password,usetoken,port]) - Installs AS3 as a package. Returns True or False
  • uninstallAS3([version,filename,host,username,password,usetoken,port]) - Uninstalls current AS3 package. Returns True or False
  • github(url, [method,data,useragent,stream]) - this is a helper to retrieve from github F5 repository. Return True or False
  • versionToId(version) - Returns a Github object ID related to a version number. eg version is 'v3.16.0' and ID is 22093972


Tested this on version:

13.0
Published Dec 20, 2019
Version 1.0

Was this article helpful?

1 Comment

  • If you are having a problem using this module, once you have instantiated object 't' in the example I found it useful to set the debug attribute to True as this allows for feedback on the installAS3 method when it's called e.g.:

    >>> t.debug=True
    >>> t.installAS3(host='BIGIP',username='SOME_USER',password='SOME_PASSWORD',filename='f5-appsvcs-3.17.1-1.noarch.rpm')
    DEBUG: Filename f5-appsvcs-3.17.1-1.noarch.rpm specified, uploading to host BIGIP
    DEBUG: Uploading file f5-appsvcs-3.17.1-1.noarch.rpm
    DEBUG: Installing package f5-appsvcs-3.17.1-1.noarch.rpm from /var/config/rest/downloads
    DEBUG: Created task to install package f5-appsvcs-3.17.1-1.noarch.rpm
    DEBUG: Waiting for 5 secs
    DEBUG: Checking whether the package is installed
    DEBUG: Response from /mgmt/shared/appsvcs/info False
    False
    >>>

    I also found in the imports in the module itself, that on my system (and I did do this in a virtual environment as well), I needed to amend the import statements as follows

    #replaced import iCR
    from iCR import iCR

    I found when I used it, that the module was not referring to the iCR class correctly, and it needed the above in order to work without throwing an exception regarding the module not being callable.

    HTH but still got a couple of snags left 😞 but looks very, very, useful when working so I am persevering with this. (note I am using python3.6.0)

    If this is open sourced I can try and make this work on my system and submit a pull request with more detail if that is helpful.