@Override protected HostInventory getSelfInventory() { return KVMHostInventory.valueOf(getSelf()); }
private void handle(GetKVMHostDownloadCredentialMsg msg) { final GetKVMHostDownloadCredentialReply reply = new GetKVMHostDownloadCredentialReply(); String key = asf.getPrivateKey(); String hostname = null; if (Strings.isNotEmpty(msg.getDataNetworkCidr())) { String dataNetworkAddress = getDataNetworkAddress(self.getUuid(), msg.getDataNetworkCidr()); if (dataNetworkAddress != null) { hostname = dataNetworkAddress; } } reply.setHostname(hostname == null ? getSelf().getManagementIp() : hostname); reply.setUsername(getSelf().getUsername()); reply.setSshPort(getSelf().getPort()); reply.setSshKey(key); bus.reply(msg, reply); }
private void handle(KvmRunShellMsg msg) { SshResult result = runShell(msg.getScript()); KvmRunShellReply reply = new KvmRunShellReply(); if (result.isSshFailure()) { reply.setError(operr("unable to connect to KVM[ip:%s, username:%s, sshPort:%d ] to do DNS check," + " please check if username/password is wrong; %s", self.getManagementIp(), getSelf().getUsername(), getSelf().getPort(), result.getExitErrorMessage())); } else { reply.setStdout(result.getStdout()); reply.setStderr(result.getStderr()); reply.setReturnCode(result.getReturnCode()); } bus.reply(msg, reply); }
@Override protected HostVO updateHost(APIUpdateHostMsg msg) { if (!(msg instanceof APIUpdateKVMHostMsg)) { return super.updateHost(msg); } KVMHostVO vo = (KVMHostVO) super.updateHost(msg); vo = vo == null ? getSelf() : vo; APIUpdateKVMHostMsg umsg = (APIUpdateKVMHostMsg) msg; if (umsg.getUsername() != null) { vo.setUsername(umsg.getUsername()); } if (umsg.getPassword() != null) { vo.setPassword(umsg.getPassword()); } if (umsg.getSshPort() != null && umsg.getSshPort() > 0 && umsg.getSshPort() <= 65535) { vo.setPort(umsg.getSshPort()); } return vo; } }
extEmitter.beforeRebootVmOnKvm(KVMHostInventory.valueOf(getSelf()), vminv); } catch (KVMException e) { String err = String.format("failed to reboot vm[uuid:%s name:%s] on kvm host[uuid:%s, ip:%s], because %s", vminv.getUuid(), vminv.getName(),
extEmitter.beforeStopVmOnKvm(KVMHostInventory.valueOf(getSelf()), vminv); } catch (KVMException e) { ErrorCode err = operr("failed to stop vm[uuid:%s name:%s] on kvm host[uuid:%s, ip:%s], because %s", vminv.getUuid(), vminv.getName(),
KVMHostInventory khinv = KVMHostInventory.valueOf(getSelf()); extEmitter.beforeStartVmOnKvm(khinv, spec, cmd);
extEmitter.beforeDestroyVmOnKvm(KVMHostInventory.valueOf(getSelf()), vminv); } catch (KVMException e) { ErrorCode err = operr("failed to destroy vm[uuid:%s name:%s] on kvm host[uuid:%s, ip:%s], because %s", vminv.getUuid(), vminv.getName(),