f5-common-python
f5-common-python copied to clipboard
shared/sys/backup endpoint
Hi All, I took a first try at writing some code to handle using the backup worker capability that exists in BIG-IP. I use the worker in some of my scripts using requests, since it completes immediately and running the typical save sys ucs command will timeout, sometimes.
Could I get someone to check out my work? Not sure if I need to add anything else. https://github.com/vsnine/f5-common-python/commit/4b1d74cf573c824b89d61bd3387b68ab39eed509
I've tested the following calls against v13.1.0.3, and it seems to work pretty well. List all backups:
bkups = mgmt.tm.shared.sys.backups.get_collection()
for y in bkups:
pp.pprint(y.raw)
Create a backup:
makejob = mgmt.tm.shared.sys.backups.backup.create(name="backup1",file="backup1.ucs",action="BACKUP")
Delete a backup:
bkupjob = mgmt.tm.shared.sys.backups.backup.load(name="fe6069cd-4d45-451b-8c81-2dfad02326ee")
bkupjob.delete()
Check in-progress job status:
checkjob = mgmt.tm.shared.sys.backups.backup.load(name="fe6069cd-4d45-451b-8c81-2dfad02326ee")
checkjob.refresh()
One thing I've seen is that if the same create call is made in rapid succession it seems to cause the jobs on the BIG-IP to stall, but I think it needs more testing.
Another thing is that I'm not sure how to make create() not require a name attribute. You can specify it, and it appears in the output when querying jobs, but the name attribute used in load() actually refers to the value of the id attribute. The URI for a given backup job looks like this: /tm/shared/sys/backup/aeb1d552-cc9f-4a42-984e-ba03a6dcf0c1
Thanks!
@vsnine to make it not require name, add this to the resource
self._meta_data['required_creation_parameters'] = set()
Include in the set anything it requires. in other words, dont use update
also, i think id, or uuid, or both are supported unique identifiers in the icontrol rest lib that the sdk uses. so you can probably replace name in your load calls with id or uuid
https://github.com/F5Networks/f5-icontrol-rest-python/blob/1.0/icontrol/session.py#L321
looks good otherwise. i suspect the stalled jobs thing is a bug in bigip. does the same behavior occur when you run multiple tmsh commands?
@vsnine please submit PR to the repository if you wish to have this work commited