-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 18ba69d
Showing
31 changed files
with
7,104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
*.py[co] | ||
/*.egg-info | ||
/.coverage | ||
/build/ | ||
/cover | ||
/dist/ | ||
/distcheck/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2014 Carlos Valiente | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
include LICENSE | ||
include requirements.txt | ||
include version.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
all: | ||
pip install -r requirements-devel.txt | ||
pyflakes libcloudvagrant | ||
|
||
TESTS=${:libcloudvagrant} | ||
|
||
# XXX Consider ``--processes=-1`` | ||
check: all | ||
nosetests \ | ||
--detailed-errors \ | ||
--with-coverage \ | ||
--cover-branches \ | ||
--cover-erase \ | ||
--cover-html \ | ||
--cover-inclusive \ | ||
--cover-package=libcloudvagrant \ | ||
--cover-tests \ | ||
$(TESTS) | ||
|
||
lint: all | ||
pylint libcloudvagrant | ||
|
||
clean: | ||
-git clean -dfx | ||
|
||
dist: clean | ||
python setup.py sdist | ||
|
||
distcheck: dist | ||
sh distcheck.sh | ||
|
||
PYPI=${:https://testpypi.python.org/pypi} | ||
|
||
upload: dist | ||
python setup.py sdist upload -r $(PYPI) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
libcloud-vagrant - A Vagrant compute provider for Apache Libcloud | ||
================================================================= | ||
|
||
``libcloud-vagrant`` is a compute provider for `Apache Libcloud`_ which uses | ||
`Vagrant`_ to create `VirtualBox`_ nodes. | ||
|
||
With ``libcloud-vagrant`` installed, you could prototype a small cluster on | ||
your laptop, for instance, and then deploy it later on to Amazon, Rackspace, | ||
or any of the other clouds supported by Libcloud. | ||
|
||
|
||
Hello, world | ||
------------ | ||
|
||
The following snippet spins up a virtual machine running on your host:: | ||
|
||
from libcloud.compute.providers import get_driver | ||
|
||
from libcloudvagrant.driver import VAGRANT | ||
|
||
|
||
driver = get_driver(VAGRANT)() | ||
|
||
pub = driver.ex_create_network(name="pub", cidr="172.16.0.0/16", public=True) | ||
|
||
node = driver.create_node(name="n1", | ||
image=driver.get_image("hashicorp/precise64"), | ||
size=driver.list_sizes()[0], | ||
networks=[pub]) | ||
|
||
print "Node '%s' running!" % (node.name,) | ||
print ("Connect to it with 'ssh vagrant@%s' (password: 'vagrant')" % | ||
(node.public_ips[0],)) | ||
|
||
|
||
Features | ||
-------- | ||
|
||
``libcloud-vagrant`` uses Vagrant to create boxes, networks and volumes. It | ||
creates a Vagrant environment under ``~/.libcloudvagrant``, which is used | ||
to run as many Vagrant boxes as you define. | ||
|
||
Nodes created by ``libcloud-vagrant`` may be connected to *public networks* | ||
or to *private networks*. Public networks are implemented as VirtualBox | ||
`host-only`_ networks, and private networks are implemented as VirtualBox | ||
`internal`_ networks. | ||
|
||
``libcloud-vagrant`` also lets you create `VDI disks`_, and attach them to | ||
the `SATA controllers`_ of your nodes. | ||
|
||
Deployment scripts are run through Vagrant's NAT interface, using | ||
Vagrant's SSH credentials. Therefore they also work for non-networked | ||
nodes. | ||
|
||
|
||
Requirements | ||
------------ | ||
|
||
``libcloud-vagrant`` requires: | ||
|
||
* `VirtualBox`_ (tested with version 4.3.12 under 64-bit Linux). | ||
* `Vagrant`_ (tested with version 1.6.3 under 64-bit Linux). | ||
* Python 2.7. | ||
|
||
|
||
Installation | ||
------------ | ||
|
||
Once you have installed VirtualBox and Vagrant, do the usual:: | ||
|
||
$ pip install libcloud-vagrant | ||
|
||
That will install ``libcloud-vagrant`` and its Python dependencies. You | ||
might want to do that within a virtualenv. | ||
|
||
|
||
More examples | ||
------------- | ||
|
||
Have a look at the `samples`_ subdirectory of the source distribution. You | ||
wil find there a few scripts to create a single node, to show you how to | ||
provision it, and a script which creates a two-node cluster. | ||
|
||
|
||
.. _Apache Libcloud: https://libcloud.apache.org/ | ||
.. _Vagrant: http://vagrantup.com/ | ||
.. _VirtualBox: http://virtualbox.org/ | ||
.. _SATA controllers: http://virtualbox.org/manual/ch05.html#harddiskcontrollers | ||
.. _VDI disks: http://virtualbox.org/manual/ch05.html#vdidetails | ||
.. _host-only: http://virtualbox.org/manual/ch06.html#network_hostonly | ||
.. _internal: http://virtualbox.org/manual/ch06.html#network_internal | ||
.. _samples: https://github.com/carletes/libcloud-vagrant/tree/master/samples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/sh | ||
|
||
set -x | ||
|
||
here="$(cd $(dirname $0) && pwd)" | ||
|
||
version=$(python "$here/version.py") | ||
|
||
dist_tgz="$here/dist/libcloud-vagrant-${version}.tar.gz" | ||
if [ ! -r "$dist_tgz" ] ; then | ||
echo "$dist_tgz: Not found" | ||
exit 1 | ||
fi | ||
|
||
virtualenv_name="distcheck/libcloud-vagrant-${version}" | ||
|
||
rm -rf $virtualenv_name | ||
virtualenv $virtualenv_name | ||
$virtualenv_name/bin/pip install "$dist_tgz" | ||
$virtualenv_name/bin/pip install -r "$here/requirements-devel.txt" | ||
|
||
set +e | ||
$virtualenv_name/bin/python -c "import libcloudvagrant; libcloudvagrant.test()" | ||
rc="$?" | ||
set -e | ||
|
||
exit $rc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Copyright (c) 2014 Carlos Valiente | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
|
||
"""A compute provider for Apache Libcloud which uses Vagrant to manage | ||
VirtualBox nodes, networks and volumes. | ||
""" | ||
|
||
import os | ||
import sys | ||
|
||
from libcloud.compute import providers | ||
from libcloud import security | ||
|
||
try: | ||
import nose | ||
NOSE_FOUND = True | ||
except ImportError: | ||
NOSE_FOUND = False | ||
|
||
from libcloudvagrant.driver import VAGRANT, VagrantDriver, __name__ as pkg_name | ||
|
||
|
||
__all__ = [ | ||
"__version__", | ||
"test", | ||
] | ||
|
||
|
||
providers.set_driver(VAGRANT, pkg_name, VagrantDriver.__name__) | ||
|
||
security.CA_CERTS_PATH.append(os.path.join(os.path.dirname(__file__), | ||
"ca-bundle.crt")) | ||
|
||
|
||
__version__ = "0.1.0" | ||
|
||
|
||
def test(): | ||
"""Runs the tests for ``libcloud-vagrant``. | ||
Requires ``nose`` to be installed. The tests take quite a bit of time to | ||
finish, and use up about 10 GB of disk space and 3 GB of memory, since | ||
several VMs are created. | ||
""" | ||
if not NOSE_FOUND: | ||
print >> sys.stderr, "Install 'nose' in order to run the test suite." | ||
return False | ||
else: | ||
print "Testing libcloud-vagrant %s" % (__version__,) | ||
return nose.run(__name__) |
Oops, something went wrong.