-def get_cgroup_path(name):
- """ Returns the base path for the cgroup with a specific name """
- assert CGROUPS.has_key(name), \
- "No sliver %s managed by libvirt through cgroup!" % name
- return CGROUPS[name]
+def get_cgroup_paths(subsystem="cpuset"):
+ cpusetBase = os.path.join(BASE_DIR, subsystem, 'libvirt', 'lxc')
+ return filter(os.path.isdir,
+ map(lambda f: os.path.join(cpusetBase, f),
+ os.listdir(cpusetBase)))
+
+def get_cgroup_path(name, subsystem="cpuset"):
+ """ Returns the base path for the cgroup with a specific name or None."""
+ return reduce(lambda a, b: b if os.path.basename(b) == name else a,
+ get_cgroup_paths(subsystem), None)