我正在尝试制作一个程序,自动将代理和白名单添加到Nutanix中的我的设置中,到目前为止,我能够获得要添加的代理,但无法获得要添加的白名单。 白名单ip在一行中运行。“\n”对它们不起作用。下面是我的代码:
import subprocess
import sys
add_whitelists = "ncli http-proxy add-to-whitelist target-type=IPV4_ADDRESS target="
whitelist_Ip = ["192.168.1.22", "192.168.1.23"]
login = "nutanix@192.168.1.50"
add_pxy = "ncli http-proxy add name=NPX5-proxy address=proxy.npx5.local port=8080 proxy-types=HTTPS"
list_proxy = "ncli http-proxy get-whitelist"
nl = '\n'
#ssh connection
ssh = subprocess.Popen(["ssh", "-i .ssh/id_rsa", login],
stdin =subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
bufsize=0)
# Send ssh commands to stdin
ssh.stdin.write(add_pxy + "\n")
for ip in whitelist_Ip:
ssh.stdin.write(add_whitelists + ip + "\n")
ssh.stdin.close()
# Fetch output
for line in ssh.stdout:
if line == "END\n":
break
print(line,end="")
谢谢
目前没有回答
相关问题 更多 >
编程相关推荐