Search in sources :

Example 6 with ComputeSystemController

use of com.emc.storageos.computesystemcontroller.ComputeSystemController in project coprhd-controller by CoprHD.

the class AbstractDiscoveryAdapter method removeOldInitiatorFromExport.

protected void removeOldInitiatorFromExport(Host host, List<Initiator> oldInitiators) {
    // update export if host is in use
    if (!oldInitiators.isEmpty() && ComputeSystemHelper.isHostInUse(dbClient, host.getId())) {
        String taskId = UUID.randomUUID().toString();
        ComputeSystemController controller = getController(ComputeSystemController.class, null);
        List<URI> uris = Lists.newArrayList();
        for (Initiator initiator : oldInitiators) {
            uris.add(initiator.getId());
        }
        controller.removeInitiatorsFromExport(host.getId(), uris, taskId);
    }
}
Also used : Initiator(com.emc.storageos.db.client.model.Initiator) ComputeSystemController(com.emc.storageos.computesystemcontroller.ComputeSystemController) URI(java.net.URI)

Example 7 with ComputeSystemController

use of com.emc.storageos.computesystemcontroller.ComputeSystemController in project coprhd-controller by CoprHD.

the class VcenterDataCenterService method deactivateVcenterDataCenter.

/**
 * Deactivates the vCenter data center, all its clusters and hosts
 *
 * @param id the URN of a ViPR vCenter data center to be deactivated
 * @prereq none
 * @brief Delete vCenter data center
 * @return the task used for tracking the deactivation
 * @throws DatabaseException when a DB error occurs
 */
@POST
@Path("/{id}/deactivate")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.TENANT_ADMIN })
public TaskResourceRep deactivateVcenterDataCenter(@PathParam("id") URI id, @DefaultValue("false") @QueryParam("detach-storage") boolean detachStorage) throws DatabaseException {
    if (ComputeSystemHelper.isDataCenterInUse(_dbClient, id) && !detachStorage) {
        throw APIException.badRequests.resourceHasActiveReferences(VcenterDataCenter.class.getSimpleName(), id);
    } else {
        VcenterDataCenter dataCenter = queryResource(id);
        ArgValidator.checkEntity(dataCenter, id, isIdEmbeddedInURL(id));
        String taskId = UUID.randomUUID().toString();
        Operation op = _dbClient.createTaskOpStatus(VcenterDataCenter.class, dataCenter.getId(), taskId, ResourceOperationTypeEnum.DELETE_VCENTER_DATACENTER_STORAGE);
        ComputeSystemController controller = getController(ComputeSystemController.class, null);
        controller.detachDataCenterStorage(dataCenter.getId(), true, taskId);
        auditOp(OperationTypeEnum.DELETE_VCENTER_DATACENTER, true, null, dataCenter.auditParameters());
        return toTask(dataCenter, taskId, op);
    }
}
Also used : ComputeSystemController(com.emc.storageos.computesystemcontroller.ComputeSystemController) MapVcenterDataCenter(com.emc.storageos.api.mapper.functions.MapVcenterDataCenter) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 8 with ComputeSystemController

use of com.emc.storageos.computesystemcontroller.ComputeSystemController in project coprhd-controller by CoprHD.

the class VcenterDataCenterService method detachStorage.

/**
 * Detaches storage from the data center.
 *
 * @param id the URN of a ViPR data center
 * @brief Detach storage from data center
 * @return the task used for tracking the detach-storage
 * @throws DatabaseException when a DB error occurs
 */
@POST
@Path("/{id}/detach-storage")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.TENANT_ADMIN })
public TaskResourceRep detachStorage(@PathParam("id") URI id) throws DatabaseException {
    VcenterDataCenter dataCenter = queryObject(VcenterDataCenter.class, id, true);
    ArgValidator.checkEntity(dataCenter, id, true);
    String taskId = UUID.randomUUID().toString();
    Operation op = _dbClient.createTaskOpStatus(Vcenter.class, dataCenter.getId(), taskId, ResourceOperationTypeEnum.DETACH_VCENTER_DATACENTER_STORAGE);
    ComputeSystemController controller = getController(ComputeSystemController.class, null);
    controller.detachDataCenterStorage(dataCenter.getId(), false, taskId);
    return toTask(dataCenter, taskId, op);
}
Also used : ComputeSystemController(com.emc.storageos.computesystemcontroller.ComputeSystemController) MapVcenterDataCenter(com.emc.storageos.api.mapper.functions.MapVcenterDataCenter) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 9 with ComputeSystemController

use of com.emc.storageos.computesystemcontroller.ComputeSystemController in project coprhd-controller by CoprHD.

the class VcenterService method deactivateVcenter.

/**
 * Deactivates the vCenter, its vCenter data centers, clusters and hosts.
 *
 * @param id the URN of a ViPR vCenter to be deactivated
 * @prereq none
 * @brief Delete vCenter
 * @return OK if deactivation completed successfully
 * @throws DatabaseException when a DB error occurs
 */
@POST
@Path("/{id}/deactivate")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.TENANT_ADMIN })
public TaskResourceRep deactivateVcenter(@PathParam("id") URI id, @DefaultValue("false") @QueryParam("detach-storage") boolean detachStorage) throws DatabaseException {
    if (ComputeSystemHelper.isVcenterInUse(_dbClient, id) && !detachStorage) {
        throw APIException.badRequests.resourceHasActiveReferences(Vcenter.class.getSimpleName(), id);
    } else {
        Vcenter vcenter = queryObject(Vcenter.class, id, true);
        // check the user permissions for this tenant org
        verifyAuthorizedSystemAdminOrTenantOrgUser(_permissionsHelper.convertToACLEntries(vcenter.getAcls()));
        checkIfOtherTenantsUsingTheVcenter(vcenter);
        String taskId = UUID.randomUUID().toString();
        Operation op = _dbClient.createTaskOpStatus(Vcenter.class, vcenter.getId(), taskId, ResourceOperationTypeEnum.DELETE_VCENTER);
        ComputeSystemController controller = getController(ComputeSystemController.class, null);
        controller.detachVcenterStorage(vcenter.getId(), true, taskId);
        auditOp(OperationTypeEnum.DELETE_VCENTER, true, null, vcenter.auditParameters());
        TaskResourceRep taskResourceRep = toTask(vcenter, taskId, op);
        updateTaskTenant(taskResourceRep);
        return taskResourceRep;
    }
}
Also used : MapVcenter(com.emc.storageos.api.mapper.functions.MapVcenter) ComputeSystemController(com.emc.storageos.computesystemcontroller.ComputeSystemController) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 10 with ComputeSystemController

use of com.emc.storageos.computesystemcontroller.ComputeSystemController in project coprhd-controller by CoprHD.

the class AbstractDiscoveryAdapter method addNewHostsToExport.

protected void addNewHostsToExport(URI clusterURI, List<Host> hosts, URI oldClusterURI) {
    // update export if host is in use
    if (ComputeSystemHelper.isClusterInExport(dbClient, clusterURI)) {
        String taskId = UUID.randomUUID().toString();
        ComputeSystemController controller = getController(ComputeSystemController.class, null);
        List<URI> hostIds = Lists.newArrayList();
        for (Host host : hosts) {
            hostIds.add(host.getId());
        }
        controller.addHostsToExport(hostIds, clusterURI, taskId, oldClusterURI, false);
    }
}
Also used : ComputeSystemController(com.emc.storageos.computesystemcontroller.ComputeSystemController) Host(com.emc.storageos.db.client.model.Host) URI(java.net.URI)

Aggregations

ComputeSystemController (com.emc.storageos.computesystemcontroller.ComputeSystemController)21 Path (javax.ws.rs.Path)12 Produces (javax.ws.rs.Produces)12 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)10 POST (javax.ws.rs.POST)10 Host (com.emc.storageos.db.client.model.Host)9 Operation (com.emc.storageos.db.client.model.Operation)9 URI (java.net.URI)6 Initiator (com.emc.storageos.db.client.model.Initiator)4 MapVcenter (com.emc.storageos.api.mapper.functions.MapVcenter)3 TaskList (com.emc.storageos.model.TaskList)3 ArrayList (java.util.ArrayList)3 Consumes (javax.ws.rs.Consumes)3 MapVcenterDataCenter (com.emc.storageos.api.mapper.functions.MapVcenterDataCenter)2 DiscoveredObjectTaskScheduler (com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler)2 ActionableEvent (com.emc.storageos.db.client.model.ActionableEvent)2 Cluster (com.emc.storageos.db.client.model.Cluster)2 AsyncTask (com.emc.storageos.volumecontroller.AsyncTask)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2