Search in sources :

Example 26 with VirtualNAS

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

the class IsilonCommunicationInterface method findvNasByNativeId.

/**
 * Find the Virtual NAS by Native ID for Isilon cluster
 *
 * @param system
 *            storage system information including credentials.
 * @param Native
 *            id of the specified Virtual NAS
 * @return Virtual NAS Server
 */
private VirtualNAS findvNasByNativeId(StorageSystem system, String nativeId) {
    URIQueryResultList results = new URIQueryResultList();
    VirtualNAS vNas = null;
    // Set storage port details to vNas
    String nasNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, nativeId, NativeGUIDGenerator.VIRTUAL_NAS);
    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVirtualNASByNativeGuidConstraint(nasNativeGuid), results);
    Iterator<URI> iter = results.iterator();
    VirtualNAS tmpVnas = null;
    while (iter.hasNext()) {
        tmpVnas = _dbClient.queryObject(VirtualNAS.class, iter.next());
        if (tmpVnas != null && !tmpVnas.getInactive()) {
            vNas = tmpVnas;
            _log.info("found virtual NAS {}", tmpVnas.getNativeGuid() + ":" + tmpVnas.getNasName());
            break;
        }
    }
    return vNas;
}
Also used : VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 27 with VirtualNAS

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

the class VirtualNASMultipleProjectsAssociationMigration method process.

@Override
public void process() throws MigrationCallbackException {
    logger.info("Migration started.");
    DbClient dbClient = getDbClient();
    List<VirtualNAS> vNASList = new ArrayList<VirtualNAS>();
    try {
        List<URI> virtualNASUris = dbClient.queryByType(VirtualNAS.class, true);
        Iterator<VirtualNAS> virtualNASIterator = dbClient.queryIterativeObjects(VirtualNAS.class, virtualNASUris, true);
        logger.info("Processing virtual NASs to set the associated project into a set.");
        while (virtualNASIterator.hasNext()) {
            VirtualNAS virtualNAS = virtualNASIterator.next();
            URI projectURI = virtualNAS.getProject();
            if (!NullColumnValueGetter.isNullURI(projectURI)) {
                virtualNAS.associateProject(projectURI.toString());
                vNASList.add(virtualNAS);
            }
        }
        if (!vNASList.isEmpty()) {
            logger.debug("Calling updateObject() to update virtual NAS is DB.");
            dbClient.updateObject(vNASList);
        }
    } catch (Exception ex) {
        logger.error("Exception occured while associating project to virtual NAS.");
        logger.error(ex.getMessage(), ex);
    }
    logger.info("Migration completed successfully");
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) ArrayList(java.util.ArrayList) URI(java.net.URI) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)

Example 28 with VirtualNAS

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

the class IsilonFileStorageDevice method createIsilonSyncPolicy.

private String createIsilonSyncPolicy(StorageSystem storageObj, StorageSystem targetStorage, FilePolicy filePolicy, String sourcePath, String targetPath, String syncPolicyName, FileDeviceInputOutput sourceSystemArgs, FileDeviceInputOutput targetSystemArgs) {
    String scheduleValue = getIsilonPolicySchedule(filePolicy);
    _log.info("File replication policy : {} creation started", filePolicy.toString());
    try {
        VirtualNAS targetVNas = targetSystemArgs.getvNAS();
        URI targetVNasURI = null;
        if (targetVNas != null) {
            targetVNasURI = targetVNas.getId();
        }
        String targetHost = FileOrchestrationUtils.getTargetHostPortForReplication(_dbClient, targetStorage.getId(), targetSystemArgs.getVarray().getId(), targetVNasURI);
        IsilonApi isi = getIsilonDevice(storageObj);
        isi.createDir(sourcePath, true);
        IsilonSyncPolicy replicationPolicy = new IsilonSyncPolicy(syncPolicyName, sourcePath, targetPath, targetHost, Action.sync);
        if (scheduleValue != null && !scheduleValue.isEmpty()) {
            replicationPolicy.setSchedule(scheduleValue);
        }
        if (filePolicy.getFilePolicyDescription() != null) {
            replicationPolicy.setDescription(filePolicy.getFilePolicyDescription());
        }
        if (filePolicy.getNumWorkerThreads() != null && filePolicy.getNumWorkerThreads() > 0) {
            replicationPolicy.setWorkersPerNode(filePolicy.getNumWorkerThreads().intValue());
        }
        replicationPolicy.setEnabled(true);
        replicationPolicy.setSchedule(scheduleValue);
        String scheduleId;
        if (VersionChecker.verifyVersionDetails(ONEFS_V8, storageObj.getFirmwareVersion()) >= 0) {
            IsilonSyncPolicy8Above replicationPolicyCopy = new IsilonSyncPolicy8Above();
            replicationPolicyCopy = replicationPolicyCopy.copy(replicationPolicy);
            if (filePolicy.getPriority() != null) {
                replicationPolicyCopy.setPriority(FilePolicyPriority.valueOf(filePolicy.getPriority()).ordinal());
            }
            scheduleId = isi.createReplicationPolicy8above(replicationPolicyCopy);
        } else {
            scheduleId = isi.createReplicationPolicy(replicationPolicy);
        }
        FileOrchestrationUtils.updatePolicyStorageResource(_dbClient, storageObj, filePolicy, sourceSystemArgs, sourcePath, syncPolicyName, scheduleId, targetStorage, targetSystemArgs.getvNAS(), targetPath);
        return scheduleId;
    } catch (IsilonException e) {
        throw e;
    }
}
Also used : VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonSyncPolicy8Above(com.emc.storageos.isilon.restapi.IsilonSyncPolicy8Above) IsilonSyncPolicy(com.emc.storageos.isilon.restapi.IsilonSyncPolicy) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 29 with VirtualNAS

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

the class VNXFileCommunicationInterface method createVirtualNas.

/**
 * Create Virtual NAS for the specified VNX File storage array
 *
 * @param system storage system information including credentials.
 * @param discovered VDM of the specified VNX File storage array
 * @return Virtual NAS Server
 * @throws VNXFileCollectionException
 */
private VirtualNAS createVirtualNas(StorageSystem system, VNXVdm vdm) throws VNXFileCollectionException {
    VirtualNAS vNas = new VirtualNAS();
    vNas.setNasName(vdm.getVdmName());
    vNas.setStorageDeviceURI(system.getId());
    vNas.setNativeId(vdm.getVdmId());
    vNas.setNasState(vdm.getState());
    vNas.setId(URIUtil.createId(VirtualNAS.class));
    String nasNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, vdm.getVdmId(), NativeGUIDGenerator.VIRTUAL_NAS);
    vNas.setNativeGuid(nasNativeGuid);
    PhysicalNAS parentNas = findPhysicalNasByNativeId(system, vdm.getMoverId());
    if (parentNas != null) {
        vNas.setParentNasUri(parentNas.getId());
        StringMap dbMetrics = vNas.getMetrics();
        _logger.info("new Virtual NAS created with guid {} ", vNas.getNativeGuid());
        // Set the Limit Metric keys!!
        Long MaxObjects = 2048L;
        Long MaxCapacity = 200L * TBsINKB;
        String modelStr = system.getModel();
        if (modelStr.startsWith("VNX")) {
            if (Long.parseLong(modelStr.substring(3)) > 5300) {
                MaxCapacity = 256L * TBsINKB;
            }
        }
        dbMetrics.put(MetricsKeys.maxStorageCapacity.name(), String.valueOf(MaxCapacity));
        dbMetrics.put(MetricsKeys.maxStorageObjects.name(), String.valueOf(MaxObjects));
        vNas.setMetrics(dbMetrics);
    }
    return vNas;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) PhysicalNAS(com.emc.storageos.db.client.model.PhysicalNAS)

Example 30 with VirtualNAS

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

the class VNXFileCommunicationInterface method discoverVdmPortGroups.

/**
 * Discover the Data Movers (Port Groups) for the specified VNX File storage array.
 *
 * @param system storage system information including credentials.
 * @param movers Collection of all DataMovers in the VNX File storage array
 * @return Map of New and Existing VDM port groups
 * @throws VNXFileCollectionException
 */
private HashMap<String, List<StorageHADomain>> discoverVdmPortGroups(StorageSystem system, Set<StorageHADomain> movers) throws VNXFileCollectionException, VNXException {
    HashMap<String, List<StorageHADomain>> portGroups = new HashMap();
    List<StorageHADomain> newPortGroups = new ArrayList<StorageHADomain>();
    List<StorageHADomain> existingPortGroups = new ArrayList<StorageHADomain>();
    _logger.info("Start vdm port group discovery for storage system {}", system.getId());
    List<VirtualNAS> newNasServers = new ArrayList<VirtualNAS>();
    List<VirtualNAS> existingNasServers = new ArrayList<VirtualNAS>();
    List<VNXVdm> vdms = getVdmPortGroups(system);
    _logger.debug("Number VDM found: {}", vdms.size());
    VNXFileSshApi sshDmApi = new VNXFileSshApi();
    sshDmApi.setConnParams(system.getIpAddress(), system.getUsername(), system.getPassword());
    for (VNXVdm vdm : vdms) {
        StorageHADomain portGroup = null;
        // Check supported network file sharing protocols.
        StringSet protocols = new StringSet();
        if (null == vdm) {
            _logger.debug("Null vdm in list of port groups.");
            continue;
        }
        // Check if port group was previously discovered
        URIQueryResultList results = new URIQueryResultList();
        String adapterNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, vdm.getVdmName(), NativeGUIDGenerator.ADAPTER);
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStorageHADomainByNativeGuidConstraint(adapterNativeGuid), results);
        Iterator<URI> iter = results.iterator();
        while (iter.hasNext()) {
            StorageHADomain tmpGroup = _dbClient.queryObject(StorageHADomain.class, iter.next());
            if (tmpGroup != null && !tmpGroup.getInactive() && tmpGroup.getStorageDeviceURI().equals(system.getId())) {
                portGroup = tmpGroup;
                _logger.debug("Found duplicate {} ", vdm.getVdmName());
                break;
            }
        }
        Map<String, String> vdmIntfs = sshDmApi.getVDMInterfaces(vdm.getVdmName());
        Set<String> intfs = null;
        if (vdmIntfs != null) {
            intfs = vdmIntfs.keySet();
        }
        // if NFS Interfaces are not there ignore this..
        if (vdmIntfs == null || intfs.isEmpty()) {
            // There are no interfaces for this VDM via nas_server command
            // so ignore this
            _logger.info("Ignoring VDM {} because no NFS interfaces found via ssh query", vdm.getVdmName());
        } else {
            _logger.info("Process VDM {} because  interfaces found {}", vdm.getVdmName(), vdmIntfs.keySet().size());
        }
        for (String intf : intfs) {
            String vdmCapability = vdmIntfs.get(intf);
            _logger.info("Interface {} capability [{}]", vdm.getVdmName() + ":" + intf, vdmCapability);
            if (vdmCapability.contains("cifs")) {
                _logger.info("{} has CIFS Enabled since interfaces are found ", vdm.getVdmName(), intf + ":" + vdmCapability);
                protocols.add(StorageProtocol.File.CIFS.name());
            }
            if (vdmCapability.contains("vdm")) {
                _logger.info("{} has NFS Enabled since interfaces are found ", vdm.getVdmName(), intf + ":" + vdmCapability);
                protocols.add(StorageProtocol.File.NFS.name());
            }
        }
        List<VNXCifsServer> cifsServers = getCifServers(system, vdm.getVdmId(), "true");
        CifsServerMap cifsServersMap = new CifsServerMap();
        for (VNXCifsServer cifsServer : cifsServers) {
            _logger.info("Cifs Server {} for {} ", cifsServer.getName(), vdm.getVdmName());
            if (!cifsServer.getInterfaces().isEmpty()) {
                _logger.info("{} has CIFS Enabled since interfaces are found ", vdm.getVdmName(), cifsServer.getName() + ":" + cifsServer.getInterfaces());
                protocols.add(StorageProtocol.File.CIFS.name());
                NasCifsServer nasCifsServer = new NasCifsServer();
                nasCifsServer.setId(cifsServer.getId());
                nasCifsServer.setInterfaces(cifsServer.getInterfaces());
                nasCifsServer.setMoverIdIsVdm(cifsServer.getMoverIdIsVdm());
                nasCifsServer.setName(cifsServer.getName());
                nasCifsServer.setType(cifsServer.getType());
                nasCifsServer.setDomain(cifsServer.getDomain());
                cifsServersMap.put(cifsServer.getName(), nasCifsServer);
            }
        }
        if (protocols.isEmpty()) {
            // No valid interfaces found and ignore this
            _logger.info("Ignoring VDM {} because no NFS/CIFS interfaces found ", vdm.getVdmName());
            continue;
        }
        // If the data mover (aka port group) was not previously discovered
        if (portGroup == null) {
            portGroup = new StorageHADomain();
            portGroup.setId(URIUtil.createId(StorageHADomain.class));
            portGroup.setNativeGuid(adapterNativeGuid);
            portGroup.setStorageDeviceURI(system.getId());
            portGroup.setAdapterName(vdm.getVdmName());
            portGroup.setName(vdm.getVdmId());
            portGroup.setFileSharingProtocols(protocols);
            portGroup.setVirtual(true);
            portGroup.setAdapterType(StorageHADomain.HADomainType.VIRTUAL.toString());
            // Get parent Data Mover
            StorageHADomain matchingParentMover = getMatchingMoverById(movers, vdm.getMoverId());
            // Check for valid data mover
            if (null != matchingParentMover) {
                portGroup.setParentHADomainURI(matchingParentMover.getId());
            } else {
                _logger.info("Matching parent DataMover {} for {} not found ", vdm.getMoverId(), vdm.getVdmName());
            }
            _logger.info("Found Vdm {} at {}", vdm.getVdmName(), vdm.getVdmId() + "@" + vdm.getMoverId());
            newPortGroups.add(portGroup);
        } else {
            // For rediscovery if cifs is not enabled
            portGroup.setFileSharingProtocols(protocols);
            existingPortGroups.add(portGroup);
        }
        VirtualNAS existingNas = findvNasByNativeId(system, vdm.getVdmId());
        if (existingNas != null) {
            existingNas.setProtocols(protocols);
            existingNas.setCifsServersMap(cifsServersMap);
            existingNas.setNasState(vdm.getState());
            existingNas.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
            PhysicalNAS parentNas = findPhysicalNasByNativeId(system, vdm.getMoverId());
            if (parentNas != null) {
                existingNas.setParentNasUri(parentNas.getId());
            }
            existingNasServers.add(existingNas);
        } else {
            VirtualNAS vNas = createVirtualNas(system, vdm);
            if (vNas != null) {
                vNas.setProtocols(protocols);
                vNas.setCifsServersMap(cifsServersMap);
                newNasServers.add(vNas);
            }
        }
    }
    List<VirtualNAS> discoveredVNasServers = new ArrayList<VirtualNAS>();
    // Persist the NAS servers!!!
    if (existingNasServers != null && !existingNasServers.isEmpty()) {
        _logger.info("discoverVdmPortGroups - modified VirtualNAS servers size {}", existingNasServers.size());
        _dbClient.persistObject(existingNasServers);
        discoveredVNasServers.addAll(existingNasServers);
    }
    if (newNasServers != null && !newNasServers.isEmpty()) {
        _logger.info("discoverVdmPortGroups - new VirtualNAS servers size {}", newNasServers.size());
        _dbClient.createObject(newNasServers);
        discoveredVNasServers.addAll(newNasServers);
    }
    // Verify the existing vnas servers!!!
    DiscoveryUtils.checkVirtualNasNotVisible(discoveredVNasServers, _dbClient, system.getId());
    _logger.info("Vdm Port group discovery for storage system {} complete.", system.getId());
    for (StorageHADomain newDomain : newPortGroups) {
        _logger.debug("New Storage Domain : {} : {}", newDomain.getNativeGuid(), newDomain.getAdapterName() + ":" + newDomain.getId());
    }
    for (StorageHADomain domain : existingPortGroups) {
        _logger.debug("Old Storage Domain : {} : {}", domain.getNativeGuid(), domain.getAdapterName() + ":" + domain.getId());
    }
    // return portGroups;
    portGroups.put(NEW, newPortGroups);
    portGroups.put(EXISTING, existingPortGroups);
    return portGroups;
}
Also used : VNXCifsServer(com.emc.storageos.vnx.xmlapi.VNXCifsServer) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) VNXVdm(com.emc.storageos.vnx.xmlapi.VNXVdm) VNXFileSshApi(com.emc.storageos.vnx.xmlapi.VNXFileSshApi) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) CifsServerMap(com.emc.storageos.db.client.model.CifsServerMap) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) NamespaceList(com.emc.storageos.plugins.common.domainmodel.NamespaceList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) NasCifsServer(com.emc.storageos.db.client.model.NasCifsServer) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) PhysicalNAS(com.emc.storageos.db.client.model.PhysicalNAS)

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