I’m using pylxd latest version (2.3.1). I tried to get all instances and I’m receiving those. But I want to add a check on response like below:
response = client.instances.all()
if response.status_code != 200:
print("Failed to get instances. Status code:", response.status_code)
exit()
if len(response) < 0:
print("No instance found")
exit()
if len(response):
further work...
More, How can we directly get the full details of each instance without creating custom dictionary/custom parsing like below:
instance_list = []
for instance in instances:
instance_dict = {
'name': instance.name,
'status': instance.status,
'ipv4': [],
'ipv6': [],
'architecture': instance.architecture,
'created_at': instance.created_at,
'config': instance.config,
'devices': instance.devices,
'ephemeral': instance.ephemeral,
'expanded_config': instance.expanded_config,
'expanded_devices': instance.expanded_devices,
'description': instance.description,
'profiles': instance.profiles,
'last_used_at': instance.last_used_at,
'location': instance.location,
'type':instance.type,
'status_code':instance.status_code,
'stateful':instance.stateful
}
and lastly how can we get to know what is actually return if we call any api using pylxd client?