rootdir = os.path.join(rootdir, "bootstrap")
bsenv.dirsetup(rootdir)
- #when mic in mic-bootstrap is py2, use mic version in mic-bootstrap.
- if cropts['use_mic_in_bootstrap'] | (mic_py2_in_mic_bootstrap(os.path.join(rootdir, '/usr/bin/mic'.lstrip('/'))) == True):
+ if cropts['use_mic_in_bootstrap']:
msger.info("No copy host mic")
else:
- msger.info("Copy host mic to bootstrap")
- sync_mic(rootdir, plugin=cropts['plugin_dir'])
+ #when mic in mic-bootstrap is py2, use mic version in mic-bootstrap.
+ if (mic_py2_in_mic_bootstrap(os.path.join(rootdir, '/usr/bin/mic'.lstrip('/'))) == True):
+ msger.info("Copy host mic conf to bootstrap")
+ sync_mic_conf(rootdir)
+ else:
+ msger.info("Copy host mic to bootstrap")
+ sync_mic(rootdir, plugin=cropts['plugin_dir'])
#FIXME: sync the ks file to bootstrap
if "/" == os.path.dirname(os.path.abspath(configmgr._ksconf)):
def get_mic_libpath():
return os.getenv("MIC_LIBRARY_PATH", "/usr/lib/mic")
+def sync_mic_conf(bootstrap, conf = '/etc/mic/mic.conf'):
+ _path = lambda p: os.path.join(bootstrap, p.lstrip('/'))
+
+ try:
+ safecopy(conf, _path(conf), False)
+ except (OSError, IOError) as err:
+ raise errors.BootstrapError(err)
+
+ # auto select backend
+ with open(_path(conf), 'r') as rf:
+ conf_str = rf.read()
+ conf_str = re.sub("pkgmgr\s*=\s*.*", "pkgmgr=auto", conf_str)
+ with open(_path(conf), 'w') as wf:
+ wf.write(conf_str)
+
# the hard code path is prepared for bootstrap
def sync_mic(bootstrap, binpth = '/usr/bin/mic',
libpth='/usr/lib',
raise errors.BootstrapError(err)
# auto select backend
- conf_str = open(_path(conf)).read()
+ with open(_path(conf), 'r') as rf:
+ conf_str = rf.read()
conf_str = re.sub("pkgmgr\s*=\s*.*", "pkgmgr=auto", conf_str)
with open(_path(conf), 'w') as wf:
wf.write(conf_str)