Search in sources :

Example 51 with VirtualNAS

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

the class FileStorageScheduler method placeFileShareExport.

/**
 * Select storage port for exporting file share to the given client. One IP
 * transport zone per varray. Selects only one storage port for all exports
 * of a file share
 *
 * @param fs
 *            file share being exported
 * @param protocol
 *            file storage protocol for this export
 * @param clients
 *            client network address or name
 * @return storgaePort
 * @throws badRequestException
 */
public StoragePort placeFileShareExport(FileShare fs, String protocol, List<String> clients) {
    StoragePort sp;
    if (fs.getStoragePort() == null) {
        _log.info("Placement for file system {} with no assigned port.", fs.getName());
        // if no storage port is selected yet, select one and record the
        // selection
        List<StoragePort> ports = getStorageSystemPortsInVarray(fs.getStorageDevice(), fs.getVirtualArray());
        StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, fs.getStorageDevice());
        if (Type.isilon.name().equals(storageSystem.getSystemType())) {
            if (ports != null && !ports.isEmpty()) {
                // Check if these ports are associated with vNAS
                for (Iterator<StoragePort> iterator = ports.iterator(); iterator.hasNext(); ) {
                    StoragePort storagePort = iterator.next();
                    List<VirtualNAS> vNASList = StoragePortAssociationHelper.getStoragePortVirtualNAS(storagePort, _dbClient);
                    if (vNASList != null && !vNASList.isEmpty()) {
                        /*
                             * Remove the associated port. Because during file system placement,
                             * storage port will already be assigned to FS. In that case, this block won't
                             * be executed.
                             */
                        _log.info("Removing port {} as it is assigned to a vNAS.", storagePort.getNativeGuid());
                        iterator.remove();
                    }
                }
            }
        }
        // required)
        if ((null != protocol) && (!protocol.isEmpty())) {
            getPortsWithFileSharingProtocol(protocol, ports);
        }
        if (ports == null || ports.isEmpty()) {
            _log.error(MessageFormat.format("There are no active and registered storage ports assigned to virtual array {0}", fs.getVirtualArray()));
            throw APIException.badRequests.noStoragePortFoundForVArray(fs.getVirtualArray().toString());
        }
        Collections.shuffle(ports);
        sp = ports.get(0);
        // update storage port selections for file share exports
        fs.setStoragePort(sp.getId());
        fs.setPortName(sp.getPortName());
        _dbClient.persistObject(fs);
    } else {
        // if a storage port is already selected for the fileshare, use that
        // port for all exports
        sp = _dbClient.queryObject(StoragePort.class, fs.getStoragePort());
        _log.info("Placement for file system {} with port {}.", fs.getName(), sp.getPortName());
        // verify port supports new request.
        if ((null != protocol) && (!protocol.isEmpty())) {
            List<StoragePort> ports = new ArrayList<StoragePort>();
            ports.add(sp);
            getPortsWithFileSharingProtocol(protocol, ports);
            if (ports.isEmpty()) {
                _log.error(MessageFormat.format("There are no active and registered storage ports assigned to virtual array {0}", fs.getVirtualArray()));
                throw APIException.badRequests.noStoragePortFoundForVArray(fs.getVirtualArray().toString());
            }
        }
    }
    return sp;
}
Also used : VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 52 with VirtualNAS

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

the class FileDeviceController method assignFileSnapshotPolicyToVirtualPools.

@Override
public void assignFileSnapshotPolicyToVirtualPools(URI storageSystemURI, URI vNASURI, URI filePolicyToAssign, URI vpoolURI, String opId) throws ControllerException {
    StorageSystem storageObj = null;
    FilePolicy filePolicy = null;
    VirtualNAS vNAS = null;
    VirtualPool vpool = null;
    try {
        WorkflowStepCompleter.stepExecuting(opId);
        FileDeviceInputOutput args = new FileDeviceInputOutput();
        storageObj = _dbClient.queryObject(StorageSystem.class, storageSystemURI);
        filePolicy = _dbClient.queryObject(FilePolicy.class, filePolicyToAssign);
        vpool = _dbClient.queryObject(VirtualPool.class, vpoolURI);
        if (vNASURI != null) {
            vNAS = _dbClient.queryObject(VirtualNAS.class, vNASURI);
            args.setvNAS(vNAS);
        }
        args.setFileProtectionPolicy(filePolicy);
        args.setVPool(vpool);
        _log.info("Assigning file snapshot policy: {} to vpool: {}", filePolicyToAssign, vpoolURI);
        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 : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) 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 53 with VirtualNAS

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

the class FileDeviceController method checkFilePolicyPathHasResourceLabel.

@Override
public void checkFilePolicyPathHasResourceLabel(URI storage, URI filePolicyURI, URI nasURI, URI vpoolURI, URI projectURI, String opId) {
    try {
        WorkflowStepCompleter.stepExecuting(opId);
        StorageSystem system = _dbClient.queryObject(StorageSystem.class, storage);
        FileDeviceInputOutput args = new FileDeviceInputOutput();
        FilePolicy filePolicy = _dbClient.queryObject(FilePolicy.class, filePolicyURI);
        args.setFileProtectionPolicy(filePolicy);
        if (vpoolURI != null) {
            VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, vpoolURI);
            args.setVPool(vpool);
        }
        if (projectURI != null) {
            Project project = _dbClient.queryObject(Project.class, projectURI);
            TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, project.getTenantOrg());
            args.setProject(project);
            args.setTenantOrg(tenant);
        }
        if (nasURI != null) {
            if (URIUtil.isType(nasURI, VirtualNAS.class)) {
                VirtualNAS vNAS = _dbClient.queryObject(VirtualNAS.class, nasURI);
                args.setvNAS(vNAS);
            }
        }
        BiosCommandResult result = getDevice(system.getSystemType()).checkFilePolicyPathHasResourceLabel(system, 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 error = DeviceControllerException.errors.jobFailed(e);
        _log.error("Error occured while checking policy path has resorce label.", e);
        WorkflowStepCompleter.stepFailed(opId, error);
    }
}
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 54 with VirtualNAS

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

the class FileDeviceController method assignFileReplicationPolicyToProjects.

@Override
public void assignFileReplicationPolicyToProjects(URI storageSystemURI, URI targetSystemURI, URI sourceVNasURI, URI targetVArrayURI, URI targetVNasURI, URI filePolicyToAssign, URI vpoolURI, URI projectURI, String opId) throws InternalException {
    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);
        Project project = _dbClient.queryObject(Project.class, projectURI);
        TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, project.getTenantOrg());
        VirtualArray targetVarray = _dbClient.queryObject(VirtualArray.class, targetVArrayURI);
        VirtualNAS sourceVNAS = null;
        VirtualNAS targetVNAS = null;
        FileDeviceInputOutput sourceArgs = new FileDeviceInputOutput();
        FileDeviceInputOutput targetArgs = new FileDeviceInputOutput();
        sourceArgs.setFileProtectionPolicy(filePolicy);
        sourceArgs.setVPool(vpool);
        sourceArgs.setProject(project);
        sourceArgs.setTenantOrg(tenant);
        targetArgs.setVarray(targetVarray);
        if (sourceVNasURI != null) {
            sourceVNAS = _dbClient.queryObject(VirtualNAS.class, sourceVNasURI);
            sourceArgs.setvNAS(sourceVNAS);
            targetArgs.setSourceVNAS(sourceVNAS);
        }
        targetArgs.setTarget(true);
        targetArgs.setSourceSystem(sourceSystem);
        targetArgs.setVPool(vpool);
        targetArgs.setProject(project);
        targetArgs.setTenantOrg(tenant);
        if (targetVNasURI != null) {
            targetVNAS = _dbClient.queryObject(VirtualNAS.class, targetVNasURI);
            targetArgs.setvNAS(targetVNAS);
        }
        _log.info("Assigning file snapshot policy: {} to vpool {} and project: {}", filePolicyToAssign, vpoolURI, projectURI);
        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 : Project(com.emc.storageos.db.client.model.Project) 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) 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)

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