Search in sources :

Example 16 with ActionableEvent

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);
        }
    }
}
Also used : ActionableEvent(com.emc.storageos.db.client.model.ActionableEvent) Host(com.emc.storageos.db.client.model.Host) URI(java.net.URI)

Example 17 with ActionableEvent

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();
}
Also used : ActionableEvent(com.emc.storageos.db.client.model.ActionableEvent) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 18 with ActionableEvent

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);
}
Also used : ActionableEvent(com.emc.storageos.db.client.model.ActionableEvent) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

ActionableEvent (com.emc.storageos.db.client.model.ActionableEvent)18 URI (java.net.URI)6 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5 NamedURI (com.emc.storageos.db.client.model.NamedURI)3 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)3 POST (javax.ws.rs.POST)3 ComputeSystemController (com.emc.storageos.computesystemcontroller.ComputeSystemController)2 NamedElement (com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement)2 TaskList (com.emc.storageos.model.TaskList)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2 GET (javax.ws.rs.GET)2 BulkList (com.emc.storageos.api.service.impl.response.BulkList)1 AggregationQueryResultList (com.emc.storageos.db.client.constraint.AggregationQueryResultList)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 DataObject (com.emc.storageos.db.client.model.DataObject)1 Host (com.emc.storageos.db.client.model.Host)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)1