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
>>> web = conn.create_security_group('apache', 'Our Apache Group') | |
>>> web | |
SecurityGroup:apache | |
>>> web.authorize('tcp', 80, 80, '0.0.0.0/0') | |
True | |
>>> |
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
>>> app = conn.create_security_group('appserver', 'The application tier') | |
>>> app.authorize(src_group=web) | |
True | |
>>> web.authorize(ip_protocol='tcp', from_port=22, to_port=22, \ | |
cidr_ip='192.168.1.130/32') | |
True | |
>>> web.rules | |
[IPPermissions:tcp(80-80), | |
IPPermissions:tcp(22-22)] | |
>>> web.revoke('tcp', 22, 22, cidr_ip='192.168.1.130/32') |
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
from fabric.api import local | |
def prepare_deploy(): | |
local("./manage.py test my_app") | |
local("git add -p && git commit") |
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
$ fab prepare_deploy | |
[localhost] run: ./manage.py test my_app | |
Creating test database... | |
Creating tables | |
Creating indexes | |
.......................................... | |
---------------------------------------------------------------------- | |
Ran 42 tests in 9.138s | |
OK |
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
from fabric.api import local | |
def test(): | |
local("./manage.py test my_app") | |
def commit(): | |
local("git add -p && git commit") | |
def prepare_deploy(): | |
test() |
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
$ fab prepare_deploy | |
[localhost] run: ./manage.py test my_app | |
Creating test database... | |
Creating tables | |
Creating indexes | |
.............E............................ | |
====================================================================== | |
ERROR: testSomething (my_project.my_app.tests.MainTests) | |
---------------------------------------------------------------------- | |
Traceback (most recent call last): |
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
from __future__ import with_statement | |
from fabric.api import local, settings, abort | |
from fabric.contrib.console import confirm | |
def test(): | |
with settings(warn_only=True): | |
result = local('./manage.py test my_app', capture=True) | |
if result.failed and not confirm("Tests failed. Continue anyway?"): | |
abort("Aborting at user request.") |
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
def deploy(): | |
code_dir = '/srv/django/myproject' | |
with cd(code_dir): | |
run("git pull") | |
run("touch app.wsgi") |
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
$ fab deploy | |
No hosts found. Please specify (single) host string for connection: my_server | |
[my_server] run: git pull | |
[my_server] out: Already up-to-date. | |
[my_server] out: | |
[my_server] run: touch app.wsgi | |
Done. |
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
def deploy(): | |
code_dir = '/srv/django/myproject' | |
with settings(warn_only=True): | |
if run("test -d %s" % code_dir).failed: | |
run("git clone user@vcshost:/path/to/repo/.git %s" % code_dir) | |
with cd(code_dir): | |
run("git pull") | |
run("touch app.wsgi") |