Search in sources :

Example 6 with FileDeviceInputOutput

use of com.emc.storageos.volumecontroller.FileDeviceInputOutput in project coprhd-controller by CoprHD.

the class FileDeviceController method reduceFS.

@Override
public void reduceFS(URI storage, URI uri, long newFSsize, String opId) throws ControllerException {
    ControllerUtils.setThreadLocalLogData(uri, opId);
    FileShare fs = null;
    StoragePool pool = null;
    StorageSystem storageObj = null;
    FileDeviceInputOutput args = new FileDeviceInputOutput();
    try {
        fs = _dbClient.queryObject(FileShare.class, uri);
        pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
        storageObj = _dbClient.queryObject(StorageSystem.class, storage);
        args.addFSFileObject(fs);
        args.addStoragePool(pool);
        args.setFileOperation(true);
        args.setNewFSCapacity(newFSsize);
        args.setOpId(opId);
        // work flow and we need to add TaskCompleter
        WorkflowStepCompleter.stepExecuting(opId);
        acquireStepLock(storageObj, opId);
        BiosCommandResult result = getDevice(storageObj.getSystemType()).doReduceFS(storageObj, args);
        if (result.getCommandPending()) {
            // async operation
            return;
        }
        if (result.isCommandSuccess()) {
            _log.info("FileSystem old capacity :" + args.getFsCapacity() + ":Reduced Size:" + args.getNewFSCapacity());
            args.setFsCapacity(args.getNewFSCapacity());
            WorkflowStepCompleter.stepSucceded(opId);
        } else if (!result.getCommandPending()) {
            WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
        }
        if (!result.isCommandSuccess() && !result.getCommandPending()) {
            WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
        }
        // Set status
        fs.getOpStatus().updateTaskStatus(opId, result.toOperation());
        _dbClient.updateObject(fs);
        String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
        recordFileDeviceOperation(_dbClient, OperationTypeEnum.REDUCE_FILE_SYSTEM, result.isCommandSuccess(), eventMsg, "", fs, String.valueOf(newFSsize));
    } catch (Exception e) {
        String[] params = { storage.toString(), uri.toString(), String.valueOf(newFSsize), e.getMessage() };
        _log.error("Unable to reduce file system: storage {}, FS URI {}, size {}: {}", params);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
        updateTaskStatus(opId, fs, e);
        if (fs != null) {
            recordFileDeviceOperation(_dbClient, OperationTypeEnum.REDUCE_FILE_SYSTEM, false, e.getMessage(), "", fs, String.valueOf(newFSsize));
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) FileDeviceInputOutput(com.emc.storageos.volumecontroller.FileDeviceInputOutput) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 7 with FileDeviceInputOutput

use of com.emc.storageos.volumecontroller.FileDeviceInputOutput in project coprhd-controller by CoprHD.

the class FileDeviceController method assignFileSnapshotPolicyToProjects.

@Override
public void assignFileSnapshotPolicyToProjects(URI storageSystemURI, URI vNASURI, URI filePolicyToAssign, URI vpoolURI, URI projectURI, String opId) throws InternalException {
    try {
        WorkflowStepCompleter.stepExecuting(opId);
        FileDeviceInputOutput args = new FileDeviceInputOutput();
        StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storageSystemURI);
        FilePolicy filePolicy = _dbClient.queryObject(FilePolicy.class, filePolicyToAssign);
        VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, vpoolURI);
        Project project = _dbClient.queryObject(Project.class, projectURI);
        TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, project.getTenantOrg());
        if (vNASURI != null) {
            VirtualNAS vNAS = _dbClient.queryObject(VirtualNAS.class, vNASURI);
            args.setvNAS(vNAS);
        }
        args.setFileProtectionPolicy(filePolicy);
        args.setVPool(vpool);
        args.setProject(project);
        args.setTenantOrg(tenant);
        _log.info("Assigning file snapshot policy: {} to vpool {} and project: {}", filePolicyToAssign, vpoolURI, projectURI);
        BiosCommandResult result = getDevice(storageObj.getSystemType()).checkFilePolicyExistsOrCreate(storageObj, args);
        if (result.getCommandPending()) {
            return;
        }
        if (!result.isCommandSuccess() && !result.getCommandPending()) {
            WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
        }
        if (result.isCommandSuccess()) {
            WorkflowStepCompleter.stepSucceded(opId);
        }
    } catch (Exception e) {
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
    }
}
Also used : Project(com.emc.storageos.db.client.model.Project) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) FilePolicy(com.emc.storageos.db.client.model.FilePolicy) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) FileDeviceInputOutput(com.emc.storageos.volumecontroller.FileDeviceInputOutput) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 8 with FileDeviceInputOutput

use of com.emc.storageos.volumecontroller.FileDeviceInputOutput in project coprhd-controller by CoprHD.

the class FileDeviceController method deleteQuotaDirectory.

@Override
public void deleteQuotaDirectory(URI storage, URI quotaDir, URI fs, String task) throws ControllerException {
    FileShare fsObj = null;
    QuotaDirectory quotaDirObj = null;
    try {
        String[] params = { storage.toString(), quotaDir.toString(), fs.toString() };
        _log.info("FileDeviceController::deleteQuotaDirectory: storage : {}, quotadir : {}, fs : {}", params);
        StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
        fsObj = _dbClient.queryObject(FileShare.class, fs);
        quotaDirObj = _dbClient.queryObject(QuotaDirectory.class, quotaDir);
        FileDeviceInputOutput args = new FileDeviceInputOutput();
        args.addFSFileObject(fsObj);
        args.addQuotaDirectory(quotaDirObj);
        args.setOpId(task);
        FileStorageDevice nasDevice = getDevice(storageObj.getSystemType());
        BiosCommandResult result = nasDevice.doDeleteQuotaDirectory(storageObj, args);
        if (result.getCommandPending()) {
            return;
        }
        fsObj.getOpStatus().updateTaskStatus(task, result.toOperation());
        quotaDirObj.getOpStatus().updateTaskStatus(task, result.toOperation());
        String fsName = fsObj.getName();
        quotaDirObj.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(_dbClient, quotaDirObj, fsName));
        if (!result.isCommandSuccess()) {
            _log.error("FileDeviceController::deleteQuotaDirectory: command is not successfull");
        } else {
            // If delete operation is successful, then remove obj from ViPR db by setting inactive=true
            quotaDirObj.setInactive(true);
        }
        // save the task status in db
        _dbClient.updateObject(quotaDirObj);
        _dbClient.updateObject(fsObj);
        fsObj = _dbClient.queryObject(FileShare.class, fs);
        _log.debug("FileDeviceController::deleteQuotaDirectory: After deleteQuotaDirectory created and fs persisted, Task Stauts {} -- Operation Details : {}", fsObj.getOpStatus().get(task).getStatus(), result.toOperation());
        String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
        recordFileDeviceOperation(_dbClient, OperationTypeEnum.DELETE_FILE_SYSTEM_QUOTA_DIR, result.isCommandSuccess(), eventMsg, "", quotaDirObj, fsObj);
    } catch (Exception e) {
        String[] params = { storage.toString(), fs.toString(), quotaDir.toString(), e.getMessage() };
        _log.error("FileDeviceController::deleteQuotaDirectory: Unable to create file system quota dir: storage {}, FS {}, quotadir {}: {}", params);
        updateTaskStatus(task, fsObj, e);
        updateTaskStatus(task, quotaDirObj, e);
        if ((fsObj != null) && (quotaDirObj != null)) {
            recordFileDeviceOperation(_dbClient, OperationTypeEnum.DELETE_FILE_SYSTEM_QUOTA_DIR, false, e.getMessage(), "", quotaDirObj, fsObj);
        }
    }
}
Also used : QuotaDirectory(com.emc.storageos.db.client.model.QuotaDirectory) FileShareQuotaDirectory(com.emc.storageos.volumecontroller.FileShareQuotaDirectory) FileStorageDevice(com.emc.storageos.volumecontroller.FileStorageDevice) FileDeviceInputOutput(com.emc.storageos.volumecontroller.FileDeviceInputOutput) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 9 with FileDeviceInputOutput

use of com.emc.storageos.volumecontroller.FileDeviceInputOutput in project coprhd-controller by CoprHD.

the class FileDeviceController method assignFileSystemSnapshotPolicy.

@Override
public void assignFileSystemSnapshotPolicy(URI storage, URI fsURI, URI policy, String opId) throws InternalException {
    ControllerUtils.setThreadLocalLogData(fsURI, opId);
    FileDeviceInputOutput args = new FileDeviceInputOutput();
    FileShare fs = null;
    try {
        fs = _dbClient.queryObject(FileShare.class, fsURI);
        SchedulePolicy fp = _dbClient.queryObject(SchedulePolicy.class, policy);
        if (fs != null && fp != null) {
            StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
            _log.info("Controller Recieved File Policy  {}", policy);
            args.addFSFileObject(fs);
            args.setFileSystemPath(fs.getPath());
            StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
            args.addStoragePool(pool);
            args.addFilePolicy(fp);
            args.setFileOperation(true);
            args.setOpId(opId);
            // Do the Operation on device.
            BiosCommandResult result = getDevice(storageObj.getSystemType()).assignFilePolicy(storageObj, args);
            if (result.isCommandSuccess()) {
                // Update FS database
                StringSet fpolicies = fs.getFilePolicies();
                fpolicies.add(fp.getId().toString());
                fs.setFilePolicies(fpolicies);
                // Update SchedulePolicy database
                StringSet resources = fp.getAssignedResources();
                resources.add(fs.getId().toString());
                fp.setAssignedResources(resources);
            }
            if (result.getCommandPending()) {
                return;
            }
            // Audit & Update the task status
            OperationTypeEnum auditType = null;
            auditType = OperationTypeEnum.ASSIGN_FILE_SYSTEM_SNAPSHOT_SCHEDULE;
            fs.getOpStatus().updateTaskStatus(opId, result.toOperation());
            // Monitoring - Event Processing
            String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
            recordFileDeviceOperation(_dbClient, auditType, result.isCommandSuccess(), eventMsg, args.getFileSystemPath(), fs, fp);
            _dbClient.updateObject(fs);
            _dbClient.updateObject(fp);
        } else {
            throw DeviceControllerException.exceptions.invalidObjectNull();
        }
    } catch (Exception e) {
        String[] params = { storage.toString(), fsURI.toString(), e.getMessage() };
        _log.error("Unable to assign policy : storage {}, FS URI {},: Error {}", params);
        updateTaskStatus(opId, fs, e);
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) OperationTypeEnum(com.emc.storageos.services.OperationTypeEnum) StringSet(com.emc.storageos.db.client.model.StringSet) FileDeviceInputOutput(com.emc.storageos.volumecontroller.FileDeviceInputOutput) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) SchedulePolicy(com.emc.storageos.db.client.model.SchedulePolicy) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 10 with FileDeviceInputOutput

use of com.emc.storageos.volumecontroller.FileDeviceInputOutput in project coprhd-controller by CoprHD.

the class FileDeviceController method assignFileReplicationPolicyToVirtualPools.

@Override
public void assignFileReplicationPolicyToVirtualPools(URI storageSystemURI, URI targetSystemURI, URI sourceVNasURI, URI targetVArrayURI, URI targetVNasURI, URI filePolicyToAssign, URI vpoolURI, String opId) throws ControllerException {
    try {
        WorkflowStepCompleter.stepExecuting(opId);
        StorageSystem sourceSystem = _dbClient.queryObject(StorageSystem.class, storageSystemURI);
        StorageSystem targetSystem = _dbClient.queryObject(StorageSystem.class, targetSystemURI);
        FilePolicy filePolicy = _dbClient.queryObject(FilePolicy.class, filePolicyToAssign);
        VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, vpoolURI);
        VirtualArray targetVarray = _dbClient.queryObject(VirtualArray.class, targetVArrayURI);
        VirtualNAS sourceVNAS = null;
        VirtualNAS targetVNAS = null;
        FileDeviceInputOutput sourceArgs = new FileDeviceInputOutput();
        FileDeviceInputOutput targetArgs = new FileDeviceInputOutput();
        targetArgs.setVarray(targetVarray);
        sourceArgs.setFileProtectionPolicy(filePolicy);
        sourceArgs.setVPool(vpool);
        if (sourceVNasURI != null) {
            sourceVNAS = _dbClient.queryObject(VirtualNAS.class, sourceVNasURI);
            sourceArgs.setvNAS(sourceVNAS);
            targetArgs.setSourceVNAS(sourceVNAS);
        }
        targetArgs.setSourceSystem(sourceSystem);
        targetArgs.setVPool(vpool);
        targetArgs.setTarget(true);
        if (targetVNasURI != null) {
            targetVNAS = _dbClient.queryObject(VirtualNAS.class, targetVNasURI);
            targetArgs.setvNAS(targetVNAS);
        }
        _log.info("Assigning file replication policy: {} to vpool: {}", filePolicyToAssign, vpoolURI);
        BiosCommandResult result = getDevice(sourceSystem.getSystemType()).checkFileReplicationPolicyExistsOrCreate(sourceSystem, targetSystem, sourceArgs, targetArgs);
        if (result.getCommandPending()) {
            return;
        }
        if (!result.isCommandSuccess() && !result.getCommandPending()) {
            WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
        }
        if (result.isCommandSuccess()) {
            WorkflowStepCompleter.stepSucceded(opId);
        }
    } catch (Exception e) {
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) FilePolicy(com.emc.storageos.db.client.model.FilePolicy) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) FileDeviceInputOutput(com.emc.storageos.volumecontroller.FileDeviceInputOutput) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

FileDeviceInputOutput (com.emc.storageos.volumecontroller.FileDeviceInputOutput)48 FileShare (com.emc.storageos.db.client.model.FileShare)33 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)33 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)32 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)32 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)32 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)32 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)32 ControllerException (com.emc.storageos.volumecontroller.ControllerException)32 WorkflowException (com.emc.storageos.workflow.WorkflowException)32 URISyntaxException (java.net.URISyntaxException)32 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)25 StoragePool (com.emc.storageos.db.client.model.StoragePool)16 Snapshot (com.emc.storageos.db.client.model.Snapshot)15 FileObject (com.emc.storageos.db.client.model.FileObject)14 ArrayList (java.util.ArrayList)14 Test (org.junit.Test)11 FilePolicy (com.emc.storageos.db.client.model.FilePolicy)10 OperationTypeEnum (com.emc.storageos.services.OperationTypeEnum)9 FileExport (com.emc.storageos.db.client.model.FileExport)7