VolumeInventory vol = VolumeInventory.valueOf(dbf.findByUuid(sp.getVolumeUuid(), VolumeVO.class)); TakeSnapshotOnHypervisorMsg hmsg = new TakeSnapshotOnHypervisorMsg(); hmsg.setHostUuid(hostUuid); hmsg.setVmUuid(vol.getVmInstanceUuid()); hmsg.setVolume(vol); hmsg.setSnapshotName(msg.getStruct().getCurrent().getUuid()); hmsg.setFullSnapshot(msg.getStruct().isFullSnapshot()); String installPath = makeSnapshotInstallPath(vol, sp); hmsg.setInstallPath(installPath); bus.makeTargetServiceIdByResourceUuid(hmsg, HostConstant.SERVICE_ID, hostUuid); bus.send(hmsg, new CloudBusCallBack(completion) {
private void handle(TakeSnapshotOnHypervisorMsg msg) { TakeSnapshotOnHypervisorReply reply = new TakeSnapshotOnHypervisorReply(); if (!config.snapshotSuccess) { reply.setError(operr("on purpose")); bus.reply(msg, reply); return; } List<TakeSnapshotOnHypervisorMsg> lst = config.snapshots.get(msg.getHostUuid()); lst = new ArrayList<TakeSnapshotOnHypervisorMsg>(); lst.add(msg); config.snapshots.put(msg.getHostUuid(), lst); }
TakeSnapshotCmd cmd = new TakeSnapshotCmd(); if (msg.getVmUuid() != null) { SimpleQuery<VmInstanceVO> q = dbf.createQuery(VmInstanceVO.class); q.select(VmInstanceVO_.state); q.add(VmInstanceVO_.uuid, SimpleQuery.Op.EQ, msg.getVmUuid()); VmInstanceState vmState = q.findValue(); if (vmState != VmInstanceState.Running && vmState != VmInstanceState.Stopped && vmState != VmInstanceState.Paused) { throw new OperationFailureException(operr("vm[uuid:%s] is not Running or Stopped, current state[%s]", msg.getVmUuid(), vmState)); throw new OperationFailureException(err(SysErrors.NO_CAPABILITY_ERROR, "kvm host[uuid:%s, name:%s, ip:%s] doesn't not support live snapshot. please stop vm[uuid:%s] and try again", self.getUuid(), self.getName(), self.getManagementIp(), msg.getVmUuid() )); cmd.setVolumeUuid(msg.getVolume().getUuid()); cmd.setVmUuid(msg.getVmUuid()); cmd.setDeviceId(msg.getVolume().getDeviceId()); cmd.setVolumeInstallPath(msg.getVolume().getInstallPath()); cmd.setInstallPath(msg.getInstallPath()); cmd.setFullSnapshot(msg.isFullSnapshot()); chain.setName(String.format("before-take-snapshot-%s-for-volume-%s", msg.getSnapshotName(), msg.getVolume().getUuid())); chain.then(new NoRollbackFlow() { @Override
TakeSnapshotOnHypervisorMsg hmsg = new TakeSnapshotOnHypervisorMsg(); hmsg.setHostUuid(hostUuid); hmsg.setVmUuid(vol.getVmInstanceUuid()); hmsg.setVolume(vol); hmsg.setSnapshotName(msg.getStruct().getCurrent().getUuid()); hmsg.setFullSnapshot(msg.getStruct().isFullSnapshot()); String installPath = makeSnapshotInstallPath(vol, sp); hmsg.setInstallPath(installPath); bus.makeTargetServiceIdByResourceUuid(hmsg, HostConstant.SERVICE_ID, hostUuid); bus.send(hmsg, new CloudBusCallBack(completion) {
TakeSnapshotOnHypervisorMsg hmsg = new TakeSnapshotOnHypervisorMsg(); hmsg.setHostUuid(huuid); hmsg.setVmUuid(vol.getVmInstanceUuid()); hmsg.setVolume(volInv); hmsg.setSnapshotName(msg.getStruct().getCurrent().getUuid()); hmsg.setFullSnapshot(msg.getStruct().isFullSnapshot()); final String installPath = NfsPrimaryStorageKvmHelper.makeKvmSnapshotInstallPath(getSelfInventory(), volInv, msg.getStruct().getCurrent()); hmsg.setInstallPath(installPath); bus.makeTargetServiceIdByResourceUuid(hmsg, HostConstant.SERVICE_ID, huuid); bus.send(hmsg, new CloudBusCallBack(msg) {