zoukankan      html  css  js  c++  java
  • fab提供远程IP和账号密码

    #!/usr/bin/python
    #-*- coding: UTF-8 -*-
    from fabric.api import *
    from fabric.context_managers import *
    
    # env.hosts=['root@192.168.2.2']
    # env.password='mypass'
    
    
    def t_exportvminfor():
        remote_fab_folder = '/var/fab/'
        local_file = 'D:\py\sf\ExportKVM.py'
        local_result_folder = 'D:pysf'
        #判断/var/fabric目录是否存在
        run('if [ ! -d /var/fab ]; then mkdir /var/fab; fi')
        #将ExportKVM_vms.py脚本拷贝到远程服务器
        remote_fab_script = os.path.join(remote_fab_folder,os.path.split(local_file)[1])
        put(local_file,remote_fab_folder)
        run('python %s %s' %(remote_fab_script,env.host))
        #将ExportKVM_vms.py脚本的执行结果拷贝到本地服务器
        vm_result_csvfile = '%squeryresult-%s.csv' %(remote_fab_folder,env.host)
        get(vm_result_csvfile,local_result_folder)
    
    
    def dotask():
        execute(t_exportvminfor)

    在外部提供远程服务器和账号密码(Windows下不支持parallel):

    fab -f D:py est-01.py dotask -H root@192.168.2.2 -p mypasswd

  • 相关阅读:
    P4047 部落划分
    P1440 求m区间的最小值
    P2880 平衡的阵容
    P2700 逐个击破
    P2814 家谱 map模版
    P4403 秦腾与教学评估
    无油无糖低脂酸奶芒果蛋糕
    紫薯铜锣烧
    Spring In Action ③
    Spring In Action ②
  • 原文地址:https://www.cnblogs.com/dreamer-fish/p/5795828.html
Copyright © 2011-2022 走看看