diff --git a/README.rst b/README.rst index d793336..5838d60 100644 --- a/README.rst +++ b/README.rst @@ -5,8 +5,8 @@ Virtual Serial Port Concentrator for use in the vSphere environment. It collects serial console logs from VMs which have configured virtual serial port pointing to it. -Usage -===== +Usage with OpenStack +-------------------- Copy ``vspc.conf.sample`` as ``vspc.conf`` and edit as appropriate:: @@ -21,4 +21,21 @@ Copy ``vspc.conf.sample`` as ``vspc.conf`` and edit as appropriate:: Then start with:: - $ vmware-vspc --config-file vspc.conf \ No newline at end of file + $ vmware-vspc --config-file vspc.conf + +In ``nova.conf`` add the following properties:: + + [vmware] + serial_port_service_uri = vmware-vspc + serial_port_proxy_uri = telnets://:13370#thumbprint= + +where ``vspc_host`` is the host where VSPC runs and ``vspc_thumbprint`` is the SHA1 +thumbprint of the configured certificate. + +Usage with Devstack +------------------- + +There is a devstack plugin, so simply add this to your ``local.conf``:: + + [[local|localrc]] + enable_plugin vmware-vspc https://github.com/openstack/vmware-vspc diff --git a/devstack/plugin.sh b/devstack/plugin.sh new file mode 100644 index 0000000..0c10344 --- /dev/null +++ b/devstack/plugin.sh @@ -0,0 +1,80 @@ +# Save trace setting +XTRACE=$(set +o | grep xtrace) +set -o xtrace + +NOVA_CONF=/etc/nova/nova.conf +VSPC_CONF_DIR=/etc/vmware +VSPC_CONF=$VSPC_CONF_DIR/vspc.conf +VSPC_PORT=${VSPC_PORT:-13370} +VSPC_URI=vspc-uri +VSPC_LOG_DIR=$DATA_DIR/vspc + +function install_vspc { + # save the old values of PYTHON3_VERSION and USE_PYTHON3 + # since we are going to change them + PYTHON3_VERSION_OLD=$PYTHON3_VERSION + USE_PYTHON3_OLD=$USE_PYTHON3 + PYTHON3_VERSION=${PYTHON3_VERSION:-3.5} + USE_PYTHON3=True + install_python3 + USE_PYTHON3=True PYTHON3_VERSION=$PYTHON3_VERSION $TOP_DIR/tools/install_pip.sh + echo_summary "Installing vmware-vspc" + setup_package $DEST/vmware-vspc -e + USE_PYTHON3=$USE_PYTHON3_OLD + PYTHON3_VERSION=$PYTHON3_VERSION_OLD +} + +function configure_vspc { + echo_summary "Generating VSPC certificate and key" + sudo install -d -o $STACK_USER $VSPC_CONF_DIR + openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 \ + -subj '/CN=devstack' -keyout $VSPC_CONF_DIR/key.pem \ + -out $VSPC_CONF_DIR/cert.pem + THUMBPRINT=$(openssl x509 -in $VSPC_CONF_DIR/cert.pem -sha1 -noout -fingerprint | awk -F'=' '{print $2}') + + echo_summary "Creating VSPC config file" + rm -f $VSPC_CONF + iniset $VSPC_CONF DEFAULT debug "$ENABLE_DEBUG_LOG_LEVEL" + iniset $VSPC_CONF DEFAULT host "$SERVICE_HOST" + iniset $VSPC_CONF DEFAULT port "$VSPC_PORT" + iniset $VSPC_CONF DEFAULT cert "$VSPC_CONF_DIR/cert.pem" + iniset $VSPC_CONF DEFAULT key "$VSPC_CONF_DIR/key.pem" + iniset $VSPC_CONF DEFAULT uri "$VSPC_URI" + sudo install -d -o $STACK_USER $VSPC_LOG_DIR + iniset $VSPC_CONF DEFAULT serial_log_dir "$VSPC_LOG_DIR" + + echo_summary "Configuring VSPC settings in nova.conf" + PROXY_URI="telnets://$SERVICE_HOST:$VSPC_PORT#thumbprint=$THUMBPRINT" + iniset $NOVA_CONF vmware serial_port_service_uri "$VSPC_URI" + iniset $NOVA_CONF vmware serial_port_proxy_uri "$PROXY_URI" +} + +function start_vspc { + echo_summary "Starting vmware-vspc ..." + BIN_DIR=$(get_python_exec_prefix) + run_process vmware-vspc "$BIN_DIR/vmware-vspc --config-file $VSPC_CONF" +} + +# check for service enabled +if is_service_enabled vmware-vspc; then + + if [[ "$1" == "stack" && "$2" == "install" ]]; then + # Perform installation of service source + install_vspc + + elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then + # Configure after the other layer 1 and 2 services have been configured + configure_vspc + + elif [[ "$1" == "stack" && "$2" == "extra" ]]; then + # Initialize and start vmware-vspc + start_vspc + fi + + if [[ "$1" == "unstack" ]]; then + stop_process vmware-vspc + fi +fi + +# Restore xtrace +$XTRACE diff --git a/devstack/settings b/devstack/settings new file mode 100644 index 0000000..96868cf --- /dev/null +++ b/devstack/settings @@ -0,0 +1 @@ +enable_service vmware-vspc