Search in sources :

Example 1 with VirtualNAS

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

the class FileDeviceController method setVirtualNASinArgs.

/**
 * Set is the vNAS entity in args only if vNASURI is not null
 *
 * @param vNASURI
 *            the URI of VirtualNAS
 * @param args
 *            instance of FileDeviceInputOutput
 */
private void setVirtualNASinArgs(URI vNASURI, FileDeviceInputOutput args) {
    if (vNASURI != null) {
        VirtualNAS vNAS = _dbClient.queryObject(VirtualNAS.class, vNASURI);
        args.setvNAS(vNAS);
    }
}
Also used : VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS)

Example 2 with VirtualNAS

use of com.emc.storageos.db.client.model.VirtualNAS 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 3 with VirtualNAS

use of com.emc.storageos.db.client.model.VirtualNAS 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)

Example 4 with VirtualNAS

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

the class FileDeviceController method updateNFSAcl.

@Override
public void updateNFSAcl(URI storage, URI fsURI, NfsACLUpdateParams param, String opId) throws InternalException {
    ControllerUtils.setThreadLocalLogData(fsURI, opId);
    FileObject fsObj = null;
    FileDeviceInputOutput args = new FileDeviceInputOutput();
    FileShare fs = null;
    Snapshot snapshotObj = null;
    boolean isFile = false;
    try {
        StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
        args.setSubDirectory(param.getSubDir());
        args.setAllNfsAcls(param);
        _log.info("Controller Recieved NfsACLUpdateParams {}", param);
        // File
        if (URIUtil.isType(fsURI, FileShare.class)) {
            isFile = true;
            fs = _dbClient.queryObject(FileShare.class, fsURI);
            fsObj = fs;
            args.addFSFileObject(fs);
            args.setFileSystemPath(fs.getPath());
            StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
            args.addStoragePool(pool);
        } else {
            // Snapshot
            snapshotObj = _dbClient.queryObject(Snapshot.class, fsURI);
            fsObj = snapshotObj;
            fs = _dbClient.queryObject(FileShare.class, snapshotObj.getParent());
            args.addFileShare(fs);
            args.setFileSystemPath(fs.getPath());
            args.addSnapshotFileObject(snapshotObj);
            StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
            args.addStoragePool(pool);
        }
        if (fs.getVirtualNAS() != null) {
            VirtualNAS vNas = _dbClient.queryObject(VirtualNAS.class, fs.getVirtualNAS());
            if (vNas != null && !vNas.getInactive()) {
                args.setvNAS(vNas);
            }
        }
        args.setFileOperation(isFile);
        args.setOpId(opId);
        // Do the Operation on device.
        BiosCommandResult result = getDevice(storageObj.getSystemType()).updateNfsACLs(storageObj, args);
        if (result.isCommandSuccess()) {
            // Update Database
            updateNFSACLsInDB(param, fs, args);
            WorkflowStepCompleter.stepSucceded(opId);
        }
        if (result.getCommandPending()) {
            return;
        }
        if (!result.isCommandSuccess() && !result.getCommandPending()) {
            WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
        }
        // Audit & Update the task status
        OperationTypeEnum auditType = null;
        auditType = (isFile) ? OperationTypeEnum.UPDATE_FILE_SYSTEM_NFS_ACL : OperationTypeEnum.UPDATE_FILE_SNAPSHOT_NFS_ACL;
        fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
        // Monitoring - Event Processing
        String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
        if (isFile) {
            recordFileDeviceOperation(_dbClient, auditType, result.isCommandSuccess(), eventMsg, args.getFileSystemPath(), fs, storageObj);
        } else {
            recordFileDeviceOperation(_dbClient, auditType, result.isCommandSuccess(), eventMsg, args.getFileSystemPath(), snapshotObj, fs, storageObj);
        }
        _dbClient.updateObject(fsObj);
    } catch (Exception e) {
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
        String[] params = { storage.toString(), fsURI.toString() };
        _log.error("Unable to set ACL on  file system or snapshot: storage {}, FS/snapshot URI {}", params, e);
        _log.error("{}, {} ", e.getMessage(), e);
        updateTaskStatus(opId, fsObj, e);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) OperationTypeEnum(com.emc.storageos.services.OperationTypeEnum) 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) Snapshot(com.emc.storageos.db.client.model.Snapshot) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) FileObject(com.emc.storageos.db.client.model.FileObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 5 with VirtualNAS

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

the class StoragePortAssociationHelper method runUpdateVirtualNasAssociationsProcess.

/**
 * This method is responsible for
 * Assign the virtual arrays of storage port to virtual nas
 *
 * @param ports
 * @param remPorts
 * @param dbClient
 * @param coordinator
 * @throws IOException
 */
public static void runUpdateVirtualNasAssociationsProcess(Collection<StoragePort> ports, Collection<StoragePort> remPorts, DbClient dbClient) {
    try {
        List<VirtualNAS> modifiedServers = new ArrayList<VirtualNAS>();
        if (ports != null && !ports.isEmpty()) {
            // for better reading, added a method to group Ports by Network
            Map<String, List<NetworkLite>> vNasNetworkMap = getVNasNetworksMap(ports, dbClient);
            if (!vNasNetworkMap.isEmpty()) {
                for (Map.Entry<String, List<NetworkLite>> vNasEntry : vNasNetworkMap.entrySet()) {
                    String nativeId = vNasEntry.getKey();
                    VirtualNAS vNas = findvNasByNativeId(nativeId, dbClient);
                    if (vNas != null) {
                        for (NetworkLite network : vNasEntry.getValue()) {
                            Set<String> varraySet = new HashSet<String>(network.getAssignedVirtualArrays());
                            if (vNas.getAssignedVirtualArrays() == null) {
                                vNas.setAssignedVirtualArrays(new StringSet());
                            }
                            vNas.getAssignedVirtualArrays().addAll(varraySet);
                            _log.info("found virtual NAS: {} and varrays: {}", vNas.getNasName(), varraySet.toString());
                        }
                        modifiedServers.add(vNas);
                    }
                }
            }
        }
        if (!modifiedServers.isEmpty()) {
            dbClient.persistObject(modifiedServers);
        }
    } catch (Exception e) {
        _log.error("Update Port Association process failed", e);
    }
}
Also used : NetworkLite(com.emc.storageos.util.NetworkLite) ArrayList(java.util.ArrayList) IOException(java.io.IOException) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Aggregations

VirtualNAS (com.emc.storageos.db.client.model.VirtualNAS)54 URI (java.net.URI)26 ArrayList (java.util.ArrayList)19 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)18 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)16 StringSet (com.emc.storageos.db.client.model.StringSet)15 PhysicalNAS (com.emc.storageos.db.client.model.PhysicalNAS)9 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)9 List (java.util.List)9 StoragePort (com.emc.storageos.db.client.model.StoragePort)8 URISyntaxException (java.net.URISyntaxException)8 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)7 FileDeviceInputOutput (com.emc.storageos.volumecontroller.FileDeviceInputOutput)7 Project (com.emc.storageos.db.client.model.Project)6 StringMap (com.emc.storageos.db.client.model.StringMap)6 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)6 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)6 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)6 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)6 ControllerException (com.emc.storageos.volumecontroller.ControllerException)6