Table of Contents

Top#OS Management

Windows Operation with Fabric (winope.py)

$FHHOME/fabfile/winope.py


Operation with Fabric

$ fab  -l |grep winope
$ echo xx.xx.xx.xx | fab  auth.pro  winope.xxxx
$ echo xx.xx.xx.xx | fab  auth.pro  winope.cmd:hostname


How to Check to Use Fabric in Windows

$ ssh user01@xx.xx.xx.xx hostname
$ ssh user01@xx.xx.xx.xx "PowerShell.exe -Command Get-Host"


Fabric one-line Task Examples

$ fab -H xx.xx.xx.xx -u USER -p PASSWORD --shell="Cmd.exe /C" --no-pty -- hostname
$ echo xx.xx.xx.xx | fab auth.winpro --shell="Cmd.exe /C" --no-pty  -- ipconfig /all


winope.py

$FHHOME/fabfile/winope.py

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

FHHOME=os.environ["FHHOME"]


#------------------------------------------------------------------
# winope.cmd
#------------------------------------------------------------------
@task
def cmd(cmd):
    """winope.cmd:hostname"""
    run("%s" % cmd, shell=False, pty=False)

#------------------------------------------------------------------
# winope.powershell:'$PSVersionTable'
#------------------------------------------------------------------
@task
def powershell(cmd):
    """winope.powershell:'$PSVersionTable' """
    run("PowerShell.exe -Command %s" % cmd, shell=False, pty=False)


#------------------------------------------------------------------
# winope.put:local, remote
#------------------------------------------------------------------
@task
def put(local, remote):
    """ winope.put:local,remote  # /tmp/test.txt C:\\tmp\\ """
    put("%s" % local, "%s" % remote)

#------------------------------------------------------------------
# winope.get:remote, local
#------------------------------------------------------------------
@task
def get(remote, local):
    """ winope.get:remote, local # C:\\tmp\\test.txt , /tmp/ """
    get("%s" % remote, "%s" % local)


Top#OS Management





Top#OS Management