【问题标题】:java, xenserver, does anybody knows how to run a command on a virtual machine?java,xenserver,有人知道如何在虚拟机上运行命令吗?
【发布时间】:2013-03-10 09:03:38
【问题描述】:

我正在使用 XenServer,我正在连接池,获取所有 VM 的列表。 现在我需要登录到虚拟机。 并在所有 VM 上执行一个 exe 文件。 有人知道吗?

谢谢!

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.
    }
}

【问题讨论】:

    标签: java virtual-machine


    【解决方案1】:

    据我所知,XenServer API 没有提供任何可以在 VM 中执行命令的 api。恕我直言,像 XenServer 或 VMware 这样的 VMM 不应该有权在其托管的任何 VM 中执行命令。那么,为什么不获取所有 vm 的 ip 并使用一些 ssh 库来执行命令呢?

    【讨论】:

      【解决方案2】:

      使用 sshj 的 Session.exec() 通过 ssh 执行远程命令。有an example of doing this in the Github repo

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-07-29
        • 1970-01-01
        • 2015-09-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多