Add --live option for run --live templates.

master
Mike Hiretsky 13 years ago
parent 7aba074364
commit 2f1a19c711

@ -154,6 +154,9 @@ CMD_OPTIONS = [{'shortOption':"d",
{'longOption':"startup",
'help':_("configure current system")
},
{'longOption':"live",
'help':_("configure only mutable parameters in current system")
},
{'longOption':"install",
'help':_("install package")
},
@ -191,7 +194,10 @@ class install_cmd(share_cmd):
self.logicObj = cl_install()
# names incompatible options with --startup
self.optionsStartupIncompatible = ["type","d", "b", "mbr",
"w", "f","U", "s","install","uninstall","build","u"]
"w", "f","U", "s","install","uninstall","build","u","live"]
# names incompatible options with --live
self.optionsLiveIncompatible = ["type","d", "b", "mbr",
"w", "f","U", "s","install","uninstall","build","u","startup"]
self.optionsDhcpIncompatible = ["ip","gateway","dns"]
self.errorWithExample = \
_("option {optname}: {errormess}:"
@ -218,6 +224,14 @@ class install_cmd(share_cmd):
self.optobj.error(_("incompatible options")+":"+" %s"\
%self.getStringIncompatibleOptions(incompatible+["startup"]))
def checkIncompatibleLive(self):
"""Check incompatible options for option --live"""
incompatible = list(set(self._getNamesAllSetOptions()) &
set(self.optionsLiveIncompatible))
if incompatible:
self.optobj.error(_("incompatible options")+":"+" %s"\
%self.getStringIncompatibleOptions(incompatible+["live"]))
def checkIncompatibleDhcp(self):
"""Check incompatible options for option --dchp"""
incompatible = list(set(self._getNamesAllSetOptions()) &
@ -252,6 +266,8 @@ class install_cmd(share_cmd):
self.checkIncompatibleInstallUninstall()
if values.startup:
self.checkIncompatibleStartup()
if values.live:
self.checkIncompatibleLive()
if values.dhcp:
self.checkIncompatibleDhcp()
if not values.v:
@ -293,7 +309,9 @@ class install_cmd(share_cmd):
errormess=_("%s specifing error")%_("route"),
value=route,
example="default:192.168.1.1"))
if not (values.install or values.uninstall or values.startup):
# if system installation
if not (values.install or values.uninstall
or values.startup or values.live):
if values.v is False and \
not values.p and \
values.d is None and \
@ -413,10 +431,14 @@ class install_cmd(share_cmd):
return False
return True
def setAction(self,startup):
def setAction(self,startup,live):
"""Set action by configuration or install system"""
self.logicObj.clVars.Set('cl_action',
"merge" if startup else "system",True)
if live:
self.logicObj.clVars.Set('cl_action',"live",True)
elif startup:
self.logicObj.clVars.Set('cl_action',"merge",True)
else:
self.logicObj.clVars.Set('cl_action',"system",True)
def checkAndSetInstallOptions(self,diskOptions, swapOptions,
usersOptions):
@ -568,15 +590,3 @@ class install_cmd(share_cmd):
return True
else:
return False
def parse_args(self, args=None, values=None):
"""
Preparse for catch non option --live
"""
rargs = self.optobj._get_args(args)
if rargs:
for arg in rargs:
if arg == "--live":
self.optobj.error(_("option %s:") %"--live" +\
" " + _("option is depricated, use '--startup' option"))
return self.optobj.parse_args(args,values)

@ -32,7 +32,7 @@ if __name__ == "__main__":
install = install_cmd()
install.logicObj.initVars()
# set lang
ret = install.parse_args()
ret = install.optobj.parse_args()
if ret is False:
sys.exit(1)
options, args = ret
@ -50,8 +50,9 @@ if __name__ == "__main__":
if not install.setVars(options):
sys.exit(1)
# check and set installed options
install.setAction(options.startup)
if not (options.startup or options.install or options.uninstall):
install.setAction(options.startup,options.live)
if not (options.startup or options.install or options.uninstall or
options.live):
if not install.checkAndSetInstallOptions(options.d,options.w,
options.u):
sys.exit(1)
@ -66,7 +67,7 @@ if __name__ == "__main__":
if not install.isRoot():
sys.exit(1)
# configurate current system
if options.startup:
if options.startup or options.live:
if not install.configureSystem():
sys.exit(1)
elif options.install:

Loading…
Cancel
Save