Skip to content

Commit

Permalink
isoInstaller.py: Added support for secondary ks device.
Browse files Browse the repository at this point in the history
In order to use secondary kickstart device syntax to use at command
line is:

ks=<device-path>:<path reference to device>

Ex:- ks=/dev/sr1:/isolinux/sample_ks.cfg

The secondary device will be mounted in path /mnt/ks and kickstart
file will be read from the mounted path.

Change-Id: Ic720e0e563c58cd27bf03285e7231f18186f5afb
  • Loading branch information
gpiyush-dev committed Nov 16, 2021
1 parent 871dc56 commit 7574836
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
29 changes: 16 additions & 13 deletions photon_installer/isoInstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, options):
self.insecure_installation = bool(int(arg[len("insecure_installation="):]))

if photon_media:
self.mount_media(photon_media)
self.media_mount_path = self.mount_media(photon_media)

if not repo_path:
if self.media_mount_path:
Expand Down Expand Up @@ -127,16 +127,20 @@ def _load_ks_config(self, path):
path = os.path.join(self.media_mount_path, path.replace("cdrom:/", "", 1))
elif not path.startswith("/"):
path = os.path.join(os.getcwd(), path)
elif len(path.split(':')) == 2:
ks_path_split = path.split(':')
ks_mounted_path = self.mount_media(ks_path_split[0], mount_path='/mnt/ks')
if ks_path_split[1].startswith("/"):
ks_path_split[1] = ks_path_split[1][1:]
path = os.path.join(ks_mounted_path, ks_path_split[1])
else:
raise Exception("Kickstart file provided is not in correct format.")
return (JsonWrapper(path)).read()

def mount_media(self, photon_media):
"""Mount the cd with RPMS"""
# check if the cd is already mounted
if self.media_mount_path:
return
mount_path = "/mnt/media"
def mount_media(self, photon_media, mount_path="/mnt/media"):
"""Mount the external media"""

# Mount the cd to get the RPMS
# Make the mounted directories
os.makedirs(mount_path, exist_ok=True)

# Construct mount cmdline
Expand All @@ -158,13 +162,12 @@ def mount_media(self, photon_media):
process = subprocess.Popen(cmdline)
retval = process.wait()
if retval == 0:
self.media_mount_path = mount_path
return
print("Failed to mount the cd, retry in a second")
return mount_path
print("Failed to mount the device, retry in a second")
time.sleep(1)
print("Failed to mount the cd, exiting the installer")
print("Failed to mount the device, exiting the installer")
print("check the logs for more details")
raise Exception("Can not mount the cd")
raise Exception("Can not mount the device")


if __name__ == '__main__':
Expand Down
15 changes: 15 additions & 0 deletions photon_installer/ks_config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@
* Copyright © 2020 VMware, Inc.
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-only
*/
Ways to provide Kickstart path:

1. Remote kickstart:-

ks=http://<kickstart-link>

2. Kickstart from cdrom attched with iso:

ks=cdrom:/isolinux/sample_ks.cfg

3. Secondary Device Kickstart

ks=<device-path>:<path-referential-to-device>
Ex- ks=/dev/sr1:/isolinux/sample_ks.cfg

Kickstart config file is a json format with following possible parameters:

"additional_files": (optional)
Expand Down

0 comments on commit 7574836

Please sign in to comment.