Created
February 11, 2016 21:05
-
-
Save starlocke/aa69af01fed512c1e3be to your computer and use it in GitHub Desktop.
Small python script template to get current system to lock on to a particular load balance server; must be customized for target hosts
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
#!/usr/bin/python | |
import os | |
import sys | |
if len(sys.argv) < 2: | |
print 'Usage: load [a|b|c]' | |
raise SystemExit() | |
if sys.argv[1] == 'a': | |
ip = '203.0.113.1' | |
if sys.argv[1] == 'b': | |
ip = '203.0.113.2' | |
if sys.argv[1] == 'c': | |
ip = '203.0.113.3' | |
if not ip: | |
print 'Param must be: a|b|c' | |
raise SystemExit() | |
host = 'www.example.com' | |
cmd = 'sed -i "s|.*' +host+ '|' +ip+ ' ' +host+ '|g"' | |
target = '/etc/hosts' | |
## Example command, expanded out ## | |
# sed -i "s|.*www.example.com|203.0.113.1 www.example.com|g" /etc/hosts | |
os.system(cmd + ' ' + target) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://sites.google.com/site/sudokillall9/articles/lockingontoloadbalancers