<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="chsdate"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        text-align:justify;
        text-justify:inter-ideograph;
        font-size:10.5pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:Arial;
        color:windowtext;}
 /* Page Definitions */
 @page Section1
        {size:595.3pt 841.9pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;
        layout-grid:15.6pt;}
div.Section1
        {page:Section1;}
-->
</style>

</head>

<body lang=ZH-CN link=blue vlink=purple style='text-justify-trim:punctuation'>

<div class=Section1 style='layout-grid:15.6pt'>

<p class=MsoNormal><font size=1 face=Arial><span lang=EN-US style='font-size:
9.0pt;font-family:Arial'>Hi, Dear Mr/Mrs.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span lang=EN-US style='font-size:
9.0pt;font-family:Arial'>I have trouble in connecting to a VM ESXi server with
python.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span lang=EN-US style='font-size:
9.0pt;font-family:Arial'>I am a developer using libvirt to control remote VM
ESXi with python language. But I am not able to connect to a remote VM ESXi
server.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span lang=EN-US style='font-size:
9.0pt;font-family:Arial'>I make my try to solve this issue:<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span lang=EN-US style='font-size:
9.0pt;font-family:Arial'>1: I use the function libvirt.Open() to open the
remote VM ESXi Server, but I don’t know how to input the password. It seems
that there is no parameter for password input. <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span lang=EN-US style='font-size:
9.0pt;font-family:Arial'>2: I use “virsh connect ---“. It is succeed
when it is executed on locale machine manual, but failed when I invoke this
command in python environment. I use “subprocess.Popen” to execute the
command “virsh”, but this function would be hung on after command “communicate”
executed.<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:42.0pt;mso-para-margin-left:4.0gd'><font
size=1 face=Arial><span lang=EN-US style='font-size:9.0pt;font-family:Arial'>-bash-4.1#
python<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:42.0pt;mso-para-margin-left:4.0gd'><font
size=1 face=Arial><span lang=EN-US style='font-size:9.0pt;font-family:Arial'>Python
<st1:chsdate IsROCDate="False" IsLunarDate="False" Day="30" Month="12"
Year="1899" w:st="on">2.6.6</st1:chsdate> (r266:84292, May 20 2011, 16:42:11) <o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:42.0pt;mso-para-margin-left:4.0gd'><font
size=1 face=Arial><span lang=EN-US style='font-size:9.0pt;font-family:Arial'>[GCC
4.4.5 20110214 (Red Hat <st1:chsdate IsROCDate="False" IsLunarDate="False"
Day="30" Month="12" Year="1899" w:st="on">4.4.5</st1:chsdate>-6)] on linux2<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:42.0pt;mso-para-margin-left:4.0gd'><font
size=1 face=Arial><span lang=EN-US style='font-size:9.0pt;font-family:Arial'>Type
"help", "copyright", "credits" or
"license" for more information.<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:42.0pt;mso-para-margin-left:4.0gd'><font
size=1 face=Arial><span lang=EN-US style='font-size:9.0pt;font-family:Arial'>>>>
from subprocess import Popen,PIPE,STDOUT<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:42.0pt;mso-para-margin-left:4.0gd'><font
size=1 face=Arial><span lang=EN-US style='font-size:9.0pt;font-family:Arial'>>>>
command=['virsh', '-c', 'esx://192.168.58.144/?no_verify=1','list', '--all']<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:42.0pt;mso-para-margin-left:4.0gd'><font
size=1 face=Arial><span lang=EN-US style='font-size:9.0pt;font-family:Arial'>>>>
p=Popen(command, stdin=PIPE,stdout=PIPE, stderr=STDOUT)<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:42.0pt;mso-para-margin-left:4.0gd'><font
size=1 face=Arial><span lang=EN-US style='font-size:9.0pt;font-family:Arial'>>>>
output = p.communicate()[0]<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span lang=EN-US style='font-size:
9.0pt;font-family:Arial'>How to fix it?<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span lang=EN-US style='font-size:
9.0pt;font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span lang=EN-US style='font-size:
9.0pt;font-family:Arial'>Thanks for help!<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span lang=EN-US style='font-size:
9.0pt;font-family:Arial'>Best regards!<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span lang=EN-US style='font-size:
9.0pt;font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span lang=EN-US style='font-size:
9.0pt;font-family:Arial'><o:p> </o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Times New Roman"><span lang=EN-US
style='font-size:10.0pt'><o:p> </o:p></span></font></p>

</div>

</body>

</html>