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 135 forks source link

using tar bash comannd in sdk python #1545

Open rbouali34 opened 5 years ago

rbouali34 commented 5 years ago

Hello,

i want to use a bash "tar -xzf" command in a python scrypt to uncompress an ucs file.

yyy=mgmt2.tm.util.bash.exec_cmd('run',utilCmdArgs="-c 'tar -xzf /var/local/ucs/tmp/migration/TEST.ucs'")

but I can not. I have a failure with this error msagge:

Python\Python37-32\lib\site-packages\f5\bigip\mixins.py", line 95, in getattr raise LazyAttributesRequired(error_message) f5.sdk_exception.LazyAttributesRequired: ('"allowed_lazy_attributes" not in', 'container._meta_data for class Bash')

I'm stuck if someone can help me

thank you

jasonrahm commented 4 years ago

Not sure what's causing your error there unless it's something I can't see. This works fine for me:

result = b.tm.util.bash.exec_cmd('run', utilCmdArgs='-c "tar -xzf /var/local/ucs/tmp/migration/TEST.ucs -C /var/tmp/test/"')

Note that if you don't use the -C option with tar, it will dump the extracted files in /var/service/restjavad, which is likely not the desired target.