[python]Getting VS name and VS’ profile with iControl API

I have written two more functions to check the profile type of a virtual server, previously i tried to use F5 SDK unfortunately this SDK does not have attributes for fastL4 and fasthttp.

Below are the codes:

def bigip_vs_profile_type(vs_name):
    for bigip_address in BIGIP_ADDRESSES:
        try:
            response = bigip.get("https://" + bigip_address + LTM_BASE_VS_URI + PARTITION + vs_name + "/profiles")
            vs_configs = response.json()
            logging.info("Successfully connected to bigip, retrieving {} profile type...".format(vs_name))
        except Exception as e:
            logging.error(e)
            exit(1)
    for vs_config in vs_configs['items']:
        vs_profile = vs_config['name']
    return vs_profile


def list_bigip_vs():
    vs_s = []
    for bigip_address in BIGIP_ADDRESSES:
        try:
            response = bigip.get("https://" + bigip_address + LTM_BASE_VS_URI)
            vs_collections = response.json()
            logging.info("Successfully connected to bigip, collecting vs parameters...")
        except Exception as e:
            logging.error(e)
            exit(1)
    for vs in vs_collections['items']:
        vs_s.append(vs['name'])
        logging.info("Collecting available virtual servers' names...")
    return vs_s
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s