private List<SnapshotVO> getNonDestroyedSnapshots(long csVolumeId) { List<SnapshotVO> lstSnapshots = snapshotDao.listByVolumeId(csVolumeId); if (lstSnapshots == null) { lstSnapshots = new ArrayList<>(); } List<SnapshotVO> lstSnapshots2 = new ArrayList<>(); for (SnapshotVO snapshot : lstSnapshots) { if (!Snapshot.State.Destroyed.equals(snapshot.getState())) { lstSnapshots2.add(snapshot); } } return lstSnapshots2; }
private void pubishOnEventBus(String event, String status, Snapshot vo, State oldState, State newState) { String configKey = Config.PublishResourceStateEvent.key(); String value = s_configDao.getValue(configKey); boolean configValue = Boolean.parseBoolean(value); if(!configValue) { return; } try { s_eventBus = ComponentContext.getComponent(EventBus.class); } catch (NoSuchBeanDefinitionException nbe) { return; // no provider is configured to provide events bus, so just return } String resourceName = getEntityFromClassName(Snapshot.class.getName()); org.apache.cloudstack.framework.events.Event eventMsg = new org.apache.cloudstack.framework.events.Event(ManagementService.Name, EventCategory.RESOURCE_STATE_CHANGE_EVENT.getName(), event, resourceName, vo.getUuid()); Map<String, String> eventDescription = new HashMap<String, String>(); eventDescription.put("resource", resourceName); eventDescription.put("id", vo.getUuid()); eventDescription.put("old-state", oldState.name()); eventDescription.put("new-state", newState.name()); String eventDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z").format(new Date()); eventDescription.put("eventDateTime", eventDate); eventMsg.setDescription(eventDescription); try { s_eventBus.publish(eventMsg); } catch (EventBusException e) { s_logger.warn("Failed to publish state change event on the the event bus."); } }
public boolean equals(String status) { return this.toString().equalsIgnoreCase(status); } }
@Override public String toString() { return this.name(); }
public boolean equals(final String status) { return this.toString().equalsIgnoreCase(status); }
if (Snapshot.State.Error.equals(snapshotVO.getState())) { List<SnapshotDataStoreVO> storeRefs = snapshotStoreDao.findBySnapshotId(snapshotId); for (SnapshotDataStoreVO ref : storeRefs) { if (!Snapshot.State.BackedUp.equals(snapshotVO.getState()) && !Snapshot.State.Error.equals(snapshotVO.getState()) && !Snapshot.State.Destroying.equals(snapshotVO.getState())) { throw new InvalidParameterValueException("Can't delete snapshotshot " + snapshotId + " due to it is in " + snapshotVO.getState() + " Status");
if (origState.equals(Snapshot.State.BackedUp)) { snapObj.processEvent(Snapshot.Event.OperationNotPerformed); } else {
@Override public boolean deleteSnapshot(Long snapshotId) { Preconditions.checkArgument(snapshotId != null, "'snapshotId' cannot be 'null'."); SnapshotVO snapshotVO = snapshotDao.findById(snapshotId); if (Snapshot.State.Destroyed.equals(snapshotVO.getState())) { return true; } if (Snapshot.State.Error.equals(snapshotVO.getState())) { snapshotDao.remove(snapshotId); return true; } if (!Snapshot.State.BackedUp.equals(snapshotVO.getState())) { throw new InvalidParameterValueException("Unable to delete snapshot '" + snapshotId + "' because it is in the following state: " + snapshotVO.getState()); } return cleanupSnapshotOnPrimaryStore(snapshotId); }
@Override public String toString() { return this.name(); }
private List<SnapshotVO> getNonDestroyedSnapshots(long csVolumeId) { List<SnapshotVO> lstSnapshots = snapshotDao.listByVolumeId(csVolumeId); if (lstSnapshots == null) { lstSnapshots = new ArrayList<>(); } List<SnapshotVO> lstSnapshots2 = new ArrayList<>(); for (SnapshotVO snapshot : lstSnapshots) { if (!State.Destroyed.equals(snapshot.getState())) { lstSnapshots2.add(snapshot); } } return lstSnapshots2; } }