2019-02-19 13:09:32 -05:00
|
|
|
#!/usr/bin/python3
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
#
|
|
|
|
|
|
|
|
"""
|
|
|
|
Contains helper functions that will configure basic system settings.
|
|
|
|
"""
|
|
|
|
|
|
|
|
from consts.timeout import HostTimeout
|
|
|
|
from utils import serial
|
|
|
|
from utils.install_log import LOG
|
2023-05-04 17:21:54 -03:00
|
|
|
from helper import host_helper
|
|
|
|
|
2019-02-19 13:09:32 -05:00
|
|
|
|
|
|
|
def update_platform_cpus(stream, hostname, cpu_num=5):
|
|
|
|
"""
|
|
|
|
Update platform CPU allocation.
|
|
|
|
"""
|
|
|
|
|
|
|
|
LOG.info("Allocating %s CPUs for use by the %s platform.", cpu_num, hostname)
|
2023-05-04 17:21:54 -03:00
|
|
|
serial.send_bytes(
|
|
|
|
stream,
|
|
|
|
"\nsource /etc/platform/openrc; system host-cpu-modify "
|
|
|
|
f"{hostname} -f platform -p0 {cpu_num}",
|
|
|
|
prompt="keystone",
|
|
|
|
timeout=300,
|
|
|
|
)
|
|
|
|
|
2019-02-19 13:09:32 -05:00
|
|
|
|
|
|
|
def set_dns(stream, dns_ip):
|
|
|
|
"""
|
|
|
|
Perform DNS configuration on the system.
|
|
|
|
"""
|
|
|
|
|
|
|
|
LOG.info("Configuring DNS to %s.", dns_ip)
|
2023-05-04 17:21:54 -03:00
|
|
|
serial.send_bytes(
|
|
|
|
stream,
|
|
|
|
"source /etc/platform/openrc; system dns-modify "
|
|
|
|
f"nameservers={dns_ip}",
|
|
|
|
prompt="keystone",
|
|
|
|
)
|
2019-02-19 13:09:32 -05:00
|
|
|
|
|
|
|
|
2023-05-22 15:18:13 -03:00
|
|
|
def config_controller(stream, password):
|
2019-02-19 13:09:32 -05:00
|
|
|
"""
|
|
|
|
Configure controller-0 using optional arguments
|
|
|
|
"""
|
|
|
|
|
2023-05-04 17:21:54 -03:00
|
|
|
serial.send_bytes(
|
|
|
|
stream,
|
|
|
|
"ansible-playbook /usr/share/ansible/stx-ansible/playbooks/bootstrap.yml",
|
|
|
|
expect_prompt=False,
|
|
|
|
)
|
2019-02-19 13:09:32 -05:00
|
|
|
host_helper.check_password(stream, password=password)
|
2023-05-04 17:21:54 -03:00
|
|
|
ret = serial.expect_bytes(stream, "~$", timeout=HostTimeout.LAB_CONFIG)
|
2019-02-19 13:09:32 -05:00
|
|
|
if ret != 0:
|
|
|
|
LOG.info("Configuration failed. Exiting installer.")
|
2023-05-04 17:21:54 -03:00
|
|
|
raise Exception("Configcontroller failed") # pylint: disable=E0012, W0719
|