Thanks so much for responding. And yes, the last line of code is wrong.
so what i am trying to do is to attach an existing policy to a virtual server. my understanding was that trying to load a policy that is not already attached to the server would cause a failure:
vs.policies_s.policies.load(name='Portal_QA1', partition ='QA1_Web', subPath = 'Shared')
yields:
File "C:\Users\ttait\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\f5\bigip\tm\ltm\virtual.py", line 138, in load
raise NonExtantVirtualPolicy(msg)f5.sdk_exception.NonExtantVirtualPolicy: The Policy named, Portal_QA1, does not exist on the device.
but was successful if the policy had already been attached to the server (which i tested using the UI)
when i try to load and publish the existing policy
policy = mgmt.tm.ltm.policys.policy.load(name='Portal_QA1', partition ='QA1_Web', subPath = 'Shared') ## <-- this is successful
policy.publish()
i get this error:
policy.publish()
File "C:\Users\ttait\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\f5\bigip\tm\ltm\policy.py", line 155, in publish
assert 'Drafts' in self._meta_data['uri']
AssertionError
i have tried using 'create' to attach an existing policy to the virtual server:
vs.policies_s.policies.create(name='Portal_QA1', partition ='QA1_Web', subPath = 'Shared')
and that yields this error:
File "C:\Users\ttait\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\icontrol\session.py", line 295, in wrapper
raise iControlUnexpectedHTTPError(error_message, response=response)
icontrol.exceptions.iControlUnexpectedHTTPError: 404 Unexpected Error: Not Found for uri: https://10.80.91.172:443/mgmt/tm/ltm/virtual/~QA1_Web~reporting~serviceMain/policies/
Text: '{"code":404,"message":"01020036:3: The requested policy (Portal_QA1) was not found.","errorStack":[],"apiError":3}'
i feel like there should be some way to load the policy using mgmt.tm.ltm.policys.policy.load and then attach that to the virtual_server, but i cannot find anything in the documentation, or the examples that allows that.
the thing that's causing me the headache is that i can load the policy using the ltm.policys, so i know it exists on the f5, but i cannot load it using the vs.policies_s.policies.create() or vs.policies_s.policies.load()
is there something i need to do to the virtual server in order to allow this?