use of com.emc.storageos.fileorchestrationcontroller.FileDescriptor in project coprhd-controller by CoprHD.
the class FileDeviceController method addStepsForCreateFileSystems.
@Override
public String addStepsForCreateFileSystems(Workflow workflow, String waitFor, List<FileDescriptor> filesystems, String taskId) throws InternalException {
if (filesystems != null && !filesystems.isEmpty()) {
// create source filesystems
List<FileDescriptor> sourceDescriptors = FileDescriptor.filterByType(filesystems, FileDescriptor.Type.FILE_DATA, FileDescriptor.Type.FILE_MIRROR_SOURCE);
for (FileDescriptor sourceDescriptor : sourceDescriptors) {
// create a step
waitFor = workflow.createStep(CREATE_FILESYSTEMS_STEP, String.format("Creating File systems:%n%s", taskId), null, sourceDescriptor.getDeviceURI(), getDeviceType(sourceDescriptor.getDeviceURI()), this.getClass(), createFileSharesMethod(sourceDescriptor), rollbackMethodNullMethod(), null);
}
// create targetFileystems
List<FileDescriptor> targetDescriptors = FileDescriptor.filterByType(filesystems, FileDescriptor.Type.FILE_MIRROR_TARGET);
if (targetDescriptors != null && !targetDescriptors.isEmpty()) {
for (FileDescriptor descriptor : targetDescriptors) {
FileShare fileShare = _dbClient.queryObject(FileShare.class, descriptor.getFsURI());
FileShare fileShareSource = _dbClient.queryObject(FileShare.class, fileShare.getParentFileShare().getURI());
if (fileShare.getParentFileShare() != null) {
waitFor = workflow.createStep(CREATE_FILESYSTEMS_STEP, String.format("Creating Target File systems:%n%s", taskId), waitFor, descriptor.getDeviceURI(), getDeviceType(descriptor.getDeviceURI()), this.getClass(), createFileSharesMethod(descriptor), rollbackCreateFileSharesMethod(fileShareSource.getStorageDevice(), asList(fileShare.getParentFileShare().getURI()), sourceDescriptors), null);
}
}
}
}
// find out which value we should return
return waitFor = CREATE_FILESYSTEMS_STEP;
}
use of com.emc.storageos.fileorchestrationcontroller.FileDescriptor in project coprhd-controller by CoprHD.
the class FileDeviceController method createExpandFileshareStep.
/**
* Expand File System Step
*
* @param workflow
* @param waitFor
* @param fileDescriptors
* @param taskId
* @return
*/
private String createExpandFileshareStep(Workflow workflow, String waitFor, List<FileDescriptor> fileDescriptors, String taskId) {
_log.info("START Expand file system");
Map<URI, Long> filesharesToExpand = new HashMap<URI, Long>();
for (FileDescriptor descriptor : fileDescriptors) {
// Grab the fileshare, let's see if an expand is really needed
FileShare fileShare = _dbClient.queryObject(FileShare.class, descriptor.getFsURI());
// new size > existing fileshare's provisioned capacity, otherwise we can ignore.
if (fileShare.getCapacity() != null && fileShare.getCapacity().longValue() != 0 && descriptor.getFileSize() > fileShare.getCapacity().longValue()) {
filesharesToExpand.put(fileShare.getId(), descriptor.getFileSize());
}
}
Workflow.Method expandMethod = null;
for (Map.Entry<URI, Long> entry : filesharesToExpand.entrySet()) {
_log.info("Creating WF step for Expand FileShare for {}", entry.getKey().toString());
FileShare fileShareToExpand = _dbClient.queryObject(FileShare.class, entry.getKey());
StorageSystem storage = _dbClient.queryObject(StorageSystem.class, fileShareToExpand.getStorageDevice());
Long fileSize = entry.getValue();
expandMethod = expandFileSharesMethod(storage.getId(), fileShareToExpand.getId(), fileSize);
waitFor = workflow.createStep(EXPAND_FILESYSTEMS_STEP, String.format("Expand FileShare %s", fileShareToExpand), waitFor, storage.getId(), storage.getSystemType(), getClass(), expandMethod, null, null);
_log.info("Creating workflow step {}", EXPAND_FILESYSTEMS_STEP);
}
return waitFor;
}
use of com.emc.storageos.fileorchestrationcontroller.FileDescriptor in project coprhd-controller by CoprHD.
the class FileDeviceController method createReduceFileshareStep.
/**
* Reduce File System Step
*
* @param workflow
* @param waitFor
* @param fileDescriptors
* @param taskId
* @return
*/
private String createReduceFileshareStep(Workflow workflow, String waitFor, List<FileDescriptor> fileDescriptors, String taskId) {
_log.info("START Reduce file system");
Map<URI, Long> filesharesToReduce = new HashMap<URI, Long>();
for (FileDescriptor descriptor : fileDescriptors) {
FileShare fileShare = _dbClient.queryObject(FileShare.class, descriptor.getFsURI());
if (fileShare.getCapacity() != null && fileShare.getCapacity().longValue() != 0) {
filesharesToReduce.put(fileShare.getId(), descriptor.getFileSize());
}
}
Workflow.Method reduceMethod = null;
for (Map.Entry<URI, Long> entry : filesharesToReduce.entrySet()) {
_log.info("Creating WF step for Reduce FileShare for {}", entry.getKey().toString());
FileShare fileShareToReduce = _dbClient.queryObject(FileShare.class, entry.getKey());
StorageSystem storage = _dbClient.queryObject(StorageSystem.class, fileShareToReduce.getStorageDevice());
Long fileSize = entry.getValue();
reduceMethod = reduceFileSharesMethod(storage.getId(), fileShareToReduce.getId(), fileSize);
waitFor = workflow.createStep(REDUCE_FILESYSTEMS_STEP, String.format("Reduce FileShare %s", fileShareToReduce), waitFor, storage.getId(), storage.getSystemType(), getClass(), reduceMethod, null, null);
_log.info("Creating workflow step {}", REDUCE_FILESYSTEMS_STEP);
}
return waitFor;
}
use of com.emc.storageos.fileorchestrationcontroller.FileDescriptor in project coprhd-controller by CoprHD.
the class FileReplicationDeviceController method createFileMirrorSession.
/**
* Create Mirror Work Flow Step - creates replication session between source and target
*
* @param workflow
* @param waitFor
* @param sourceDescriptors
* @param uriFileShareMap
* @return
*/
protected String createFileMirrorSession(Workflow workflow, String waitFor, List<FileDescriptor> sourceDescriptors, Map<URI, FileShare> uriFileShareMap) {
for (FileDescriptor sourceDescriptor : sourceDescriptors) {
FileShare source = uriFileShareMap.get(sourceDescriptor.getFsURI());
for (String targetStr : source.getMirrorfsTargets()) {
URI targetURI = URI.create(targetStr);
StorageSystem system = dbClient.queryObject(StorageSystem.class, source.getStorageDevice());
Workflow.Method createMethod = createMirrorFilePairStep(system.getId(), source.getId(), targetURI, null);
Workflow.Method rollbackMethod = rollbackMirrorFilePairMethod(system.getId(), source.getId(), targetURI);
// Ensure CreateElementReplica steps are executed sequentially (CQ613404)
waitFor = workflow.createStep(CREATE_FILE_MIRRORS_STEP, CREATE_FILE_MIRRORS_STEP_DESC, waitFor, system.getId(), system.getSystemType(), getClass(), createMethod, rollbackMethod, null);
}
}
return waitFor = CREATE_FILE_MIRRORS_STEP;
}
use of com.emc.storageos.fileorchestrationcontroller.FileDescriptor in project coprhd-controller by CoprHD.
the class FileMirrorServiceApiImpl method getDescriptorsOfFileShareDeleted.
@Override
protected List<FileDescriptor> getDescriptorsOfFileShareDeleted(URI systemURI, List<URI> fileShareURIs, String deletionType, boolean forceDelete, boolean deleteOnlyMirrors) {
List<FileDescriptor> fileDescriptors = new ArrayList<FileDescriptor>();
for (URI fileURI : fileShareURIs) {
FileShare fileShare = _dbClient.queryObject(FileShare.class, fileURI);
FileDescriptor.Type descriptorType;
if (fileShare.getPersonality() == null || fileShare.getPersonality().contains("null")) {
descriptorType = FileDescriptor.Type.FILE_DATA;
} else if (FileShare.PersonalityTypes.TARGET == getPersonality(fileShare)) {
if (isParentInactiveForTarget(fileShare)) {
descriptorType = FileDescriptor.Type.FILE_DATA;
} else {
_log.warn("Attempted to delete an Mirror target that had an active Mirror source");
throw APIException.badRequests.cannotDeleteMirrorFileShareTargetWithActiveSource(fileURI, fileShare.getParentFileShare().getURI());
}
} else {
descriptorType = FileDescriptor.Type.FILE_MIRROR_SOURCE;
}
FileDescriptor fileDescriptor = new FileDescriptor(descriptorType, fileShare.getStorageDevice(), fileShare.getId(), fileShare.getPool(), deletionType, forceDelete, deleteOnlyMirrors);
fileDescriptors.add(fileDescriptor);
}
return fileDescriptors;
}
Aggregations