Skip to content

Commit

Permalink
1.Update default-user-data 2.Fix default test user/password
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur-at-work committed Oct 20, 2024
1 parent 866c2f9 commit aa362cf
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ autoinstall:
path: /usr/share/glib-2.0/schemas/certification.gschema.override
users:
- default
- name: ubuntu
sudo: "ALL=(ALL) NOPASSWD:ALL"
lock_passwd: false
shell: /bin/bash
# this is just "ubuntu"
passwd: "$6$rounds=4096$PCrfo.ggdf4ubP$REjyaoY2tUWH2vjFJjvLs3rDxVTszGR9P7mhH9sHb2MsELfc53uV/v15jDDOJU/9WInfjjTKJPlD5URhX5Mix0"

locale: en_US.UTF-8

Expand All @@ -66,10 +71,6 @@ autoinstall:
package_upgrade: false

runcmd:
# use default ubuntu user, and unlock password login
# password hash generated by `mkpasswd --method=SHA-512 --rounds=4096`
- ["usermod", "-p", "$6$rounds=4096$GjrIPJoz2JMcNfLy$U8Sp/n.LlJK9kLagAJoRXjTIu9rStDmjU9JtPn4UqFHxP3uFETLhXk.cPuLncuL/Enpyxz.K6kiO75lJp3q6W0", "ubuntu"]
- ["passwd", "-u", "ubuntu"]
- ["glib-compile-schemas", "/usr/share/glib-2.0/schemas"]
- ["sudo", "-u", "ubuntu", "-H", "gsettings", "reset-recursively", "org.gnome.settings-daemon.plugins.power"]
- ["sudo", "-u", "ubuntu", "-H", "gsettings", "reset-recursively", "org.gnome.desktop.session"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ EOF

if [ $# -lt 3 ]; then
usage
exit
exit 1
fi

TARGET_USER="ubuntu"
Expand Down Expand Up @@ -212,7 +212,7 @@ do

if [ -z "$STORE_PART" ]; then
echo "Can't find partition to store ISO on target $addr"
exit
exit 1
fi
RESET_PART="${STORE_PART:0:-1}2"
RESET_PARTUUID=$($SSH "$TARGET_USER"@"$addr" -- lsblk -n -o PARTUUID "$RESET_PART")
Expand Down Expand Up @@ -300,4 +300,5 @@ do
done

echo "Deployment will start after reboot"
exit 0
# Let device connector to poll the status
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ def copy_to_deploy_path(self, source_path, dest_path):
def run_deploy_script(self, image_url):
"""Run the script to deploy ISO and config files"""
device_ip = self.config["device_ip"]
test_username = self.get_test_data_or_default(
"test_username", "ubuntu"
)

logger.info("Running deployment script")

Expand All @@ -130,6 +133,8 @@ def run_deploy_script(self, image_url):
deploy_script,
"--iso-dut",
image_url,
"-u",
test_username,
"--local-config",
ATTACHMENTS_PROV_DIR,
device_ip,
Expand Down Expand Up @@ -173,18 +178,25 @@ def test_ssh_access(self):
logger.error("SSH connection failed: %s", result.stderr)
raise ProvisioningError("Failed SSH to DUT")

def copy_ssh_id(self):
"""Copy the ssh id to the device"""
def get_test_data_or_default(self, attribute, default_value):
"""Helper function to safely get test attributes"""
try:
test_username = self.job_data.get("test_data", {}).get(
"test_username", "ubuntu"
)
test_password = self.job_data.get("test_data", {}).get(
"test_password", "ubuntu"
return self.job_data.get("test_data", {}).get(
attribute, default_value
)
except AttributeError:
test_username = "ubuntu"
test_password = "ubuntu"
return default_value

def copy_ssh_id(self):
"""Copy the ssh id to the device"""

test_username = self.get_test_data_or_default(
"test_username", "ubuntu"
)
test_password = self.get_test_data_or_default(
"test_password", "ubuntu"
)

cmd = [
"sshpass",
"-p",
Expand Down

0 comments on commit aa362cf

Please sign in to comment.