use of com.emc.storageos.db.client.model.ActionableEvent in project coprhd-controller by CoprHD.
the class HostCompleter method complete.
@Override
protected void complete(DbClient dbClient, Status status, ServiceCoded coded) throws DeviceControllerException {
super.complete(dbClient, status, coded);
for (URI id : getIds()) {
switch(status) {
case error:
Host host = dbClient.queryObject(Host.class, id);
if (!NullColumnValueGetter.isNullURI(host.getComputeElement())) {
host.setProvisioningStatus(Host.ProvisioningJobStatus.ERROR.toString());
dbClient.updateObject(host);
}
if (!NullColumnValueGetter.isNullURI(eventId)) {
ActionableEvent event = dbClient.queryObject(ActionableEvent.class, eventId);
if (event != null) {
event.setEventStatus(ActionableEvent.Status.failed.name());
dbClient.updateObject(event);
}
}
if (oldHostClusters.containsKey(id)) {
_logger.info(String.format("Updating cluster to %s for host %s", oldHostClusters.get(id), id));
ComputeSystemHelper.updateHostAndInitiatorClusterReferences(dbClient, oldHostClusters.get(id), id);
}
if (oldHostVcenterDataCenters.containsKey(id)) {
_logger.info(String.format("Updating vcenter datacenter to %s for host %s", oldHostVcenterDataCenters.get(id), id));
ComputeSystemHelper.updateHostVcenterDatacenterReference(dbClient, id, oldHostVcenterDataCenters.get(id));
}
dbClient.error(Host.class, id, getOpId(), coded);
break;
default:
dbClient.ready(Host.class, id, getOpId());
}
if (deactivateOnComplete && status.equals(Status.ready)) {
Host host = dbClient.queryObject(Host.class, id);
ComputeSystemHelper.doDeactivateHost(dbClient, host);
_logger.info("Deactivating Host: " + id);
}
}
}
use of com.emc.storageos.db.client.model.ActionableEvent in project coprhd-controller by CoprHD.
the class EventService method deleteEvent.
/**
* Delete Event
*
* @param id
* @brief Delete an event
* @return
* @throws DatabaseException
*/
@POST
@Path("/{id}/deactivate")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN })
public Response deleteEvent(@PathParam("id") URI id) throws DatabaseException {
ActionableEvent event = queryObject(ActionableEvent.class, id, false);
// check the user permissions
verifyAuthorizedInTenantOrg(event.getTenant(), getUserFromContext());
_dbClient.markForDeletion(event);
_log.info("Deleting Actionable Event: " + event.getId() + " Tenant: " + event.getTenant() + " Description: " + event.getDescription() + " Warning: " + event.getWarning() + " Event Status: " + event.getEventStatus() + " Resource: " + event.getResource() + " Event Code: " + event.getEventCode());
return Response.ok().build();
}
use of com.emc.storageos.db.client.model.ActionableEvent in project coprhd-controller by CoprHD.
the class EventService method declineEvent.
/**
* Decline Event
*
* @param id
* @brief Change an event to declined
* @return
* @throws DatabaseException
*/
@POST
@Path("/{id}/decline")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN })
public TaskList declineEvent(@PathParam("id") URI id) throws DatabaseException {
ActionableEvent event = queryObject(ActionableEvent.class, id, false);
verifyAuthorizedInTenantOrg(event.getTenant(), getUserFromContext());
if (!StringUtils.equalsIgnoreCase(event.getEventStatus(), ActionableEvent.Status.pending.name()) && !StringUtils.equalsIgnoreCase(event.getEventStatus(), ActionableEvent.Status.failed.name())) {
throw APIException.badRequests.eventCannotBeDeclined(event.getEventStatus());
}
_log.info("Declining Actionable Event: " + event.getId() + " Tenant: " + event.getTenant() + " Description: " + event.getDescription() + " Warning: " + event.getWarning() + " Event Status: " + event.getEventStatus() + " Resource: " + event.getResource() + " Event Code: " + event.getEventCode());
return executeEventMethod(event, false);
}
Aggregations