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);
}
}
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);
}
}
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);
}
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;
}
}
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);
}
}
Aggregations