FastHandle is fast operation tools for infrastructure configurations and tests.
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
preparation:fhhome:init.py.html [2018/02/04 23:09] kurihara |
preparation:fhhome:init.py.html [2019/02/13 00:18] (current) kurihara |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| [[: | [[: | ||
| - | ====== $FHHOME/ | + | ====== $FHHOME/linux/ |
| Line 8: | Line 8: | ||
| <sxh bash toolbar: | <sxh bash toolbar: | ||
| - | import sys, select | + | import sys, os, glob, select, importlib, re |
| from fabric.api import * | from fabric.api import * | ||
| from fabric.contrib import files | from fabric.contrib import files | ||
| - | + | from datetime import datetime | |
| + | |||
| + | # | ||
| + | # SSH User | ||
| + | # | ||
| + | hostname = os.uname()[1] | ||
| + | |||
| + | if hostname == " | ||
| + | env.user = ' | ||
| + | env.password = ' | ||
| + | elif hostname == " | ||
| + | env.user = ' | ||
| + | env.password = ' | ||
| + | elif hostname == " | ||
| + | env.user = ' | ||
| + | env.key_filename = ' | ||
| + | # | ||
| + | |||
| + | # | ||
| + | # Variable | ||
| + | # | ||
| + | FHHOME=os.environ[" | ||
| env.warn_only = True | env.warn_only = True | ||
| env.port = 22 | env.port = 22 | ||
| env.eagerly_disconnect = True | env.eagerly_disconnect = True | ||
| - | + | ||
| - | + | #don't create *.pyc without __init__.pyc | |
| + | sys.dont_write_bytecode = True | ||
| + | |||
| + | |||
| + | |||
| + | # | ||
| + | # | ||
| + | # standard in for example echo x.x.x.x | ||
| if select.select([sys.stdin, | if select.select([sys.stdin, | ||
| lines = sys.stdin.read().splitlines() | lines = sys.stdin.read().splitlines() | ||
| env.hosts = filter(bool, | env.hosts = filter(bool, | ||
| - | + | ||
| - | + | ||
| - | import auth | + | #FastHandle Operation History to log file |
| - | import test | + | TIME = datetime.now().strftime(' |
| - | + | yymm = datetime.now().strftime(' | |
| - | ## OS Management | + | |
| - | import user | + | f=open(" |
| - | import pkg | + | |
| - | import net | + | if env.hosts == []: |
| - | import set | + | f.write(" |
| - | import get | + | |
| - | import | + | |
| - | import ope | + | |
| - | + | for p in env.hosts: | |
| - | ## Middleware Management | + | |
| - | import httpd | + | |
| - | import nginx | + | |
| - | import postfix | + | f.close() |
| - | import squid | + | |
| - | + | ||
| - | ## Programing Languages | + | # auto import |
| - | import php | + | # Ref. https:// |
| + | pathThisFile = os.path.dirname(os.path.abspath(__file__)) | ||
| + | |||
| + | def loadModule(): | ||
| + | |||
| + | myself = sys.modules[__name__] | ||
| + | |||
| + | #print __name__ | ||
| + | |||
| + | | ||
| + | for py_file in mod_paths: | ||
| + | | ||
| + | if re.search(" | ||
| + | mod = importlib.import_module(__name__+ " | ||
| + | | ||
| + | | ||
| + | # | ||
| + | loadModule() | ||
| </ | </ | ||
My Sites
SNS
Copyright (c) 2025 FastHandle - IT Operations Examples All Rights Reserved.