Search in sources :

Example 91 with FileShare

use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.

the class FileMirrorRollbackCompleter method complete.

@Override
protected void complete(DbClient dbClient, Status status, ServiceCoded serviceCoded) {
    List<FileShare> sourceFileShareList = dbClient.queryObject(FileShare.class, getIds());
    if (sourceFileShareList != null && !sourceFileShareList.isEmpty()) {
        List<FileShare> fileSharesToUpdate = new ArrayList<FileShare>();
        for (FileShare fileShare : sourceFileShareList) {
            if (fileShare.getMirrorfsTargets() != null && !fileShare.getMirrorfsTargets().isEmpty()) {
            // need be to implemented
            }
        }
    }
    super.complete(dbClient, status, serviceCoded);
}
Also used : ArrayList(java.util.ArrayList) FileShare(com.emc.storageos.db.client.model.FileShare)

Example 92 with FileShare

use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.

the class FilePolicyUnAssignWorkflowCompleter method updatePolicyUnAssignedResources.

protected void updatePolicyUnAssignedResources(DbClient dbClient, FilePolicy filePolicy, Status status, ServiceCoded coded) {
    for (URI resourceURI : unassignFromResource) {
        filePolicy.removeAssignedResources(resourceURI);
        FilePolicyApplyLevel applyLevel = FilePolicyApplyLevel.valueOf(filePolicy.getApplyAt());
        switch(applyLevel) {
            case vpool:
                VirtualPool vpool = dbClient.queryObject(VirtualPool.class, resourceURI);
                vpool.removeFilePolicy(filePolicy.getId());
                dbClient.updateObject(vpool);
                break;
            case project:
                Project project = dbClient.queryObject(Project.class, resourceURI);
                project.removeFilePolicy(project, filePolicy.getId());
                dbClient.updateObject(project);
                break;
            case file_system:
                FileShare fs = dbClient.queryObject(FileShare.class, resourceURI);
                fs.removeFilePolicy(filePolicy.getId());
                dbClient.updateObject(fs);
                break;
            default:
                _log.error("Not a valid policy apply level: " + applyLevel);
        }
    }
    if (filePolicy.getAssignedResources() == null || filePolicy.getAssignedResources().isEmpty()) {
        // remove the file policy vpool
        if (!NullColumnValueGetter.isNullURI(filePolicy.getFilePolicyVpool())) {
            filePolicy.setFilePolicyVpool(NullColumnValueGetter.getNullURI());
        }
        // If no other resources are assigned to replication policy
        // Remove the replication topology from the policy
        FileOrchestrationUtils.removeTopologyInfo(filePolicy, dbClient);
    }
    dbClient.updateObject(filePolicy);
}
Also used : Project(com.emc.storageos.db.client.model.Project) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) FilePolicyApplyLevel(com.emc.storageos.db.client.model.FilePolicy.FilePolicyApplyLevel) FileShare(com.emc.storageos.db.client.model.FileShare)

Example 93 with FileShare

use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.

the class FileSystemVpoolChangeCompleter method handleFileShareErrors.

private void handleFileShareErrors(DbClient dbClient) {
    for (FileDescriptor fileDescriptor : FileDescriptor.getDescriptors(_fileDescriptors, FileDescriptor.Type.FILE_DATA)) {
        FileShare fileShare = dbClient.queryObject(FileShare.class, fileDescriptor.getFsURI());
        if (fileShare != null && (fileShare.getNativeId() == null || fileShare.getNativeId().equals(""))) {
            _log.info("No native id was present on FileShare {}, marking inactive", fileShare.getLabel());
            dbClient.markForDeletion(fileShare);
        }
    }
}
Also used : FileShare(com.emc.storageos.db.client.model.FileShare) FileDescriptor(com.emc.storageos.fileorchestrationcontroller.FileDescriptor)

Example 94 with FileShare

use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.

the class MirrorFileFailbackTaskCompleter method complete.

@Override
protected void complete(DbClient dbClient, Status status, ServiceCoded coded) throws DeviceControllerException {
    try {
        setDbClient(dbClient);
        recordMirrorOperation(dbClient, OperationTypeEnum.FAILBACK_FILE_MIRROR, status, getId());
    } catch (Exception e) {
        _log.error("Failed updating status. MirrorSessionFailback {}, for task " + getOpId(), getId(), e);
    } finally {
        if (Operation.Status.error.equals(status)) {
            FileShare fileshare = dbClient.queryObject(FileShare.class, getId());
            fileshare.setMirrorStatus(MirrorStatus.FAILED_OVER.name());
            dbClient.updateObject(fileshare);
        }
        super.complete(dbClient, status, coded);
    }
}
Also used : FileShare(com.emc.storageos.db.client.model.FileShare) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 95 with FileShare

use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method doFailoverLink.

/**
 * perform failover operation
 * systemTarget - failover to target system
 * fs - target filesystem
 * completer - task completer
 *
 * return BiosCommandResult
 */
@Override
public BiosCommandResult doFailoverLink(StorageSystem systemTarget, FileShare fs, TaskCompleter completer) {
    _log.info("IsilonFileStorageDevice -  doFailoverLink started ");
    FileShare sourceFS = null;
    FileShare targetFS = null;
    StorageSystem sourceSystem = null;
    StorageSystem targetSystem = null;
    boolean failback = false;
    if (fs.getPersonality().equals(PersonalityTypes.TARGET.name())) {
        sourceFS = _dbClient.queryObject(FileShare.class, fs.getParentFileShare());
        targetFS = fs;
    } else if (fs.getPersonality().equals(PersonalityTypes.SOURCE.name())) {
        sourceFS = fs;
        List<String> targetfileUris = new ArrayList<String>();
        targetfileUris.addAll(fs.getMirrorfsTargets());
        if (!targetfileUris.isEmpty()) {
            targetFS = _dbClient.queryObject(FileShare.class, URI.create(targetfileUris.get(0)));
        } else {
            ServiceError serviceError = DeviceControllerErrors.isilon.unableToFailoverFileSystem(systemTarget.getIpAddress(), "Unable to get target filesystem for source filesystem " + fs.getName());
            return BiosCommandResult.createErrorResult(serviceError);
        }
        failback = true;
    }
    sourceSystem = _dbClient.queryObject(StorageSystem.class, sourceFS.getStorageDevice());
    targetSystem = _dbClient.queryObject(StorageSystem.class, targetFS.getStorageDevice());
    PolicyStorageResource policyStrRes = getEquivalentPolicyStorageResource(sourceFS, _dbClient);
    if (policyStrRes != null) {
        IsilonSyncPolicy syncPolicy = policyNativeIdValidation(sourceSystem, policyStrRes);
        String policyName = syncPolicy.getName();
        BiosCommandResult cmdResult = null;
        // In case of failback we do failover on the source file system, so we need to append _mirror
        if (failback) {
            String mirrorPolicyName = syncPolicy.getName();
            mirrorPolicyName = mirrorPolicyName.concat(MIRROR_POLICY);
            // prepared policy for failback
            cmdResult = prepareFailbackOp(sourceSystem, policyName);
            if (!cmdResult.isCommandSuccess()) {
                return cmdResult;
            }
            // Call Isilon Api failback job
            return doFailoverMirrorPolicy(sourceSystem, policyName, targetSystem, mirrorPolicyName, completer);
        } else {
            // prepared policy for failover
            cmdResult = prepareFailoverOp(sourceSystem, policyName);
            if (!cmdResult.isCommandSuccess()) {
                _log.info("Unable to stop replication policy on source");
                _log.info("Proceeding with failover anyway");
            }
            // Call Isilon Api failover job
            return mirrorOperations.doFailover(targetSystem, syncPolicy.getId(), completer);
        }
    }
    ServiceError serviceError = DeviceControllerErrors.isilon.unableToFailoverFileSystem(systemTarget.getIpAddress(), "Unable to get the policy details for filesystem :" + fs.getName());
    return BiosCommandResult.createErrorResult(serviceError);
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) IsilonList(com.emc.storageos.isilon.restapi.IsilonApi.IsilonList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource) IsilonSyncPolicy(com.emc.storageos.isilon.restapi.IsilonSyncPolicy) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

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