Skip to content

Instantly share code, notes, and snippets.

@f5-rahm
f5-rahm / heatmap
Last active November 17, 2022 22:49
Colin Walker's original heatmap iRule (for reference - use heatmap_2022 instead)
ltm rule /Common/heatmap {
when HTTP_REQUEST {
if {[HTTP::uri] starts_with "/heatmap"} {
set chld ""
set chd ""
foreach state [table keys -subtable states] {
append chld $state
append chd "[table lookup -subtable states $state],"
}
set chd [string trimright $chd ","]
@f5-rahm
f5-rahm / heatmap_2022
Created November 17, 2022 22:47
Update of Colin Walker's original Heatmap iRule to utilize Google's Geocharts
ltm rule /Common/heatmap_2022 {
when RULE_INIT priority 500 {
set static::geochart "
<html>
<head>
<title>Heatmap</title>
<script type='text/javascript' src='https://www.gstatic.com/charts/loader.js'></script>
</head>
<body>
cli script vip_ssl_check.tcl {
proc script::init {} {
set ::cssl_profiles ""
set ::sssl_profiles ""
}
proc print_ssl_details {vip cs ss insp} {
puts "Virtual: $vip"
puts "\tClient-side encrypted: $cs"
puts "\tServer-side encrypted: $ss"
puts "\tInspection possible: $insp"
@f5-rahm
f5-rahm / runtime_calc_v2.py
Created September 1, 2022 15:43
Excel output of iRule performance
# coding=utf-8
#
# Copyright 2015-2019 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
#
import os
import sys
from typing import Dict
from bigrest.bigip import BIGIP
def get_credentials() -> Dict:
#return {'host': os.getenv('F5_HOST'), 'user': os.getenv('F5_USER'), 'pass': os.getenv('F5_PASS')}
return {'host': 'ltm3.test.local', 'user': 'admin', 'pass': 'admin'}
@f5-rahm
f5-rahm / afm_policy_rules_xlsx_export.py
Created July 21, 2022 20:43
Export AFM policies to Excel
from bigrest.bigip import BIGIP
import argparse
import getpass
import sys
import xlsxwriter
def build_parser():
parser = argparse.ArgumentParser()
parser.add_argument("host", help="BIG-IP IP/FQDN")
import bigsuds
b = bigsuds.BIGIP(hostname='ltm3.test.local')
zone_view = {'view_name': 'external',
'zone_name': 'dctest1.local.'
}
b.Management.Zone.zone_exist([zone_view])
# [0]
@f5-rahm
f5-rahm / tmos_install.py
Created September 8, 2021 01:21
INCOMPLETE - Install tmos on BIG-IP
###################################################################################
# tmos_install.py
# v 0.1 - INCOMPLETE
#
# author: jason rahm
#
# usage: tmos_install.py [-h] [-a] inventory user password
#
# positional arguments:
# inventory inventory file (host IP/FQDN,image path)
@f5-rahm
f5-rahm / file_upload.py
Created May 21, 2021 15:41
Upload files to BIG-IP with python
def _upload(host, creds, fp):
chunk_size = 512 * 1024
headers = {
'Content-Type': 'application/octet-stream'
}
fileobj = open(fp, 'rb')
filename = os.path.basename(fp)
if os.path.splitext(filename)[-1] == '.iso':
uri = 'https://%s/mgmt/cm/autodeploy/software-image-uploads/%s' % (host, filename)
@f5-rahm
f5-rahm / toolchain_prep.py
Created May 5, 2021 16:07
Upload the F5 Automation Toolchain packages
import argparse
import sys
from time import sleep
from bigrest.bigip import BIGIP
from bigrest.common.exceptions import RESTAPIError
from pathlib import Path
DO = "/Users/rahm/Downloads/f5-declarative-onboarding-1.20.0-2.noarch.rpm"