F5Networks / f5-common-python

Python SDK for configuration and monitoring of F5® BIG-IP® devices via the iControl® REST API.
https://f5-sdk.readthedocs.org
Apache License 2.0
262 stars 133 forks source link

Error when updating an object that is created within a Transaction #1309

Open r-teller opened 6 years ago

r-teller commented 6 years ago

It looks like there is an issue in the TransactionContextManager function used to wrap different rest calls into a transaction. When I attempt to modify an object that is created within a transaction an error message is returned.

From what I can tell when an object is updated the _meta_data['uri'] attribute incorrectly refers to the URI path of the transaction instead of the URI path of the object that will be created.

Using the snippet below pool._meta_data['uri'] == 'https://10.10.1.202:80/mgmt/tm/transaction/1507766047230839/commands/1/' but in order to modify the object within the transaction the _meta_data['uri'] path is expected to be 'https://10.10.1.202:80/mgmt/tm/ltm/pool/pool_1/'

Code Snippet:

from f5.bigip import ManagementRoot
mgmt = ManagementRoot(hostname='10.10.1.202', port='80', username='myUsername', password='myPassword')
transaction = mgmt.tm.transactions.transaction
with TransactionContextManager(transaction, validate_only=False) as tx:
    pool = tx.tm.ltm.pools.pool.create(name='pool_1')
    pool.update(description = 'pool_descr')

Error:

Text: u'{"code":400,"message":"Found invalid command id 1/","errorStack":[],"apiError":1}'
caphrim007 commented 6 years ago

@rotelly and I verified this offline. I will be handling it's fix

wojtek0806 commented 6 years ago

@caphrim007 any status on this ?

jllorente commented 4 years ago

I have also run into this issue on a rather recent version, is there a workaround available ?