Skip to content

Commit 7574836

Browse files
committed
isoInstaller.py: Added support for secondary ks device.
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
1 parent 871dc56 commit 7574836

File tree

2 files changed

+31
-13
lines changed

2 files changed

+31
-13
lines changed

photon_installer/isoInstaller.py

+16-13
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __init__(self, options):
4747
self.insecure_installation = bool(int(arg[len("insecure_installation="):]))
4848

4949
if photon_media:
50-
self.mount_media(photon_media)
50+
self.media_mount_path = self.mount_media(photon_media)
5151

5252
if not repo_path:
5353
if self.media_mount_path:
@@ -127,16 +127,20 @@ def _load_ks_config(self, path):
127127
path = os.path.join(self.media_mount_path, path.replace("cdrom:/", "", 1))
128128
elif not path.startswith("/"):
129129
path = os.path.join(os.getcwd(), path)
130+
elif len(path.split(':')) == 2:
131+
ks_path_split = path.split(':')
132+
ks_mounted_path = self.mount_media(ks_path_split[0], mount_path='/mnt/ks')
133+
if ks_path_split[1].startswith("/"):
134+
ks_path_split[1] = ks_path_split[1][1:]
135+
path = os.path.join(ks_mounted_path, ks_path_split[1])
136+
else:
137+
raise Exception("Kickstart file provided is not in correct format.")
130138
return (JsonWrapper(path)).read()
131139

132-
def mount_media(self, photon_media):
133-
"""Mount the cd with RPMS"""
134-
# check if the cd is already mounted
135-
if self.media_mount_path:
136-
return
137-
mount_path = "/mnt/media"
140+
def mount_media(self, photon_media, mount_path="/mnt/media"):
141+
"""Mount the external media"""
138142

139-
# Mount the cd to get the RPMS
143+
# Make the mounted directories
140144
os.makedirs(mount_path, exist_ok=True)
141145

142146
# Construct mount cmdline
@@ -158,13 +162,12 @@ def mount_media(self, photon_media):
158162
process = subprocess.Popen(cmdline)
159163
retval = process.wait()
160164
if retval == 0:
161-
self.media_mount_path = mount_path
162-
return
163-
print("Failed to mount the cd, retry in a second")
165+
return mount_path
166+
print("Failed to mount the device, retry in a second")
164167
time.sleep(1)
165-
print("Failed to mount the cd, exiting the installer")
168+
print("Failed to mount the device, exiting the installer")
166169
print("check the logs for more details")
167-
raise Exception("Can not mount the cd")
170+
raise Exception("Can not mount the device")
168171

169172

170173
if __name__ == '__main__':

photon_installer/ks_config.txt

+15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22
* Copyright © 2020 VMware, Inc.
33
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-only
44
*/
5+
Ways to provide Kickstart path:
6+
7+
1. Remote kickstart:-
8+
9+
ks=http://<kickstart-link>
10+
11+
2. Kickstart from cdrom attched with iso:
12+
13+
ks=cdrom:/isolinux/sample_ks.cfg
14+
15+
3. Secondary Device Kickstart
16+
17+
ks=<device-path>:<path-referential-to-device>
18+
Ex- ks=/dev/sr1:/isolinux/sample_ks.cfg
19+
520
Kickstart config file is a json format with following possible parameters:
621

722
"additional_files": (optional)

0 commit comments

Comments
 (0)