Skip to content

Commit

Permalink
Merge pull request #47 from 128technology/handle-ibu
Browse files Browse the repository at this point in the history
Handle IBU images
  • Loading branch information
laneshields authored Dec 29, 2022
2 parents df33963 + db0667d commit 70778e3
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 19 deletions.
1 change: 1 addition & 0 deletions webapp/blaster/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@
COMBINED_ISO_INTERACTIVE_UEFI_KS_FILE = 'ks-interactive-uefi.cfg'
LEGACY_OTP_KICKSTART_FILE = 'ks.cfg'
LEGACY_STANDARD_KICKSTART_FILE = '128T-ks.cfg'
IBU_INSTALL_SCRIPT = 'install.sh'
5 changes: 5 additions & 0 deletions webapp/blaster/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,9 @@ def init_app(app):
with current_app.open_resource('schema_v1.sql') as f:
db.executescript(f.read().decode('utf8'))

if user_version < 2:
LOG.info("Updating DB schema to v2...")
with current_app.open_resource('schema_v2.sql') as f:
db.executescript(f.read().decode('utf8'))

db.commit()
2 changes: 1 addition & 1 deletion webapp/blaster/iso.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def add(name=None):
@bp.route('/list')
def list():
db = get_db()
isos = db.execute('SELECT id, name, pre_bootstrap_script, post_bootstrap_script, status FROM iso').fetchall()
isos = db.execute('SELECT id, name, pre_bootstrap_script, post_bootstrap_script, status, iso_type FROM iso').fetchall()
scripts = db.execute('SELECT name FROM script').fetchall()
active = get_active()
pias={}
Expand Down
3 changes: 3 additions & 0 deletions webapp/blaster/schema_v2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE iso ADD iso_type TEXT;

PRAGMA user_version = 2;
73 changes: 57 additions & 16 deletions webapp/blaster/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def stage_image(name):
return False

combined_iso = False
ibu_iso = False
if (nfs_dir / constants.LEGACY_OTP_KICKSTART_FILE).exists():
ks_file = constants.LEGACY_OTP_KICKSTART_FILE
print(f"{name} is a legacy format OTP ISO based on the kickstart file found")
Expand All @@ -89,8 +90,11 @@ def stage_image(name):
(nfs_dir / constants.COMBINED_ISO_INTERACTIVE_UEFI_KS_FILE).exists():
print(f"{name} is a combined ISO based on the kickstart files found")
combined_iso = True
elif (nfs_dir / constants.IBU_INSTALL_SCRIPT).exists():
print(f"{name} is an IBU based ISO")
ibu_iso = True
else:
print(f"Could not find either expected kickstart file in {name}, aborting")
print(f"Could not find either expected kickstart file or IBU script in {name}, aborting")
update_db_failed(name)
return False

Expand Down Expand Up @@ -130,6 +134,18 @@ def stage_image(name):
f"inst.ks=nfs:{constants.NFS_IP}:{ pathlib.Path(constants.IMAGE_FOLDER) / name }/{ constants.COMBINED_ISO_OTP_UEFI_KS_FILE } "
"console=ttyS0,115200n81\n",
])
elif ibu_iso:
with open(uefi_pxelinux_dir / name, "w+") as fh:
fh.writelines(["UI menu.c32\n",
"timeout 30\n",
"\n",
f"label {name}\n",
f" kernel images/{name}/vmlinuz\n",
f" append initrd=http://{constants.UEFI_IP}/images/{name}/initrd.img "
f"inst.stage2=nfs:{constants.NFS_IP}:{ pathlib.Path(constants.IMAGE_FOLDER) / name } "
f"rd.plymouth=0 plymouth.enable=0 --log-level=0 systemd.log_level=0 systemd.show_status=0 SSRBOOT=iso "
"console=ttyS0,115200n81\n",
])
else:
with open(uefi_pxelinux_dir / name, "w+") as fh:
fh.writelines(["UI menu.c32\n",
Expand Down Expand Up @@ -167,6 +183,22 @@ def stage_image(name):
f"inst.ks=nfs:{constants.NFS_IP}:{ pathlib.Path(constants.IMAGE_FOLDER) / name }/{ constants.COMBINED_ISO_OTP_KS_FILE } "
"console=ttyS0,115200n81\n",
])
elif ibu_iso:
with open(bios_pxelinux_dir / name, "w+") as fh:
fh.writelines([f"default {name}\n",
"timeout 30\n",
"\n",
"display boot.msg\n",
"\n",
"MENU TITLE PXE Boot MENU\n",
"\n",
f"label {name}\n",
f" kernel images/{name}/vmlinuz\n",
f" append initrd=images/{name}/initrd.img "
f"inst.stage2=nfs:{constants.NFS_IP}:{ pathlib.Path(constants.IMAGE_FOLDER) / name } "
f"rd.plymouth=0 plymouth.enable=0 --log-level=0 systemd.log_level=0 systemd.show_status=0 SSRBOOT=iso "
"console=ttyS0,115200n81\n",
])
else:
with open(bios_pxelinux_dir / name, "w+") as fh:
fh.writelines([f"default {name}\n",
Expand All @@ -184,26 +216,35 @@ def stage_image(name):
"console=ttyS0,115200n81\n",
])

print(f"Appending new post section to kickstart to post identifier after blast")
if combined_iso:
with open(nfs_dir / constants.COMBINED_ISO_OTP_UEFI_KS_FILE, 'a') as fh:
fh.writelines(KS_POST_ADDITIONS)
with open(nfs_dir / constants.COMBINED_ISO_OTP_KS_FILE, 'a') as fh:
fh.writelines(KS_POST_ADDITIONS)
else:
with open(nfs_dir / ks_file, 'a') as fh:
fh.writelines(KS_POST_ADDITIONS)
if not ibu_iso:
print(f"Appending new post section to kickstart to post identifier after blast")
if combined_iso:
with open(nfs_dir / constants.COMBINED_ISO_OTP_UEFI_KS_FILE, 'a') as fh:
fh.writelines(KS_POST_ADDITIONS)
with open(nfs_dir / constants.COMBINED_ISO_OTP_KS_FILE, 'a') as fh:
fh.writelines(KS_POST_ADDITIONS)
else:
with open(nfs_dir / ks_file, 'a') as fh:
fh.writelines(KS_POST_ADDITIONS)

print(f"Setting up snippet to stage bootstrap scripts for image {name}")
shutil.copyfile(constants.SCRIPT_KS_SNIPPET, nfs_dir / 'setup_scripts.sh')
print(f"Setting up snippet to eject USB drives before install for image {name}")
shutil.copyfile(constants.EJECT_USB_KS_SNIPPET, nfs_dir / 'eject_usb_disks.sh')
print(f"Setting up snippet to stage bootstrap scripts for image {name}")
shutil.copyfile(constants.SCRIPT_KS_SNIPPET, nfs_dir / 'setup_scripts.sh')
print(f"Setting up snippet to eject USB drives before install for image {name}")
shutil.copyfile(constants.EJECT_USB_KS_SNIPPET, nfs_dir / 'eject_usb_disks.sh')

print(f"Updating password hashes for image {name}")
update_password(name)

print(f"Updating password hashes for image {name}")
update_password(name)
print(f"Image {name} appears to have been setup correctly, updating DB")
db = get_db()
db.execute('UPDATE iso SET status = ? WHERE name = ?', ('Ready', name))
if ibu_iso:
db.execute('UPDATE iso SET iso_type = ? WHERE name = ?', ('IBU', name))
elif combined_iso:
db.execute('UPDATE iso SET iso_type = ? WHERE name = ?', ('COMBINED', name))
else:
db.execute('UPDATE iso SET iso_type = ? WHERE name = ?', ('LEGACY', name))

db.commit()

return True
Expand Down
16 changes: 14 additions & 2 deletions webapp/blaster/templates/iso_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,20 @@ <h1>ISOs</h1>
<tr>
<td>{{ iso['name'] }}</td>
<td>{{ iso['status'] }}</td>
{%- if (iso['iso_type'] != 'IBU') %}
<td>
<select class="post_select" id="{{ iso['id'] }}_post_install_action" name="{{ iso['id'] }}_post_install_action" onchange="">
<option value="current">{{ post_install_actions[iso['name']] }}</option>
<option value="alternate">{% if post_install_actions[iso['name']] == "shutdown" %}reboot{% else %}shutdown{% endif %}</option>
</select>
</td>
{%- else %}
<td>
</td>
{%- endif %}
{%- if iso['pre_bootstrap_script'] %}
<td>{{ iso['pre_bootstrap_script'] }}</td>
{%- else %}
{%- elif (iso['iso_type'] != 'IBU') %}
<td>
<select class="script_select" id="{{ iso['id'] }}_pre" name="{{ iso['id'] }}_pre" onchange="">
<option value="">Select script</option>
Expand All @@ -84,10 +89,13 @@ <h1>ISOs</h1>
{%- endfor %}
</select>
</td>
{%- else %}
<td>
</td>
{%- endif %}
{%- if iso['post_bootstrap_script'] %}
<td>{{ iso['post_bootstrap_script'] }}</td>
{%- else %}
{%- elif (iso['iso_type'] != 'IBU') %}
<td>
<select class="script_select" id="{{ iso['id'] }}_post" name="{{ iso['id'] }}_post" onchange="">
<option value="">Select script</option>
Expand All @@ -96,6 +104,9 @@ <h1>ISOs</h1>
{%- endfor %}
</select>
</td>
{%- else %}
<td>
</td>
{%- endif %}
<td>{% if active == iso['name'] %}X{% endif %}</td>
<td>
Expand Down Expand Up @@ -125,5 +136,6 @@ <H2>ISO List</H2>
<P>A status of "Processing" indicates a download is in progress. Depending on Internet connection speed, this should take no more than 30 minutes. If this status does not change, logs should be investigated. A status of failed indicates there was a problem either downloading or staging the ISO.</P>
<P>Relevant logs can be found by entering the docker container via <span class="code">docker exec -it blaster_webapp_1 bash</span> and from there checking the log files found in <span class="code">/var/log/celery</span>.</P>
<P>If an ISO fails or is stuck in processing, it should be deleted after investigating the issue.</P>
<P><strong>Note:</string> image based (IBU) installations do not support scripts, modifying post-install actions, or changing default passwords.</P>
</div>
{% endblock %}
1 change: 1 addition & 0 deletions webapp/blaster/templates/passwords_manage.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ <H2>Managing Passwords</H2>
<P>The 128T ISOs include a default password. If you wish to override these passwords with your own, it can be done from this page. Simply select the username from the dropdown list (only root and the default t128 user passwords can be set at this time), enter your desired password, enter the same password again to verify, and click the Submit button. The blaster will create a valid Linux password hash for this password and store it to the local database. Any custom password hashes created will be shown in a table on this page.</P>
<P>When custom passwords are set here, the password values will be overriden for any new ISOs downloaded from the <strong>Manage Passwords</strong> menu. ISOs that have previously been downloaded will only have their passwords updated after clicking the Update ISOs button.</P>
<P>If custom passwords are deleted, clicking the Update ISOs button will restore the default 128T passwords.</P>
<P><strong>Note:</strong> image based (IBU) installations do not support changing default passwords.</P>
</div>
{% endblock %}

0 comments on commit 70778e3

Please sign in to comment.