canonical/pylxd

pylxd version conflicts

irtaza9 opened this issue · 3 comments

I installed old version the pylxd which is 2.2.10 and verified it on my system. Now when I run any function It throw errors that this is not available in pylxd.

doing:

import pylxd
import json

cert=('/home/myuser/xxxxxyyyyzzzz.crt', '/home/myuser/xxxxxyyyyzzzz.key')
                      
try:
    client = pylxd.Client(endpoint='https://lxd-host.com:8443', cert=cert, verify=False)
    instance = client.instances.get('testirtaza1')
    addresses = instance.state().network['eth0']['addresses']
    addresses[0]
except pylxd.exceptions.ClientConnectionFailed as e:
    print(f"Connection to LXD failed: {e}")
except pylxd.exceptions.LXDAPIException as e:
    print(f"Error calling LXD API: {e}")

Error:

Traceback (most recent call last):
File "/home/xxxxxyyyyzzzz/python/test.py", line 8, in
instance = client.instances.get('testirtaza1')

AttributeError: 'Client' object has no attribute 'instances'

2.2.10 is too old to know about instances, it only knows about containers: https://github.com/lxc/pylxd/tree/2.2.10/pylxd/models

@simondeziel Like will this issue be fix if I update the pylxd?

AttributeError: 'Client' object has no attribute 'instances' should indeed be resolved with a newer version.