How Do I Import Image From a URL Using LXD API: No Source Provided Error

Nothing I tried worked so far, here is what I am using so far:

^ array:2 [▼
  "auto_update" => false
  "source" => array:4 [▼
    "alias" => "test-alias"
    "image_type" => "container"
    "type" => "instance"
    "url" => "https://xxx.com"
  ]
]

I get a No Source Provided Error, I have changed the type to container, same error, if I change the type to image, it tries to connect to an empty lxd server, meaning I need to add the server key and supply the value in the source array, but that is not what I want, I don’t wanna import from an lxd server, I want to import from a URL.

Importing from URL works manually so far, can someone provide the correct payload for me?

If you try the following (replace the --unix-socket bit by your LXD server URL):

curl -s --unix-socket /var/lib/lxd/unix.socket -X POST -d \
'{"source":{"type":"url","mode":"pull","protocol":"simplestreams","url":"https://xxx.com"}' \
a/1.0/images | jq .

what is the output ?

1 Like

Thank you, type url was the missing piece, also, the simplestreams can be omitted as well. Please, the team should try to make certain things clear in the doc

For future readers using CURL or PHP, here is the payload (which includes importing a URL with an alias):

^ array:3 [▼
  "auto_update" => false
  "aliases" => array:1 [▼
    0 => array:1 [▼
      "name" => "AddImageAliasOrFingerPrint"
    ]
  ]
  "source" => array:3 [▼
    "mode" => "pull"
    "type" => "url"
    "url" => "https://xxx.com"
  ]
]
1 Like

What format is the image in, and what is the URL? Are you trying to add a remote to a LXD server, or is is a basic HTTP server?

Just trying to import a unified tarball from a URL, while it does make sense for the type to be URL, it wasn’t clear since if you are importing with the CLI tool you do not specify a type

1 Like