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:test.py.html [2017/11/26 23:21] kurihara  | 
                
                    preparation:fhhome:test.py.html [2019/02/13 00:18] (current) kurihara  | 
            ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| [[: | [[: | ||
| - | ====== fabfile/ | + | ======  | 
| + | \\ | ||
| + | {{INLINETOC}} | ||
| + | \\ | ||
| + | ===== Operation ===== | ||
| + | <sxh bash toolbar: | ||
| + | $ echo xx.xx.xx.xx | fab -- hostname | ||
| + | $ echo xx.xx.xx.xx | fab -- sudo cat /etc/shadow | ||
| + | $ fab local_hostname | ||
| + | |||
| + | $ fab -l |grep test. # check options | ||
| + | |||
| + | $ echo xx.xx.xx.xx | fab test.hostname | ||
| + | $ fhghost.sh " | ||
| + | </ | ||
| + | |||
| + | \\ | ||
| ===== fabfile/ | ===== fabfile/ | ||
| <sxh bash toolbar: | <sxh bash toolbar: | ||
| - | import sys | + | import sys, os | 
| from fabric.api import * | from fabric.api import * | ||
| from fabric.contrib import files | from fabric.contrib import files | ||
| + | from datetime import datetime | ||
| + | FHLINUX=os.environ[" | ||
| + | |||
| + | # test.local_hostname | ||
| @task | @task | ||
| def local_hostname(): | def local_hostname(): | ||
|     local(' |     local(' | ||
| + | # test.hostname | ||
| @task | @task | ||
| def hostname(): | def hostname(): | ||
|     run(' |     run(' | ||
| + | |||
| + | # test.sudo | ||
| @task | @task | ||
| - | def cat_etc_shadow(): | + | def sudo(): | 
| + |     """ | ||
|     sudo(' |     sudo(' | ||
| - | </ | ||
| + | # test.arg1: | ||
| + | @task | ||
| + | def arg1(cmd): | ||
| + |     """ | ||
| + |     run(' | ||
| + | |||
| + | |||
| + | # test.arg2: | ||
| + | @task | ||
| + | def arg2(cmd1, cmd2): | ||
| + |     """ | ||
| + |     run(' | ||
| + |     run(' | ||
| + |     run(' | ||
| + | |||
| + | |||
| + | # test.put | ||
| + | @task | ||
| + | def put(): | ||
| + |     date = datetime.now().strftime(' | ||
| + |     local(' | ||
| + |     put('/ | ||
| + |     run(' | ||
| + |     run(' | ||
| + | |||
| + | # test.get | ||
| + | @task | ||
| + | def get(): | ||
| + |     date = datetime.now().strftime(' | ||
| + |     run(' | ||
| + |     get('/ | ||
| + |     local(' | ||
| + |     local(' | ||
| - | \\ | ||
| - | \\ | ||
| - | ===== Configuration Test ===== | ||
| - | <sxh bash toolbar: | ||
| - | $ echo xx.xx.xx.xx | fab -- hostname | ||
| - | $ echo xx.xx.xx.xx | fab -- sudo cat /etc/shadow | ||
| </ | </ | ||
| + | |||
| + | |||
| + | |||
| \\ | \\ | ||
| <WRAP box 90%> | <WRAP box 90%> | ||
| [[: | [[: | ||
| - | <catlist -noAddPageButton -noHead  | + | < | 
| </ | </ | ||
| \\ | \\ | ||
| [[: | [[: | ||
My Sites
SNS
Copyright (c) 2025 FastHandle - IT Operations Examples All Rights Reserved.