Skip to content

Commit

Permalink
Move the swift backend to dulwich/contrib.
Browse files Browse the repository at this point in the history
Subcommands for initializing repositories on swift are now available
from the dulwich.contrib.swift module. In the future, we could
expose this functionality as a dulwich-swift script. The main reason
I haven't done this yet is to keep it clear that this script is in
contrib.
  • Loading branch information
jelmer committed Jun 7, 2014
1 parent 39e7ba8 commit e0282d5
Show file tree
Hide file tree
Showing 12 changed files with 246 additions and 182 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ check:: build
$(RUNTEST) dulwich.tests.test_suite

check-tutorial:: build
$(RUNTEST) dulwich.tests.tutorial_test_suite
$(RUNTEST) dulwich.tests.tutorial_test_suite

check-nocompat:: build
$(RUNTEST) dulwich.tests.nocompat_test_suite
Expand Down
7 changes: 5 additions & 2 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@
for concurrency of some object store operations.
(Fabien Boucher)

* Various changes to improve compatibility with Python 3.
(Gary van der Merwe, Hannu Valtonen, michael-k)
* Various changes to improve compatibility with Python 3.
(Gary van der Merwe, Hannu Valtonen, michael-k)

* Add OpenStack Swift backed repository implementation
in dulwich.contrib. See README.swift for details. (Fabien Boucher)

API CHANGES

Expand Down
15 changes: 8 additions & 7 deletions README.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
Openstack Swift as backend for Dulwich
======================================
Fabien Boucher <fabien.boucher@enovance.com>

The module dulwich/swift.py implements dulwich.repo.BaseRepo
The module dulwich/contrib/swift.py implements dulwich.repo.BaseRepo
in order to being compatible with Openstack Swift.
We can then use Dulwich as server (Git server) and instead of using
a regular POSIX file system to store repository objects we use the
Expand Down Expand Up @@ -55,7 +56,7 @@ How to start unittest
There is no need to have a Swift cluster running to run the unitests.
Just run the following command in the Dulwich source directory:

$ PYTHONPATH=. nosetests dulwich/tests/test_swift.py
$ PYTHONPATH=. python -m dulwich.contrib.test_swift

How to start functional tests
-----------------------------
Expand All @@ -64,7 +65,7 @@ We provide some basic tests to perform smoke tests against a real Swift
cluster. To run those functional tests you need a properly configured
configuration file. The tests can be run as follow:

$ DULWICH_SWIFT_CFG=/etc/swift-dul.conf PYTHONPATH=. nosetests dulwich/tests_swift/test_smoke.py
$ DULWICH_SWIFT_CFG=/etc/swift-dul.conf PYTHONPATH=. python -m dulwich.contrib.test_swift_smoke

How to install
--------------
Expand All @@ -79,7 +80,7 @@ How to run the server

Start the server using the following command:

$ dul-daemon -c /etc/swift-dul.conf -l 127.0.0.1 --backend=swift
$ python -m dulwich.contrib.swift daemon -c /etc/swift-dul.conf -l 127.0.0.1

Note that a lot of request will be performed against the Swift
cluster so it is better to start the Dulwich server as close
Expand All @@ -93,7 +94,7 @@ Once you have validated that the functional tests is working as expected and
the server is running we can init a bare repository. Run this
command with the name of the repository to create:

$ dulwich init-swift -c /etc/swift-dul.conf edeploy
$ python -m dulwich.contrib.swift init -c /etc/swift-dul.conf edeploy

The repository name will be the container that will contain all the Git
objects for the repository. Then standard c Git client can be used to
Expand All @@ -116,8 +117,8 @@ Then push an existing project in it:
The other Git commands can be used the way you do usually against
a regular repository.

Note the swift-dul-daemon start a Git server listening for the
Git protocol. Therefor there ins't any authentication or encryption
Note the daemon subcommands starts a Git server listening for the
Git protocol. Therefor there is no authentication or encryption
at all between the cGIT client and the GIT server (Dulwich).

Note on the .info file for pack object
Expand Down
32 changes: 0 additions & 32 deletions bin/dulwich
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@ from dulwich.pack import Pack, sha_to_hex
from dulwich.patch import write_tree_diff
from dulwich.repo import Repo

try:
import gevent
import geventhttpclient
gevent_support = True
except ImportError:
gevent_support = False


def cmd_archive(args):
opts, args = getopt(args, "", [])
Expand Down Expand Up @@ -163,30 +156,6 @@ def cmd_init(args):

porcelain.init(path, bare=("--bare" in opts))

def cmd_init_swift(args):
if not gevent_support:
print "gevent and geventhttpclient libraries are mandatory " \
" for use the Swift backend."
sys.exit(1)
from dulwich.swift import (
SwiftRepo,
SwiftConnector,
load_conf,
)
opts, args = getopt(args, "c:", [])
opts = dict(opts)
try:
conf = opts['-c']
conf = load_conf(conf)
except KeyError:
conf = load_conf()
if args == []:
print "Usage: dulwich init-swift [-c config_file] REPONAME"
sys.exit(1)
else:
repo = args[0]
scon = SwiftConnector(repo, conf)
SwiftRepo.init_bare(scon, conf)

def cmd_clone(args):
opts, args = getopt(args, "", ["bare"])
Expand Down Expand Up @@ -289,7 +258,6 @@ commands = {
"fetch-pack": cmd_fetch_pack,
"fetch": cmd_fetch,
"init": cmd_init,
"init-swift": cmd_init_swift,
"log": cmd_log,
"reset": cmd_reset,
"rev-list": cmd_rev_list,
Expand Down
28 changes: 28 additions & 0 deletions dulwich/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# __init__.py -- Contrib module for Dulwich
# Copyright (C) 2014 Jelmer Vernooij <jelmer@samba.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2
# of the License or (at your option) any later version of
# the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.


def test_suite():
import unittest
names = [
'swift',
]
module_names = ['dulwich.contrib.test_' + name for name in names]
loader = unittest.TestLoader()
return loader.loadTestsFromNames(module_names)
Loading

0 comments on commit e0282d5

Please sign in to comment.