Forum Discussion
Upload SSL certificate/key via REST API
Hi Jason,
Do you still have this python script?
you'll want something a little more foolhardy. That logic has been rolled into either the f5-common-python library (no longer maintained) or the newer bigrest library, which is actively being developed (but not by F5). Even so, I recommend the latter.
To do it with bigrest (untested but should be close):
from bigrest.bigip import BIGIP
from pathlib import Path
import sys
def instantiate_bigip(host, user, password):
try:
obj = BIGIP(host, user, password)
except Exception as e:
print(f"Failed to connect to {host} due to {type(e).__name__}:\n")
print(f"{e}")
sys.exit()
return obj
def upload_file(obj, filename):
if Path(filename).suffix == ".iso":
endpoint = "/mgmt/cm/autodeploy/software-image-uploads"
else:
endpoint = "/mgmt/shared/file-transfer-uploads"
try:
obj.upload(endpoint, filename)
except Exception as e:
print(f"Failed to upload {Path(filename).name} due to {type(e).__name__}:\n")
print(f"{e}")
sys.exit()
if __name__ == "__main__":
host = '1.1.1.1'
user = 'admin'
password = 'admin'
f = '/path/to/your/file/file.xyz'
b = instantiate_bigip(host, user, password)
upload_file(f)
You can add argparse to take arguments instead of hardcoding the file and bigip details, or set them as environment variables and include them that way. Obviously not secure to keep credentials this way.
- Raj6Jan 25, 2024Nimbostratus
Hi,
Can we achieve the same using Node.js? If yes, can you help me with the steps as I could not find any relevant docs on how to upload file using the REST apis in node.js.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com