i'm using XenServer, i'm connecting the pool, getting the list of all VM. now i need to loging to the VM. and to execute an exe file on all VM. anyone has any idea ?
Thank you!
connection = new Connection(url);
Session.loginWithPassword(connection, userName, Password, APIVersion.latest().toString());
Map<VM, VM.Record> vms = VM.getAllRecords(connection);
for (VM.Record record : vms.values()){
if (!record.isATemplate){
// now i need somehow to connect with the VM username and password
// now i need to run an exe file.
}
}
As far as I know, XenServer API doesn't provide any api that can execute commands in VM. And IMHO, a VMM like XenServer or VMware should not have the right to execute commands in any VM that it hosts. So , why not get the ip of all the vm and use some ssh libraries to execute the commands ?
Use sshj's Session.exec()
to execute remote commands via ssh. There's an example of doing this in the Github repo .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.