vimclient สองอินสแตนซ์ขึ้นไป

ฉันกำลังเขียนแอปพลิเคชัน C# ที่ต้องการเข้าถึงโฮสต์ vSphere สองตัวขึ้นไป ไม่ใช่ vCenter ฉันสามารถเชื่อมต่อได้ทั้งหมดและแสดงรายการ VM แต่เมื่อฉันค้นหา VM ระบบจะใช้ข้อมูล vimClient จากโฮสต์ vShere ที่เชื่อมต่อครั้งล่าสุด มีวิธีเก็บข้อมูลโฮสต์ VM ไว้กับ VM แต่ละตัวหรือไม่

ฉันใช้สิ่งต่อไปนี้เพื่อเชื่อมต่อกับโฮสต์ 1:

Client_1.Connect(logon.esxiLogonURL(IP_1.Text));
Client_1.Login(logon.esxiLogonUser(username_1.Text), logon.esxiPassword(password_1.Text));

และต่อไปนี้เพื่อเชื่อมต่อกับโฮสต์ 2

Client_2.Connect(logon.esxiLogonURL(IP_2.Text));
Client_2.Login(logon.esxiLogonUser(userName_2.Text), logon.esxiPassword(password_2.Text));

มีความคิดใด ๆ เกี่ยวกับวิธีที่ฉันสามารถทำเช่นนี้?

ขอบคุณ


person Reaz    schedule 27.07.2017    source แหล่งที่มา


คำตอบ (1)


บันทึกออบเจ็กต์การเชื่อมต่อลงในรายการและอ้างอิงถึงในภายหลัง

List<VimClient> ConnectionList = new List<VimClient>();

Client_1.Connect(logon.esxiLogonURL(IP_1.Text)); Client_1.Login(logon.esxiLogonUser(username_1.Text); logon.esxiPassword(password_1.Text));

ConnectionList.Add(Client_1);

Client_2.Connect(logon.esxiLogonURL(IP_2.Text)); Client_2.Login(logon.esxiLogonUser(userName_2.Text); logon.esxiPassword(password_2.Text));

ConnectionList.Add(Client_2);

foreach (VimClient Connection in ConnectionList){ get vmhost information }

person Caleb Chandler    schedule 14.03.2018