Java 有人知道如何在虚拟机上运行命令吗?
我正在使用XenServer,连接池,获取所有VM的列表。 现在我需要登录到虚拟机。 并在所有虚拟机上执行exe文件。 有人知道吗 谢谢大家!Java 有人知道如何在虚拟机上运行命令吗?,java,virtual-machine,Java,Virtual Machine,我正在使用XenServer,连接池,获取所有VM的列表。 现在我需要登录到虚拟机。 并在所有虚拟机上执行exe文件。 有人知道吗 谢谢大家! connection = new Connection(url); Session.loginWithPassword(connection, userName, Password, APIVersion.latest().toString()); Map<VM, VM.Record> vms = VM.getAllRecords(con
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.
}
}
connection=新连接(url);
Session.loginWithPassword(连接、用户名、密码、APIVersion.latest().toString());
映射vms=VM.getAllRecords(连接);
for(VM.Record记录:vms.values()){
如果(!record.isamplate){
//现在我需要以某种方式连接VM用户名和密码
//现在我需要运行一个exe文件。
}
}
据我所知,XenServer API不提供任何可以在VM中执行命令的API。而IMHO,像XenServer或VMware这样的VMM不应有权在其托管的任何VM中执行命令。那么,为什么不获取所有vm的ip并使用一些ssh库来执行命令呢?使用sshj的Session.exec()
通过ssh执行远程命令。有一个