如何用Python替代PowerShell获取Citrix Broker关联的VDI列表及参数?
需求:通过Python获取Citrix Broker的VDI列表及参数(Linux Docker环境)
我需要获取连接到Citrix Broker的所有VDI(Virtual Desktop Interfaces)的列表及相关参数。此前已通过PowerShell实现该需求,代码如下:
# credentials used for remote connection to citrix controllers $pass=$(ConvertTo-SecureString -String $env:CitrixPassword -AsPlainText -Force) [pscredential]$creds = New-Object System.Management.Automation.PSCredential ($env:CitrixUser,$pass) #create the session $session = New-PSSession -ComputerName $controller -Credential $creds -Authentication Negotiate Write-Output -message "Session on $controller successfully established!" Write-Output -message "loading citrix snapin" Invoke-Command -Session $session -ScriptBlock {Add-PSSnapin citrix*} # pay attention here Write-Output -message "Loading Snapin successful" #get the stuff Write-Output -message "Read the data..." $controllers = Invoke-Command -Session $session -ScriptBlock {Get-BrokerController} Write-Output -message "... controllers done" $desktops = Invoke-Command -Session $session -ScriptBlock {Get-BrokerDesktop -MaxRecordCount 10000} Write-Output -message "... desktop done" ...
尝试用Python实现相同功能时遇到困难,测试WSman相关代码无法正常运行,测试代码如下:
# create the session wsman = WSMan(citrix_ddc, username = citrix_user, password = citrix_pass, auth = "basic", port = 443, cert_validation = False) with RunspacePool(wsman) as pool: ps = PowerShell(pool) ps.add_cmdlet("Add-PSSnapin").add_parameter("citrix*") ps.invoke() # we will print the first object returned back to us print(ps.output[0])
请求端点https://<my_controller_ip>:443/wsman返回404错误:
Code: 404, Content: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd"> <HTML><HEAD><TITLE>Not Found</TITLE> <META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD> <BODY><h2>Not Found</h2> <hr><p>HTTP Error 404. The requested resource is not found.</p> </BODY></HTML>
需要一个适用于Linux环境Docker容器的Python解决方案。
内容的提问来源于stack exchange,提问作者USER_RANDOM_010101NR
相关产品推荐
相关产品推荐

