()
Get all domains
Get all domains
Get all domains
def list_domains():
    """ Get all domains """
    connect()

    domain_list = []
    try:
        domains = conn.listAllDomains(0)
        for d in domains:
            domain = dict()
            domain["name"] = d.name()
            domain["id"] = d.ID()
            domain["uuid"] = d.UUIDString()
            if d.info()[0] == 1:
                domain["state"] = "running"
            else:
                domain["state"] = "shut off"
            domain_list.append(domain)

        domain_list.sort(key=lambda k: k["name"])
        return domain_list
    except Exception as e:
        logger.debug(str(e))
        raise Exception("Could not list domains")
def list_domains ( ) : connect ( ) domain_list = [ ] try : domains = conn . listAllDomains ( 0 ) for d in domains : domain = dict ( ) domain [ "name" ] = d . name ( ) domain [ "id" ] = d . ID ( ) domain [ "uuid" ] = d . UUIDString ( ) if d . info ( ) [ 0 ] == 1 : domain [ "state" ] = "running" else : domain [ "state" ] = "shut off" domain_list . append ( domain ) domain_list . sort ( key = lambda k : k [ "name" ] ) return domain_list except Exception as e : logger . debug ( str ( e ) ) raise Exception ( "Could not list domains" )