Search in sources :

Example 36 with VirtualNAS

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

the class FileOrchestrationUtils method getTargetHostPortForReplication.

public static String getTargetHostPortForReplication(DbClient dbClient, URI targetStorageSystemURI, URI targetVarrayURI, URI targetVNasURI) {
    StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, targetStorageSystemURI);
    String targetHost = targetSystem.getIpAddress();
    StringSet targetNasVarraySet = null;
    StringSet targetStoragePortSet = null;
    if (targetVNasURI != null) {
        VirtualNAS targetVNas = dbClient.queryObject(VirtualNAS.class, targetVNasURI);
        targetStoragePortSet = targetVNas.getStoragePorts();
        targetNasVarraySet = targetVNas.getTaggedVirtualArrays();
    } else {
        PhysicalNAS pNAS = FileOrchestrationUtils.getSystemPhysicalNAS(dbClient, targetSystem);
        targetStoragePortSet = pNAS.getStoragePorts();
        targetNasVarraySet = pNAS.getTaggedVirtualArrays();
    }
    List<String> drPorts = new ArrayList<String>();
    for (String nasPort : targetStoragePortSet) {
        StoragePort port = dbClient.queryObject(StoragePort.class, URI.create(nasPort));
        if (port != null && !port.getInactive()) {
            StringSet varraySet = port.getTaggedVirtualArrays();
            if (varraySet == null || !varraySet.contains(targetVarrayURI.toString())) {
                continue;
            }
            if (targetNasVarraySet != null) {
                if (!targetNasVarraySet.contains(targetVarrayURI.toString())) {
                    continue;
                }
            }
            targetHost = port.getPortNetworkId();
            // iterate until dr port found!!
            if (port.getTag() != null) {
                ScopedLabelSet portTagSet = port.getTag();
                if (portTagSet != null && !portTagSet.isEmpty()) {
                    for (ScopedLabel tag : portTagSet) {
                        if ("dr_port".equals(tag.getLabel())) {
                            _log.info("DR port {} found from storage system {} for replication", port.getPortNetworkId(), targetSystem.getLabel());
                            drPorts.add(port.getPortNetworkId());
                        }
                    }
                }
            }
        }
    }
    if (!drPorts.isEmpty()) {
        Collections.shuffle(drPorts);
        return drPorts.get(0);
    }
    return targetHost;
}
Also used : VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) ScopedLabel(com.emc.storageos.db.client.model.ScopedLabel) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) StoragePort(com.emc.storageos.db.client.model.StoragePort) PhysicalNAS(com.emc.storageos.db.client.model.PhysicalNAS) ScopedLabelSet(com.emc.storageos.db.client.model.ScopedLabelSet) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 37 with VirtualNAS

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

the class FileOrchestrationUtils method getVNASServersOfStorageSystemAndVarrayOfVpool.

/**
 * Get the list of virtual nas servers from storage system which are part of vpool and project
 *
 * @param dbClient
 * @param storageSystemURI
 * @param vpoolURI
 * @param projectURI
 * @return
 */
public static List<URI> getVNASServersOfStorageSystemAndVarrayOfVpool(DbClient dbClient, URI storageSystemURI, URI vpoolURI, URI projectURI) {
    VirtualPool vpool = dbClient.queryObject(VirtualPool.class, vpoolURI);
    Project project = null;
    if (projectURI != null) {
        project = dbClient.queryObject(Project.class, projectURI);
    }
    StringSet varraySet = vpool.getVirtualArrays();
    URIQueryResultList vNasURIs = new URIQueryResultList();
    List<URI> vNASURIList = new ArrayList<URI>();
    dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceVirtualNasConstraint(storageSystemURI), vNasURIs);
    Iterator<URI> vNasIter = vNasURIs.iterator();
    while (vNasIter.hasNext()) {
        URI vNasURI = vNasIter.next();
        VirtualNAS vNas = dbClient.queryObject(VirtualNAS.class, vNasURI);
        if (vNas != null && !vNas.getInactive()) {
            // Dont pick the other project nas servers!!!
            if (project != null && vNas.getAssociatedProjects() != null && !vNas.getAssociatedProjects().isEmpty()) {
                if (!vNas.getAssociatedProjects().contains(project.getId().toString())) {
                    _log.info("vNas server {} assigned to other project, so ignoring this vNas server", vNas.getNasName());
                    continue;
                }
            }
            StringSet vNASVarraySet = vNas.getAssignedVirtualArrays();
            if (varraySet != null && !varraySet.isEmpty() && vNASVarraySet != null) {
                vNASVarraySet.retainAll(varraySet);
                if (!vNASVarraySet.isEmpty()) {
                    vNASURIList.add(vNas.getId());
                }
            }
        }
    }
    return vNASURIList;
}
Also used : Project(com.emc.storageos.db.client.model.Project) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 38 with VirtualNAS

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

the class UnManagedFilesystemService method isIngestUmfsValidForProject.

/**
 * Validate vNAS of unmanaged file system association with project
 *
 * @param project
 * @param dbClient
 * @param nasUri
 * @return true if ingestion is possible for a project against a vNAS; false otherwise
 */
public boolean isIngestUmfsValidForProject(Project project, DbClient dbClient, String nasUri) {
    _logger.info("Inside isIngestUmfsValidForProject() project name: {}", project.getLabel());
    boolean isIngestValid = true;
    if (nasUri != null && "VirtualNAS".equals(URIUtil.getTypeName(nasUri))) {
        VirtualNAS virtualNAS = dbClient.queryObject(VirtualNAS.class, URI.create(nasUri));
        _logger.info("vNAS name: {}", virtualNAS.getNasName());
        StringSet projectVNASServerSet = project.getAssignedVNasServers();
        if (projectVNASServerSet != null && !projectVNASServerSet.isEmpty()) {
            /*
                 * Step 1: check file system is mounted to VNAS
                 * Step 2: if project has any associated vNAS
                 * Step 3: then check nasUri in project associated vNAS list
                 */
            _logger.debug("Project vNAS server list: {}", projectVNASServerSet);
            _logger.debug("vNAS: {} assigned to project? {}", virtualNAS.getNasName(), !virtualNAS.isNotAssignedToProject());
            if (!projectVNASServerSet.contains(nasUri) && !virtualNAS.isNotAssignedToProject()) {
                _logger.info("vNAS: {} is not associated with project: {}.", virtualNAS.getNasName(), project.getLabel());
                isIngestValid = false;
            } else {
                if (!virtualNAS.isNotAssignedToProject() && !virtualNAS.getAssociatedProjects().contains(project.getId().toString())) {
                    _logger.info("vNAS: {} is associated with other project.", virtualNAS.getNasName());
                    isIngestValid = false;
                }
            }
        }
    }
    _logger.info("Exit isIngestUmfsValidForProject() returning: {}", isIngestValid);
    return isIngestValid;
}
Also used : VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) StringSet(com.emc.storageos.db.client.model.StringSet)

Example 39 with VirtualNAS

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

the class UnManagedFilesystemService method getIsilonStoragePort.

/**
 * This function will return one of the NAS server port which is part of given virtual array
 * it return null, if any of the NAS server port is not part of given virtual array
 *
 * @param umfsStoragePort
 *            port which is assigned to file system while UMFS discovery
 * @param nasUri
 *            NAS server URI
 * @param virtualArray
 *            virtual array
 */
private StoragePort getIsilonStoragePort(StoragePort umfsStoragePort, String nasUri, URI virtualArray) {
    StoragePort sp = null;
    NASServer nasServer = null;
    if (StringUtils.equals("VirtualNAS", URIUtil.getTypeName(nasUri))) {
        nasServer = _dbClient.queryObject(VirtualNAS.class, URI.create(nasUri));
    } else {
        nasServer = _dbClient.queryObject(PhysicalNAS.class, URI.create(nasUri));
    }
    if (nasServer != null) {
        List<URI> virtualArrayPorts = returnAllPortsInVArray(virtualArray);
        StringSet virtualArrayPortsSet = new StringSet();
        StringSet storagePorts = nasServer.getStoragePorts();
        for (URI tempVarrayPort : virtualArrayPorts) {
            virtualArrayPortsSet.add(tempVarrayPort.toString());
        }
        StringSet commonPorts = null;
        if (virtualArrayPorts != null && storagePorts != null) {
            commonPorts = new StringSet(storagePorts);
            commonPorts.retainAll(virtualArrayPortsSet);
        }
        if (commonPorts != null && !commonPorts.isEmpty()) {
            List<String> tempList = new ArrayList<String>(commonPorts);
            Collections.shuffle(tempList);
            sp = _dbClient.queryObject(StoragePort.class, URI.create(tempList.get(0)));
            return sp;
        }
    }
    return null;
}
Also used : NASServer(com.emc.storageos.db.client.model.NASServer) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) StoragePort(com.emc.storageos.db.client.model.StoragePort) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) PhysicalNAS(com.emc.storageos.db.client.model.PhysicalNAS) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 40 with VirtualNAS

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

the class ProjectService method assignVNasServersToProject.

/**
 * Assign VNAS Servers to a project
 *
 * @param id the URN of a ViPR Project
 * @param vnasParam Assign virtual NAS server parameters
 * @prereq none
 * @brief Assign VNAS Servers to a project
 * @return No data returned in response body
 * @throws BadRequestException
 */
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/assign-vnas-servers")
@CheckPermission(roles = { Role.SYSTEM_ADMIN }, acls = { ACL.ALL, ACL.OWN })
public Response assignVNasServersToProject(@PathParam("id") URI id, VirtualNasParam vnasParam) {
    checkCompatibleVersion();
    Project project = getProjectById(id, true);
    StringBuilder errorMsg = new StringBuilder();
    StringSet validVNasServers = validateVNasServers(project, vnasParam, errorMsg);
    if (validVNasServers != null && !validVNasServers.isEmpty()) {
        for (String validNas : validVNasServers) {
            URI vnasURI = URI.create(validNas);
            VirtualNAS vnas = _permissionsHelper.getObjectById(vnasURI, VirtualNAS.class);
            vnas.associateProject(project.getId().toString());
            _dbClient.persistObject(vnas);
        }
        project.setAssignedVNasServers(validVNasServers);
        _dbClient.persistObject(project);
        _log.info("Successfully assigned {} virtual NAS Servers to project : {} ", validVNasServers.size(), project.getLabel());
    }
    // Report error, if there are any invalid vnas servers found!!!
    if (errorMsg != null && errorMsg.length() > 0) {
        _log.error("Failed to assign virtual NAS server(s) to project. Error: {} ", errorMsg.toString());
        throw APIException.badRequests.oneOrMorevNasServersNotAssociatedToProject();
    }
    return Response.ok().build();
}
Also used : MapProject(com.emc.storageos.api.mapper.functions.MapProject) Project(com.emc.storageos.db.client.model.Project) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) StringSet(com.emc.storageos.db.client.model.StringSet) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

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