Search in sources :

Example 21 with PhysicalNAS

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

the class IsilonCommunicationInterface method computeStaticLoadMetrics.

private void computeStaticLoadMetrics(final URI storageSystemId) throws BaseCollectionException {
    StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
    _log.info("started computeStaticLoadMetrics for storagesystem: {}", storageSystem.getLabel());
    StringMap dbMetrics = null;
    String accessZoneId = null;
    try {
        IsilonApi isilonApi = getIsilonDevice(storageSystem);
        VirtualNAS virtualNAS = null;
        // //step-1 process the dbmetrics for user define access zones
        List<IsilonAccessZone> accessZoneList = isilonApi.getAccessZones(null);
        for (IsilonAccessZone isAccessZone : accessZoneList) {
            accessZoneId = isAccessZone.getZone_id().toString();
            // get the total fs count and capacity for AZ
            if (isAccessZone.isSystem() != true) {
                virtualNAS = findvNasByNativeId(storageSystem, accessZoneId);
                if (virtualNAS != null) {
                    _log.info("Process db metrics for access zone : {}", isAccessZone.getName());
                    dbMetrics = virtualNAS.getMetrics();
                    if (dbMetrics == null) {
                        dbMetrics = new StringMap();
                    }
                    // process db metrics
                    populateDbMetricsAz(isAccessZone, isilonApi, dbMetrics);
                    // set AZ dbMetrics in db
                    virtualNAS.setMetrics(dbMetrics);
                    _dbClient.updateObject(virtualNAS);
                }
            } else {
                PhysicalNAS physicalNAS = findPhysicalNasByNativeId(storageSystem, accessZoneId);
                if (physicalNAS == null) {
                    _log.error(String.format("computeStaticLoadMetrics is failed for  Storagesystemid: %s", storageSystemId));
                    return;
                }
                dbMetrics = physicalNAS.getMetrics();
                if (dbMetrics == null) {
                    dbMetrics = new StringMap();
                }
                /* process the system accesszone dbmetrics */
                _log.info("process db metrics for access zone : {}", isAccessZone.getName());
                populateDbMetricsAz(isAccessZone, isilonApi, dbMetrics);
                physicalNAS.setMetrics(dbMetrics);
                _dbClient.updateObject(physicalNAS);
            }
        }
    } catch (Exception e) {
        _log.error("CollectStatisticsInformation failed. Storage system: " + storageSystemId, e);
    }
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) IsilonAccessZone(com.emc.storageos.isilon.restapi.IsilonAccessZone) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) PhysicalNAS(com.emc.storageos.db.client.model.PhysicalNAS) IsilonException(com.emc.storageos.isilon.restapi.IsilonException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) IOException(java.io.IOException) JSONException(org.codehaus.jettison.json.JSONException) URISyntaxException(java.net.URISyntaxException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) IsilonCollectionException(com.emc.storageos.plugins.metering.isilon.IsilonCollectionException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 22 with PhysicalNAS

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

the class IsilonCommunicationInterface method findPhysicalNasByNativeId.

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

Example 23 with PhysicalNAS

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

the class IsilonCommunicationInterface method discoverAccessZones.

/**
 * discover the access zone and add to vipr db
 *
 * @param storageSystem
 */
private void discoverAccessZones(StorageSystem storageSystem) {
    URI storageSystemId = storageSystem.getId();
    VirtualNAS virtualNAS = null;
    PhysicalNAS physicalNAS = null;
    List<VirtualNAS> newvNASList = new ArrayList<VirtualNAS>();
    List<VirtualNAS> existingvNASList = new ArrayList<VirtualNAS>();
    List<PhysicalNAS> newPhysicalNASList = new ArrayList<PhysicalNAS>();
    List<PhysicalNAS> existingPhysicalNASList = new ArrayList<PhysicalNAS>();
    List<VirtualNAS> discoveredVNASList = new ArrayList<VirtualNAS>();
    // Discover storage ports
    try {
        _log.info("discoverAccessZones for storage system {} - start", storageSystemId);
        IsilonApi isilonApi = getIsilonDevice(storageSystem);
        // Make restapi call to get access zones
        List<IsilonAccessZone> accessZoneList = isilonApi.getAccessZones(null);
        if (accessZoneList == null || accessZoneList.isEmpty()) {
            // No access zones defined. Throw an exception and fail the discovery
            IsilonCollectionException ice = new IsilonCollectionException("discoverAccessZones failed. No Zones defined");
            throw ice;
        }
        // Find the smart connect zones
        List<IsilonNetworkPool> isilonNetworkPoolsSysAZ = new ArrayList<>();
        // get the system access zone and use it later
        List<IsilonNetworkPool> isilonNetworkPoolList = discoverNetworkPools(storageSystem);
        for (IsilonNetworkPool isilonNetworkPool : isilonNetworkPoolList) {
            if (isilonNetworkPool.getAccess_zone().equalsIgnoreCase(SYSTEM_ACCESS_ZONE_NAME)) {
                isilonNetworkPoolsSysAZ.add(isilonNetworkPool);
            }
        }
        // set the protocol based storagesystem version
        // by default all version support CIFS and version above 7.2 NFS also
        StringSet protocols = new StringSet();
        protocols.add(CIFS);
        boolean isNfsV4Enabled = isilonApi.nfsv4Enabled(storageSystem.getFirmwareVersion());
        if (VersionChecker.verifyVersionDetails(ONEFS_V7_2, storageSystem.getFirmwareVersion()) >= 0) {
            protocols.add(NFS);
            if (isNfsV4Enabled) {
                protocols.add(NFSv4);
            }
        }
        List<IsilonNetworkPool> isilonNetworkPools = null;
        // process the access zones list
        for (IsilonAccessZone isilonAccessZone : accessZoneList) {
            // add protocol to NAS servers
            // is it a System access zone?
            isilonNetworkPools = null;
            if (isilonAccessZone.isSystem() == false) {
                _log.info("Process the user defined access zone {} ", isilonAccessZone.toString());
                isilonNetworkPools = new ArrayList<IsilonNetworkPool>();
                // get the smart connect zone information
                for (IsilonNetworkPool eachNetworkPool : isilonNetworkPoolList) {
                    if (eachNetworkPool.getAccess_zone().equalsIgnoreCase(isilonAccessZone.getName())) {
                        isilonNetworkPools.add(eachNetworkPool);
                    }
                }
                // find virtualNAS in db
                virtualNAS = findvNasByNativeId(storageSystem, isilonAccessZone.getZone_id().toString());
                if (virtualNAS == null) {
                    if (isilonNetworkPools != null && !isilonNetworkPools.isEmpty()) {
                        virtualNAS = createVirtualNas(storageSystem, isilonAccessZone);
                        newvNASList.add(virtualNAS);
                    }
                } else {
                    copyUpdatedPropertiesInVNAS(storageSystem, isilonAccessZone, virtualNAS);
                    existingvNASList.add(virtualNAS);
                }
                // Set authentication providers
                setCifsServerMapForNASServer(isilonAccessZone, virtualNAS);
                // set protocol support
                if (virtualNAS != null) {
                    virtualNAS.setProtocols(protocols);
                }
                // set the smart connect
                setStoragePortsForNASServer(isilonNetworkPools, storageSystem, virtualNAS);
            } else {
                _log.info("Process the System access zone {} ", isilonAccessZone.toString());
                // set protocols
                StringSet protocolSet = new StringSet();
                protocolSet.add(CIFS);
                protocolSet.add(NFS);
                if (isNfsV4Enabled) {
                    protocolSet.add(NFSv4);
                }
                physicalNAS = findPhysicalNasByNativeId(storageSystem, isilonAccessZone.getZone_id().toString());
                if (physicalNAS == null) {
                    physicalNAS = createPhysicalNas(storageSystem, isilonAccessZone);
                    physicalNAS.setProtocols(protocolSet);
                    // add system access zone
                    newPhysicalNASList.add(physicalNAS);
                } else {
                    setMaxDbMetricsAz(storageSystem, physicalNAS.getMetrics());
                    existingPhysicalNASList.add(physicalNAS);
                }
                // Set authentication providers
                setCifsServerMapForNASServer(isilonAccessZone, physicalNAS);
                // set the smart connect zone
                setStoragePortsForNASServer(isilonNetworkPoolsSysAZ, storageSystem, physicalNAS);
            }
        }
        // Persist the vNAS servers and
        if (newvNASList != null && !newvNASList.isEmpty()) {
            // add the parent system access zone to user defined access zones
            if (physicalNAS != null) {
                for (VirtualNAS vNas : newvNASList) {
                    // set the parent uri or system access zone uri to vNAS
                    vNas.setParentNasUri(physicalNAS.getId());
                }
            }
            _log.info("New Virtual NAS servers size {}", newvNASList.size());
            _dbClient.createObject(newvNASList);
            discoveredVNASList.addAll(newvNASList);
        }
        if (existingvNASList != null && !existingvNASList.isEmpty()) {
            _log.info("Modified Virtual NAS servers size {}", existingvNASList.size());
            _dbClient.updateObject(existingvNASList);
            discoveredVNASList.addAll(existingvNASList);
        }
        // Persist the NAS servers!!!
        if (existingPhysicalNASList != null && !existingPhysicalNASList.isEmpty()) {
            _log.info("Modified Physical NAS servers size {}", existingPhysicalNASList.size());
            _dbClient.updateObject(existingPhysicalNASList);
        }
        if (newPhysicalNASList != null && !newPhysicalNASList.isEmpty()) {
            _log.info("New Physical NAS servers size {}", newPhysicalNASList.size());
            _dbClient.createObject(newPhysicalNASList);
        }
        DiscoveryUtils.checkVirtualNasNotVisible(discoveredVNASList, _dbClient, storageSystemId);
    } catch (Exception e) {
        _log.error("discoverAccessZones failed. Storage system: {}", storageSystemId, e);
        IsilonCollectionException ice = new IsilonCollectionException("discoverAccessZones failed. Storage system: " + storageSystemId);
        throw ice;
    }
}
Also used : ArrayList(java.util.ArrayList) IsilonAccessZone(com.emc.storageos.isilon.restapi.IsilonAccessZone) IsilonCollectionException(com.emc.storageos.plugins.metering.isilon.IsilonCollectionException) URI(java.net.URI) IsilonException(com.emc.storageos.isilon.restapi.IsilonException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) IOException(java.io.IOException) JSONException(org.codehaus.jettison.json.JSONException) URISyntaxException(java.net.URISyntaxException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) IsilonCollectionException(com.emc.storageos.plugins.metering.isilon.IsilonCollectionException) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) StringSet(com.emc.storageos.db.client.model.StringSet) IsilonNetworkPool(com.emc.storageos.isilon.restapi.IsilonNetworkPool) PhysicalNAS(com.emc.storageos.db.client.model.PhysicalNAS) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi)

Example 24 with PhysicalNAS

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

the class IsilonCommunicationInterface method createPhysicalNas.

/**
 * Create Physical NAS for the specified Isilon cluster storage array
 *
 * @param system
 * @param isiAccessZone
 * @return Physical NAS Server
 */
private PhysicalNAS createPhysicalNas(final StorageSystem system, IsilonAccessZone isiAccessZone) {
    PhysicalNAS phyNas = new PhysicalNAS();
    phyNas.setStorageDeviceURI(system.getId());
    phyNas.setNasName(isiAccessZone.getName());
    phyNas.setNativeId(isiAccessZone.getId());
    // set base directory path
    phyNas.setNasState(VirtualNasState.LOADED.toString());
    phyNas.setId(URIUtil.createId(PhysicalNAS.class));
    // Set storage port details to vNas
    String physicalNasNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, isiAccessZone.getZone_id().toString(), NativeGUIDGenerator.PHYSICAL_NAS);
    phyNas.setNativeGuid(physicalNasNativeGuid);
    _log.info("Physical NAS created with guid {} ", phyNas.getNativeGuid());
    StringMap dbMetrics = phyNas.getMetrics();
    if (dbMetrics == null) {
        dbMetrics = new StringMap();
    }
    // set the Limitation Metrics keys
    setMaxDbMetricsAz(system, dbMetrics);
    phyNas.setMetrics(dbMetrics);
    return phyNas;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) PhysicalNAS(com.emc.storageos.db.client.model.PhysicalNAS)

Aggregations

PhysicalNAS (com.emc.storageos.db.client.model.PhysicalNAS)24 URI (java.net.URI)14 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)9 VirtualNAS (com.emc.storageos.db.client.model.VirtualNAS)9 ArrayList (java.util.ArrayList)6 NASServer (com.emc.storageos.db.client.model.NASServer)5 StringMap (com.emc.storageos.db.client.model.StringMap)5 PolicyStorageResource (com.emc.storageos.db.client.model.PolicyStorageResource)4 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)4 StringSet (com.emc.storageos.db.client.model.StringSet)4 List (java.util.List)4 NasCifsServer (com.emc.storageos.db.client.model.NasCifsServer)3 StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)3 NamespaceList (com.emc.storageos.plugins.common.domainmodel.NamespaceList)3 HashMap (java.util.HashMap)3 LinkedList (java.util.LinkedList)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 CifsServerMap (com.emc.storageos.db.client.model.CifsServerMap)2 FileReplicaPolicyTarget (com.emc.storageos.db.client.model.FileReplicaPolicyTarget)2 FileReplicaPolicyTargetMap (com.emc.storageos.db.client.model.FileReplicaPolicyTargetMap)2