2017-05-23 15 views
1

저는 처음으로 fabric을 사용하여 systemimager 주변의 자동화를 관리하고 있습니다. 개념은 간단합니다 : 나는 X 호스트에 systemimager 명령을 보내려고합니다.은 Fabric.api의 기능에서 사전을 관리 할 수 ​​없습니다.

host_dict = { 
'192.168.1.1': 'hostname1', 
'192.168.1.2': 'hostname2', 
'192.168.1.3': 'hostname3', 
} #list of servers to backup 

env.hosts = host_dict.keys() #we initialize the env host for fabric 

def prepare_client(): 
    # A function to send prepare_client command to a remoteserver by his hostname 
    print("Executing prepare_client on %s" % (env.host)) 
    run("si_prepareclient --server " + env.host + " --yes") 
    time.sleep(30) #30 sec to let prepare_client to complete 

내 기능에 내 host_dict의 키를 사용하고 싶습니다. 이처럼 :

def prepare_client(): 
# A function to send prepare_client command to a remoteserver by his 
hostname 
    print("Executing prepare_client on %s" % (host_dict(env.host))) 

하지만 난이 오류가 나타납니다

fab prepare_client

print("Executing prepare_client on %s" % (host_dict(env.host))) TypeError: 'dict' object is not callable 

누군가가 저를 정정 할 수 있습니까? 감사합니다.

+0

'host_dict [env.host]', 대괄호 –

+0

무슨 수치입니까! 모세에게 감사드립니다. – mothinx

답변