- 追加された行はこの色です。
- 削除された行はこの色です。
*Swift/使い方 [#off95cf7]
[[インストール>Swift/インストール方法]]、[[設定ファイルの作成>Swift/設定ファイルの作成]]、[[起動用スクリプトの作成>Swift/起動用スクリプトの作成]]が終わったら実際に動かしてみましょう。
クライアントからの利用方法についてです。
*サーバの起動 [#d13113ef]
*Cloud Files API [#u613943b]
スクリプトを使用して、各種サーバを起動させます。~
まずはRingを構築します。
SwiftはCloud Filesプロトコルを使用しています。~
Cloud Files用のAPIが公開されており、PHP、Java、.NET、Ruby、Pythonのライブラリが提供されています。
# remakerings
*CyberDuckからの利用 [#a46abf82]
テストを行ないます。~
Cloud Filesプロトコルに対応しているソフトウェアにはCyberDuckがあります。~
# cd ~/swift/trunk; ./.unittests
......................................................................
======================================================================
FAIL: test_whataremyips (test.unit.common.test_utils.TestUtils)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/nanodayo/swift/trunk/test/unit/common/test_utils.py", line 226, in test_whataremyips
self.assert_(len(myips) > 1)
AssertionError
Name Stmts Exec Cover Missing
----------------------------------------------------------
swift 0 0 100%
swift.account 0 0 100%
(中略)
----------------------------------------------------------
TOTAL 5414 3969 73%
----------------------------------------------------------------------
Ran 371 tests in 37.550s
**Mac OSからの利用 [#z4890062]
FAILED (failures=1)
デフォルトの状態では、CloudFilesを選ぶとサーバのアドレスが固定されています。~
下記のコマンドを実行することでSwiftを選ぶことができるようになり、サーバアドレスを編集できるようです。~
特にエラーがなければサーバを起動します。~
こちらの環境では上記のようにAssertionErrorが出て、FAILEDになっていますが~
起動等は問題なく行なえます。
# defaults write ch.sudo.cyberduck protocol.cf.swift.enable true
# startmain
ただし現状、動作を確認出来ていません(調査中)~
Swiftのドキュメントにも、CyberDuckからの利用について触れられていますが~
ソースコードを参照し、URLを定義しているファイルを書き換えてコンパイルする方法が書かれています。
rootユーザ以外だと、"Unable to increase file descriptor limit. Running as non-root?"と出ますが問題なく起動します。
**Windowsからの利用 [#eab40c09]
テスト用のswiftのアカウントを作成します。
Windows版のCyberDuckは、Private Betaとして配布されています。~
[[CyberDuck>http://cyberduck.ch/]]のトップページから、申し込むことができます。~
※メールベースでの申し込みです。実際にもらえるまでには結構な時間がかかります。~
# swift-auth-create-account test tester testing
バージョン4.07bで動作を確認しています。~
その前のバージョンでは選択肢にSwiftがなく、未対応でした。
//ヘルプによると、Setting hidden preferences is not currently supported on Windows.とあり~
//現行ではSwiftを有効にできないようです。
作成後、X-Storage-UrlとX-Auth-Tokenを取得します。
**CyberDuckでのSwift利用方法 [#s9efeb4d]
# curl -v -H 'X-Storage-User: test:tester' -H 'X-Storage-Pass: testing' http://127.0.0.1:11000/v1.0
* About to connect() to 127.0.0.1 port 11000 (#0)
* Trying 127.0.0.1... connected
* Connected to 127.0.0.1 (127.0.0.1) port 11000 (#0)
> GET /v1.0 HTTP/1.1
> User-Agent: curl/7.19.7 (i486-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
> Host: 127.0.0.1:11000
> Accept: */*
> X-Storage-User: test:tester
> X-Storage-Pass: testing
>
< HTTP/1.1 204 No Content
< X-Storage-Url: http://127.0.0.1:9000/v1/ef7a92d3-a959-4dcd-9ab1-82028fd67d6b
< X-Storage-Token: tkc3f4640b-68fa-4ffd-bb09-29d80ee64ab4
< X-Auth-Token: tkc3f4640b-68fa-4ffd-bb09-29d80ee64ab4
< Content-Length: 0
< Date: Wed, 01 Sep 2010 00:07:13 GMT
<
* Connection #0 to host 127.0.0.1 left intact
* Closing connection #0
CyberDuckからSwiftを利用する場合の手順です。~
Windows 7 + CyberDuck 4.07bで動作を確認しています。
出力結果から、X-Storage-UrlとX-Auth-Tokenを取り出し、その後の操作に使用します。~
X-Storage-Urlはポート番号9000番という結果が返ってきますが、Swiftには9000番を使用しているサービスはありません。~
プロクシサーバのポート(8080)を指定すると想定する動作を行うので、ここでは8080に置き換えて使用します。
まずは新規接続を選びます。
以下のようにしてHTTPのGETメソッドでテストを行ないます。
#ref(cyberduck.png)
# curl -v -H 'X-Auth-Token: tkc3f4640b-68fa-4ffd-bb09-29d80ee64ab4' http://127.0.0.1:8080/v1/ef7a92d3-a959-4dcd-9ab1-82028fd67d6b
* About to connect() to 127.0.0.1 port 8080 (#0)
* Trying 127.0.0.1... connected
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET /v1/ef7a92d3-a959-4dcd-9ab1-82028fd67d6b HTTP/1.1
> User-Agent: curl/7.19.7 (i486-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
> Host: 127.0.0.1:8080
> Accept: */*
> X-Auth-Token: tkc3f4640b-68fa-4ffd-bb09-29d80ee64ab4
>
< HTTP/1.1 204 No Content
< X-Container-Object-Count: 0
< X-Container-Bytes-Used: 0
< Content-Length: 0
< Date: Wed, 01 Sep 2010 00:11:51 GMT
<
* Connection #0 to host 127.0.0.1 left intact
* Closing connection #0
サーバの情報を入力する画面になるので、プロトコルをSwiftにします。
この時点ではまだ何もオブジェクトがないため、No Contentと表示されます。
#ref(cyberduck2.png)
他にもPUTメソッドでディレクトリの作成やファイルのアップロードが行なえます。~
ディレクトリの作成は、以下のように、-XオプションでPUTメソッドを指定し、作成するディレクトリ名をURLの末尾に追加します。
サーバの情報を入力します。~
サーバとポートはそれぞれAuth Serverの情報を入力します。~
ユーザ名は<account>:<user>の形式で入力します。~
パスは空白のままにします。
# curl -X PUT -v -H 'X-Auth-Token: tkc3f4640b-68fa-4ffd-bb09-29d80ee64ab4' http://127.0.0.1:8080/v1/ef7a92d3-a959-4dcd-9ab1-82028fd67d6b/aaaa
* About to connect() to 127.0.0.1 port 8080 (#0)
* Trying 127.0.0.1... connected
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> PUT /v1/ef7a92d3-a959-4dcd-9ab1-82028fd67d6b/aaaa HTTP/1.1
> User-Agent: curl/7.19.7 (i486-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
> Host: 127.0.0.1:8080
> Accept: */*
> X-Auth-Token: tkc3f4640b-68fa-4ffd-bb09-29d80ee64ab4
>
< HTTP/1.1 201 Created
< Content-Length: 18
< Content-Type: text/plain; charset=UTF-8
< Date: Wed, 01 Sep 2010 00:17:51 GMT
<
201 Created
* Connection #0 to host 127.0.0.1 left intact
* Closing connection #0
#ref(cyberduck3.png)
201 Createdがでれば成功です。~
既にディレクトリがある場合は202 Acceptedと出るようです。
接続すると、コンテナの一覧が表示されます。~
右クリックメニューから、アップロードやフォルダ作成が行えます。
ファイルのアップロードは以下のようにします。~
#ref(cyberduck4.png)
# curl -X PUT -T test -v -H 'X-Auth-Token: tkc3f4640b-68fa-4ffd-bb09-29d80ee64ab4' http://127.0.0.1:8080/v1/ef7a92d3-a959-4dcd-9ab1-82028fd67d6b/aaaa/
* About to connect() to 127.0.0.1 port 8080 (#0)
* Trying 127.0.0.1... connected
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> PUT /v1/ef7a92d3-a959-4dcd-9ab1-82028fd67d6b/aaaa/test HTTP/1.1
> User-Agent: curl/7.19.7 (i486-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
> Host: 127.0.0.1:8080
> Accept: */*
> X-Auth-Token: tkc3f4640b-68fa-4ffd-bb09-29d80ee64ab4
> Content-Length: 17
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
< HTTP/1.1 201 Created
< Content-Length: 118
< Content-Type: text/plain; charset=UTF-8
< Etag: 7276c6ddf848dc69460b7873bd6ddb77
< Last-Modified: Wed, 01 Sep 2010 00:22:20 GMT
< Date: Wed, 01 Sep 2010 00:22:20 GMT
<
<html>
<head>
<title>201 Created</title>
</head>
<body>
<h1>201 Created</h1>
<br /><br />
</body>
* Connection #0 to host 127.0.0.1 left intact
* Closing connection #0
コンテナの中身はこのようになっています。~
コンテナの中に、ディレクトリを作成することができて、コンテナとは違うアイコンで表示されます。
アップロードしたファイルは、GETメソッドで確認できます。~
hogehogeの部分に、ファイルの内容が表示されます。
# curl -v -H 'X-Auth-Token: tkc3f4640b-68fa-4ffd-bb09-29d80ee64ab4' http://127.0.0.1:8080/v1/ef7a92d3-a959-4dcd-9ab1-82028fd67d6b/aaaa/test
* About to connect() to 127.0.0.1 port 8080 (#0)
* Trying 127.0.0.1... connected
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET /v1/ef7a92d3-a959-4dcd-9ab1-82028fd67d6b/aaaa/test HTTP/1.1
> User-Agent: curl/7.19.7 (i486-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
> Host: 127.0.0.1:8080
> Accept: */*
> X-Auth-Token: tkc3f4640b-68fa-4ffd-bb09-29d80ee64ab4
>
< HTTP/1.1 200 OK
< Last-Modified: Wed, 01 Sep 2010 00:22:20 GMT
< Etag: 7276c6ddf848dc69460b7873bd6ddb77
< Content-Length: 17
< Content-Type: application/octet-stream
< Date: Wed, 01 Sep 2010 00:31:55 GMT
<
hogehoge
hogege
* Connection #0 to host 127.0.0.1 left intact
* Closing connection #0
stという、Swiftに含まれているコマンドでもテストを行ないます。
# st -A http://127.0.0.1:11000/v1.0 -U test:tester -K testing stat
こちらの環境ではエラーになり、現在調査中です。
*リンク [#q68dd5fb]
[[Swift All In One>http://swift.openstack.org/development_saio.html]]
-[[RackSpace>http://www.rackspacecloud.com/]]
-[[Cloud Files API>http://www.rackspacecloud.com/cloud_hosting_products/files/api]]
-[[CyberDuck>http://cyberduck.ch/]]