#!/usr/bin/env python # $Id: S99KusuNodeResolvConf.rc.py 4377 2009-02-26 04:49:22Z ltsai $ # # Copyright 2007 Platform Computing Inc. # # Licensed under GPL version 2; See LICENSE file for details. # from kusu.core import rcplugin from path import path class KusuRC(rcplugin.Plugin): def __init__(self): rcplugin.Plugin.__init__(self) self.name = 'resolv_conf' self.desc = 'Setting up dns resolver' self.ngtypes = ['compute', 'compute-imaged', 'compute-diskless'] self.delete = True def run(self): """ Workaround an autoinstall bug for opensuse 10.3 where /etc/resolv.conf is clobbered during the first boot. """ # This kusu-resolv.conf is generated by a post-script in # kusu-autoinst.xml. generated_resolv_conf = path('/root/kusu-resolv.conf') if self.os_name == 'opensuse': resolv_conf = path('/etc/resolv.conf') if generated_resolv_conf.exists() and \ resolv_conf.exists() and \ not resolv_conf.text(): generated_resolv_conf.move(resolv_conf) # Cleanup if generated_resolv_conf.exists(): generated_resolv_conf.remove() return True