Created
June 23, 2010 19:41
-
-
Save paulosuzart/450438 to your computer and use it in GitHub Desktop.
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.operations import sudo, local | |
from fabric.api import env, settings | |
from fabric.context_managers import cd | |
env.cwd = '/home/user' | |
def _switch_resolv(): | |
with cd('/etc'): | |
local('sudo rm resolv.conf') | |
local('sudo cp resolv.tmp.conf resolv.conf') | |
def routes(dev1='eth1', dev2='eth0', gateway='10.1.0.1'): | |
""" -> Remove a rota default, adiciona o gateway correto e as rotas. | |
Depois deve copiar um novo resolv.conf para o /etc """ | |
local('sudo route del default') | |
local('sudo route add default gateway %s netmask 0.0.0.0 dev %s' % (gateway, dev1)) | |
with settings(warn_only=True): | |
for ip in ['172.21.0.0', '171.22.0.0', '172.27.0.0']: | |
local('sudo route add -net %s netmask 255.255.0.0 dev %s' % (ip, dev2)) | |
_switch_resolv() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment