From: Ondrej Lichtner <olichtne(a)redhat.com>
This patch adds support for option 'machine_pool_dirs' in section
'environment' of config files.
This option is a list of directories separated by whitespace.
Whitespaces in names need to be escaped with '\'.
Behaviour for this option is also a bit different, config files with
higher priority don't overwrite the previous value but instead are added
to the list.
This list is later passed to class MachinePool. Currently this class
doesn't check for the existence of these directories. Nonexistent
directories will cause a crash of the application so be sure to create
them before trying to use them.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
Common/Config.py | 10 ++++++++++
NetTest/NetTestController.py | 3 ++-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/Common/Config.py b/Common/Config.py
index 4b02a54..6e68918 100644
--- a/Common/Config.py
+++ b/Common/Config.py
@@ -12,6 +12,7 @@ olichtne(a)redhat.com (Ondrej Lichtner)
import os
import logging
+import re
from ConfigParser import ConfigParser
from NetUtils import verify_ip_address, verify_mac_address
@@ -77,6 +78,8 @@ class Config():
section['mac_pool_range'] = self.optionMacRange(config[option])
elif option == 'rpcport':
section['rpcport'] = self.optionPort(config[option])
+ elif option == 'machine_pool_dirs':
+ section['pool_dirs'] = self.optionPoolDirs(config[option])
else:
msg = "Unknown option: %s in section environment" % option
raise ConfigError(msg)
@@ -111,3 +114,10 @@ class Config():
msg = "Invalid MAC address: %s" % vals[1]
raise ConfigError(msg)
return vals
+
+ def optionPoolDirs(self, option):
+ env = self.get_section('environment')
+ if 'pool_dirs' not in env:
+ env['pool_dirs'] = []
+ opts = re.split(r'(?<!\\)\s', option)
+ return env['pool_dirs'] + opts
diff --git a/NetTest/NetTestController.py b/NetTest/NetTestController.py
index f191b4d..059a65e 100644
--- a/NetTest/NetTestController.py
+++ b/NetTest/NetTestController.py
@@ -43,7 +43,8 @@ class NetTestController:
self._remote_capture_files = {}
self._config = config
- self._machine_pool = MachinePool([])
+ self._machine_pool = MachinePool(config.get_option('environment',
+ 'pool_dirs'))
self._recipe = {}
definitions = {"recipe": self._recipe}
--
1.7.11.4