Add pxe installation.

master
Mike Hiretsky 13 years ago
parent f350a4b5da
commit 29ec169697

@ -1356,6 +1356,29 @@ class FlashDistributive(PartitionDistributive):
_("Installation to flash does not support %s"%
source.__class__.__name__))
class PxeDistributive(Distributive):
def __init__(self,directory,parent=None):
Distributive.__init__(self,parent=parent)
self.directory = path.join(directory,"calculate")
self.origdir = directory
def getDirectory(self):
return self.origdir
def installFrom(self,source):
# make temporary directory for creating iso image
distrTo = self.directory
# getting squash from source
if isinstance(source,IsoDistributive):
if path.exists(self.directory):
removeDir(self.directory)
self._makeDirectory(self.directory)
self.rsync(source.getIsoContentDirectory(),distrTo)
else:
raise DistributiveError(
_("Installation for PXE does not support %s"%
source.__class__.__name__))
class ScratchDistributive(Distributive):
def __init__(self,directory,parent=None,mdirectory="/mnt/install",
check=False):

@ -76,15 +76,17 @@ class fillVars(object, glob_attr):
actionsMap = {'merge':'up',
'system':'up'}
cl_action = self.Get('cl_action')
if cl_action == 'system' and \
self.Get('os_install_root_type') == 'flash':
if cl_action == 'system' and (
self.Get('os_install_root_type') == 'flash' or
self.Get('os_install_pxe') == 'on'):
return ""
return actionsMap[cl_action] if cl_action in actionsMap else ""
def get_ac_install_system(self):
"""Need perform templates for install:system"""
if self.Get('cl_action') == 'system' and \
self.Get('os_install_root_type') != "flash":
self.Get('os_install_root_type') != "flash" and \
self.Get('os_install_pxe') != "on":
return "up"
else:
return ""
@ -96,6 +98,13 @@ class fillVars(object, glob_attr):
return "up"
return ""
def get_ac_install_pxe(self):
"""Need perform templates for install:flash"""
clAction = self.Get('cl_action')
if clAction == 'system' and self.Get('os_install_pxe') == 'on':
return "up"
return ""
def get_ac_install_live(self):
"""Need perform templates for install:live"""
if self.Get('ac_install_merge') == "up" and \
@ -1344,6 +1353,8 @@ class fillVars(object, glob_attr):
return res[0][0]
def get_os_install_mbr(self):
if self.Get('os_install_pxe') == 'on':
return ''
if self.Get('os_install_root_type') in ("flash","usb-hdd"):
rootdev = self.Get('os_install_root_dev')
device = filter(lambda x:x in rootdev,

@ -63,7 +63,7 @@ from cl_print import color_print
from cl_distr import PartitionDistributive,DistributiveRepository,\
DistributiveError, ScratchPartitionDistributive, \
MultiPartitions, Spinner, FlashDistributive, SignalInterrupt,\
Distributive
Distributive, PxeDistributive
from cl_string import tableReport
from time import sleep
from subprocess import PIPE,STDOUT
@ -895,6 +895,8 @@ class cl_install(color_print, SignalInterrupt):
mbrdisk = _("will not be changed")
flash = clGet('os_install_root_type')=="flash"
pxe = clGet('os_install_pxe')=='on'
pxeflash = flash or pxe
usbhdd = clGet('os_install_root_type')=="usb-hdd"
hdd = clGet('os_install_root_type')=="hdd"
if not flash:
@ -912,12 +914,12 @@ class cl_install(color_print, SignalInterrupt):
self.printSUCCESS(_("Installation") + " Calculate Linux")
printData = [
[(_("System"),True),
(_("Computer name"),clGet('os_install_net_hostname'),not flash),
(_("Domain name"),clGet('os_install_net_domain'),not flash),
(_("Users"), musers,not flash),
(_("Computer name"),clGet('os_install_net_hostname'),not pxeflash),
(_("Domain name"),clGet('os_install_net_domain'),not pxeflash),
(_("Users"), musers,not pxeflash),
(_("Installed system"),installedSystem,True)
],
[(_("Localization"),not flash),
[(_("Localization"),not pxeflash),
(_("Language"),
clGet('os_install_locale_lang'),True),
(_("Keymap"),clGet('os_install_locale_xkbname'),True),
@ -939,13 +941,13 @@ class cl_install(color_print, SignalInterrupt):
clGet('os_install_x11_video_drv'),hdd),
(_("Screen resolution"),clGet('os_install_x11_resolution'),hdd)
],
[(_("Network devices"),not flash),
[(_("Network devices"),not pxeflash),
(self.printNetworkTables,None,True)
],
[(_("Routes"),not flash),
[(_("Routes"),not pxeflash),
(self.printRouteTables,None,True)
],
[(_("Location"),True),
[(_("Location"),not pxe),
(_("Master boot record")+" (MBR)",mbrdisk,True),
(self.printLocationTables,None,True)
],
@ -1021,7 +1023,7 @@ class cl_install(color_print, SignalInterrupt):
self.installLegacyGrubBootloader(targetDistr)
def getTargetDistributive(self,disk,fileSystem="reiserfs",isFormat=False,
systemId=None,buildermode=False):
systemId=None,buildermode=False,pxemode=False):
"""Get target distributive by params"""
rootLabelName = "%s-%s"%(self.clVars.Get('os_install_linux_shortname'),
self.clVars.Get('os_install_linux_ver'))
@ -1032,6 +1034,8 @@ class cl_install(color_print, SignalInterrupt):
isFormat=isFormat, systemId=systemId,
rootLabel=rootLabelName,
partitionTable=mapPartPT.get(disk,None))
elif pxemode:
return PxeDistributive('/var/calculate/pxe')
elif self.clVars.Get('os_install_root_type')=="flash":
return FlashDistributive(disk,mdirectory="/mnt/install",
check=True, fileSystem=fileSystem,
@ -2430,7 +2434,7 @@ class cl_install(color_print, SignalInterrupt):
return True
def installSystem(self, force=False, bootDisk=None, stdinReadPwd=False,
builder=False, flagSpinner=True, update=False):
builder=False, flagSpinner=True, update=False, pxe=False):
"""install System by current variable enviroment"""
sourceDistr = None
targetDistr = None
@ -2453,6 +2457,7 @@ class cl_install(color_print, SignalInterrupt):
targetDistr = self.getTargetDistributive(rootPartdev,
buildermode=builder,
pxemode=pxe,
fileSystem=rootPartFileSystem,
isFormat=rootPartIsFormat,
systemId=rootPartSystemId)
@ -2483,7 +2488,8 @@ the system") + " (yes/no)"
self.printERROR(_("Installation interrupted"))
return False
# set Users passwords
if self.clVars.Get('os_install_root_type') != "flash":
if self.clVars.Get('os_install_root_type') != "flash" and \
self.clVars.Get('os_install_pxe') != 'on':
changePwdUsers = \
self.generateHashRoot(stdinRead=stdinReadPwd)
addUsers = self.generateHashUsers(stdinRead=stdinReadPwd)
@ -2508,14 +2514,20 @@ the system") + " (yes/no)"
targetDistr.installFrom(sourceDistr)
self.printByResult(True)
if self.clVars.Get('os_install_root_type') != "flash":
if self.clVars.Get('os_install_root_type') != "flash" and \
self.clVars.Get('os_install_pxe') != 'on':
self.afterCopyHDDinstall(targetDistr, addUsers,
changePwdUsers, migrateUsers)
else:
# join templates
self.printMessageForTest(
_("Configure flash installation"))
self.applyTemplatesFlash(targetDistr.getDirectory())
if self.clVars.Get('os_install_pxe') == 'on':
self.printMessageForTest(
_("Configure PXE installation"))
self.applyTemplatesFlash('/')
else:
# join templates
self.printMessageForTest(
_("Configure flash installation"))
self.applyTemplatesFlash(targetDistr.getDirectory())
self.printByResult(True)
self.closeClTemplate()
# change boot config

@ -78,6 +78,9 @@ CMD_OPTIONS = [{'shortOption':"d",
{'longOption':"build",
'help':_("installation for assemble")
},
{'longOption':"pxe",
'help':_("installation for pxe loading")
},
{'shortOption':"l",
'longOption':"lang",
'optVal':"LANG",
@ -210,6 +213,8 @@ class install_cmd(share_cmd):
self.optionsStartupIncompatible = ["type","d", "b", "mbr",
"w", "f","U", "s","install","uninstall","build","u"]
self.optionsDhcpIncompatible = ["ip","gateway","dns"]
self.optionsPxeIncompatible = ["b","build","install","uninstall",
"mbr", "w","U","d","u","ip","gateway","dns","dhcp"]
self.errorWithExample = \
_("option {optname}: {errormess}:"
" '{value}' (example: '{example}')")
@ -243,6 +248,14 @@ class install_cmd(share_cmd):
self.optobj.error(_("incompatible options")+":"+" %s"\
%self.getStringIncompatibleOptions(incompatible+["dhcp"]))
def checkIncompatibleInstallPxe(self):
"""Check incompatible options for option --dchp"""
incompatible = list(set(self._getNamesAllSetOptions()) &
set(self.optionsPxeIncompatible))
if incompatible:
self.optobj.error(_("incompatible options")+":"+" %s"\
%self.getStringIncompatibleOptions(incompatible+["pxe"]))
def checkIncompatibleInstallUninstall(self):
"""Check incompatible options for options --install and --uninstall"""
opts = self._getNamesAllSetOptions()
@ -274,6 +287,8 @@ class install_cmd(share_cmd):
self.checkIncompatibleInstallUninstall()
if values.startup:
self.checkIncompatibleStartup()
if values.pxe:
self.checkIncompatibleInstallPxe()
if values.dhcp:
self.checkIncompatibleDhcp()
if values.A == "root":
@ -475,6 +490,10 @@ class install_cmd(share_cmd):
self.logicObj.clVars.Set('os_install_scratch',"on",True)
else:
self.logicObj.clVars.Set('os_install_scratch',"off",True)
if self.optobj.values.pxe:
self.logicObj.clVars.Set('os_install_pxe',"on",True)
else:
self.logicObj.clVars.Set('os_install_pxe',"off",True)
if self.optobj.values.type:
self.logicObj.clVars.Set('os_install_root_type',
self.optobj.values.type, True)
@ -576,11 +595,12 @@ class install_cmd(share_cmd):
def installSystem(self, force=False, bootDisk=None, users=[],
stdinReadPwd=False, builder=False, flagSpinner=True,
update=False):
update=False,pxe=False):
"""Run install system"""
if self.logicObj.installSystem(force=force, bootDisk=bootDisk,
stdinReadPwd=stdinReadPwd, builder=builder,
flagSpinner=flagSpinner,update=update):
flagSpinner=flagSpinner,update=update,
pxe=pxe):
if self.logicObj.clVars.Get('os_install_root_type') != "flash":
self.defaultPrint("\n")
self.defaultPrint(_("To apply the changes you have to reboot")+

@ -46,6 +46,11 @@ class Data:
"""
ac_install_flash = {}
"""
Action variable which has value "up" for PXE installation
"""
ac_install_pxe = {}
"""
Action which "up" value describe dinamic templates
"""
@ -403,6 +408,12 @@ class Data:
# install system in scratch mode
os_install_scratch = {}
# install system for pxe boot
os_install_pxe = {'value':'off'}
# path to pxe installation
os_install_pxe_path = {'value':'/var/calculate/pxe'}
# nvidia-drivers atom mask
os_nvidia_mask = {}

@ -81,7 +81,8 @@ if __name__ == "__main__":
flagSpinner = not options.nospinner
if not install.installSystem(force=forceOpions, bootDisk=options.mbr,
stdinReadPwd=options.P,builder=options.build,
flagSpinner=flagSpinner,update=options.U):
flagSpinner=flagSpinner,update=options.U,
pxe=options.pxe):
sys.exit(1)
#if not install.writeVars(options):
# sys.exit(1)

Loading…
Cancel
Save