DEFAULT_GSITECONF = '/etc/mic/mic.conf'
class ConfigMgr(object):
- DEFAULTS = {'common': {},
+ DEFAULTS = {'common': {
+ "distro_name": "Default Distribution",
+ },
'create': {
"tmpdir": '/var/tmp/mic',
"cachedir": '/var/tmp/mic/cache',
"logfile": None,
"record_pkgs": [],
"compress_disk_image": None,
- "distro_name": "Default Distribution",
"name_prefix": None,
"proxy": None,
"no_proxy": None,
parser = ConfigParser.SafeConfigParser()
parser.read(siteconf)
+ # append common section items to other sections
+ for section in self.DEFAULTS.keys():
+ if section != "common":
+ getattr(self, section).update(self.common)
+
for section in parser.sections():
if section in self.DEFAULTS.keys():
getattr(self, section).update(dict(parser.items(section)))
self.__builddir = None
self.__bindmounts = []
+ self.ks = None
+ self.name = "target"
+ self.tmpdir = "/var/tmp/mic"
+ self.cachedir = "/var/tmp/mic/cache"
+ self.destdir = "."
+ self.target_arch = "noarch"
+ self._local_pkgs_path = None
+
# Eeach image type can change these values as they might be image type
# specific
if not hasattr(self, "_valid_compression_methods"):
self._img_compression_method = None
if createopts:
- # A pykickstart.KickstartParser instance."""
- self.ks = createopts['ks']
+ optmap = {"pkgmgr" : "pkgmgr_name",
+ "outdir" : "destdir",
+ "arch" : "target_arch",
+ "local_pkgs_path" : "_local_pkgs_path",
+ "compress_disk_image" : "_img_compression_method",
+ }
+
+ # update setting from createopts
+ for key in createopts.keys():
+ if key in optmap:
+ option = optmap[key]
+ else:
+ option = key
+ setattr(self, option, createopts[key])
- self.destdir = os.path.abspath(os.path.expanduser(createopts["outdir"]))
+ self.destdir = os.path.abspath(os.path.expanduser(self.destdir))
- # A name for the image."""
- self.name = createopts['name']
- if createopts['release']:
+ if 'release' in createopts and createopts['release']:
self.name += '-' + createopts['release']
- # check whether destine dir exist
if os.path.exists(self.destdir):
- if msger.ask('Image dir: %s already exists, '
- 'cleanup and continue?' % self.destdir):
+ if msger.ask("Image dir: %s already exists, cleanup and" \
+ "continue?" % self.destdir):
shutil.rmtree(self.destdir, ignore_errors = True)
else:
- raise Abort('Canceled')
-
- # pending FEA: save log by default for --release
+ raise Abort("Canceled")
- # The directory in which all temporary files will be created."""
- self.tmpdir = createopts['tmpdir']
- self.cachedir = createopts['cachedir']
- self.target_arch = createopts['arch']
- self._local_pkgs_path = createopts['local_pkgs_path']
- self._img_compression_method = createopts['compress_disk_image']
-
- else:
- self.ks = None
- self.name = "target"
- self.tmpdir = "/var/tmp/mic"
- self.cachedir = "/var/tmp/mic/cache"
- self.destdir = "."
- self.target_arch = "noarch"
- self._local_pkgs_path = None
+ # pending FEA: save log by default for --release
self._dep_checks = ["ls", "bash", "cp", "echo", "modprobe", "passwd"]
- self.distro_name = createopts['distro_name']
-
# Output image file names
self.outimage = []