Python fabric.api.env 模块,connection_attempts() 实例源码
我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用fabric.api.env.connection_attempts()。
def connect_to_instance_in_ssh(address, keypair_path, user='root'):
"""
Run the command LS on a given instance
:param address: ip or dns name of a machine
:type address: str
:param keypair_path: keypair path
:type keypair_path: str
"""
env.host_string = address
env.user = user
env.parallel = False
env.key_filename = keypair_path
env.disable_known_hosts = True
env.connection_attempts = 10
env.timeout = 120
ocb.log(run('ls -la /root'), level='INFO')
def main(argv):
global APPS
global DURATION
global VMLIST
env.user = 'ubuntu'
env.connection_attempts = 10
DURATION = int(sys.argv[1])
with open('./tests') as f:
APPS = f.read().splitlines()
with open('./vmlist') as f:
for line in f:
vals = line.split()
VMMAP[vals[0]] = (vals[1], vals[2])
sample_count = DURATION / INTERVAL
#image_dir='data'
#files = os.listdir(image_dir)
image_file=''
executor(sample_count,image_file)
def main(argv):
global APPS
global DURATION
global VMLIST
env.user = 'ubuntu'
env.connection_attempts = 100
DURATION = int(sys.argv[1])
with open('./tests') as f:
APPS = f.read().splitlines()
with open('./vmlist') as f:
for line in f:
vals = line.split()
VMMAP[vals[0]] = (vals[1], vals[2])
sample_count = DURATION / INTERVAL
executor(sample_count)
def set_fabric_common_env():
"""
??????????fabric env
"""
env.user = 'astd'
env.use_ssh_config = True # This is important when running under root.
env.connection_attempts = 5
env.disable_known_hosts = True
env.keepalive = 60
def _init_fabric(self):
env.warn_only = True
env.connection_attempts = 10
env.timeout = 10
env.user = self.user
env.key_filename = self.key_filename
env.hosts = self.hosts
env.password = self.password