From 4d8220b2dfe53aa987b9c235b08a103764af9261 Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Thu, 15 Nov 2018 09:49:31 -0600 Subject: [PATCH] Updates to DevStack plugin * Add a basic DevStack job to exercise this * Clean up plugin to match DevStack conventions Change-Id: I5b079eacebf9ddb433b5e831d557afe6a1be6880 Signed-off-by: Dean Troyer --- .zuul.yaml | 49 ++++++++++++ devstack/files/debs/stx-nfv | 1 + devstack/files/rpms/stx-nfv | 1 + devstack/lib/stx-nfv | 152 ++++++++++++++++++++---------------- devstack/plugin.sh | 24 +++--- devstack/settings | 7 +- tox.ini | 5 ++ 7 files changed, 159 insertions(+), 80 deletions(-) create mode 100644 devstack/files/debs/stx-nfv create mode 100644 devstack/files/rpms/stx-nfv diff --git a/.zuul.yaml b/.zuul.yaml index 1f907c2e..82f9e85b 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -12,6 +12,8 @@ - nfv-tox-pylint - nova-api-proxy-tox-pep8 - nova-api-proxy-tox-pylint + - stx-devstack-nfv: + voting: false gate: jobs: - build-openstack-api-ref @@ -73,3 +75,50 @@ vars: tox_envlist: pylint tox_extra_args: -c nova-api-proxy/tox.ini + +- job: + name: stx-devstack-nfv + parent: stx-devstack-base + timeout: 7800 + required-projects: + - openstack/stx-fault + vars: + tox_envlist: functional + devstack_services: + # Cinder services + c-api: false + c-bak: false + c-sch: false + c-vol: false + cinder: false + # Glance services + g-api: false + g-reg: false + # Nova services + n-api: false + n-api-meta: false + n-cauth: false + n-cond: false + n-cpu: false + n-novnc: false + n-obj: false + n-sch: false + placement-api: false + # Neutron services + q-agt: true + q-dhcp: false + q-l3: false + q-meta: false + q-metering: false + q-svc: false + horizon: false + # StarlingX services + nfv-common: true + nfv-vim: true + nfv-client: true + guest-client: true + devstack_plugins: + stx-fault: git://git.starlingx.io/stx-fault + stx-nfv: git://git.starlingx.io/stx-nfv + devstack_localrc: + LIBS_FROM_GIT: keystone diff --git a/devstack/files/debs/stx-nfv b/devstack/files/debs/stx-nfv new file mode 100644 index 00000000..472edf67 --- /dev/null +++ b/devstack/files/debs/stx-nfv @@ -0,0 +1 @@ +libjson-c-dev diff --git a/devstack/files/rpms/stx-nfv b/devstack/files/rpms/stx-nfv new file mode 100644 index 00000000..e0e47453 --- /dev/null +++ b/devstack/files/rpms/stx-nfv @@ -0,0 +1 @@ +json-c-devel diff --git a/devstack/lib/stx-nfv b/devstack/lib/stx-nfv index 0562026b..a35dd54d 100644 --- a/devstack/lib/stx-nfv +++ b/devstack/lib/stx-nfv @@ -1,44 +1,57 @@ #!/bin/bash +# +# lib/stx-nfv +# Functions to control the configuration and operation of stx-nfv -PREFIX=/usr -INCLUDE_DIR=$PREFIX/include -UNIT_DIR=/etc/systemd/system +_XTRACE_STX_NFV=$(set +o | grep xtrace) +set -o xtrace -GUEST_CLIENT_VERSION="3.0.1" -GUEST_CLIENT_DIR=$DEST/stx-nfv/guest-client/guest-client-$GUEST_CLIENT_VERSION -CGCS_SDK_DEPLOY_DIR=/opt/deploy/cgcs_sdk +STXNFV_DIR=$DEST/stx-nfv +STXNFV_SYSCONFDIR=/etc -NFV_DIR=$DEST/stx-nfv/nfv +STX_BIN_DIR=$(get_python_exec_prefix) +STX_PREFIX=${STX_BIN_DIR%/*} + +NFV_DIR=$STXNFV_DIR/nfv +NFV_CONF_DIR=$STXNFV_SYSCONFDIR/nfv NFV_CLIENT_DIR=$NFV_DIR/nfv-client NFV_COMMON_DIR=$NFV_DIR/nfv-common NFV_PLUGINS_DIR=$NFV_DIR/nfv-plugins NFV_TOOLS_DIR=$NFV_DIR/nfv-tools NFV_VIM_DIR=$NFV_DIR/nfv-vim -function clean_guest_client(){ - sudo rm -rf $INCLUDE_DIR/guest-client - sudo rm -rf $CGCS_SDK_DEPLOY_DIR - sudo rm -rf $UNIT_DIR/guest-client.service - sudo rm -rf /etc/guest-client - sudo rm -rf /usr/local/bin/guest-client - sudo rm -rf /usr/local/lib/libguest_common_api.so.$GUEST_CLIENT_VERSION - sudo rm -rf /usr/local/lib/libguest_heartbeat_api.so.$GUEST_CLIENT_VERSION +GUEST_CLIENT_VERSION="3.0.1" + +STX_SDK_DEPLOY_DIR=${STX_SDK_DEPLOY_DIR:-/opt/deploy/cgcs_sdk} + +function cleanup_guest_client { + sudo rm -rf $STX_PREFIX/include/guest-client + sudo rm -rf $STX_SDK_DEPLOY_DIR + sudo rm -rf $STXNFV_SYSCONFDIR/systemd/system/guest-client.service + sudo rm -rf $STXNFV_SYSCONFDIR/guest-client + sudo rm -rf $STX_PREFIX/bin/guest-client + sudo rm -rf $STX_PREFIX/lib/libguest_common_api.so.$GUEST_CLIENT_VERSION + sudo rm -rf $STX_PREFIX/lib/libguest_heartbeat_api.so.$GUEST_CLIENT_VERSION } -function clean_init_nfv(){ +function cleanup_init_nfv { sudo userdel nfv sudo groupdel nfv sudo rm -rf /opt/platform/nfv } -function clean_nfv(){ +function cleanup_nfv { if is_service_enabled stx-nfv; then - clean_guest_client - clean_init_nfv + clean_init_nfv + fi + if is_service_enabled guest-client; then + cleanup_guest_client fi } -function init_nfv(){ +function init_nfv { + # TODO: This is all too specific, remove hard-coded uid and gid references + # create the nfv group sudo groupadd -g 172 nfv @@ -48,95 +61,99 @@ function init_nfv(){ sudo mkdir -p /opt/platform/nfv } -function install_guest_client(){ - pushd $GUEST_CLIENT_DIR +function install_guest_client { + pushd $STXNFV_DIR/guest-client/guest-client-$GUEST_CLIENT_VERSION + make clean - make build sysconfdir=/etc + make build sysconfdir=$STXNFV_SYSCONFDIR make sample make tar ARCHIVE_NAME=wrs-guest-heartbeat-$GUEST_CLIENT_VERSION find build # Sudo Install for guest-client package - sudo install -m 755 -d $INCLUDE_DIR/guest-client - sudo install -m 644 -p -D guest_client/src/heartbeat/guest_heartbeat_msg_defs.h $INCLUDE_DIR/guest-client/guest_heartbeat_msg_defs.h - sudo install -d $CGCS_SDK_DEPLOY_DIR - sudo install -m 640 build/wrs-guest-heartbeat-$GUEST_CLIENT_VERSION.tgz $CGCS_SDK_DEPLOY_DIR + sudo install -m 755 -d $STX_PREFIX/include/guest-client + sudo install -m 644 -p -D guest_client/src/heartbeat/guest_heartbeat_msg_defs.h $STX_PREFIX/include/guest-client/guest_heartbeat_msg_defs.h + sudo install -d $STX_SDK_DEPLOY_DIR + sudo install -m 640 build/wrs-guest-heartbeat-$GUEST_CLIENT_VERSION.tgz $STX_SDK_DEPLOY_DIR # Systemd services - sudo install -m 644 -p -D guest_client/scripts/guest-client.service $UNIT_DIR/guest-client.service - sudo install -m 744 -p -D guest_client/scripts/guest-client.systemd /etc/guest-client/guest-client.systemd + sudo install -m 644 -p -D guest_client/scripts/guest-client.service $STXNFV_SYSCONFDIR/systemd/system/guest-client.service + sudo install -m 744 -p -D guest_client/scripts/guest-client.systemd $STXNFV_SYSCONFDIR/guest-client/guest-client.systemd + + sudo install -m 750 -d $STXNFV_SYSCONFDIR/guest-client/heartbeat + sudo install -m 755 -p -D guest_client/scripts/guest_heartbeat.conf $STXNFV_SYSCONFDIR/guest-client/heartbeat/guest_heartbeat.conf + sudo install -m 755 -p -D guest_client/scripts/sample_event_handling_script $STXNFV_SYSCONFDIR/guest-client/heartbeat/sample_event_handling_script + sudo install -m 755 -p -D guest_client/scripts/sample_health_check_script $STXNFV_SYSCONFDIR/guest-client/heartbeat/sample_health_check_script + sudo install -m 640 -p -D build/guest-client $STX_PREFIX/bin/guest-client + sudo install -m 640 -p -D build/libguest_common_api.so.$GUEST_CLIENT_VERSION $STX_PREFIX/lib/libguest_common_api.so.$GUEST_CLIENT_VERSION + sudo install -m 640 -p -D build/libguest_heartbeat_api.so.$GUEST_CLIENT_VERSION $STX_PREFIX/lib/libguest_heartbeat_api.so.$GUEST_CLIENT_VERSION - sudo install -m 750 -d /etc/guest-client/heartbeat - sudo install -m 755 -p -D guest_client/scripts/guest_heartbeat.conf /etc/guest-client/heartbeat/guest_heartbeat.conf - sudo install -m 755 -p -D guest_client/scripts/sample_event_handling_script /etc/guest-client/heartbeat/sample_event_handling_script - sudo install -m 755 -p -D guest_client/scripts/sample_health_check_script /etc/guest-client/heartbeat/sample_health_check_script - sudo install -m 640 -p -D build/guest-client /usr/local/bin/guest-client - sudo install -m 640 -p -D build/libguest_common_api.so.$GUEST_CLIENT_VERSION /usr/local/lib/libguest_common_api.so.$GUEST_CLIENT_VERSION - sudo install -m 640 -p -D build/libguest_heartbeat_api.so.$GUEST_CLIENT_VERSION /usr/local/lib/libguest_heartbeat_api.so.$GUEST_CLIENT_VERSION popd } -function install_nfv(){ - if is_service_enabled guest-client; then - install_guest_client +function install_nfv { + if is_service_enabled nfv-common; then + init_nfv + install_nfv_common + install_nfv_plugins + install_nfv_tools fi - if is_service_enabled nfv-common; then - init_nfv - install_nfv_common - install_nfv_plugins - install_nfv_tools - install_nfv_client + if is_service_enabled nfv-client; then + install_nfv_client fi if is_service_enabled nfv-vim; then - install_nfv_vim + install_nfv_vim + fi + + if is_service_enabled guest-client; then + install_guest_client fi } -function install_nfv_client(){ +function install_nfv_client { pushd $NFV_CLIENT_DIR python setup.py build sudo python setup.py install - sudo install -d -m 755 /etc/bash_completion.d - sudo install -m 444 scripts/sw-manager.completion /etc/bash_completion.d/sw-manager + sudo install -d -m 755 $STXNFV_SYSCONFDIR/bash_completion.d + sudo install -m 444 scripts/sw-manager.completion $STXNFV_SYSCONFDIR/bash_completion.d/sw-manager popd } -function install_nfv_common(){ +function install_nfv_common { pushd $NFV_COMMON_DIR python setup.py build sudo python setup.py install popd } -function install_nfv_plugins(){ +function install_nfv_plugins { pushd $NFV_PLUGINS_DIR python setup.py build sudo python setup.py install - sudo install -d -m 755 /etc/nfv/ - sudo install -d -m 755 /etc/nfv/nfv_plugins/ - sudo install -d -m 755 /etc/nfv/nfv_plugins/alarm_handlers/ - sudo install -p -D -m 600 nfv_plugins/alarm_handlers/config.ini /etc/nfv/nfv_plugins/alarm_handlers/config.ini - sudo install -d -m 755 /etc/nfv/nfv_plugins/event_log_handlers/ - sudo install -p -D -m 600 nfv_plugins/event_log_handlers/config.ini /etc/nfv/nfv_plugins/event_log_handlers/config.ini - sudo install -d -m 755 /etc/nfv/nfv_plugins/nfvi_plugins/ - sudo install -p -D -m 600 nfv_plugins/nfvi_plugins/config.ini /etc/nfv/nfv_plugins/nfvi_plugins/config.ini - sudo install -d -m 755 / - sudo install -p -D -m 644 scripts/nfvi-plugins.logrotate /etc/logrotate.d/nfvi-plugins.logrotate + sudo install -d -m 755 $NFV_CONF_DIR + sudo install -d -m 755 $NFV_CONF_DIR/nfv_plugins/ + sudo install -d -m 755 $NFV_CONF_DIR/nfv_plugins/alarm_handlers/ + sudo install -p -D -m 600 nfv_plugins/alarm_handlers/config.ini $NFV_CONF_DIR/nfv_plugins/alarm_handlers/config.ini + sudo install -d -m 755 $NFV_CONF_DIR/nfv_plugins/event_log_handlers/ + sudo install -p -D -m 600 nfv_plugins/event_log_handlers/config.ini $NFV_CONF_DIR/nfv_plugins/event_log_handlers/config.ini + sudo install -d -m 755 $NFV_CONF_DIR/nfv_plugins/nfvi_plugins/ + sudo install -p -D -m 600 nfv_plugins/nfvi_plugins/config.ini $NFV_CONF_DIR/nfv_plugins/nfvi_plugins/config.ini + sudo install -p -D -m 644 scripts/nfvi-plugins.logrotate $STXNFV_SYSCONFDIR/logrotate.d/nfvi-plugins.logrotate popd } -function install_nfv_tools(){ +function install_nfv_tools { pushd $NFV_TOOLS_DIR python setup.py build sudo python setup.py install popd } -function install_nfv_vim(){ +function install_nfv_vim { pushd $NFV_VIM_DIR python setup.py build sudo python setup.py install @@ -145,9 +162,10 @@ function install_nfv_vim(){ sudo install -p -D -m 755 scripts/vim /usr/lib/ocf/resource.d/nfv/vim sudo install -p -D -m 755 scripts/vim-api /usr/lib/ocf/resource.d/nfv/vim-api sudo install -p -D -m 755 scripts/vim-webserver /usr/lib/ocf/resource.d/nfv/vim-webserver - sudo install -d -m 755 /etc/nfv/ - sudo install -d -m 755 /etc/nfv/vim/ - sudo install -p -D -m 600 nfv_vim/config.ini /etc/nfv/vim/config.ini - sudo install -p -D -m 600 nfv_vim/debug.ini /etc/nfv/vim/debug.ini + sudo install -d -m 755 $NFV_CONF_DIR/vim/ + sudo install -p -D -m 600 nfv_vim/config.ini $NFV_CONF_DIR/vim/config.ini + sudo install -p -D -m 600 nfv_vim/debug.ini $NFV_CONF_DIR/vim/debug.ini popd } + +$_XTRACE_STX_NFV diff --git a/devstack/plugin.sh b/devstack/plugin.sh index 50fbc989..ba90ba03 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -1,27 +1,29 @@ #!/bin/bash -# -# lib/stx-nfv -# Functions to control the configuration and operation of the **network function virtualization** service + +# devstack/plugin.sh +# Triggers specific functions to install and configure stx-nfv + +echo_summary "stx-nfv devstack plugin.sh called: $1/$2" # check for service enabled if is_service_enabled stx-nfv; then if [[ "$1" == "stack" && "$2" == "install" ]]; then - # Perform installation of service source - echo_summary "Installing stx-nfv" + # Perform installation of service source + echo_summary "Installing stx-nfv" install_nfv elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then - # Configure after the other layer 1 and 2 services have been configured - echo_summary "Configuring stx-nfv" - : + # Configure after the other layer 1 and 2 services have been configured + echo_summary "Configuring stx-nfv" + : fi if [[ "$1" == "unstack" ]]; then - : + : fi if [[ "$1" == "clean" ]]; then - echo_summary "Clean stx-nfv" - clean_nfv + echo_summary "Clean stx-nfv" + cleanup_nfv fi fi diff --git a/devstack/settings b/devstack/settings index 05236034..b7f282b8 100644 --- a/devstack/settings +++ b/devstack/settings @@ -10,6 +10,9 @@ STX_NFV_NAME=stx-nfv enable_service $STX_NFV_NAME if is_service_enabled stx-nfv; then - # Initial source of lib script - source $DEST/stx-nfv/devstack/lib/stx-nfv + # Enable prerequisites here + : fi + +# Initial source of lib script +source $DEST/stx-nfv/devstack/lib/stx-nfv diff --git a/tox.ini b/tox.ini index 40ec54b5..e4ef08f8 100644 --- a/tox.ini +++ b/tox.ini @@ -72,3 +72,8 @@ commands = rm -rf api-ref/build sphinx-build -W -b html -d api-ref/build/doctrees api-ref/source api-ref/build/html whitelist_externals = rm + +[testenv:functional] +basepython = python3 +whitelist_externals = cat +commands = cat /etc/fm/fm.conf