sdk
21 TopicsTrying to assign a policy to a virtual server
i am trying to change policies on a virtual server, using the python sdk. i load the vs, i can load the existing policy on the vs, and delete it, but when i try to create a new policy for the vs, i get a 404 error saying that the policy cannot be found. ## load the virtual server vs = mgmt.tm.ltm.virtuals.virtual.load(name="serviceMain", partition ="partition", subPath = "subPath") ## load the policy. this works policy = mgmt.tm.ltm.policys.policy.load(name="pol_name", partition ="partition", subPath = "subPath") ## load existing policy from the vs and delete it. this works pol = vs.policies_s.policies.load(name="pol_name", partition ="partition", subPath = "subPath") pol.delete() ## create a new policy. this fails mgmt.tm.ltm.policys.policy.create(name="pol_name", partition ="partition", subPath = "subPath") i get this error: Text: '{"code":404,"message":"01020036:3: The requested policy (pol_name) was not found.","errorStack":[],"apiError":3}' the policy exists, and was loaded earlier in the script, but it can't be found. i have tried other methods of attaching the policy, and they have all failed. any ideas? thanks, -tSolved1.5KViews1like11CommentsHow to install a cert and a key through Python SDK
I am trying to install a cert and a key through Python SDK. BIG-IP Version: 12.1.2 First.. I had no problem with uploading certs and keys to F5's /var/config/rest/downloads/ folder. Now when I tried the following python code to install cert and key, I didn't see any error. key = bitip.tm.sys.file.ssl_keys.ssl_key.create(name='test', partition='Common', sourcePath='file:/var/config/rest/downloads/test.key') cert = bitip.tm.sys.file.ssl_certs.ssl_cert.create(name='test', partition='Common', sourcePath='file:/var/config/rest/downloads/test.crt') However when I logged on BIG-IP device and clicked a cert or key to see their actual content, I couldn't see any content. "No certificate" under certificate tab and an error message of "An error has occurred while trying to process your request." under Key tab. Does any one know what is causing this problem? Or is there any way I can troubleshoot this issue? Thank you.1KViews1like4Commentspython f5 SDK 401 Unexpected Error: F5 Authorization Required
when I try to run the script below from f5.bigip import BigIP from f5.bigip import ManagementRoot bigip = BigIP("host", "username", "password") # Get a list of all pools on the BigIP and print their name and their # members' name pools = bigip.ltm.pools.get_collection() for pool in pools: print(pool.name) for member in pool.members: print (member.name) it promote error below: Unexpected Error: F5 Authorization Required for uri: https://host:443/mgmt/tm/sys/ Text: '{"code":401,"message":"Authorization failed: user=https://localhost/mgmt/shared/authz/users/user resource=/mgmt/tm/sys verb=GET uri:http://localhost:8100/mgmt/tm/sys/ referrer:10.209.18.167 sender:10.209.18.167","referer":"10.209.18.167","restOperationId":115127900,"errorStack":["java.lang.SecurityException: Authorization failed: user=https://localhost/mgmt/shared/authz/users/user resource=/mgmt/tm/sys verb=GET uri:http://localhost:8100/mgmt/tm/sys/ referrer:mysource sender:mysource","at com.f5.rest.workers.EvaluatePermissions.failPermissionValidation(EvaluatePermissions.java:249)","at com.f5.rest.workers.EvaluatePermissions.access$100(EvaluatePermissions.java:24)","at com.f5.rest.workers.EvaluatePermissions$2.completed(EvaluatePermissions.java:202)","at com.f5.rest.workers.EvaluatePermissions$2.completed(EvaluatePermissions.java:186)","at com.f5.rest.workers.RolesWorker$10.completed(RolesWorker.java:963)","at com.f5.rest.workers.RolesWorker$10.completed(RolesWorker.java:954)","at com.f5.rest.workers.Cache$1.completed(Cache.java:151)","at com.f5.rest.workers.TmosRoleCache$1.completed(TmosRoleCache.java:69)","at com.f5.rest.workers.TmosRoleCache$1.completed(TmosRoleCache.java:64)","at com.f5.rest.common.RestOperation.complete(RestOperation.java:2411)","at com.f5.rest.common.RestWorker$3.completed(RestWorker.java:757)","at com.f5.rest.common.RestWorker$3.completed(RestWorker.java:746)","at com.f5.rest.common.RestOperation.complete(RestOperation.java:2411)","at com.f5.rest.tmos.shared.adapter.TmosRoleWorker$1.completed(TmosRoleWorker.java:65)","at com.f5.rest.tmos.shared.adapter.TmosRoleWorker$1.completed(TmosRoleWorker.java:58)","at com.f5.rest.tmos.shared.mcp.McpOperation.complete(McpOperation.java:377)","at com.f5.rest.tmos.shared.mcp.McpRunnableTask.run(McpRunnableTask.java:47)","at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:473)","at java.util.concurrent.FutureTask.run(FutureTask.java:262)","at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)","at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)","at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)","at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:622)","at java.lang.Thread.run(Thread.java:748)\\n"],"kind":":resterrorresponse"}' but actually , if I try to use request API , I can access https://host:443/mgmt/tm/sys/ here is the output . so what's the problem . how can I fix it . {'kind': 'tm:sys:syscollectionstate', 'selfLink': 'https://localhost/mgmt/tm/sys?ver=13.1.1.4', 'items': [{'reference': {'link': 'https://localhost/mgmt/tm/sys/application?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/daemon-log-settings?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/diags?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/disk?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/dynad?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/ecm?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/file?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/fpga?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/icall?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/sflow?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/software?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/turboflex?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/url-db?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/aom?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/autoscale-group?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/cluster?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/daemon-ha?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/datastor?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/db?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/dns?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/feature-module?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/folder?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/global-settings?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/httpd?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/icontrol-soap?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/log-rotate?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/management-dhcp?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/management-ip?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/management-ovsdb?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/management-proxy-config?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/management-route?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/ntp?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/outbound-smtp?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/provision?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/scriptd?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/service?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/smtp-server?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/snmp?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/sshd?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/state-mirroring?ver=13.1.1.4'}}, {'reference': {'link': 'https://localhost/mgmt/tm/sys/syslog?ver=13.1.1.4'}}]}Solved1.4KViews1like3Comments