Forum Discussion

Joel_Breton's avatar
Joel_Breton
Icon for Nimbostratus rankNimbostratus
May 26, 2017

Verify if NTLM Profile exists - Python F5-SDK

I'm trying to create ntlm profiles with Python, before creating the profile I want to verify if it already exists. I am able to accomplish this with the http profile but for some reason I'm not able with the ntlm profile

 

Here's the sample http script

 

from f5.bigip import ManagementRoot
bigip = ManagementRoot('ipaddress', 'user', 'password')
pfhttp = bigip.tm.ltm.profile.https

if pfhttp.http.exists(name='myhttpprofile', partition='mypartition'):
    pass
else:
    pfhttp.http.create(name='myhttpprofile', partition='mypartition'):

Here's the sample ntlm script

 

from f5.bigip import ManagementRoot
bigip = ManagementRoot('ipaddress', 'user', 'password')
pfntlm = bigip.tm.ltm.profile.ntlms

if pfntlm.ntlm.exists(name='myntlmprofile', partition='mypartition'):
    pass
else:
    pfntlm.ntlm.create(name='myntlmprofile', partition='mypartition'):

The script throws a 409 error - The object already exists on the BIG-IP, the if statement returns a Boolean value of False even though the object exists.

 

The requested Config Instance ( /mypartition/myntlmprofile profile_ntlm) already exists in partition 
mypartition.","errorStack":[],"apiError":3}'

If I try to load the ntlm profile

 

pfntlm.ntlm.load(name='myntlmprofile', partition='mypartition')

I get a 404 error

 

'{"code":404,"message":"Error in ntlm: \\"/mypartition/myntlmprofile\\" not found.\\n01020036:3: The requested 
Config Instance ( /mypartition/myntlmprofile profile_ntlm) was not found.","errorStack":[],"apiError":3}'

Also note If I try the same code with the default ntlm profile in the Common partition the script works as expected

 

if pfntlm.ntlm.exists(name='ntlm', partition='Common'):
    print('The ntlm profile already exist')
No RepliesBe the first to reply