stdout - Python Fabric - How to create files and folders on remote hosts and direct output there -
stdout - Python Fabric - How to create files and folders on remote hosts and direct output there -
i kind of asked question before ("direct output python fabric function file on remote host") 1 reply given didn't work. i'm trying utilize fabric script take various outputs before reboot, , compare them outputs of same commands, after reboot. want test differences between 2 files , print output of differences, if any. easy bash, boss making me utilize python fabric , i'm having much harder time. have far fabfile allows me connect various hosts , run commands date or uptime. fab file sits on 'jump' host used connect various other hosts. run fabfile jump host, connects other hosts, , output of commands runs displays on jumphost me see.
what left forcefulness output of commands directed folder within specific directory on jump server. each command needs go own folder within directory (i'm going end them .pre , .post differentiate, uptime.pre , uptime.post). folder name alter each time, file names remain constant.
i've set code i've got below. have lot more functions 1 phone call host name, they're simple defs in same format.
#!/usr/local/bin/python2.7 ''' usage: add together info here ''' import json import re import requests import platform import argparse import socket import time import os import fabric fabric.api import * fabric.colors import * fabric.contrib.files import append, sed, get, exists fabric.state import * failed = red('failed') passed = green('passed') # utilize simadmin business relationship env.user = 'simadmin' env.password = 'htysbmm%pf23' fabric.state.output['running'] = false fabric.state.output['user'] = false fabric.state.output['status'] = false fabric.state.output['stdout'] = true env.gateway = "stopcprvjump1.va.neustar.com" env.warn_only = true env.parallel = false env.skip_bad_hosts = true env.no_keys = true env.reject_interactive_password = true # read host list file def get_hosts(): env.hosts = open('hosts', 'r').readlines() def hostname(): '''checking hostname''' output = run("hostname") print "checking hostname...." if output == "": print failed else: print green("hostname: {}".format(output))
python stdout fabric remote-server
Comments
Post a Comment