Automatized stx-openstack install for AIO-SX
Users can now install stx-openstack in an automated manner by using the --openstack-helm-location parameter when running the script installation, and by increasing the node storage to at least 360 GB. Story: 2005051 Task: 48149 Change-Id: I2eade54dca3328fa5fe5282355e9a1b9f33b059f Signed-off-by: Tomás Barros <tomas.barros@encora.com>
This commit is contained in:
parent
0c1a53cebd
commit
c56230011f
@ -204,6 +204,12 @@ def parse_config_location(parser: ArgumentParser):
|
||||
dashboard instalation and configuration.
|
||||
""",
|
||||
type=str)
|
||||
parser.add_argument("--openstack-package-location", help=
|
||||
"""
|
||||
Path to stx-openstack package location
|
||||
""",
|
||||
type=str,
|
||||
default=None)
|
||||
|
||||
|
||||
def parse_disk_info(parser: ArgumentParser):
|
||||
|
@ -146,7 +146,13 @@ will be configured and used.
|
||||
-O $HOME/Downloads/stx-8.iso
|
||||
```
|
||||
|
||||
5. Now you're ready to run the script. From the `/virtualbox/pybox`
|
||||
5. (Optional) Get the latest stx-openstack application package if you want to install it:
|
||||
```shell
|
||||
wget https://mirror.starlingx.cengn.ca/mirror/starlingx/release/latest_release/debian/monolithic/outputs/helm-charts/stx-openstack-1.0-1.stx.6-debian-stable-latest.tgz\
|
||||
-O $HOME/Downloads/stx-openstack-pkg.tgz
|
||||
```
|
||||
|
||||
6. Now you're ready to run the script. From the `/virtualbox/pybox`
|
||||
folder, do (remember to change the password on the below command before
|
||||
running it):
|
||||
|
||||
|
@ -8,11 +8,11 @@ This module contains the HostTimeout class, which provides timeout values (in se
|
||||
for various operations on a host.
|
||||
"""
|
||||
|
||||
class HostTimeout: #pylint: disable=too-few-public-methods
|
||||
"""The `HostTimeout` class provides timeout values (in seconds) for various
|
||||
operations on a host."""
|
||||
# pylint: disable=R0903
|
||||
|
||||
CONTROLLER_UNLOCK = 3600+1800
|
||||
|
||||
class HostTimeout:
|
||||
CONTROLLER_UNLOCK = 3600 + 1800
|
||||
REBOOT = 900
|
||||
INSTALL = 3600
|
||||
LAB_INSTALL = 3600
|
||||
|
@ -1978,6 +1978,169 @@ def stage_custom_script5():
|
||||
mode = 'user'
|
||||
run_custom_script(script, timeout, console, mode)
|
||||
|
||||
@connect_to_ssh('controller-0')
|
||||
def stage_openstack_config(ssh_client):
|
||||
"""A Function to configure pre-requisites necessary for installing stx-openstack"""
|
||||
|
||||
if V_BOX_OPTIONS.openstack_package_location is None:
|
||||
return
|
||||
if V_BOX_OPTIONS.setup_type != AIO_SX:
|
||||
raise Exception("The installer currently does not support installing stx-openstack in setup types other than \
|
||||
AIO-SX.")
|
||||
|
||||
concat_ssh_cmd = [
|
||||
"source /etc/platform/openrc",
|
||||
"DATA0IF=enp0s9",
|
||||
"DATA1IF=enp0s10",
|
||||
"export NODE=controller-0",
|
||||
"PHYSNET0='physnet0'",
|
||||
"PHYSNET1='physnet1'",
|
||||
"SPL=/tmp/tmp-system-port-list",
|
||||
"SPIL=/tmp/tmp-system-host-if-list",
|
||||
"system host-port-list ${NODE} --nowrap > ${SPL}",
|
||||
"system host-if-list -a ${NODE} --nowrap > ${SPIL}",
|
||||
"DATA0PCIADDR=$(cat $SPL | grep $DATA0IF |awk '{print $8}')",
|
||||
"DATA1PCIADDR=$(cat $SPL | grep $DATA1IF |awk '{print $8}')",
|
||||
"DATA0PORTUUID=$(cat $SPL | grep ${DATA0PCIADDR} | awk '{print $2}')",
|
||||
"DATA1PORTUUID=$(cat $SPL | grep ${DATA1PCIADDR} | awk '{print $2}')",
|
||||
"DATA0PORTNAME=$(cat $SPL | grep ${DATA0PCIADDR} | awk '{print $4}')",
|
||||
"DATA1PORTNAME=$(cat $SPL | grep ${DATA1PCIADDR} | awk '{print $4}')",
|
||||
"DATA0IFUUID=$(cat $SPIL | awk -v DATA0PORTNAME=$DATA0PORTNAME " +
|
||||
"'($12 ~ DATA0PORTNAME) {print $2}')",
|
||||
"DATA1IFUUID=$(cat $SPIL | awk -v DATA1PORTNAME=$DATA1PORTNAME " +
|
||||
"'($12 ~ DATA1PORTNAME) {print $2}')",
|
||||
"system datanetwork-add ${PHYSNET0} vlan",
|
||||
"system datanetwork-add ${PHYSNET1} vlan",
|
||||
"system host-if-modify -m 1500 -n data0 -c data ${NODE} ${DATA0IFUUID}",
|
||||
"system host-if-modify -m 1500 -n data1 -c data ${NODE} ${DATA1IFUUID}",
|
||||
"system interface-datanetwork-assign ${NODE} ${DATA0IFUUID} ${PHYSNET0}",
|
||||
"system interface-datanetwork-assign ${NODE} ${DATA1IFUUID} ${PHYSNET1}",
|
||||
"system host-label-assign controller-0 openstack-control-plane=enabled",
|
||||
"system host-label-assign controller-0 openstack-compute-node=enabled",
|
||||
"system host-label-assign controller-0 openvswitch=enabled",
|
||||
"export NODE=controller-0",
|
||||
"system host-fs-add ${NODE} instances=34"
|
||||
]
|
||||
|
||||
run_ssh_cmd(ssh_client, "\n".join(concat_ssh_cmd))
|
||||
|
||||
|
||||
def step_check_platform_integ_apps(ssh_client):
|
||||
"""A function that checks whether the platform_integ_apps application is in the required state,
|
||||
as it is a prerequisite for installing stx-openstack"""
|
||||
|
||||
LOG.info("#### Checking if platform_integ_apps is already applied")
|
||||
regex_1 = r'\|\s*status\s*\|\s*applied\s*\|'
|
||||
regex_2 = r'\|\s*active\s*\|\s*True\s*\|'
|
||||
ssh_cmd_list = [
|
||||
f'system application-show platform-integ-apps | grep -E "{regex_1}"',
|
||||
f'system application-show platform-integ-apps | grep -E "{regex_2}"'
|
||||
]
|
||||
run_ssh_cmd_list(ssh_client, ssh_cmd_list, timeout=HostTimeout.NORMAL_OP, scale=2)
|
||||
LOG.info("#### Sleeping for 60sec")
|
||||
time.sleep(60)
|
||||
|
||||
|
||||
def step_increase_docker_partition(ssh_client):
|
||||
"""A Function that increases docker_lv filesystem necessary
|
||||
for the stx-openstack installation"""
|
||||
|
||||
LOG.info("#### Modifying the size of the docker_lv filesystem")
|
||||
_, _, return_code = run_ssh_cmd(ssh_client,
|
||||
'source /etc/platform/openrc;\
|
||||
system host-fs-modify controller-0 docker=60',
|
||||
timeout=HostTimeout.NORMAL_OP)
|
||||
|
||||
if int(return_code) == 0:
|
||||
return
|
||||
raise Exception("Couldn't allocate appropriate size to docker partition!")
|
||||
|
||||
|
||||
def step_upload_package(ssh_client):
|
||||
"""A function that uploads the stx-openstack installation package"""
|
||||
|
||||
LOG.info("Copying stx-openstack package .tgz file")
|
||||
ip_addr, port = get_ssh_ip_and_port(
|
||||
'controller-0')
|
||||
destination_loc = f'/home/{V_BOX_OPTIONS.username}/stx-openstack-pkg.tgz'
|
||||
sftp_send(
|
||||
V_BOX_OPTIONS.openstack_package_location,
|
||||
destination_loc,
|
||||
{
|
||||
"remote_host": ip_addr,
|
||||
"remote_port": port,
|
||||
"username": V_BOX_OPTIONS.username,
|
||||
"password": V_BOX_OPTIONS.password
|
||||
}
|
||||
)
|
||||
|
||||
LOG.info("#### Uploading the application package")
|
||||
regex = r'\|\s*status\s*\|\s*uploaded\s*\|'
|
||||
ssh_cmd_list = [
|
||||
"system application-upload stx-openstack-pkg.tgz",
|
||||
f'system application-show stx-openstack | grep -E "{regex}"'
|
||||
]
|
||||
run_ssh_cmd_list(ssh_client, ssh_cmd_list, timeout=HostTimeout.NORMAL_OP)
|
||||
LOG.info("#### Sleeping for 60sec")
|
||||
time.sleep(60)
|
||||
|
||||
|
||||
|
||||
def step_apply_openstack(ssh_client):
|
||||
"""A function to apply the stx-openstack application"""
|
||||
|
||||
LOG.info("#### Applying openstack application package")
|
||||
regex_1 = r'\|\s*status\s*\|\s*applied\s*\|'
|
||||
regex_2 = r'\|\s*active\s*\|\s*True\s*\|'
|
||||
ssh_cmd_list = [
|
||||
"system application-apply stx-openstack",
|
||||
f'system application-show stx-openstack | grep -E "{regex_1}"',
|
||||
f'system application-show stx-openstack | grep -E "{regex_2}"'
|
||||
]
|
||||
run_ssh_cmd_list(ssh_client, ssh_cmd_list, scale=6)
|
||||
LOG.info("#### Sleeping for 10sec")
|
||||
time.sleep(10)
|
||||
run_ssh_cmd(ssh_client, 'source /etc/platform/openrc;\
|
||||
system application-show stx-openstack',
|
||||
timeout=HostTimeout.NORMAL_OP)
|
||||
|
||||
|
||||
def step_config_openstack_dashboard(ssh_client):
|
||||
"""Creates the stx-openstack horizon port-forward in vbox"""
|
||||
|
||||
LOG.info("#### Creating stx-openstack horizon port forward")
|
||||
ip_addr = V_BOX_OPTIONS.controller0_ip
|
||||
rule_name = V_BOX_OPTIONS.labname + "-openstack-horizon"
|
||||
|
||||
create_port_forward(rule_name,
|
||||
V_BOX_OPTIONS.vboxnet_name,
|
||||
local_port=V_BOX_OPTIONS.openstack_horizon_port,
|
||||
guest_port='31000',
|
||||
guest_ip=ip_addr)
|
||||
|
||||
LOG.info ('#### Setting up admin credentials on active controller')
|
||||
run_ssh_cmd(ssh_client, "sed " +
|
||||
"'/export OS_AUTH_URL/c\\export OS_AUTH_URL=http://keystone.openstack.svc.cluster." +
|
||||
"local/v3' /etc/platform/openrc > ~/openrc.os")
|
||||
|
||||
|
||||
@connect_to_ssh('controller-0')
|
||||
def stage_install_openstack(ssh_client):
|
||||
"""Move the application package to the VM, upload the package, and then install stx-openstack"""
|
||||
|
||||
if V_BOX_OPTIONS.openstack_package_location is None:
|
||||
return
|
||||
if V_BOX_OPTIONS.setup_type != AIO_SX:
|
||||
raise Exception("The installer currently does not support installing stx-openstack in setup types other than \
|
||||
AIO-SX.")
|
||||
step_check_platform_integ_apps(ssh_client)
|
||||
step_increase_docker_partition(ssh_client)
|
||||
step_upload_package(ssh_client)
|
||||
step_apply_openstack(ssh_client)
|
||||
step_config_openstack_dashboard(ssh_client)
|
||||
LOG.info("#### stx-openstack was successfully installed!")
|
||||
return
|
||||
|
||||
|
||||
STG_CREATE_LAB = "create-lab"
|
||||
STG_INSTALL_CONTROLLER0 = "install-controller-0"
|
||||
@ -2000,6 +2163,8 @@ STG_CUSTOM_SCRIPT2 = "custom-script2"
|
||||
STG_CUSTOM_SCRIPT3 = "custom-script3"
|
||||
STG_CUSTOM_SCRIPT4 = "custom-script4"
|
||||
STG_CUSTOM_SCRIPT5 = "custom-script5"
|
||||
STG_CONFIG_OPENSTACK = "config-openstack"
|
||||
STG_INSTALL_OPENSTACK = "install-openstack"
|
||||
|
||||
# For internal testing only, one stage is always successful
|
||||
# the other one always raises an exception.
|
||||
@ -2062,29 +2227,36 @@ STAGE_CALLBACKS = {
|
||||
HELP: "Run lab_setup with one or more --lab-setup-conf files"},
|
||||
STG_CUSTOM_SCRIPT1:
|
||||
{CALLBACK: stage_custom_script1,
|
||||
HELP: "Run a custom script from /home/wrsroot, make sure you" \
|
||||
"upload it in the rsync-config stage and it is +x. See help."},
|
||||
HELP: "Run a custom script from /home/wrsroot, make sure you\
|
||||
upload it in the rsync-config stage and it is +x. See help."},
|
||||
STG_CUSTOM_SCRIPT2:
|
||||
{CALLBACK: stage_custom_script2,
|
||||
HELP: "Run a custom script from /home/wrsroot, make sure you" \
|
||||
"upload it in the rsync-config stage and it is +x. See help."},
|
||||
HELP: "Run a custom script from /home/wrsroot, make sure you\
|
||||
upload it in the rsync-config stage and it is +x. See help."},
|
||||
STG_CUSTOM_SCRIPT3:
|
||||
{CALLBACK: stage_custom_script3,
|
||||
HELP: "Run a custom script from /home/wrsroot, make sure you" \
|
||||
"upload it in the rsync-config stage and it is +x. See help."},
|
||||
HELP: "Run a custom script from /home/wrsroot, make sure you\
|
||||
upload it in the rsync-config stage and it is +x. See help."},
|
||||
STG_CUSTOM_SCRIPT4:
|
||||
{CALLBACK: stage_custom_script4,
|
||||
HELP: "Run a custom script from /home/wrsroot, make sure you" \
|
||||
"upload it in the rsync-config stage and it is +x. See help."},
|
||||
HELP: "Run a custom script from /home/wrsroot, make sure you\
|
||||
upload it in the rsync-config stage and it is +x. See help."},
|
||||
STG_CUSTOM_SCRIPT5:
|
||||
{CALLBACK: stage_custom_script5,
|
||||
HELP: "Run a custom script from /home/wrsroot, make sure you" \
|
||||
"upload it in the rsync-config stage and it is +x. See help."},
|
||||
HELP: "Run a custom script from /home/wrsroot, make sure you\
|
||||
upload it in the rsync-config stage and it is +x. See help."},
|
||||
# internal testing
|
||||
STC_TEST_SUCCESS: {CALLBACK: stage_test_success,
|
||||
HELP: "Internal only, does not do anything, used for testing."},
|
||||
STG_TEST_FAIL: {CALLBACK: stage_test_fail,
|
||||
HELP: "Internal only, raises exception, used for testing."},
|
||||
STG_CONFIG_OPENSTACK:
|
||||
{CALLBACK: stage_openstack_config,
|
||||
HELP: "Run a custom script to assign labels to prepare stx-openstack installation."},
|
||||
STG_INSTALL_OPENSTACK:
|
||||
{CALLBACK: stage_install_openstack,
|
||||
HELP: "Run a custom script to upload the application package and installs \
|
||||
the stx-openstack."}
|
||||
}
|
||||
|
||||
AVAILABLE_STAGES = [STG_CREATE_LAB,
|
||||
@ -2109,15 +2281,19 @@ AVAILABLE_STAGES = [STG_CREATE_LAB,
|
||||
STG_CUSTOM_SCRIPT4,
|
||||
STG_CUSTOM_SCRIPT5,
|
||||
STC_TEST_SUCCESS,
|
||||
STG_TEST_FAIL]
|
||||
STG_TEST_FAIL,
|
||||
STG_CONFIG_OPENSTACK,
|
||||
STG_INSTALL_OPENSTACK]
|
||||
|
||||
AIO_SX_STAGES = [
|
||||
STG_CREATE_LAB,
|
||||
STG_INSTALL_CONTROLLER0,
|
||||
STG_CONFIG_CONTROLLER,
|
||||
STG_SETUP_CONTROLLER_0,
|
||||
STG_CONFIG_OPENSTACK,
|
||||
STG_UNLOCK_CONTROLLER0,
|
||||
STG_ENABLE_KUBERNETES,
|
||||
STG_INSTALL_OPENSTACK
|
||||
]
|
||||
|
||||
AIO_DX_STAGES = [
|
||||
@ -2401,8 +2577,8 @@ if __name__ == "__main__":
|
||||
if stage not in AVAILABLE_STAGES:
|
||||
invalid_stages.append(stage)
|
||||
if invalid_stages:
|
||||
LOG.info("Following custom stages are not supported: %s.\n" \
|
||||
"Choose from: %s", invalid_stages, AVAILABLE_STAGES)
|
||||
LOG.info("Following custom stages are not supported: %s.\n\
|
||||
Choose from: %s", invalid_stages, AVAILABLE_STAGES)
|
||||
sys.exit(1)
|
||||
else:
|
||||
# List all stages between 'from-stage' to 'to-stage'
|
||||
|
Loading…
x
Reference in New Issue
Block a user