add fabfile

This commit is contained in:
aozhiwei 2019-01-09 15:11:09 +08:00
parent c8ec7a4894
commit b2fb4fac28
2 changed files with 52 additions and 0 deletions

26
scripts/fabfile/fabfile.py vendored Executable file
View File

@ -0,0 +1,26 @@
#!/usr/bin/env python3
import time
from fabric import Connection
from fabric import task
from optparse import OptionParser
import serverlist_dev
def execCmd(svr_conf, cmd):
c = Connection(host=svr_conf['host'], user='root', connect_kwargs = {
'password': 'kingsome'
})
c.run(cmd)
parser = OptionParser(usage="%prog [options]")
parser.add_option(
"-c",
"--cmd",
dest = "cmd",
help = "cmd"
)
(options, args) = parser.parse_args()
if options.cmd:
for a in map(lambda svr_conf : execCmd(svr_conf, options.cmd), serverlist_dev.server_list):
pass

View File

@ -0,0 +1,26 @@
server_list = [
{
'server_id': 1,
'host': '192.168.100.21',
},
{
'server_id': 2,
'host': '192.168.100.37',
},
{
'server_id': 3,
'host': '192.168.100.38',
},
{
'server_id': 4,
'host': '192.168.100.22',
},
{
'server_id': 5,
'host': '192.168.100.23',
},
{
'server_id': 6,
'host': '192.168.100.36',
}
]