use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.
the class ComputeSystemControllerImpl method waitForAsyncFileExportTask.
/**
* Waits for the file export or unexport task to complete.
* This is required because FileDeviceController does not use a workflow.
*
* @param fileShareId
* id of the FileShare being exported
* @param stepId
* id of the workflow step
*/
private void waitForAsyncFileExportTask(URI fileShareId, String stepId) {
boolean done = false;
try {
while (!done) {
Thread.sleep(1000);
FileShare fsObj = _dbClient.queryObject(FileShare.class, fileShareId);
if (fsObj.getOpStatus().containsKey(stepId)) {
Operation op = fsObj.getOpStatus().get(stepId);
if (op.getStatus().equalsIgnoreCase("ready")) {
WorkflowStepCompleter.stepSucceded(stepId);
done = true;
} else if (op.getStatus().equalsIgnoreCase("error")) {
WorkflowStepCompleter.stepFailed(stepId, op.getServiceError());
done = true;
}
}
}
} catch (InterruptedException ex) {
WorkflowStepCompleter.stepFailed(stepId, DeviceControllerException.errors.jobFailed(ex));
}
}
use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.
the class ComputeSystemControllerImpl method addStepsForIpInterfaceFileShares.
public String addStepsForIpInterfaceFileShares(Workflow workflow, String waitFor, URI hostId, URI ipId) {
List<FileShare> fileShares = ComputeSystemHelper.getFileSharesByHost(_dbClient, hostId);
IpInterface ipinterface = _dbClient.queryObject(IpInterface.class, ipId);
List<String> endpoints = Arrays.asList(ipinterface.getIpAddress());
for (FileShare fileShare : fileShares) {
if (fileShare != null && fileShare.getFsExports() != null) {
for (FileExport fileExport : fileShare.getFsExports().values()) {
if (fileExport != null && fileExport.getClients() != null) {
if (fileExportContainsEndpoint(fileExport, endpoints)) {
StorageSystem device = _dbClient.queryObject(StorageSystem.class, fileShare.getStorageDevice());
List<String> clients = fileExport.getClients();
clients.removeAll(endpoints);
fileExport.setStoragePort(fileShare.getStoragePort().toString());
FileShareExport export = new FileShareExport(clients, fileExport.getSecurityType(), fileExport.getPermissions(), fileExport.getRootUserMapping(), fileExport.getProtocol(), fileExport.getStoragePortName(), fileExport.getStoragePort(), fileExport.getPath(), fileExport.getMountPath(), "", "");
if (clients.isEmpty()) {
_log.info("Unexporting file share " + fileShare.getId());
waitFor = workflow.createStep(UNEXPORT_FILESHARE_STEP, String.format("Unexport fileshare %s", fileShare.getId()), waitFor, fileShare.getId(), fileShare.getId().toString(), this.getClass(), unexportFileShareMethod(device.getId(), device.getSystemType(), fileShare.getId(), export), null, null);
} else {
_log.info("Updating export for file share " + fileShare.getId());
waitFor = workflow.createStep(UPDATE_FILESHARE_EXPORT_STEP, String.format("Update fileshare export %s", fileShare.getId()), waitFor, fileShare.getId(), fileShare.getId().toString(), this.getClass(), updateFileShareMethod(device.getId(), device.getSystemType(), fileShare.getId(), export), null, null);
}
}
}
}
}
}
return waitFor;
}
use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.
the class ComputeSystemControllerImpl method unexportFileShare.
public void unexportFileShare(URI deviceId, String systemType, URI fileShareId, FileShareExport export, String stepId) {
WorkflowStepCompleter.stepExecuting(stepId);
FileController fileController = getController(FileController.class, systemType);
FileShare fs = _dbClient.queryObject(FileShare.class, fileShareId);
_dbClient.createTaskOpStatus(FileShare.class, fs.getId(), stepId, ResourceOperationTypeEnum.UNEXPORT_FILE_SYSTEM);
fileController.unexport(deviceId, fileShareId, Arrays.asList(export), stepId);
waitForAsyncFileExportTask(fileShareId, stepId);
}
use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.
the class ComputeSystemHelper method isHostIpInterfacesInUse.
/**
* Checks if an ipInterface in use by a file export
*
* @param ipAddress the interface IP address
* @return true if the ipInterface in use by a file export
*/
public static boolean isHostIpInterfacesInUse(DbClient dbClient, List<String> endpoints, URI hostId) {
if (endpoints == null || endpoints.isEmpty()) {
return false;
}
Host host = dbClient.queryObject(Host.class, hostId);
List<FileShare> fileShares = null;
if (!NullColumnValueGetter.isNullURI(host.getProject())) {
fileShares = CustomQueryUtility.queryActiveResourcesByRelation(dbClient, host.getProject(), FileShare.class, "project");
} else if (!NullColumnValueGetter.isNullURI(host.getTenant())) {
fileShares = CustomQueryUtility.queryActiveResourcesByRelation(dbClient, host.getTenant(), FileShare.class, "tenant");
}
if (fileShares == null || fileShares.isEmpty()) {
return false;
}
for (FileShare fileShare : fileShares) {
if (fileShare != null && fileShare.getFsExports() != null) {
for (FileExport fileExport : fileShare.getFsExports().values()) {
if (fileExport != null && fileExport.getClients() != null) {
for (String endpoint : endpoints) {
if (fileExport.getClients().contains(endpoint)) {
return true;
}
}
}
}
}
}
return false;
}
use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.
the class UnManagedFilesystemService method recordBourneFileSystemEvent.
/**
* Generate and Record a Bourne filesystem specific event
*
* @param dbClient
* @param evtType
* @param status
* @param desc
* @throws Exception
*/
public void recordBourneFileSystemEvent(DbClient dbClient, String evtType, Operation.Status status, String desc, URI id) throws Exception {
RecordableEventManager eventManager = new RecordableEventManager();
eventManager.setDbClient(dbClient);
FileShare fileShareObj = dbClient.queryObject(FileShare.class, id);
RecordableBourneEvent event = ControllerUtils.convertToRecordableBourneEvent(fileShareObj, evtType, desc, "", dbClient, EVENT_SERVICE_TYPE, RecordType.Event.name(), EVENT_SERVICE_SOURCE);
try {
eventManager.recordEvents(event);
_logger.info("ViPR {} event recorded", evtType);
} catch (Exception ex) {
_logger.error("Failed to record event. Event description: {}. Error:", evtType, ex);
}
}
Aggregations