

def _extract_images(self, compute):
    '\n        Extract image disks from a compute node XML representation.\n\n        Extract image disk descriptions from a compute node XML representation,\n        converting the disks to an NodeImage object.\n\n        :type  compute: :class:`ElementTree`\n        :param compute: XML representation of a compute node.\n\n        :rtype:  ``list`` of :class:`NodeImage`\n        :return: Disks attached to a compute node.\n        '
    disks = list()
    for element in compute.findall('DISK'):
        disk = element.find('STORAGE')
        image_id = disk.attrib['href'].partition('/storage/')[2]
        if ('id' in element.attrib):
            disk_id = element.attrib['id']
        else:
            disk_id = None
        disks.append(NodeImage(id=image_id, name=disk.attrib.get('name', None), driver=self.connection.driver, extra={
            'type': element.findtext('TYPE'),
            'disk_id': disk_id,
            'target': element.findtext('TARGET'),
        }))
    if (len(disks) > 1):
        return disks
    elif (len(disks) == 1):
        return disks[0]
    else:
        return None

dataset/ETHPy150Open apache/libcloud/libcloud/compute/drivers/opennebula.py OpenNebula_2_0_NodeDriver._extract_images/original