Reputation: 10144
On a ubuntu 16.04 machine with lxd 2.21, the following code returns all my containers:
from pylxd import Client
client = Client()
client.containers.all()
On a ubuntu 18.04 machine with lxd 3.0.1, the same code returns an empty list
On both machines, the command lxc list
returns many containers,
for some reason the client connection on the newer lxd host is not "seeing" the containers.
Upvotes: 0
Views: 239
Reputation: 10144
The solution was to set this environment variable:
export LXD_DIR=/var/lib/lxd
The api uses the socket /var/snap/lxd/common/lxd/unix.socket
by default, and in my installation the proper socket to use is /var/lib/lxd/unix.socket
from pylxd import Client
os.environ["LXD_DIR"] = "/var/lib/lxd"
client = Client()
client.containers.all()
Upvotes: 1