summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael E Brown <mebrown@michaels-house.net>2008-01-08 14:54:10 -0600
committerMichael E Brown <mebrown@michaels-house.net>2008-01-08 14:54:10 -0600
commit67628dae8b37a226cb6899ffebffd66b40e74161 (patch)
tree6891acbe99a0435fa4fa02754e59316fc6a10fd0
parentcc889dbb4ed40909ffd6c29bc29623cfcf1a1ca5 (diff)
downloadmock-67628dae8b37a226cb6899ffebffd66b40e74161.tar.gz
mock-67628dae8b37a226cb6899ffebffd66b40e74161.tar.xz
mock-67628dae8b37a226cb6899ffebffd66b40e74161.zip
add ability to conditionally enable tmpfs based on minimum ram availability.
-rw-r--r--etc/mock/defaults.cfg2
-rwxr-xr-xpy/mock.py2
-rw-r--r--py/mock/plugins/tmpfs.py11
3 files changed, 12 insertions, 3 deletions
diff --git a/etc/mock/defaults.cfg b/etc/mock/defaults.cfg
index 626ef99..802f4c3 100644
--- a/etc/mock/defaults.cfg
+++ b/etc/mock/defaults.cfg
@@ -66,7 +66,7 @@
# config_opts['plugin_conf']['bind_mount_opts']['dirs'].append(('/host/path', '/bind/mount/path/in/chroot/' ))
#
# config_opts['plugin_conf']['tmpfs_enable'] = False
-# config_opts['plugin_conf']['tmpfs_opts'] = {}
+# config_opts['plugin_conf']['tmpfs_opts'] = {'required_ram_mb': 1024}
#############################################################################
#
diff --git a/py/mock.py b/py/mock.py
index bf0d616..d27d73e 100755
--- a/py/mock.py
+++ b/py/mock.py
@@ -240,7 +240,7 @@ def setup_default_config_opts(config_opts, unprivUid):
# ('/another/host/path', '/another/bind/mount/path/in/chroot/'),
]},
'tmpfs_enable': False,
- 'tmpfs_opts': {},
+ 'tmpfs_opts': {'required_ram_mb': 900},
}
# dependent on guest OS
diff --git a/py/mock/plugins/tmpfs.py b/py/mock/plugins/tmpfs.py
index 74c39a1..4896d26 100644
--- a/py/mock/plugins/tmpfs.py
+++ b/py/mock/plugins/tmpfs.py
@@ -15,7 +15,16 @@ requires_api_version = "1.0"
# plugin entry point
decorate(traceLog())
def init(rootObj, conf):
- Tmpfs(rootObj, conf)
+ system_ram_bytes = os.sysconf(os.sysconf_names['SC_PAGE_SIZE']) * os.sysconf(os.sysconf_names['SC_PHYS_PAGES'])
+ system_ram_mb = system_ram_bytes / (1024 * 1024)
+ if system_ram_mb > conf['required_ram_mb']:
+ Tmpfs(rootObj, conf)
+ else:
+ getLog().warning("Tmpfs plugin disabled. "
+ "System does not have the required amount of RAM to enable the tmpfs plugin. "
+ "System has %sMB RAM, but the config specifies the minimum required is %sMB RAM. "
+ %
+ (system_ram_mb, conf['required_ram_mb']))
# classes
class Tmpfs(object):