Closed chen23 closed 8 years ago
@chen23 how about deleting the pool_path =
line and having the print debug statement that used it be:
print("Created pool %s" % pool.selfLink)
instead?
Instead of directly calling instance.__str__()
call str(instance)
.
Here's the output with the suggested changes:
python cf2bigip-bad.py -f create.csv 10.1.1.5
create.csv
Created pool https://localhost/mgmt/tm/transaction/1471889627257896/commands/2?ver=11.6.1
Added member 192.168.11.11:80
Created policy rule dora.local.pcfdev.io
@chen23 do you have code I can use to reproduce?
And I!
This is a breaking change introduced in requests 2.11 https://github.com/kennethreitz/requests/issues/3477
A bit late. Here's the code: https://github.com/f5devcentral/f5-icontrol-codeshare-python/tree/master/pcf-example, use pcf-phase1.py.
The issue had two issues: 1. transaction ID in header 2. URI getting mangled during a transaction. Let me know if I should open a new ticket for the second issue, reopen, or leave my code as-is. Thanks.
Thanks @chen23 for your fixes !
I tried to create a virtual server with a member using a same transaction. Using f5-sdk==3.0.21
E icontrol.exceptions.iControlUnexpectedHTTPError: 400 Unexpected Error: Bad Request for uri: https://lb-bigip01/mgmt/tm/transaction/1583156579056330/commands/3/members/
E Text: '{"code":400,"message":"Found invalid command id 3/members/","errorStack":[],"apiError":1}'
Code to reproduce
host = os.getenv("BIGIP_BENCH_HOST")
user = os.getenv("BIGIP_BENCH_USER")
password = os.getenv("BIGIP_BENCH_PASSWORD")
mgmt = ManagementRoot(host, user, password)
tx = mgmt.tm.transactions.transaction
with TransactionContextManager(tx) as api:
https_monitor = api.tm.ltm.monitor.https_s.https.create(name="MyHttpsMonitor")
# create a node
node = api.tm.ltm.nodes.node.create(name="MyNode", address="1.2.3.4")
# create a pool
pool_name = "MyPool"
partition = "Common"
pool = api.tm.ltm.pools.pool.create(
name=pool_name,
loadBalancingMode="round-robin",
monitor="MyHttpsMonitor",
partition=partition
)
# Fixes {"code":400,"message":"Found invalid command id 3/members/","errorStack":[],"apiError":1}
# pool._meta_data['uri'] = pool._meta_data['uri'].split("/transaction/")[0] + "/ltm/pool/~%s~%s/" %(partition, pool_name)
# create a pool member - inherit monitor from pool.
member = pool.members_s.members.create(
name="MyNode:42", address="1.2.3.4", partition="Common"
)
# create vip
vip = api.tm.ltm.virtuals.virtual.create(
name="MyVip", pool=pool_name, source="0.0.0.0/0", destination="1.2.3.4:42"
)
Testing on 11.6.1 w/ f5-sdk 1.3.1 ran into two issues with transactions
I've patched my code to workaround the issues, not sure the best way to handle for the F5 Python SDK
Errors seen:
Code that avoids errors: