'Get a list of libvirt.Domain objects for nova instances
:param only_running: True to only return running instances
:param only_guests: True to filter out any host domain (eg Dom-0)
Query libvirt to a get a list of all libvirt.Domain objects
that correspond to nova instances. If the only_running parameter
is true this list will only include active domains, otherwise
inactive domains will be included too. If the only_guests parameter
is true the list will have any "host" domain (aka Xen Domain-0)
filtered out.
:returns: list of libvirt.Domain objects'

def list_instance_domains(self, only_running=True, only_guests=True):

    flags = libvirt.VIR_CONNECT_LIST_DOMAINS_ACTIVE
    if (not only_running):
        flags = (flags | libvirt.VIR_CONNECT_LIST_DOMAINS_INACTIVE)
    alldoms = self.get_connection().listAllDomains(flags)
    doms = []
    for dom in alldoms:
        if (only_guests and (dom.ID() == 0)):
            continue
        doms.append(dom)
    return doms
