From 67628dae8b37a226cb6899ffebffd66b40e74161 Mon Sep 17 00:00:00 2001 From: Michael E Brown Date: Tue, 8 Jan 2008 14:54:10 -0600 Subject: add ability to conditionally enable tmpfs based on minimum ram availability. --- py/mock/plugins/tmpfs.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'py/mock/plugins/tmpfs.py') 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): -- cgit