Forum Discussion

rliu_330156's avatar
rliu_330156
Icon for Nimbostratus rankNimbostratus
Aug 17, 2017

Error return on modifying pool member property with python script

Hi,

 

I have tried to use python script to modify the 'ratio' field for the member of pool and I always get following message in spite of using 'put' or 'patch' method:

 

{u'errorStack': [], u'message': u'invalid property value "state":"up"', u'code': 400, u'apiError': 26214401}

 

If using iControl REST curl command, the value of 'ratio' can be changed without problem.

 

Anyone can help me to figure out ?

 

Thanks,

 

Roger

 

2 Replies

  • Hi Roger,

    I assume this is the task you want to do:

    tmsh:

    modify ltm pool members modify { { ratio } }

    iControl REST (curl):

    curl -sku -H "Content-type: application/json" -X PATCH -d '{"ratio":}' https:///mgmt/tm/ltm/pool//members/

    e.g. (changing the ratio of the member ~Commmon~apache:80 in the pool CentOS to 10),

     

    curl -sku admin:admin -H "Content-type: application/json" -X PATCH 
         -d '{"ratio":10}' 
         https://192.168.0.2/mgmt/tm/ltm/pool/CentOS/members/~Common~apache:80

     

    A Python code for the above example would look like this (there should be better ways to do this):

     

    from f5.bigip import ManagementRoot
    
    mgmt = ManagementRoot('192.168.0.2', 'admin', 'admin')
    pool = mgmt.tm.ltm.pools.pool.load(name='CentOS', partition='Common')
    members = pool.members_s.get_collection()
    for member in members:
        print '{}: Ratio {}'.format(member.name, member.ratio)
        if member.name == 'apache:80':
            member.update(ratio=10)
            break
        

     

  • Probably you do not have pip installed or it is located somewhere not in your path. Install it first (I use yum so yum install python2-pip.noarch for my Python 2.7.5).