@@ -61,7 +61,8 @@ if len(args) != 1:
drop_caches = global_config.global_config.get_config_value('CLIENT',
'drop_caches',
- type=bool)
+ type=bool,
+ default=True)
# JOB: run the specified job control file.
job.runjob(os.path.realpath(args[0]), drop_caches, options)
@@ -1,5 +1,6 @@
-import os, logging
+import os, logging, ConfigParser
from autotest_lib.client.common_lib import autotemp, base_packages, error
+from autotest_lib.client.common_lib import global_config
from autotest_lib.client.bin import harness
@@ -20,6 +21,18 @@ class harness_autoserv(harness.harness):
super(harness_autoserv, self).__init__(job)
self.status = os.fdopen(3, 'w', 0)
+ # If a bug on the client run code prevents global_config.ini
+ # from being copied to the client machine, the client will run
+ # without a global config, relying only on the defaults of the
+ # config items. To avoid that happening silently, the check below
+ # was written.
+ try:
+ cfg = global_config.global_config.get_section_values("CLIENT")
+ except ConfigParser.NoSectionError:
+ logging.error("Empty CLIENT configuration session. "
+ "global_config.ini missing. This probably means "
+ "a bug on the server code. Please verify.")
+
def run_start(self):
# set up the package fetcher for direct-from-autoserv fetches
@@ -233,7 +233,7 @@ class base_client_job(base_job.base_job):
self.drop_caches_between_iterations = (
global_config.global_config.get_config_value('CLIENT',
'drop_caches_between_iterations',
- type=bool))
+ type=bool, default=True))
self.drop_caches = drop_caches
if self.drop_caches:
logging.debug("Dropping caches")
@@ -5,7 +5,7 @@ provides access to global configuration file
__author__ = 'raphtee@google.com (Travis Miller)'
-import os, sys, ConfigParser
+import os, sys, ConfigParser, logging
from autotest_lib.client.common_lib import error
@@ -44,11 +44,9 @@ elif config_in_client:
DEFAULT_SHADOW_FILE = None
RUNNING_STAND_ALONE_CLIENT = True
else:
- raise ConfigError("Could not find configuration files "
- "needed for this program to function. Please refer to "
- "http://autotest.kernel.org/wiki/GlobalConfig "
- "for more info.")
-
+ DEFAULT_CONFIG_FILE = None
+ DEFAULT_SHADOW_FILE = None
+ RUNNING_STAND_ALONE_CLIENT = True
class global_config(object):
_NO_DEFAULT_SPECIFIED = object()
@@ -145,10 +143,11 @@ class global_config(object):
def parse_config_file(self):
- if not os.path.exists(self.config_file):
- raise ConfigError('%s not found' % (self.config_file))
self.config = ConfigParser.ConfigParser()
- self.config.read(self.config_file)
+ if self.config_file and os.path.exists(self.config_file):
+ self.config.read(self.config_file)
+ else:
+ raise ConfigError('%s not found' % (self.config_file))
# now also read the shadow file if there is one
# this will overwrite anything that is found in the
@@ -29,16 +29,15 @@ try:
default_protection = global_config.global_config.get_config_value(
'HOSTS', 'default_protection', default=_bad_value)
if default_protection == _bad_value:
- if running_client:
- logging.debug('Client stand alone run detected. '
- 'host_protection.default will not be set.')
- else:
+ if not running_client:
raise global_config.ConfigError(
'No HOSTS.default_protection defined in global_config.ini')
else:
default = Protection.get_value(default_protection)
+# It is OK to have an empty global configuration object (stand alone client)
+# so we trap this exception.
except global_config.ConfigError:
- raise global_config.ConfigError('No global_config.ini exists, aborting')
+ pass
choices = Protection.choices()