private ErrorCode isOperationAllowed(Message msg) { if (allowedStatus.isOperationAllowed(msg.getClass().getName(), currentRoot.getStatus().toString())) { return null; } else { return err(VolumeSnapshotErrors.NOT_IN_CORRECT_STATE, "snapshot[uuid:%s, name:%s]'s status[%s] is not allowed for message[%s], allowed status%s", currentRoot.getUuid(), currentRoot.getName(), currentRoot.getStatus(), msg.getClass().getName(), allowedStatus.getStatesForOperation(msg.getClass().getName())); } }
private void changeStatus(VolumeSnapshotStatus.StatusEvent event) { self.setStatus(self.getStatus().nextState(event)); dbf.update(self); }
new While<>(msg.getVolumeSnapshotJobs()).all((struct, whileCompletion) -> { VolumeSnapshotVO vo = Q.New(VolumeSnapshotVO.class).eq(VolumeSnapshotVO_.uuid, struct.getResourceUuid()).find(); if (vo.getStatus().equals(VolumeSnapshotStatus.Ready)) { logger.warn(String.format("snapshot %s on volume %s is ready, no need to create again!", vo.getUuid(), vo.getVolumeUuid()));
public void fireSnapShotStatusChangedEvent(VolumeSnapshotStatus oldStatus, VolumeSnapshotInventory vsi) { SnapShotCanonicalEvents.SnapShotStatusChangedData d = new SnapShotCanonicalEvents.SnapShotStatusChangedData(); d.setInventory(vsi); d.setDate(new Date()); d.setNewStatus(vsi.getStatus()); d.setOldStatus(oldStatus == null ? null : oldStatus.toString()); d.setSnapShotUuid(vsi.getUuid()); evtf.fire(SnapShotCanonicalEvents.SNAPSHOT_STATUS_CHANGED_PATH, d); } }
public static APIQueryVolumeSnapshotReply __example__() { APIQueryVolumeSnapshotReply reply = new APIQueryVolumeSnapshotReply(); VolumeSnapshotInventory inv = new VolumeSnapshotInventory(); inv.setUuid(uuid()); inv.setName("My Snapshot 2"); inv.setPrimaryStorageUuid(uuid()); inv.setFormat("qcow2"); inv.setLatest(false); inv.setPrimaryStorageUuid("/zstack_ps/rootVolumes/acct-e77f16d460ea46e18262547b56972273/vol-13c66bb52d0949398e520183b917f813/snapshots/2fa6979af5c6479fa98f37d316f44b5f.qcow2"); inv.setSize(1310720); inv.setStatus(VolumeSnapshotStatus.Ready.toString()); inv.setState(VolumeSnapshotState.Enabled.toString()); inv.setVolumeType(VolumeType.Root.toString()); reply.setInventories(Collections.singletonList(inv)); return reply; }
public static APIUpdateVolumeSnapshotEvent __example__() { APIUpdateVolumeSnapshotEvent event = new APIUpdateVolumeSnapshotEvent(); VolumeSnapshotInventory inv = new VolumeSnapshotInventory(); inv.setUuid(uuid()); inv.setName("My Snapshot 2"); inv.setPrimaryStorageUuid(uuid()); inv.setFormat("qcow2"); inv.setLatest(false); inv.setPrimaryStorageUuid("/zstack_ps/rootVolumes/acct-e77f16d460ea46e18262547b56972273/vol-13c66bb52d0949398e520183b917f813/snapshots/2fa6979af5c6479fa98f37d316f44b5f.qcow2"); inv.setSize(1310720); inv.setStatus(VolumeSnapshotStatus.Ready.toString()); inv.setState(VolumeSnapshotState.Enabled.toString()); inv.setVolumeType(VolumeType.Root.toString()); event.setInventory(inv); return event; }
public static APIQueryVolumeSnapshotTreeReply __example__() { APIQueryVolumeSnapshotTreeReply reply = new APIQueryVolumeSnapshotTreeReply(); VolumeSnapshotInventory inv = new VolumeSnapshotInventory(); inv.setUuid(uuid()); inv.setName("My Snapshot 2"); inv.setPrimaryStorageUuid(uuid()); inv.setFormat("qcow2"); inv.setVolumeUuid(uuid()); inv.setLatest(false); inv.setPrimaryStorageUuid("/zstack_ps/rootVolumes/acct-e77f16d460ea46e18262547b56972273/vol-13c66bb52d0949398e520183b917f813/snapshots/2fa6979af5c6479fa98f37d316f44b5f.qcow2"); inv.setSize(1310720); inv.setStatus(VolumeSnapshotStatus.Ready.toString()); inv.setState(VolumeSnapshotState.Enabled.toString()); inv.setVolumeType(VolumeType.Root.toString()); VolumeSnapshotTree.SnapshotLeafInventory linv = new VolumeSnapshotTree.SnapshotLeafInventory(); linv.setInventory(inv); linv.setParentUuid(uuid()); VolumeSnapshotTreeInventory tinv = new VolumeSnapshotTreeInventory(); tinv.setUuid(uuid()); tinv.setCurrent(false); tinv.setVolumeUuid(inv.getVolumeUuid()); tinv.setTree(linv); return reply; }
public static VolumeSnapshotInventory valueOf(VolumeSnapshotVO vo) { VolumeSnapshotInventory inv = new VolumeSnapshotInventory(); inv.setName(vo.getName()); inv.setCreateDate(vo.getCreateDate()); inv.setDescription(vo.getDescription()); inv.setLastOpDate(vo.getLastOpDate()); inv.setParentUuid(vo.getParentUuid()); inv.setState(vo.getState().toString()); inv.setType(vo.getType()); inv.setVolumeUuid(vo.getVolumeUuid()); inv.setFormat(vo.getFormat()); inv.setUuid(vo.getUuid()); inv.setStatus(vo.getStatus().toString()); inv.setPrimaryStorageUuid(vo.getPrimaryStorageUuid()); inv.setPrimaryStorageInstallPath(vo.getPrimaryStorageInstallPath()); inv.setLatest(vo.isLatest()); inv.setSize(vo.getSize()); inv.setVolumeType(vo.getVolumeType()); inv.setTreeUuid(vo.getTreeUuid()); inv.setBackupStorageRefs(VolumeSnapshotBackupStorageRefInventory.valueOf(vo.getBackupStorageRefs())); return inv; }