2014-12-19 17 views
0

我使用蟒織物與多個主機並行執行的命令的命令。的Python織物在多臺機器上運行

我有以下情形。

def list1(): 
    env.hosts=[H1,H2,H3] 
def myfunction(): 
    #login into H1 and execute a command and wait for certain string. 
    #once get the string login to H2 and H3 in parallel and execute some other command 

現在我已經運行H1的命令,一旦我得到H1輸出一些所需的字符串,而它正在執行我需要既H2和H3運行一些其他的命令一些輸出的期望。 所有是Linux機器。

運行

fab -f fabfile.py -P list1 myfunction 

這樣是不正確的做法。有什麼辦法可以做到這一點?

謝謝

回答

1

我不知道我是否明白你想要什麼。我會假設你想在h1上運行一個任務,等待結果並將這個結果用作h2和h3任務的輸入。如果你想要別的東西,忘了這個答案(並改寫你的問題。)

一種選擇是創建一個python腳本(不是晶圓廠文件)執行該工廠工作。

是這樣的:

import fabfile  
from fabric.tasks import execute 

result = execute(fabfile.command_for_h1, hosts=[h1]) 
result_h1 = result[h1] 
execute(fabfile.command_for_h2_h3, hosts=[h2,h3], result_h1) 

的關鍵是execute方法。

+0

究竟這是我所期待for.Thank你@tobltobs – navaz 2014-12-19 15:03:26

相關問題