def test_read_mounted_cgroups_rh7(self): """Test get mounted point from rh7 """ subsystems2mounts = cgroups.read_mounted_cgroups() self.assertEqual( subsystems2mounts, { 'cpu': ['/sys/fs/cgroup/cpu,cpuacct'], 'cpuacct': ['/sys/fs/cgroup/cpu,cpuacct'], 'cpuset': ['/sys/fs/cgroup/cpuset', '/cgroup/cpuset'] })
def test_read_mounted_cgroups_rh6(self): """Test get mounted point from rh6 """ subsystems2mounts = cgroups.read_mounted_cgroups() self.assertEqual( subsystems2mounts, { 'blkio': ['/cgroup/blkio'], 'cpu': ['/cgroup/cpu'], 'cpuacct': ['/cgroup/cpuacct'], 'cpuset': ['/cgroup/cpuset'], })
def cgmount(): """Mount cgroups.""" mounted_cgroups = cgroups.read_mounted_cgroups() wanted_cgroups = cgroups.wanted_cgroups() unwanted_cgroups = cgroups.unwanted_cgroups() for cgname, cgmounts in six.iteritems(mounted_cgroups): _LOGGER.debug('Mounted cgroup %r(%r)', cgname, cgmounts) if cgname in unwanted_cgroups: _unmount_cgroup(cgname, cgmounts) elif len(cgmounts) > 1: _LOGGER.warning('Cgroup %r has multiple mount points: %r', cgname, cgmounts) for cgname in wanted_cgroups: if cgname not in mounted_cgroups: _mount_cgroup(cgname, wanted_cgroups[cgname])
def test_read_mounted_cgroups(self): """Test get mounted point. """ fs_linux.list_mounts.return_value = [ fs_linux.MountEntry(mount_id=24, parent_id=17, source='tmpfs', target='/sys/fs/cgroup', fs_type='tmpfs', mnt_opts={ 'mode=755', 'nodev', 'noexec', 'nosuid', 'ro', }), fs_linux.MountEntry(mount_id=24, parent_id=17, source='cgroup', target='/sys/fs/cgroup/devices', fs_type='cgroup', mnt_opts={ 'clone_children', 'noexec', 'relatime', 'rw', 'nosuid', 'devices', 'nodev', }), fs_linux.MountEntry(mount_id=24, parent_id=17, source='cgroup', target='/sys/fs/cgroup/memory', fs_type='cgroup', mnt_opts={ 'clone_children', 'noexec', 'relatime', 'rw', 'nosuid', 'memory', 'nodev', }), fs_linux.MountEntry(mount_id=24, parent_id=17, source='cgroup', target='/sys/fs/cgroup/blkio', fs_type='cgroup', mnt_opts={ 'clone_children', 'blkio', 'noexec', 'relatime', 'rw', 'nosuid', 'nodev', }), fs_linux.MountEntry(mount_id=24, parent_id=17, source='cgroup', target='/sys/fs/cgroup/net_cls,net_prio', fs_type='cgroup', mnt_opts={ 'clone_children', 'noexec', 'relatime', 'net_cls', 'rw', 'nosuid', 'nodev', 'net_prio', }), fs_linux.MountEntry(mount_id=24, parent_id=17, source='cgroup', target='/sys/fs/cgroup/pids', fs_type='cgroup', mnt_opts={ 'pids', 'clone_children', 'noexec', 'relatime', 'rw', 'nosuid', 'nodev', }), fs_linux.MountEntry(mount_id=24, parent_id=17, source='cgroup', target='/sys/fs/cgroup/hugetlb', fs_type='cgroup', mnt_opts={ 'hugetlb', 'clone_children', 'noexec', 'relatime', 'rw', 'nosuid', 'nodev', }), fs_linux.MountEntry(mount_id=24, parent_id=17, source='cgroup', target='/sys/fs/cgroup/freezer', fs_type='cgroup', mnt_opts={ 'clone_children', 'freezer', 'noexec', 'relatime', 'rw', 'nosuid', 'nodev', }), fs_linux.MountEntry(mount_id=24, parent_id=17, source='cgroup', target='/sys/fs/cgroup/cpu,cpuacct', fs_type='cgroup', mnt_opts={ 'clone_children', 'noexec', 'relatime', 'cpuacct', 'cpu', 'rw', 'nosuid', 'nodev', }), fs_linux.MountEntry(mount_id=24, parent_id=17, source='cgroup', target='/sys/fs/cgroup/perf_event', fs_type='cgroup', mnt_opts={ 'clone_children', 'noexec', 'relatime', 'rw', 'perf_event', 'nosuid', 'nodev', }), fs_linux.MountEntry(mount_id=24, parent_id=17, source='cgroup', target='/sys/fs/cgroup/cpuset', fs_type='cgroup', mnt_opts={ 'clone_children', 'cpuset', 'noexec', 'relatime', 'rw', 'nosuid', 'nodev', }), ] subsystems2mounts = cgroups.read_mounted_cgroups() self.assertEqual( subsystems2mounts, { 'blkio': ['/sys/fs/cgroup/blkio'], 'cpu': ['/sys/fs/cgroup/cpu,cpuacct'], 'cpuacct': ['/sys/fs/cgroup/cpu,cpuacct'], 'cpuset': ['/sys/fs/cgroup/cpuset'], 'memory': ['/sys/fs/cgroup/memory'], })