Search in sources :

Example 81 with FileShare

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));
    }
}
Also used : InitiatorOperation(com.emc.storageos.computesystemcontroller.impl.InitiatorCompleter.InitiatorOperation) Operation(com.emc.storageos.db.client.model.Operation) FileShare(com.emc.storageos.db.client.model.FileShare)

Example 82 with FileShare

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;
}
Also used : FileShareExport(com.emc.storageos.volumecontroller.FileShareExport) IpInterface(com.emc.storageos.db.client.model.IpInterface) FileExport(com.emc.storageos.db.client.model.FileExport) FileShare(com.emc.storageos.db.client.model.FileShare) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 83 with FileShare

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);
}
Also used : FileController(com.emc.storageos.volumecontroller.FileController) FileShare(com.emc.storageos.db.client.model.FileShare)

Example 84 with FileShare

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;
}
Also used : FileExport(com.emc.storageos.db.client.model.FileExport) Host(com.emc.storageos.db.client.model.Host) FileShare(com.emc.storageos.db.client.model.FileShare)

Example 85 with FileShare

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);
    }
}
Also used : RecordableBourneEvent(com.emc.storageos.volumecontroller.impl.monitoring.RecordableBourneEvent) RecordableEventManager(com.emc.storageos.volumecontroller.impl.monitoring.RecordableEventManager) FileShare(com.emc.storageos.db.client.model.FileShare) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) IOException(java.io.IOException)

Aggregations

FileShare (com.emc.storageos.db.client.model.FileShare)289 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)155 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)107 URI (java.net.URI)93 ArrayList (java.util.ArrayList)79 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)73 ControllerException (com.emc.storageos.volumecontroller.ControllerException)65 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)61 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)57 Operation (com.emc.storageos.db.client.model.Operation)56 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)56 URISyntaxException (java.net.URISyntaxException)56 Path (javax.ws.rs.Path)56 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)52 Produces (javax.ws.rs.Produces)51 Snapshot (com.emc.storageos.db.client.model.Snapshot)50 MapFileShare (com.emc.storageos.api.mapper.functions.MapFileShare)49 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)45 WorkflowException (com.emc.storageos.workflow.WorkflowException)42 NamedURI (com.emc.storageos.db.client.model.NamedURI)36