xcp-ng / host-installer_old

XCP-ng installer
16 stars 15 forks source link

Install fails with symlink devices #4

Closed bdonnahue closed 5 years ago

bdonnahue commented 5 years ago

In an attempt to make the install more dynamic, I set about trying to come up with a way that I could PXE boot the system without knowing which disk I wanted to use ahead of time.

My idea was that I would create a installation-start script which would create a symlink for a given device. For example, I would create a symlink from sdb to xcpng. I would then configure the answer file to install to the symlink device named xcpng rather than sdb.

The install fails of the first go around, but succeeds on the second attempt.

The stack trace is as follows:

INFO     [2018-12-31 23:16:18] INSTALL FAILED.
INFO     [2018-12-31 23:16:18] A fatal exception occurred:
INFO     [2018-12-31 23:16:18] Traceback (most recent call last):
  File "/opt/xensource/installer/install.py", line 267, in go
    backend.performInstallation(results, ui, interactive)
  File "/opt/xensource/installer/backend.py", line 351, in performInstallation
    executeSequence(prep_seq, "Preparing for installation...", answers, ui_package, False)
  File "/opt/xensource/installer/backend.py", line 259, in executeSequence
    updated_state = item.execute(answers, progressCallback)
  File "/opt/xensource/installer/backend.py", line 85, in execute
    rv = apply(self.fn, args)
  File "/opt/xensource/installer/backend.py", line 576, in writeDom0DiskPartitions
    if diskutil.blockSizeToGBSize(diskutil.getDiskDeviceSize(disk)) < constants.min_primary_disk_size_old:
  File "/opt/xensource/installer/diskutil.py", line 361, in blockSizeToGBSize
    return (long(blocks) * 512) / (1024 * 1024 * 1024)
TypeError: long() argument must be a string or a number, not 'NoneType'

Please let me know if I can provide more details

bdonnahue commented 5 years ago

I thought about modifying the code to accept symlinks... but then I thought I would just modify the installer so that scripts could regenerate the answerfile. My preinstall script could then put the correct disk name in the answerfile rather than relying on symlinks.

I had a look at the code, the init.py script is the entrypoint for the installation process

It then calls go() from the install.py file

We can see that answerfiles can be "generated" or retrieved from file locations

In this function the file is parsed and then fed into the actual install process which occurs later

The scripts are put into some type of dictionary

The answerfile.py file contains some utilities for getting the answerfile and parsing it etc

Retrieved answer files are pulled from the location and stored here: ANSWERFILE_PATH

this is hardcoded to be /tmp/answerfile in the constants.py file

We can modify the Answerfile.fetch() function to only fetch if the file has not been downloaded already

We can modify go() function: encapsulate some of the logic in a new function (the logic associated with parsing the answer file); then call the parse function again after running the installation-start scripts

This solution is a lot more powerful and about the same in terms of effort

bdonnahue commented 5 years ago

I made the code changes and they are working.

Who maintains this project? I would like to get that code integrated in the next release

stormi commented 5 years ago

You can create a pull request to this repository and we will review it. Thanks!

bdonnahue commented 5 years ago

I forgot about this project. I still need to submit the PR. Just updating the thread.

bdonnahue commented 5 years ago

It seems that all of the functionality I require comes out of the box via the answerfile_generator parameter for the installer. This parameter will allow a user to specify a script which writes the answerfile XML to stdout. The script will be downloaded and executed at the beginning of the installation process. It is mentioned in the doc/parameters.txt