Forum Discussion

HarshadS's avatar
HarshadS
Icon for Altostratus rankAltostratus
Jun 28, 2022

Restoring UCS archive using REST API

Hi,

I was trying to figure out how to load an already uploaded UCS archive on bigip ltm using the rest API. The UCS file exists in /var/local/ucs and I'm trying to load it as shown below in the code sample but getting this as response:

{
    "code": 400,
    "message": "UCS loading process failed.",
    "errorStack": [],
    "apiError": 26214401
}

Any ideas what I'm doing wrong?

 

import requests
import json

url = "https://<mgmtip>/mgmt/tm/sys/ucs"

payload = json.dumps({
  "command": "load",
  "name": "/var/local/ucs/myucsfile.ucs"
})
headers = {
  'X-F5-Auth-Token': '<token>',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

 

 

  • Hi HarshadS,

    Can you try this?

    import requests
    import json
    
    url = "https://<mgmtip>/mgmt/tm/shared/sys/backup"
    
    payload = json.dumps({
      "file":"myucs.ucs",
      "action":"RESTORE",
      "generation":0,
      "lastUpdateMicros":0
    })
    headers = {
      'X-F5-Auth-Token': '<token>',
      'Content-Type': 'application/json'
    }
    
    response = requests.request("POST", url, headers=headers, data=payload)
    
    print(response.text)

    I didn't test it. 

  • Thanks for the reply - i think I found that my issue was the version of OS where the UCS was obtained from was different than the OS Version I was trying to import into - once I fixed that, the import worked with the same command I had.