From 34f8c6a1479c2854577d83fe93a92ca647bbbd97 Mon Sep 17 00:00:00 2001 From: Shaohe Feng Date: Wed, 15 May 2019 12:43:12 +0000 Subject: [PATCH] bug fix: deploy every cyborg components correctly Different components need different config. Change-Id: Id73cd0dd7eb2abc2d411cc3d5abbbd4e3df58f0f --- devstack/lib/cyborg | 51 +++++++++++-------- devstack/plugin.sh | 60 ++++++++++++++++------- doc/source/contributor/devstack_setup.rst | 37 ++++++++++++++ 3 files changed, 108 insertions(+), 40 deletions(-) diff --git a/devstack/lib/cyborg b/devstack/lib/cyborg index 4ba9932d..86d11a1d 100644 --- a/devstack/lib/cyborg +++ b/devstack/lib/cyborg @@ -62,17 +62,22 @@ else CYBORG_API_URL="$CYBORG_SERVICE_PROTOCOL://$CYBORG_SERVICE_HOST:$CYBORG_SERVICE_PORT" fi +function install_cyborg_in_controller { + if is_service_enabled cyborg-api; then + local req_services="key" + req_services+=" placement" + for srv in $req_services; do + if ! is_service_enabled "$srv"; then + die $LINENO "$srv should be enabled for Cyborg." + fi + done + fi +} + # install_cyborg() - Install the things! function install_cyborg { - # make sure all needed service were enabled - local req_services="key" - req_services+=" nova glance neutron" - for srv in $req_services; do - if ! is_service_enabled "$srv"; then - die $LINENO "$srv should be enabled for Cyborg." - fi - done - + # make sure all needed services are enabled + install_cyborg_in_controller setup_develop $CYBORG_DIR } @@ -116,13 +121,15 @@ function configure_cyborg_dirs { # ------------------------------ # service cyborg admin function create_cyborg_accounts { - create_service_user "cyborg" "admin" - get_or_create_service "cyborg" "accelerator" "Cyborg Accelerators Service" - get_or_create_endpoint "cyborg" \ - "$REGION_NAME" \ - "$CYBORG_API_URL/v1" \ - "$CYBORG_API_URL/v1" \ - "$CYBORG_API_URL/v1" + if is_service_enabled cyborg-api; then + create_service_user "cyborg" "admin" + get_or_create_service "cyborg" "accelerator" "Cyborg Accelerators Service" + get_or_create_endpoint "cyborg" \ + "$REGION_NAME" \ + "$CYBORG_API_URL/v1" \ + "$CYBORG_API_URL/v1" \ + "$CYBORG_API_URL/v1" + fi } @@ -261,12 +268,14 @@ function create_cyborg_cache_dir { # init_cyborg() - Initialize databases, etc. function init_cyborg { - # (re)create Cyborg database - recreate_database cyborg utf8 + if is_service_enabled cyborg-api; then + # (re)create Cyborg database + recreate_database cyborg utf8 - # Migrate cyborg database - $CYBORG_BIN_DIR/cyborg-dbsync --config-file ${CYBORG_CONF_FILE} upgrade - create_cyborg_cache_dir + # Migrate cyborg database + $CYBORG_BIN_DIR/cyborg-dbsync --config-file ${CYBORG_CONF_FILE} upgrade + create_cyborg_cache_dir + fi } diff --git a/devstack/plugin.sh b/devstack/plugin.sh index 86b6daa1..4c2d4636 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -8,28 +8,52 @@ echo_summary "cyborg devstack plugin.sh called: $1/$2" source $DEST/cyborg/devstack/lib/cyborg source $DEST/cyborg/devstack/lib/opae -if is_service_enabled cyborg-api cyborg-cond; then - if [[ "$1" == "stack" ]]; then - if [[ "$2" == "pre-install" ]]; then + +function pre_install_agent { + if is_service_enabled cyborg-agent; then # stack/pre-install - Called after (OS) setup is complete and before # project source is installed - echo_summary "Installing additional Cyborg packages" - if [[ "$OPAE_INSTALL_ENABLE" == "True" ]] && install_opae_packages; then - echo_summary "INFO: Additional Cyborg packages installed" - elif [[ "$OPAE_INSTALL_ENABLE" == "True" ]]; then - echo "WARNING: Failed to install additional Cyborg packages" - fi - elif [[ "$2" == "install" ]]; then + echo_summary "Installing additional Cyborg packages" + if [[ "$OPAE_INSTALL_ENABLE" == "True" ]] && install_opae_packages; then + echo_summary "INFO: Additional Cyborg packages installed" + elif [[ "$OPAE_INSTALL_ENABLE" == "True" ]]; then + echo "WARNING: Failed to install additional Cyborg packages" + fi + fi +} + + +function install_agent { + if is_service_enabled cyborg-agent; then # stack/install - Called after the layer 1 and 2 projects source and # their dependencies have been installed - echo_summary "Installing Cyborg" - if ! is_service_enabled nova; then - source $RC_DIR/lib/nova_plugins/functions-libvirt - install_libvirt - fi + echo_summary "Installing Cyborg" + if ! is_service_enabled n-cpu; then + source $RC_DIR/lib/nova_plugins/functions-libvirt + install_libvirt + fi + fi +} + + +function cleanup_agent { + if is_service_enabled cyborg-agent; then + if [[ "$OPAE_INSTALL_ENABLE" == "True" ]]; then + uninstall_opae_packages + fi + fi +} + + +if is_service_enabled cyborg-api cyborg-cond || is_service_enabled cyborg-agent; then + if [[ "$1" == "stack" ]]; then + if [[ "$2" == "pre-install" ]]; then + pre_install_agent + elif [[ "$2" == "install" ]]; then + install_agent install_cyborg elif [[ "$2" == "post-config" ]]; then - # stack/post-config - Called after the layer 1 and 2 services have been + # stack/post-config - Called after the layer 0 and 2 services have been # configured. All configuration files for enabled services should exist # at this point. echo_summary "Configuring Cyborg" @@ -56,8 +80,6 @@ if is_service_enabled cyborg-api cyborg-cond; then # clean - Called by clean.sh before other services are cleaned, but after # unstack.sh has been called. cleanup_cyborg - if [[ "$OPAE_INSTALL_ENABLE" == "True" ]]; then - uninstall_opae_packages - fi + cleanup_agent fi fi diff --git a/doc/source/contributor/devstack_setup.rst b/doc/source/contributor/devstack_setup.rst index 29e4bf51..fe68423b 100644 --- a/doc/source/contributor/devstack_setup.rst +++ b/doc/source/contributor/devstack_setup.rst @@ -142,6 +142,35 @@ Disable OPAE install If you do not want to try Intel FPGA, you can disable OPAE install. Then you do not depend on specific OS verson. +Multi-Node Lab +-------------- +If you want to setup an OpenStack with cyborg in a realistic test configuration +with multiple physical servers. Please ref [#MultiNodeLab]_. + +Cluster Controller +>>>>>>>>>>>>>>>>>> + +:: + + disable_service cyborg-agent + +Compute Nodes +>>>>>>>>>>>>> + +:: + + enable_service cyborg-agent + disable_service cyborg-api + disable_service cyborg-cond + +- If you do not want to setup cyborg-agent on controller, you can disable it. +- You do not need to enable cyborg-api and cyborg-cond on compute nodes. + +Cell V2 Deployment +>>>>>>>>>>>>>>>>>> + +Compute node services must be mapped to a cell before they can be used. +Cell V2 deployment, please ref [#CellV2]_. Run DevStack ------------ @@ -170,3 +199,11 @@ Horizon You can access horizon to experience the web interface to OpenStack, and manage vms, networks, volumes, and images from there. + +References +========== + +.. [#MultiNodeLab] `Openstack Multi-Node Lab Setup + `_ +.. [#CellV2] `Openstack Cell V2 Deployment Guide + `_