1 Openstack Swift as backend for Dulwich
2 ======================================
3 Fabien Boucher <fabien.boucher@enovance.com>
5 The module dulwich/contrib/swift.py implements dulwich.repo.BaseRepo
6 in order to being compatible with Openstack Swift.
7 We can then use Dulwich as server (Git server) and instead of using
8 a regular POSIX file system to store repository objects we use the
9 object storage Swift via its own API.
11 c Git client <---> Dulwich server <---> Openstack Swift API
13 This implementation is still a work in progress and we can say that
14 is a Beta version so you need to be prepared to find bugs.
19 We need to provide some configuration values in order to let Dulwich
20 talk and authenticate against Swift. The following config file must
24 # Authentication URL (Keystone or Swift)
25 auth_url = http://127.0.0.1:5000/v2.0
26 # Authentication version to use
28 # The tenant and username separated by a semicolon
29 username = admin;admin
32 # The Object storage region to use (auth v2) (Default RegionOne)
33 region_name = RegionOne
34 # The Object storage endpoint URL to use (auth v2) (Default internalURL)
35 endpoint_type = internalURL
36 # Concurrency to use for parallel tasks (Default 10)
38 # Size of the HTTP pool (Default 10)
40 # Timeout delay for HTTP connections (Default 20)
42 # Chunk size to read from pack (Bytes) (Default 12228)
44 # Cache size (MBytes) (Default 20)
48 Note that for now we use the same tenant to perform the requests
49 against Swift. Therefor there is only one Swift account used
50 for storing repositories. Each repository will be contained in
56 There is no need to have a Swift cluster running to run the unitests.
57 Just run the following command in the Dulwich source directory::
59 $ PYTHONPATH=. python -m dulwich.contrib.test_swift
61 How to start functional tests
62 -----------------------------
64 We provide some basic tests to perform smoke tests against a real Swift
65 cluster. To run those functional tests you need a properly configured
66 configuration file. The tests can be run as follow::
68 $ DULWICH_SWIFT_CFG=/etc/swift-dul.conf PYTHONPATH=. python -m dulwich.contrib.test_swift_smoke
73 Install the Dulwich library via the setup.py. The dependencies will be
74 automatically retrieved from pypi::
76 $ python ./setup.py install
81 Start the server using the following command::
83 $ python -m dulwich.contrib.swift daemon -c /etc/swift-dul.conf -l 127.0.0.1
85 Note that a lot of request will be performed against the Swift
86 cluster so it is better to start the Dulwich server as close
87 as possible of the Swift proxy. The best solution is to run
88 the server on the Swift proxy node to reduce the latency.
93 Once you have validated that the functional tests is working as expected and
94 the server is running we can init a bare repository. Run this
95 command with the name of the repository to create::
97 $ python -m dulwich.contrib.swift init -c /etc/swift-dul.conf edeploy
99 The repository name will be the container that will contain all the Git
100 objects for the repository. Then standard c Git client can be used to
101 perform operations against this repository.
103 As an example we can clone the previously empty bare repository::
105 $ git clone git://localhost/edeploy
107 Then push an existing project in it::
109 $ git clone https://github.com/enovance/edeploy.git edeployclone
111 $ git remote add alt git://localhost/edeploy
112 $ git push alt master
114 9dc50a9a9bff1e232a74e365707f22a62492183e HEAD
115 9dc50a9a9bff1e232a74e365707f22a62492183e refs/heads/master
117 The other Git commands can be used the way you do usually against
118 a regular repository.
120 Note the daemon subcommands starts a Git server listening for the
121 Git protocol. Therefor there is no authentication or encryption
122 at all between the cGIT client and the GIT server (Dulwich).
124 Note on the .info file for pack object
125 --------------------------------------
127 The Swift interface of Dulwich relies only on the pack format
128 to store Git objects. Instead of using only an index (pack-sha.idx)
129 along with the pack, we add a second file (pack-sha.info). This file
130 is automatically created when a client pushes some references on the
131 repository. The purpose of this file is to speed up pack creation
132 server side when a client fetches some references. Currently this
133 .info format is not optimized and may change in future.