FastHandle - IT Operations Examples

FastHandle is fast operation tools for infrastructure configurations and tests.

User Tools

Site Tools


Sidebar


Top     SiteMap

Manager Server

Target Server

$FHHOME/bin/xxx.sh | xxxx.exp













.

os:linux:get:index.html



This is an old revision of the document!


Top#OS Management

Get OS Conf (get.py)

$FHHOME/fabfile/get.py


Operation

$ fab -l |grep get

$ fab -H $H auth.pro  get.xxxx


get.py

$FHHOME/fabfile/get.py

import sys, os
from fabric.api import *
from fabric.contrib import files

FHHOME=os.environ["FHHOME"]

#------------------------------------------------------------------
# get.file_remote_local
#     get.file_remote_local:/etc/hosts,hosts
#------------------------------------------------------------------
@task
def get.file_remote_local(remote,local):
    """get.file_remote_local:/etc/hosts,hosts"""
    date = datetime.now().strftime('%Y%m%d_%H%M')
    hostname = run("hostname")
    outfile = %s/tmp/%s.%s.%s"  % (FHHOME, local, hostname, date)
    get("%s, %s" % (remote, outfile))
    local("ls -lh %s" % (outfile))
 
#------------------------------------------------------------------
# get.sdiff_remote_local
#     get.sdiff_remote_local:/etc/hosts,/home/fasthandle/conf/hosts.server1
#------------------------------------------------------------------
@task
def sdiff_remote_local(remote,local):
    """get.sdiff_remote_local:/etc/hosts,/home/fasthandle/conf/hosts.server1"""
    date = datetime.now().strftime('%Y%m%d_%H%M')
    hostname = run("hostname")
    outfile = %s/tmp/%s.%s"  % (FHHOME, hostname, date)
    get("%s, %s" % (remote outfile))
    local("sdiff -s -w 150 %s %s" % (outfile, local))
    local("/bin/rm -f %s" % (outfile))


#------------------------------------------------------------------
# get.systeminfo
#------------------------------------------------------------------
@task
def systeminfo():
    hostname = run("hostname")
    date = datetime.now().strftime('%Y%m%d_%H%M')
    yearmonth = datetime.now().strftime('%Y%m')
    outfile = systeminfo.%s.%s"  % (hostname, date)
 
    local("test -d output/%s || mkdir output/%s"    % (yearmonth, yearmonth))
    run("test -d scripts || mkdir scripts")
 
    put("%s/scripts/systeminfo.sh", "scripts/systeminfo.sh, mode=0755 % FHHOME)
    sudo("scripts/systeminfo.sh 1>output/%s  2>/dev/null"   % (outfile))
    get("output/%s", "output/%s/%s"  % (outfile, yearmonth, outfile))
 


Scripts



os/linux/get/index.html.1515596897.txt.gz ยท Last modified: 2018/01/11 00:08 by kurihara