@Override public void protect(VolumeSnapshotInventory snapshot, Completion completion) { Path path = Paths.get(snapshot.getPrimaryStorageInstallPath()); if (!path.getParent().toString().contains(snapshot.getVolumeUuid())) { completion.fail(inerr("the snapshot[name:%s, uuid:%s, path: %s] seems not belong to the volume[uuid:%s]", snapshot.getName(), snapshot.getUuid(), snapshot.getPrimaryStorageInstallPath(), snapshot.getVolumeUuid())); return; } completion.success(); } }
@Override public void protect(VolumeSnapshotInventory snapshot, Completion completion) { Path path = Paths.get(snapshot.getPrimaryStorageInstallPath()); if (!path.getParent().toString().contains(snapshot.getVolumeUuid())) { completion.fail(inerr("the snapshot[name:%s, uuid:%s, path: %s] seems not belong to the volume[uuid:%s]", snapshot.getName(), snapshot.getUuid(), snapshot.getPrimaryStorageInstallPath(), snapshot.getVolumeUuid())); return; } completion.success(); } }
@Override public void protect(VolumeSnapshotInventory snapshot, Completion completion) { Path path = Paths.get(snapshot.getPrimaryStorageInstallPath()); if (!path.getParent().toString().contains(snapshot.getVolumeUuid())) { completion.fail(inerr("the snapshot[name:%s, uuid:%s, path: %s] seems not belong to the volume[uuid:%s]", snapshot.getName(), snapshot.getUuid(), snapshot.getPrimaryStorageInstallPath(), snapshot.getVolumeUuid())); return; } completion.success(); } }
@Override public void run(List<MessageReply> replies) { ErrorCode err = null; VolumeSnapshotInventory failSnapshot = null; for (MessageReply r : replies) { if (!r.isSuccess()) { err = r.getError(); failSnapshot = snapshots.get(replies.indexOf(r)); break; } } if (err != null) { completion.fail(operr("failed to change status of volume snapshot[uuid:%s, name:%s] by status event[%s]", failSnapshot.getUuid(), failSnapshot.getName(), evt).causedBy(err)); } else { completion.success(); } } });
@Override public void protect(VolumeSnapshotInventory snapshot, Completion completion) { if (!snapshot.getPrimaryStorageInstallPath().contains(snapshot.getVolumeUuid())) { completion.fail(inerr("the snapshot[name:%s, uuid:%s, path: %s] seems not belong to the volume[uuid:%s]", snapshot.getName(), snapshot.getUuid(), snapshot.getPrimaryStorageInstallPath(), snapshot.getVolumeUuid())); return; } completion.success(); } }
protected void handle(final RevertVolumeFromSnapshotOnPrimaryStorageMsg msg) { final RevertVolumeFromSnapshotOnPrimaryStorageReply reply = new RevertVolumeFromSnapshotOnPrimaryStorageReply(); HostInventory destHost; try { destHost = factory.getConnectedHostForOperation(PrimaryStorageInventory.valueOf(self)).get(0); }catch (OperationFailureException e){ reply.setError(operr("no host in Connected status to which nfs primary storage[uuid:%s, name:%s] attached" + " found to revert volume[uuid:%s] to snapshot[uuid:%s, name:%s]", self.getUuid(), self.getName(), msg.getVolume().getUuid(), msg.getSnapshot().getUuid(), msg.getSnapshot().getName())); bus.reply(msg, reply); return; } NfsPrimaryStorageBackend bkd = getBackend(nfsMgr.findHypervisorTypeByImageFormatAndPrimaryStorageUuid(msg.getSnapshot().getFormat(), self.getUuid())); bkd.revertVolumeFromSnapshot(msg.getSnapshot(), msg.getVolume(), destHost, new ReturnValueCompletion<RevertVolumeFromSnapshotOnPrimaryStorageReply>(msg) { @Override public void success(RevertVolumeFromSnapshotOnPrimaryStorageReply returnValue) { reply.setNewVolumeInstallPath(returnValue.getNewVolumeInstallPath()); reply.setSize(returnValue.getSize()); bus.reply(msg, reply); } @Override public void fail(ErrorCode errorCode) { reply.setError(errorCode); bus.reply(msg, reply); } }); }
chain.setName(String.format("create-template-from-snapshot-%s-%s", currentLeaf.getInventory().getName(), currentLeaf.getUuid())); chain.putData(