f5-common-python icon indicating copy to clipboard operation
f5-common-python copied to clipboard

Passing an argument with the `-` symbol

Open drenout opened this issue 7 years ago • 0 comments

I tired to run the next code snippet:

from f5.bigip import ManagementRoot

mgmt = ManagementRoot(ip, login, pass)
policy = mgmt.tm.security.firewall.policy_s.policy.create(name='baseline_firewall_policy', partition='Common')
policy.rules_s.rule.create(name='rule', placeAfter='first', action='accept')

And I got the next traceback:

  File "<stdin>", line 1, in <module>
  File "/home/nikolaev/automation/sys-perf-tests/venv3/lib/python3.6/site-packages/f5/bigip/resource.py", line 1053, in create
    return self._create(**kwargs)
  File "/home/nikolaev/automation/sys-perf-tests/venv3/lib/python3.6/site-packages/f5/bigip/resource.py", line 1000, in _create
    self._minimum_one_is_missing(**kwargs)
  File "/home/nikolaev/automation/sys-perf-tests/venv3/lib/python3.6/site-packages/f5/bigip/resource.py", line 989, in _minimum_one_is_missing
    raise MissingRequiredCreationParameter(error_message)
f5.sdk_exception.MissingRequiredCreationParameter: This resource requires at least one of the mandatory additional parameters to be provided: place-after, place-before

Could you please advice me how to correctly pass the place-after or the place-before argumet to the function. I have a workaround, but wonder is it possible to reach the same result via key-value argument. The workaround:

policy.rules_s.rule.create(**{'name': 'rule', 'place-after': 'first', 'action': 'accept'})

drenout avatar Aug 08 '18 23:08 drenout