private void updateNic(VmUpdateNicOnHypervisorMsg msg, NoErrorCompletion completion) { checkStateAndStatus(); final VmUpdateNicOnHypervisorReply reply = new VmUpdateNicOnHypervisorReply(); List<VmNicVO> nics = Q.New(VmNicVO.class).eq(VmNicVO_.vmInstanceUuid, msg.getVmInstanceUuid()).list(); UpdateNicCmd cmd = new UpdateNicCmd(); cmd.setVmInstanceUuid(msg.getVmInstanceUuid()); cmd.setNics(VmNicInventory.valueOf(nics).stream().map(this::completeNicInfo).collect(Collectors.toList())); KVMHostInventory inv = (KVMHostInventory) getSelfInventory(); for (KVMPreUpdateNicExtensionPoint ext : pluginRgty.getExtensionList(KVMPreUpdateNicExtensionPoint.class)) { ext.preUpdateNic(inv, cmd); } new Http<>(updateNicPath, cmd, AttachNicResponse.class).call(new ReturnValueCompletion<AttachNicResponse>(msg, completion) { @Override public void success(AttachNicResponse ret) { if (!ret.isSuccess()) { reply.setError(operr("failed to update nic[vm:%s] on kvm host[uuid:%s, ip:%s]," + "because %s", msg.getVmInstanceUuid(), self.getUuid(), self.getManagementIp(), ret.getError())); } bus.reply(msg, reply); completion.done(); } @Override public void fail(ErrorCode errorCode) { reply.setError(errorCode); bus.reply(msg, reply); completion.done(); } }); }
private void rebootVm(final RebootVmOnHypervisorMsg msg, final NoErrorCompletion completion) { checkStateAndStatus(); final VmInstanceInventory vminv = msg.getVmInventory();
private void attachNic(final VmAttachNicOnHypervisorMsg msg, final NoErrorCompletion completion) { checkStateAndStatus(); NicTO to = completeNicInfo(msg.getNicInventory()); final VmAttachNicOnHypervisorReply reply = new VmAttachNicOnHypervisorReply(); AttachNicCommand cmd = new AttachNicCommand(); cmd.setVmUuid(msg.getNicInventory().getVmInstanceUuid()); cmd.setNic(to); KVMHostInventory inv = (KVMHostInventory) getSelfInventory(); for (KvmPreAttachNicExtensionPoint ext : pluginRgty.getExtensionList(KvmPreAttachNicExtensionPoint.class)) { ext.preAttachNicExtensionPoint(inv, cmd); } new Http<>(attachNicPath, cmd, AttachNicResponse.class).call(new ReturnValueCompletion<AttachNicResponse>(msg, completion) { @Override public void success(AttachNicResponse ret) { if (!ret.isSuccess()) { reply.setError(operr("failed to attach nic[uuid:%s, vm:%s] on kvm host[uuid:%s, ip:%s]," + "because %s", msg.getNicInventory().getUuid(), msg.getNicInventory().getVmInstanceUuid(), self.getUuid(), self.getManagementIp(), ret.getError())); } bus.reply(msg, reply); completion.done(); } @Override public void fail(ErrorCode errorCode) { reply.setError(errorCode); bus.reply(msg, reply); completion.done(); } }); }
private void attachVolume(final AttachVolumeToVmOnHypervisorMsg msg, final NoErrorCompletion completion) { checkStateAndStatus();
private void startVm(final VmInstanceSpec spec, final NeedReplyMessage msg, final NoErrorCompletion completion) { checkStateAndStatus(); final StartVmCmd cmd = new StartVmCmd();
private void detachVolume(final DetachVolumeFromVmOnHypervisorMsg msg, final NoErrorCompletion completion) { checkStateAndStatus();
private void doTakeSnapshot(final TakeSnapshotOnHypervisorMsg msg, final NoErrorCompletion completion) { checkStateAndStatus();
private void mergeVolumeSnapshot(final MergeVolumeSnapshotOnKvmMsg msg, final NoErrorCompletion completion) { checkStateAndStatus();