OpenStack ManilaをUbuntu 14.04にインストール

Kiloのcloud-archiveリポジトリを使うか、ソースから入れる。以下はソースから入れる手順。

依存パッケージをインストール

```bash
apt-get install libmysqlclient-dev
apt-get install postgresql-common postgresql-server-dev-9.3
apt-get install python-dev libxslt-dev libffi-dev
# GlusterFSを使う場合はクライアントが必要
# apt-get install glusterfs-client
```

コードを取得して、virtualenvを構築。toolsの中に構築スクリプトがあるのでそれを使う。
最後の一行はサンプル設定ファイルの生成。

```bash
cd /opt
git clone https://git.openstack.org/openstack/manila
cd manila
git checkout stable/kilo
python tools/install_venv.py
./tools/with_venv.sh python ./setup.py install
./tools/with_venv.sh oslo-config-generator --config-file etc/oslo-config-generator/manila.conf 
```

`python-manilaclient`も忘れずに。

```bash
cd /opt
git clone https://git.openstack.org/openstack/python-manilaclient
cd python-manilaclient
git checkout stable/kilo
python tools/install_venv.py
./tools/with_venv.sh python ./setup.py install
```

aliasを張るとあとが楽。

```bash
alias manila='/opt/python-manilaclient/tools/with_venv.sh manila'
```

必要なファイルの作成とパーミッションの設定。

```/etc/sudoers.d/manila_sudoers
Defaults:manila !requiretty
manila ALL = (root) NOPASSWD: /usr/local/bin/manila-rootwrap /etc/manila/rootwrap.conf *
```

```bash
addgroup --system manila
adduser --system --home /var/lib/manila --ingroup manila --no-create-home --shell /bin/false manila
mkdir /var/log/manila /var/lib/manila /etc/manila
cp /opt/manila/etc/manila/manila.conf.sample /etc/manila/manila.conf
cp /opt/manila/etc/manila/logging_sample.conf /etc/manila/logging.conf
cp /opt/manila/etc/manila/api-paste.ini /etc/manila/
cp /opt/manila/etc/manila/policy.json /etc/manila/
cp /opt/manila/etc/manila/rootwrap.conf /etc/manila/
cp -r /opt/manila/etc/manila/rootwrap.d /etc/manila/
chown -R manila:adm /var/log/manila
chown -R manila:manila /var/lib/manila /etc/manila
chown -R root:root /etc/manila/rootwrap.d
chown root:root /etc/manila/rootwrap.conf
chmod 0750 /etc/manila
chmod 0755 /etc/manila/rootwrap.d
chmod 0750 /var/log/manila
chmod 0440 /etc/sudoers.d/manila_sudoers
ln -s /opt/manila/.venv/bin/manila-rootwrap /usr/local/bin/manila-rootwrap
```

debを解凍してこの手順を作ったが、めんどくせ(´Д｀)
これらを自動で全部やってくれるパッケージマネージャって便利だな(´Д｀)

upstartを設定。Novaのをそのままパクってきたもの。

```/etc/init/manila-api.conf
description "Manila API server"
author "makisyu <makisyu@mail.com>"
start on runlevel [2345]
stop on runlevel [!2345]
 
chdir /var/run
pre-start script
        mkdir -p /var/run/manila
        chown manila:root /var/run/manila/
        mkdir -p /var/lock/manila
        chown manila:root /var/lock/manila/
end script
exec start-stop-daemon --start --chuid manila --exec /opt/manila/tools/with_venv.sh -- manila-api --config-file=/etc/manila/manila.conf --log-file /var/log/manila/manila-api.log
```

```/etc/init/manila-scheduler.conf
description "Manila scheduler server"
author "makisyu <makisyu@mail.com>"
start on runlevel [2345]
stop on runlevel [!2345]
 
chdir /var/run
pre-start script
        mkdir -p /var/run/manila
        chown manila:root /var/run/manila/
        mkdir -p /var/lock/manila
        chown manila:root /var/lock/manila/
end script
exec start-stop-daemon --start --chuid manila --exec /opt/manila/tools/with_venv.sh -- manila-scheduler --config-file=/etc/manila/manila.conf --log-file /var/log/manila/manila-scheduler.log
```

```/etc/init/manila-share.conf
# vim: set ft=upstart:
description "Manila share worker"
author "makisyu <makisyu@mail.com>"
start on runlevel [2345]
stop on runlevel [!2345]
chdir /var/run
pre-start script
        mkdir -p /var/run/manila
        chown manila:root /var/run/manila/
        mkdir -p /var/lock/manila
        chown manila:root /var/lock/manila/
end script
exec start-stop-daemon --start --chuid manila --exec /opt/manila/tools/with_venv.sh -- manila-share --config-file=/etc/manila/manila.conf --log-file=/var/log/manila/manila-share.log
```

KeystoneにEndpointを追加

```bash
keystone service-create --name manila --type share --description "OpenStack Shared Filesystems"
keystone endpoint-create --service-id $(keystone service-list | awk '/ share / {print $2}') \
                         --publicurl http://<controller>:8786/v1/%\(tenant_id\)s \
                         --internalurl http://<controller>:8786/v1/%\(tenant_id\)s \
                         --adminurl http://<controller>:8786/v1/%\(tenant_id\)s \
                         --region RegionOne
```

Start server

```bash
./tools/with_venv.sh manila-manage --config-file /etc/manila/manila.conf db sync
service manila-api start
service manila-scheduler start
service manila-share start
```