LoginSignup
3
3

More than 5 years have passed since last update.

django-swiftbrowserを使ってみる

Last updated at Posted at 2014-09-28

vagrant-swift-all-in-oneを使ってみるの続きです


django-swiftbrowser

vagrant-swift-all-in-oneを使ってみるでSwiftサーバを構築しましたが、GUIもサーバ側で用意したいものです。OpenStackのダッシュボード・サービス(Horizon)と認証サービス(Keystone)を利用しても良いのですが、Swiftを使うためだけに導入するのは非常に手間です。そこで、Swift用の簡易GUIであるdjango-swiftbrowserを利用してみます。

# リポジトリを取得
git clone git://github.com/cschwede/django-swiftbrowser.git
# インストール
cd django-swiftbrowser
sudo python setup.py install

swiftbrowserの設定

適当なプロジェクトを作成します。

django-admin.py startproject myproj
cd myproj
cp ~/django-swiftbrowser/example/settings.py myproj/settings.py

myproj/settings.pyを修正します。

myproj/settings.py
# Swiftの認証URLをSwiftサーバの固定IPに変更
SWIFT_AUTH_URL = 'http://192.168.0.1:8080/auth/v1.0'
SWIFT_AUTH_VERSION = 1 # 2 for keystone
STORAGE_URL = 'http://192.168.0.1:8080/v1/'
BASE_URL = 'http://192.168.0.1'
SWAUTH_URL = 'http://192.168.0.1:8080/auth/v2'
STATIC_DIR = '/var/www/myproj/static'

# タイムゾーンと言語をベルリンから日本に修正
- TIME_ZONE = 'Europe/Berlin'
- LANGUAGE_CODE = 'de-de'
+ TIME_ZONE = 'Asia/Tokyo'
+ LANGUAGE_CODE = 'ja-jp'

# ALLOWED_HOSTSにSwiftサーバの固定IPを追加
ALLOWED_HOSTS = ['127.0.0.1', '192.168.0.1', 'insert_your_hostname_here']

myproj/urls.pyにURLの設定を追記します。

myproj/urls.py
  from django.conf.urls import patterns, include, url
  from django.contrib import admin
+ import swiftbrowser.urls

  urlpatterns = patterns('',
    url(r'^admin/', include(admin.site.urls)),
+   url(r'^', include(swiftbrowser.urls)),
)

静的ファイルをコピーします。

sudo python manage.py collectstatic
(既存ファイルを上書きしてもいいかと聞かれるので'yes'を入力します)

swiftbrowserの起動とログイン

Swiftbrowserを起動します。

python manage.py runserver 192.168.0.1:8000 --insecure &

問題なく起動できていれば、ブラウザからhttp://192.168.0.1:8000/login/ にアクセスするとログイン画面が表示されます。testユーザでログインするには、ユーザ名:test:tester 、パスワード:testing を入力します。

これでブラウザからSwiftを利用できるようになりました。

※うまくいかなかったところ

ファイルのアップロード時にUnauthorizedとなってしまいます。
原因が分かったら修正します。

3
3
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
3
3