From 53a513f34a04cfa58b6eec0300b33b4c6c19303e Mon Sep 17 00:00:00 2001 From: Huan Xie Date: Wed, 16 Nov 2016 00:25:14 -0800 Subject: [PATCH] Add devstack-plugins in os-xenapi When changed to use os-xenapi, we also need to change the way we install OpenStack by DevStack. This patch use the plugins mechanisem DevStack provided, we can install the extra/specific parts besides what DevStack already done. 1. Add devstack folder and scripts for devstack-plugin 2. Install Dom0 plugins 3. Add TODOs, we can configure XenServer+Neutron specific items in devstack-plugin in the future Change-Id: I6dc783eeb5c95e5fe81d907154aa2e880d6bac9e --- devstack/README.rst | 17 +++++++++ devstack/dom0_functions | 11 ++++++ devstack/plugin.sh | 85 +++++++++++++++++++++++++++++++++++++++++ devstack/settings | 0 4 files changed, 113 insertions(+) create mode 100644 devstack/README.rst create mode 100644 devstack/dom0_functions create mode 100755 devstack/plugin.sh create mode 100644 devstack/settings diff --git a/devstack/README.rst b/devstack/README.rst new file mode 100644 index 0000000..33f6fb7 --- /dev/null +++ b/devstack/README.rst @@ -0,0 +1,17 @@ +====================== + Enabling in Devstack +====================== + +This plugin will help to install XenServer Dom0 specific scripts into +XenServer Dom0 and make the proper configuration items for Neutron +OpenvSwitch agent. + +1. Download DevStack + +2. Add this repo as an external repository:: + + local.conf + [[local|localrc]] + enable_plugin os-xenapi https://github.com/openstack/os-xenapi.git [GITREF] + +3. run ``stack.sh`` diff --git a/devstack/dom0_functions b/devstack/dom0_functions new file mode 100644 index 0000000..8edbaef --- /dev/null +++ b/devstack/dom0_functions @@ -0,0 +1,11 @@ +#!/bin/bash + +function dom0_plugin_location { + for PLUGIN_DIR in "/etc/xapi.d/plugins/" "/usr/lib/xcp/plugins/" "/usr/lib/xapi/plugins" "/usr/lib64/xapi/plugins"; do + if [ -d $PLUGIN_DIR ]; then + echo $PLUGIN_DIR + return 0 + fi + done + return 1 +} \ No newline at end of file diff --git a/devstack/plugin.sh b/devstack/plugin.sh new file mode 100755 index 0000000..74c75e4 --- /dev/null +++ b/devstack/plugin.sh @@ -0,0 +1,85 @@ +#!/bin/bash +# +# Copyright 2013 OpenStack Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# + +MODE=$1 +PHASE=$2 + +OS_XENAPI_DIR=$DEST/os-xenapi + +function get_dom0_ssh { + local dom0_ip + dom0_ip=$(echo "$XENAPI_CONNECTION_URL" | cut -d "/" -f 3) + + local ssh_dom0 + ssh_dom0="sudo -u $DOMZERO_USER ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$dom0_ip" + echo $ssh_dom0 + return 0 +} + +# Install Dom0 plugins +function install_plugins { + local ssh_dom0 + ssh_dom0=$(get_dom0_ssh) + + local dom0_func + dom0_func=`cat $OS_XENAPI_DIR/devstack/dom0_functions` + local dom0_plugin_dir + dom0_plugin_dir=`$ssh_dom0 "$dom0_func; set -eux; dom0_plugin_location"` + + # Get the path that os-xenapi is installed or the path that nova source code resides + # Note: This aims to be compatible whenever dom0 plugin is in os-xenapi repo or in nova repo + local plugin_dir + plugin_dir=$(sudo -H pip show os-xenapi |grep "Location:"|cut -d " " -f 2-) + if [ -z "$plugin_dir" ]; then + pip_install_gr xenapi + plugin_dir=$DEST/nova + tar -czf - -C $plugin_dir/plugins/xenserver/xenapi/etc/xapi.d/plugins/ ./ | + $ssh_dom0 "tar -xzf - -C $dom0_plugin_dir && chmod a+x $dom0_plugin_dir/*" + else + tar -czf - -C $plugin_dir/os_xenapi/dom0/etc/xapi.d/plugins/ ./ | + $ssh_dom0 "tar -xzf - -C $dom0_plugin_dir && chmod a+x $dom0_plugin_dir/*" + fi +} + +if [[ "$MODE" == "stack" ]]; then + case "$PHASE" in + install) + install_plugins + ;; + post-config) + # Called after the layer 1 and 2 services have been configured. + # All configuration files for enabled services should exist at this point. + # TODO(huanxie): when reverse q-agt/q-domua merged, q-domua is XS specific part + # Configure XenServer neutron specific items for q-domua + # ovs native mode + # ovs VxLAN + ;; + extra) + ;; + test-config) + # Called at the end of devstack used to configure tempest + # or any other test environments + # TODO(huanxie) Maybe we can set some conf here for CI? + ;; + esac +elif [[ "$MODE" == "clean" ]]; then + # Called by clean.sh before other services are cleaned, but after unstack.sh has been called + # TODO(huanxie) + # Stop q-domua in the future? + # clean the OVS bridge created in Dom0 and iptables rules? + echo "mode is clean" +fi diff --git a/devstack/settings b/devstack/settings new file mode 100644 index 0000000..e69de29