def get_containers(description_pattern = None):
    "Returns a list all of the extant containers."

    # If we do not care about the description, we can very quickly get a list
    # of the extant containers by enumerating through the directory which
    # contains the containers' private areas. Otherwise, we have to use
    # vzlist.
    if description_pattern == None:
        # Find the directory where the container's private areas are stored
        dirPath = find_container_directory()

        # Get all the containers that have already been created
        containers = []
        for i in os.listdir(dirPath):
            try:
                containers.append(int(i))
            except __HOLE__:
                pass

        return containers
    else:
        flags = ["-d", description_pattern]

        p = subprocess.Popen([vzlistPath] + flags + ["-aHo", "ctid"],
                             stdout = subprocess.PIPE, stderr = nullFile)

        output = p.communicate()

        if p.returncode != 0:
            raise SystemError((p.returncode, "Could not list containers"))

        return [int(i.strip()) for i in output[0].splitlines()]
dataset/ETHPy150Open ucrcsedept/galah/galah/sheep/virtualsuites/vz/pyvz.py/get_containers