Fabric-Python????????????????/???????
???????????? ???????[ 2014/1/10 10:22:33 ] ????????????? ????
????#Fabric# Python??????????????????Fabric????????????λ?????????????…??????????????????????????????????????????豸/?????????????????(??????500??????????????????????????500??????)~?????????????????????м??????м????????????
?????????????????????????????????????????????
???????????????VPSee???????:
#!/usr/bin/python
# -*- coding: utf-8 -*-
from fabric.api import *
import string
from random import choice
import socket
import paramiko
env.user = 'root'
env.password = 'root'
env.hosts = [ 'grid00'?? 'grid01'?? 'grid02'?? 'grid03'?? 'grid04'?? 'grid05']
@task
@parallel
def passwd(user?? passwd=False):
with settings(hide('running'?? 'stdout'?? 'stderr')?? warn_only=True):
if isup(env.host):
if not passwd:
passwd = genpass()
sudo("echo -e '%s
%s' | passwd %s" % (passwd?? passwd?? user))
def genpass(length=10):
return ''.join(choice(string.ascii_letters + string.digits) for _ in range(length))
def isup(host):
print 'connecting host: %s' % host
timeout = socket.getdefaulttimeout()
socket.setdefaulttimeout(1)
up = True
try:
paramiko.Transport((host?? 22))
except Exception?? e:
up = False
print '%s down?? %s' % (host?? e)
finally:
socket.setdefaulttimeout(timeout)
return up
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11