我想像这样传递多个参数:
@bot test vpn PeerIP:xxxx,可选参数:Peersubnet yyyy ClCSubnet zzzz
现在,当传递多个参数时,我得到了错误:
电脑说不。有关详细信息,请参阅日志:test_vpn() 缺少 2 个必需的位置参数:“PeerSubnet”和“ClcSubnet”
代码:计算机说不。有关详细信息,请参阅日志:test_vpn() 缺少 2 个必需的位置参数:“PeerSubnet”和“ClcSubnet”
我更进一步,现在我在将多个参数传递到 powershell 时遇到问题,PS 正在寻找命名参数。
新代码:
@arg_botcmd('--dc', dest='DataCenter', type=str)
@arg_botcmd('--peerIp', dest='PeerPublicIp', type=str)
@arg_botcmd('--peerSubnet', dest='PeerSubnet', type=str)
@arg_botcmd('--ClcSubnet', dest='ClcSubnet', type=str)
def test_vpn(self, args, DataCenter=None, PeerPublicIp=None, PeerSubnet=None, ClcSubnet=None):
output = subprocess.check_output([
"C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe",
". \"C:\\Program Files\\Toolbox\\PowerShell Modules\\Juniper\\./Juniper.psm1\";",
"Test-juniperS2SVPN",
DataCenter,
PeerPublicIp,
PeerSubnet,
ClcSubnet,])
return "```\n{output}\n```".format(output=output.decode("utf-8"))
新错误:
电脑说不。有关详细信息,请参阅日志:命令 '['C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe', '。"C:\Program Files\Toolbox\PowerShell Modules\Juniper./Juniper.psm1";', 'Test-juniperS2SVPN', 'il1', '209.15.24.204', '172.16.57.0/24', '10.90.32.12 /30']' 返回非零退出状态 1。