Forum Discussion
Using Python Bigsuds for Replacing TCP Profile
Hi,
I'm trying to run the following from a Python script but i'm getting the following error message. I've tried both options but I'm getting the same error message. Any idea on why this would be happening?
Option 1.) lb_obj.LocalLB.VirtualServer.add_profile([vip],[[{'profile_context': 'PROFILE_CONTEXT_TYPE_ALL', 'profile_name': '/Common/tcp-lan-optimized'}]])
Option 2.) lb_obj.LocalLB.VirtualServer.remove_profile([vip],[[{'profile_context': 'PROFILE_CONTEXT_TYPE_CLIENT', 'profile_name': count['profile_name']}]]) lb_obj.LocalLB.VirtualServer.add_profile([vip],[[{'profile_context': 'PROFILE_CONTEXT_TYPE_ALL', 'profile_name': '/Common/tcp-lan-optimized'}]])
Error message: bigsuds.ServerError: Server raised fault: 'Exception caught in LocalLB::urn:iControl:LocalLB/VirtualServer::add_profile() Exception: Common::OperationFailed primary_error_code : 17236119 (0x01070097) secondary_error_code : 0 error_string : 01070097:3: Virtual server /Common/TESTVIP lists duplicate profiles.'
3 Replies
- JRahm
Admin
It's kind of odd that the returned data shows a field (profile_type) that isn't supported when working with the data (as well it doesn't appear to show the tcp profile until you've removed the http profile, which is also odd,) but if you eliminate that in the objects it seems to add/remove just fine:
>>> b.LocalLB.VirtualServer.get_profile(['/Common/phpauction']) [[{'profile_name': '/Common/http', 'profile_context': 'PROFILE_CONTEXT_TYPE_ALL', 'profile_type': 'PROFILE_TYPE_HTTP'}, {'profile_name': '/] >>> test_profile = [[{'profile_name': '/Common/http', 'profile_context': 'PROFILE_CONTEXT_TYPE_ALL'}]] >>> b.LocalLB.VirtualServer.remove_profile(['/Common/phpauction'], test_profile) >>> b.LocalLB.VirtualServer.get_profile(['/Common/phpauction']) [[{'profile_name': '/Common/tcp', 'profile_context': 'PROFILE_CONTEXT_TYPE_ALL', 'profile_type': 'PROFILE_TYPE_TCP'}]] >>> b.LocalLB.VirtualServer.add_profile(['/Common/phpauction'], test_profile) >>> b.LocalLB.VirtualServer.get_profile(['/Common/phpauction']) [[{'profile_name': '/Common/http', 'profile_context': 'PROFILE_CONTEXT_TYPE_ALL', 'profile_type': 'PROFILE_TYPE_HTTP'}, {'profile_name': '/] - Justin_Kinney_1
Nimbostratus
Sweet! The transaction approach completely works. Sample code below:
b = bigsuds.BIGIP(host, username, password) virtual_server = 'vs-foo' with bigsuds.Transaction(b): del_profiles = [{'profile_context': 'PROFILE_CONTEXT_TYPE_ALL', 'profile_name': '/Common/tcp'}] b.LocalLB.VirtualServer.remove_profile([virtual_server], [del_profiles]) add_profiles = [{'profile_context': 'PROFILE_CONTEXT_TYPE_ALL', 'profile_name': '/Common/tcp-wan-optimized'}] b.LocalLB.VirtualServer.add_profile([virtual_server], [add_profiles])- JRahm
Admin
Nice! I'll write this up for others when I get back into the office.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com