Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
code share

Radware config translation

Problem this snippet solves:

This is a simple Python script that translates Radware text configuration file and outputs as config snippet and certificate files.

$ ./rad2f5
Usage: rad2f5 <filename> [partition]

Example:

./rad2f5 radwareconfig.txt MyPartition
Using partition /MyPartition/
IP routes:46
Non-floating IP interfaces:26
Floating IP interfaces:19
Monitors:349
Virtual Servers:430
Pools:152
Certificates: 31
SSL profiles: 17
WARNING! Found L7 Regular Expression at "appdirector l7 farm-selection method-ta
ble setCreate l7Rule-Redirect"
Layer 7 rules:12
Layer 7 policies:4

!!  Copy all certificate files to BIG-IP /var/tmp and use load_certs.sh to load
!!
#         Configuration
#--------------------------------------#
ltm policy /MyPartition/l7rule-Redirect {
    controls { forwarding }
    requires { http }
    rules {
            Redirect {
                    actions {
                            0 {
                                    forward
                                    select
                                    pool SORRYPOOL
                             }

                     }
            ordinal 1
            }
    }
net route /MyPartition/10.20.30.40_32 {
    network 10.20.30.40/32
    gateway 10.1.1.1
}
How to use this snippet:

This includes translation of routes and non-floating self-IPs, monitors, pools, virtual servers, certificates, SSL profiles and some layer 7 rules.

To install, either download the file attached here, extract and run it or use pip:

pip install rad2f5

To load the configuration to the f5 device, output to a file eg ./rad2f5 filename>newcfg.txt, remove the statistics header from the file with a text editor, upload the file into /var/tmp on the BIG-IP and test loading with tmsh load sys config merge file /var/tmp/<filename> verify. Fix any issues and load with tmsh load sys config merge file /var/tmp/<filename>

If you want something to be added then message me with details of the text and i will try to add it.

Feel free to add or change anything

Comments on this Snippet
Comment made 14-Mar-2018 by Shahid-CRIS 0

Traceback (most recent call last): File "rad2f5", line 555, in vars = splitvars(monitors[m]['text']) KeyError: 'text'

0
Comment made 14-Mar-2018 by Pete White

Thanks for the response Shahid-CRIS, I have fixed this - it was because of an uninitialized variable so it now creates the variable as an empty string if the text doesn't exist.

I have changed the file attached to the page so you can download and use that, or modify your own version as below: Line 157 or so:

if 'a' in opts:
    output['text'] = opts['a']
    # Added in v2
else:
    output['text'] = ''
0
Comment made 14-Mar-2018 by Shahid-CRIS 0

Thanks it worked

0
Comment made 14-Mar-2018 by Pete White

Good! One point that i didn't make above is that the monitors are created but they are not assigned to the pools so you may want to do some manual assignment etc. This is because RadWare do monitor assignment to pool members and F5 generally do this at the pool level. I may look into fixing this.

If you have any issues with syntax etc then let me know and i'll amend it - I have only really used a couple of configs and the RadWare documentation is not very good about the CLI so if you have any configs that have issues or you want specific config included then PM me with the config and an explanation and i'll try to include it.

0
Comment made 3 months ago by William J Gonzalez 106

Hello,

I am executing the script but i get this :

-bash: ./rad2f5-tmsh.pl: /usr/bin/perl"^M: bad interpreter: No such file or directory

0
Comment made 3 months ago by Pete White

Hi William, it looks like you have the wrong linefeeds in the file. Try looking through the script using vi and see if the lines have a ^M at the end. If so, transfer it to the platform using ASCII mode or copy/paste. Also, check that you have /usr/bin/perl as an interpreter for it to work. I built it on Cygwin.

0
Comment made 3 months ago by Pete White

Hi William, it has just dawned on me that I wrote this in Python, not in Perl! haha

I think you also have rad2f5-tmsh.pl, my code is just rad2f5.

Try running it with rad2f5 <filename> [<partition>]

0
Comment made 2 weeks ago by Avi 1

Hi Pete,

Thanks for this; major help !

I ran the script - on a mac - to test it and I ran into this error (btw. I changed the file name and added the .py extension)

 Traceback (most recent call last):
   File "./rad2f5.py", line 403, in <module>
     if vars[1] and vars[1].startswith('P='):
 IndexError: list index out of range

First I ran into this error

 File "./rad2f5.py", line 72
  print "Using partition " + partition
                                ^
 SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Using partition " + partition)?

I'm using Python 3.6.5 :: Anaconda, Inc. - I had to change all the print statements to surround them with ( ). Prolley a python distro/version specific thing. After the change the script ran fine until the line 403 error.

Appreciate the help.

Cheers, Avi

0
Comment made 2 weeks ago by Pete White

Hi Avi,

There are two things here - one is about print and I can answer that now - I wrote this in Python v2.7 and i'm sure you know that print is one of the big differences between v2 and v3. I will look into this and change it to work correctly with v3.

On the failure point, I have a fair idea what the issue is - it's related to creating layer 7 rules and that part has quite a few options. Maybe you could PM me your config file and I will run it through and fix the issue.

0
Comment made 2 weeks ago by Avi 1

Hi Pete,

Thanks for the reply.

I'm not that deep into Python (yet) but I figured the print had something to do with different versions.

On the failure part - the source Radware config file had \ at the end of almost every line. I think it might have something to do with that. I got hinted by the monitor output of the script. So I'm editing the source config file to remove the backward slashes at the and and joining the config lines as one again.

Hopefully that will solve the issue for me. I'll let you know once the test file is done and ran the script against it - lot of config lines in there to be corrected :-(

0
Comment made 2 weeks ago by Pete White

If you can send me the original file, I can change the script to manage the \ line endings - it is best for it to be as useful as possible. Should be simple with regex.

0