Uploading ISOs via legacy f5-sdk
I'm working on porting our legacy Bash-based BIG-IP upgrade script to Python, and running into an issue when trying to upload the new image via the (apparently legacy) SDK. Here's the relevant code snippet I'm using:
print("Uploading " + firmwareIsoPath + " to " + t + "...")
try:
firmwareUpload = apiClient.cm.autodeploy.software_image_uploads.upload_file(firmwareIsoPath)
except Exception as e:
print("ERROR: could not upload firmware to " + t)
print(e)
continue
Every time it tries to run though, it throws the following exception:
Traceback (most recent call last):
File "autonet.py", line 632, in <module>
upgradeF5Appliances(username,password,inventory)
File "/mnt/c/Code/Autonet/src/api_f5_upgrade.py", line 112, in upgradeF5Appliances
firmwareUpload = apiClient.cm.autodeploy.software_image_uploads.upload_file(firmwareIsoPath)
File "/home/cshepard/.local/lib/python3.8/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 Software_Image_Uploads')
I haven't been able to figure out why this is happening based on the SDK documentation, any advice? I'm not sure what a "lazy attribute" is in this context, so I'm not sure where to start...
Ideally I'd like to use the same session as the rest of my API calls, so we don't have to go through our MFA process multiple times for one device.
Update: use upload_image, not upload_file.
This was successful (slow, but successful) for me:from f5.bigip import ManagementRoot b = ManagementRoot('ltm3.test.local', 'admin', 'admin') b.cm.autodeploy.software_image_uploads.upload_image('/Users/jrahm/Downloads/BIGIP-14.1.4.1-0.0.4.iso')
make sure your firmwareIsoPath is accurate and that method requires a .iso extension. Also, if this is greenfield and you're not really too far into a conversion, I'd highly recommend bigrest over the f5-common-python library. Here's a couple compare/contrast articles I wrote between the two: