1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

stack.sh が御三家以外のプロジェクトをインストールする仕組み

Last updated at Posted at 2019-01-05

はじめに

devstack を使った Openstack のインストールは御三家(keystone, nova, placement, glance, neutron, horizon)だけでなく、それ以外のプロジェクトも以下のように local.conf の [[local|localrc]] に記述する(例:Heat)ことでインストールできる。

# Enable heat services
enable_service h-eng h-api h-api-cfn h-api-cw

# Enable heat plugin
enable_plugin heat https://git.openstack.org/openstack/heat

しかし、どのような仕組みで御三家以外のプロジェクトのインストールが実行されるのかが分かっていなかった。
stack.sh のコードを読み勧めていく中で、この仕組みが分かったため忘備録として残す。

対象者

  • devstack で御三家以外のプロジェクトのインストールがしたい人

仕組み

localrc の enable_plugin を実行

これによりプラグイン名(リポジトリ)を環境変数DEVSTACK_PLUGINSに追加する。

function enable_plugin {
    local name=$1
    local url=$2
    local branch=${3:-master}
    if is_plugin_enabled $name; then
        die $LINENO "Plugin attempted to be enabled twice: ${name} ${url} ${branch}"
    fi
    DEVSTACK_PLUGINS+=",$name"
    GITREPO[$name]=$url
    GITDIR[$name]=$DEST/$name
    GITBRANCH[$name]=$branch
}

Configure Projects フェーズの fetch_plugins でリポジトリのクローン

fetch_plugins は、環境変数DEVSTACK_PLUGINSに入っているリポジトリをクローンする。

function fetch_plugins {
    local plugins="${DEVSTACK_PLUGINS}"
    local plugin

    # short circuit if nothing to do
    if [[ -z $plugins ]]; then
        return
    fi

    echo "Fetching DevStack plugins"
    for plugin in ${plugins//,/ }; do
        git_clone_by_name $plugin
    done
}

function git_clone_by_name {
    local name=$1
    local repo=${GITREPO[$name]}
    local dir=${GITDIR[$name]}
    local branch=${GITBRANCH[$name]}
    git_clone $repo $dir $branch
}

Extras Install フェーズで stack.sh は run_phase stack install を実行

# Extras Install
# --------------

# Phase: install
run_phase stack install

run_phase は run_plugins を実行

function run_phase {
    local mode=$1
    local phase=$2
<略>
    else
        run_plugins $mode $phase
    fi
}

run_plugins はクローンしたディレクトリ全てを対象に devstack/plugin.sh を実行

function run_plugins {
    local mode=$1
    local phase=$2

    local plugins="${DEVSTACK_PLUGINS}"
    local plugin
    for plugin in ${plugins//,/ }; do
        local dir=${GITDIR[$plugin]}
        if [[ -f $dir/devstack/plugin.sh ]]; then
            source $dir/devstack/plugin.sh $mode $phase
        fi
    done
}

plugin.sh は引数に従いインストール処理を実行

    if [[ "$1" == "stack" && "$2" == "install" ]]; then
        echo_summary "Installing heat"
        # Use stack_install_service here to account for virtualenv
        stack_install_service heat
        echo_summary "Installing heatclient"
        install_heatclient

結論

  • enable_plugin で指定しないと、そもそもリポジトリがクローンされない。
  • stack.sh の Extras Install フェーズでそれぞれのリポジトリ以下の devstack/plugin.sh が実行される。
  • 御三家のインストールの処理は、devstack に内蔵されているため plugin が不要。

おわりに

ツッコミがあればコメントくだし。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?