Forum Discussion

asabado's avatar
asabado
Icon for Altocumulus rankAltocumulus
Feb 16, 2021

How to update multiple the persistence profile of multiple virtual servers?

I need to update hundreds of virtual servers from the default cookie persistence to an encrypted cookie profile. This multiplied to several bigips as well. Is there a script to do this instead of going through each end every VS and changing them one by one?

 

Thanks in advance!

  • I'd recommend an external Python using Python SDK:

    pip install f5-sdk

    Then to start your script the first thing is to import the pip module you've just installed with above command:

    # Import the F5 module
    from f5.bigip import ManagementRoot

    Now, to define the variables, you can use dataclasses like this:

    >>> from dataclasses import dataclass
    >>> @dataclass
    ... class f5_box:
    ...     hostname: str
    ...     username: str
    ...     password: str
    ...
    ...
    >>> box1 = f5_box(hostname='example1.com', username='root', password='mypasswd')
    >>> box1.hostname
    'example1.com'
    >>> box1.username
    'root'
    >>> box1.password
    'mypasswd'
    >>>

    So in your code, you can access each box and "inside" of each object, you'll find username, hostname and password and you can iterate through each of the boxes and perform the changes you want.

     

    Here's a sample of the code for you to get comfortable with: https://lessonsintech.wordpress.com/2018/06/26/f5-python-sdk-basics/

     

    Unfortunately, I don't have a BIG-IP to test here, otherwise I'd be happy to come up with such a script for you.

     

    Good luck.

    • asabado's avatar
      asabado
      Icon for Altocumulus rankAltocumulus

      Thanks Rodrigo, this looks very promising however I have to admit that I have 0 knowledge of python.