use of com.emc.storageos.volumecontroller.BlockController in project coprhd-controller by CoprHD.
the class StorageSystemService method createStoragePortGroup.
/**
* Create a storage port group
*
* @param id
* the URN of a ViPR storage port.
*
* @brief Create a storage port
* @return The pending task
*/
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/storage-port-groups")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep createStoragePortGroup(@PathParam("id") URI id, StoragePortGroupCreateParam param) {
ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
StorageSystem system = queryResource(id);
// Only support for VMAX
if (!DiscoveredDataObject.Type.vmax.name().equals(system.getSystemType())) {
APIException.badRequests.operationNotSupportedForSystemType(OperationTypeEnum.CREATE_STORAGE_PORT_GROUP.name(), system.getSystemType());
}
ArgValidator.checkFieldNotEmpty(param.getName(), "name");
String portGroupName = param.getName();
List<URI> ports = param.getStoragePorts();
for (URI port : ports) {
ArgValidator.checkFieldUriType(port, StoragePort.class, "portURI");
StoragePort sport = _dbClient.queryObject(StoragePort.class, port);
ArgValidator.checkEntityNotNull(sport, port, isIdEmbeddedInURL(port));
}
checkForDuplicatePortGroupName(portGroupName, id);
StoragePortGroup portGroup = new StoragePortGroup();
portGroup.setLabel(portGroupName);
if (param.getRegistered()) {
portGroup.setRegistrationStatus(RegistrationStatus.REGISTERED.name());
} else {
portGroup.setRegistrationStatus(RegistrationStatus.UNREGISTERED.name());
}
portGroup.setStorageDevice(id);
portGroup.setStoragePorts(StringSetUtil.uriListToStringSet(ports));
portGroup.setId(URIUtil.createId(StoragePortGroup.class));
portGroup.setMutable(false);
_dbClient.createObject(portGroup);
String task = UUID.randomUUID().toString();
Operation op = _dbClient.createTaskOpStatus(StoragePortGroup.class, portGroup.getId(), task, ResourceOperationTypeEnum.CREATE_STORAGE_PORT_GROUP);
_dbClient.updateObject(portGroup);
auditOp(OperationTypeEnum.CREATE_STORAGE_PORT_GROUP, true, null, param.getName(), id.toString());
recordStoragePoolPortEvent(OperationTypeEnum.CREATE_STORAGE_PORT_GROUP, OperationTypeEnum.CREATE_STORAGE_PORT_GROUP.getDescription(), portGroup.getId(), "StoragePortGroup");
TaskResourceRep taskRes = toTask(portGroup, task, op);
BlockController controller = getController(BlockController.class, system.getSystemType());
controller.createStoragePortGroup(system.getId(), portGroup.getId(), task);
return taskRes;
}
use of com.emc.storageos.volumecontroller.BlockController in project coprhd-controller by CoprHD.
the class StorageSystemService method discoverStorageSystemsAll.
/**
* Allows the user to manually discover all storage systems.
*
* @brief Discover all storage systems
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
@Path("/discover")
public TaskList discoverStorageSystemsAll() {
Iterator<URI> storageIter = _dbClient.queryByType(StorageSystem.class, true).iterator();
ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>();
while (storageIter.hasNext()) {
URI storage = storageIter.next();
String taskId = UUID.randomUUID().toString();
tasks.add(new AsyncTask(StorageSystem.class, storage, taskId));
}
BlockController controller = getController(BlockController.class, "vnxblock");
return discoverStorageSystems(tasks, controller);
}
use of com.emc.storageos.volumecontroller.BlockController in project coprhd-controller by CoprHD.
the class AbstractBlockFullCopyApiImpl method detach.
/**
* {@inheritDoc}
*/
@Override
public TaskList detach(BlockObject fcSourceObj, Volume fullCopyVolume) {
// Create the task list.
TaskList taskList = new TaskList();
// Create a unique task id.
String taskId = UUID.randomUUID().toString();
// If the source is in a CG, then we will activate the corresponding
// full copies for all the volumes in the CG. Since we did not allow
// full copies for volumes or snaps in CGs prior to Jedi, there should
// be a full copy for all volumes in the CG.
Map<URI, Volume> fullCopyMap = getFullCopySetMap(fcSourceObj, fullCopyVolume);
Set<URI> fullCopyURIs = fullCopyMap.keySet();
// send detach full copy request to controller.
if ((BlockFullCopyUtils.isFullCopyDetached(fullCopyVolume, _dbClient)) || (BlockFullCopyUtils.isFullCopyInactive(fullCopyVolume, _dbClient))) {
Operation op = new Operation();
op.setResourceType(ResourceOperationTypeEnum.DETACH_VOLUME_FULL_COPY);
op.ready("Full copy is already detached");
for (URI fullCopyURI : fullCopyURIs) {
_dbClient.createTaskOpStatus(Volume.class, fullCopyURI, taskId, op);
TaskResourceRep task = TaskMapper.toTask(fullCopyMap.get(fullCopyURI), taskId, op);
taskList.addTask(task);
if (!BlockFullCopyUtils.isFullCopyDetached(fullCopyVolume, _dbClient)) {
// Make sure the replica state is set to detached.
Volume volume = fullCopyVolume;
if (!fullCopyURI.equals(fullCopyVolume.getId())) {
volume = _dbClient.queryObject(Volume.class, fullCopyURI);
}
ReplicationUtils.removeDetachedFullCopyFromSourceFullCopiesList(volume, _dbClient);
volume.setAssociatedSourceVolume(NullColumnValueGetter.getNullURI());
volume.setReplicaState(ReplicationState.DETACHED.name());
_dbClient.persistObject(volume);
}
}
} else {
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, fullCopyVolume.getStorageController());
BlockController controller = getController(BlockController.class, storageSystem.getSystemType());
for (URI fullCopyURI : fullCopyURIs) {
Operation op = _dbClient.createTaskOpStatus(Volume.class, fullCopyURI, taskId, ResourceOperationTypeEnum.DETACH_VOLUME_FULL_COPY);
fullCopyMap.get(fullCopyURI).getOpStatus().put(taskId, op);
TaskResourceRep fullCopyVolumeTask = TaskMapper.toTask(fullCopyMap.get(fullCopyURI), taskId, op);
taskList.getTaskList().add(fullCopyVolumeTask);
}
if (NullColumnValueGetter.isNotNullValue(fullCopyVolume.getReplicationGroupInstance())) {
addConsistencyGroupTasks(Arrays.asList(fcSourceObj), taskList, taskId, ResourceOperationTypeEnum.DETACH_CONSISTENCY_GROUP_FULL_COPY);
}
try {
controller.detachFullCopy(storageSystem.getId(), new ArrayList<URI>(fullCopyURIs), taskId);
} catch (ControllerException ce) {
s_logger.error("Failed to detach volume full copy {}", fullCopyVolume.getId(), ce);
handleFailedRequest(taskId, taskList, new ArrayList<Volume>(fullCopyMap.values()), ce, false);
}
}
return taskList;
}
use of com.emc.storageos.volumecontroller.BlockController in project coprhd-controller by CoprHD.
the class AbstractBlockFullCopyApiImpl method getSyncPercentage.
/**
* Gets the percent synchronized for the passed full copy volume.
*
* @param sourceURI The URI of the full copy source.
* @param fullCopyVolume A reference to the full copy volume.
*
* @return The percent synchronized.
*/
protected Integer getSyncPercentage(URI sourceURI, Volume fullCopyVolume) {
Integer result = null;
URI fullCopyURI = fullCopyVolume.getId();
if (!BlockFullCopyUtils.isFullCopyInactive(fullCopyVolume, _dbClient)) {
String taskId = UUID.randomUUID().toString();
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, fullCopyVolume.getStorageController());
BlockController controller = getController(BlockController.class, storageSystem.getSystemType());
try {
result = controller.checkSyncProgress(storageSystem.getId(), sourceURI, fullCopyURI, taskId);
} catch (ControllerException ce) {
s_logger.error("Failed to check synchronization progress for volume full copy {}", fullCopyURI, ce);
}
} else {
result = 0;
}
if (result == null) {
throw APIException.badRequests.protectionUnableToGetSynchronizationProgress();
}
return result;
}
use of com.emc.storageos.volumecontroller.BlockController in project coprhd-controller by CoprHD.
the class AbstractBlockFullCopyApiImpl method activate.
/**
* {@inheritDoc}
*/
@Override
public TaskList activate(BlockObject fcSourceObj, Volume fullCopyVolume) {
// Create the task list.
TaskList taskList = new TaskList();
// Create a unique task id.
String taskId = UUID.randomUUID().toString();
// If the source is in a CG, then we will activate the corresponding
// full copies for all the volumes in the CG. Since we did not allow
// full copies for volumes or snaps in CGs prior to Jedi, there should
// be a full copy for all volumes in the CG.
Map<URI, Volume> fullCopyMap = getFullCopySetMap(fcSourceObj, fullCopyVolume);
Set<URI> fullCopyURIs = fullCopyMap.keySet();
// to controller.
if (!BlockFullCopyUtils.isFullCopyInactive(fullCopyVolume, _dbClient)) {
Operation op = new Operation();
op.setResourceType(ResourceOperationTypeEnum.ACTIVATE_VOLUME_FULL_COPY);
op.ready("Full copy is already activated");
for (URI fullCopyURI : fullCopyURIs) {
_dbClient.createTaskOpStatus(Volume.class, fullCopyURI, taskId, op);
TaskResourceRep task = TaskMapper.toTask(fullCopyMap.get(fullCopyURI), taskId, op);
taskList.addTask(task);
}
} else {
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, fullCopyVolume.getStorageController());
BlockController controller = getController(BlockController.class, storageSystem.getSystemType());
for (URI fullCopyURI : fullCopyURIs) {
Operation op = _dbClient.createTaskOpStatus(Volume.class, fullCopyURI, taskId, ResourceOperationTypeEnum.ACTIVATE_VOLUME_FULL_COPY);
fullCopyMap.get(fullCopyURI).getOpStatus().put(taskId, op);
TaskResourceRep fullCopyVolumeTask = TaskMapper.toTask(fullCopyMap.get(fullCopyURI), taskId, op);
taskList.getTaskList().add(fullCopyVolumeTask);
}
addConsistencyGroupTasks(Arrays.asList(fcSourceObj), taskList, taskId, ResourceOperationTypeEnum.ACTIVATE_CONSISTENCY_GROUP_FULL_COPY);
try {
controller.activateFullCopy(storageSystem.getId(), new ArrayList<URI>(fullCopyURIs), taskId);
} catch (ControllerException ce) {
s_logger.error("Failed to activate volume full copy {}", fullCopyVolume.getId(), ce);
handleFailedRequest(taskId, taskList, new ArrayList<Volume>(fullCopyMap.values()), ce, false);
}
}
return taskList;
}
Aggregations