diff options
author | Michael E Brown <mebrown@michaels-house.net> | 2008-01-08 14:54:10 -0600 |
---|---|---|
committer | Michael E Brown <mebrown@michaels-house.net> | 2008-01-08 14:54:10 -0600 |
commit | 67628dae8b37a226cb6899ffebffd66b40e74161 (patch) | |
tree | 6891acbe99a0435fa4fa02754e59316fc6a10fd0 /py | |
parent | cc889dbb4ed40909ffd6c29bc29623cfcf1a1ca5 (diff) | |
download | mock-67628dae8b37a226cb6899ffebffd66b40e74161.tar.gz mock-67628dae8b37a226cb6899ffebffd66b40e74161.tar.xz mock-67628dae8b37a226cb6899ffebffd66b40e74161.zip |
add ability to conditionally enable tmpfs based on minimum ram availability.
Diffstat (limited to 'py')
-rwxr-xr-x | py/mock.py | 2 | ||||
-rw-r--r-- | py/mock/plugins/tmpfs.py | 11 |
2 files changed, 11 insertions, 2 deletions
@@ -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): |