cancel
Showing results for 
Search instead for 
Did you mean: 

F5 SDK Python - Assign HTTP Profile to VIP

Vukasin_Kopriv1
Nimbostratus
Nimbostratus

Hi, can someone draw me an example how can I assign HTTP profile to existing VIP? I am seeing that ipProtocol key is tight to tcp profile but I do not see any key that has http profile assigned when queering VIP configuration. I am little bit lost here.

3 REPLIES 3

Hi Vukasin

 

I think you'd be looking for mgmt.tm.ltm.profile.http.create():

from f5.bigip import ManagementRoot   # Connect to the BIG-IP mgmt = ManagementRoot("bigip.example.com", "admin", "somepassword")   # Create a new HTTP profile on the BigIP my_http_profile = mgmt.tm.ltm.profile.http.create(name='myhttpprofile', partition='Common')

I don't have a BIG-IP to test it but I was going through the source code here:

https://f5-sdk.readthedocs.io/en/latest/_modules/f5/bigip/tm/ltm.html?highlight=bigip.tm.ltm.profile

https://f5-sdk.readthedocs.io/en/latest/_modules/f5/bigip/resource.html?highlight=f5.bigip.resource

 

Try it out using your python REPL and check if it complains about missing arguments (like required HTTP profile fields) but according to doc above, it's similar to the regular REST API call from here: https://support.f5.com/csp/article/K13225405#http

 

It'd be good if you come back here and post a reply with your attempt using Python REPL for future reference.

Vukasin_Kopriv1
Nimbostratus
Nimbostratus

Hi Rodrigo, thank you for responding. Creating profile works for me with not issues, but I do not know how to update the VIP and assign that same profile to it. For example this particular VIP has two profiles assigned via GUI: Protocol Profile (client): tcp, and HTTP Profile: http_profile_1. Her is the output when using SDK and no signs of http profile assigned:

 

vip1:

kind tm:ltm:virtual:virtualstate

name vip1

partition Common

fullPath /Common/vip1

generation 209

selfLink https://localhost/mgmt/tm/ltm/virtual/~Common~vip1?ver=13.1.3.5

addressStatus yes

autoLasthop default

cmpEnabled yes

connectionLimit 0

destination /Common/10.3.44.72:443

enabled True

gtmScore 0

ipProtocol tcp

mask 255.255.255.255

mirror disabled

mobileAppTunnel disabled

nat64 disabled

pool /Common/test_pool_1

poolReference {'link': 'https://localhost/mgmt/tm/ltm/pool/~Common~test_pool_1?ver=13.1.3.5'}

rateLimit disabled

rateLimitDstMask 0

rateLimitMode object

rateLimitSrcMask 0

serviceDownImmediateAction none

source 0.0.0.0/0

sourceAddressTranslation {'type': 'none'}

sourcePort preserve

synCookieStatus not-activated

translateAddress enabled

translatePort enabled

vlansDisabled True

vsIndex 32

policiesReference {'link': 'https://localhost/mgmt/tm/ltm/virtual/~Common~vip1/policies?ver=13.1.3.5', 'isSubcollection': True}

profilesReference {'link': 'https://localhost/mgmt/tm/ltm/virtual/~Common~vip1/profiles?ver=13.1.3.5', 'isSubcollection': True}

_meta_data {'container': <f5.bigip.tm.ltm.virtual.Virtuals object at 0x7fe96a6da8b0>, 'bigip': <f5.bigip.ManagementRoot object at 0x7fe96a742c40>, 'icr_session': <icontrol.session.iControlRESTSession object at 0x7fe96a742c70>, 'icontrol_version': '', 'minimum_version': '11.5.0', 'allowed_commands': [], 'required_command_parameters': set(), 'exclusive_attributes': [('enabled', 'disabled'), ('vlansEnabled', 'vlansDisabled')], 'object_has_stats': True, 'minimum_additional_parameters': set(), 'required_creation_parameters': {'name'}, 'required_load_parameters': {'name'}, 'read_only_attributes': [], 'reduction_forcing_pairs': [('enabled', 'disabled'), ('online', 'offline'), ('vlansEnabled', 'vlansDisabled')], 'allowed_lazy_attributes': [<class 'f5.bigip.tm.ltm.virtual.Profiles_s'>, <class 'f5.bigip.tm.ltm.virtual.Policies_s'>, <class 'f5.bigip.resource.Stats'>], 'required_json_kind': 'tm:ltm:virtual:virtualstate', 'attribute_registry': {'tm:ltm:virtual:profiles:profilescollectionstate': <class 'f5.bigip.tm.ltm.virtual.Profiles_s'>, 'tm:ltm:virtual:policies:policiescollectionstate': <class 'f5.bigip.tm.ltm.virtual.Policies_s'>}, 'uri': 'https://ch3-lab-lb01.csfunds.org:443/mgmt/tm/ltm/virtual/~Common~vip1/', 'creation_uri_qargs': {'ver': ['13.1.3.5']}, 'creation_uri_frag': ''}

###############################################

Vukasin_Kopriv1
Nimbostratus
Nimbostratus

I was able to update vip property and assign profile using these steps:

vip_obj = mgmt.tm.ltm.virtuals.virtual.load(name=name)

vip_obj.profiles=["tcp", "http_profile_1"]

vip_obj.update()