Search in sources :

Example 1 with IsilonNetworkPool

use of com.emc.storageos.isilon.restapi.IsilonNetworkPool in project coprhd-controller by CoprHD.

the class IsilonCommunicationInterface method setStoragePortsForNASServer.

private void setStoragePortsForNASServer(List<IsilonNetworkPool> isilonNetworkPools, StorageSystem storageSystem, NASServer nasServer) {
    if (nasServer == null) {
        return;
    }
    StringSet storagePorts = nasServer.getStoragePorts();
    if (storagePorts == null) {
        storagePorts = new StringSet();
    } else {
        storagePorts.clear();
    }
    if (isilonNetworkPools != null && !isilonNetworkPools.isEmpty()) {
        for (IsilonNetworkPool isiNetworkPool : isilonNetworkPools) {
            StoragePort storagePort = findStoragePortByNativeId(storageSystem, isiNetworkPool.getSc_dns_zone());
            if (storagePort != null) {
                storagePorts.add(storagePort.getId().toString());
            }
        }
        if (DiscoveredDataObject.DiscoveryStatus.NOTVISIBLE.name().equals(nasServer.getDiscoveryStatus())) {
            _log.info("Setting discovery status of vnas {} as VISIBLE", nasServer.getNasName());
            nasServer.setDiscoveryStatus(DiscoveredDataObject.DiscoveryStatus.VISIBLE.name());
        }
        if (VirtualNAS.VirtualNasState.UNKNOWN.name().equals(nasServer.getNasState())) {
            _log.info("Setting state of vnas {} as LOADED", nasServer.getNasName());
            nasServer.setNasState(VirtualNAS.VirtualNasState.LOADED.name());
        }
    } else {
        /*
             * Smart connect zones are dissociated with this access zone.
             * So mark this access zone as not visible.
             */
        _log.info("Setting discovery status of vnas {} as NOTVISIBLE", nasServer.getNasName());
        nasServer.setDiscoveryStatus(DiscoveredDataObject.DiscoveryStatus.NOTVISIBLE.name());
        nasServer.setNasState(VirtualNAS.VirtualNasState.UNKNOWN.name());
        StringSet assignedVarrays = nasServer.getAssignedVirtualArrays();
        if (assignedVarrays != null) {
            nasServer.removeAssignedVirtualArrays(assignedVarrays);
        }
    }
    _log.info("Setting storage ports for vNAS [{}] : {}", nasServer.getNasName(), storagePorts);
    nasServer.setStoragePorts(storagePorts);
}
Also used : StringSet(com.emc.storageos.db.client.model.StringSet) IsilonStoragePort(com.emc.storageos.isilon.restapi.IsilonStoragePort) StoragePort(com.emc.storageos.db.client.model.StoragePort) IsilonNetworkPool(com.emc.storageos.isilon.restapi.IsilonNetworkPool)

Example 2 with IsilonNetworkPool

use of com.emc.storageos.isilon.restapi.IsilonNetworkPool in project coprhd-controller by CoprHD.

the class IsilonCommunicationInterface method discoverNetworkPools.

/**
 * discover the network interface of given Isilon storage cluster
 *
 * @param storageSystem
 * @return
 * @throws IsilonCollectionException
 */
private List<IsilonNetworkPool> discoverNetworkPools(StorageSystem storageSystem) throws IsilonCollectionException {
    List<IsilonNetworkPool> isilonNetworkPoolList = new ArrayList<IsilonNetworkPool>();
    URI storageSystemId = storageSystem.getId();
    _log.info("discoverNetworkPools for storage system {} - start", storageSystemId);
    List<IsilonNetworkPool> isilonNetworkPoolsTemp = null;
    try {
        if (VersionChecker.verifyVersionDetails(ONEFS_V8, storageSystem.getFirmwareVersion()) >= 0) {
            _log.info("Isilon release version {} and storagesystem label {}", storageSystem.getFirmwareVersion(), storageSystem.getLabel());
            IsilonApi isilonApi = getIsilonDevice(storageSystem);
            isilonNetworkPoolsTemp = isilonApi.getNetworkPools(null);
            if (isilonNetworkPoolsTemp != null) {
                isilonNetworkPoolList.addAll(isilonNetworkPoolsTemp);
            }
        } else {
            IsilonSshApi sshDmApi = new IsilonSshApi();
            sshDmApi.setConnParams(storageSystem.getIpAddress(), storageSystem.getUsername(), storageSystem.getPassword());
            Map<String, List<String>> networkPools = sshDmApi.getNetworkPools();
            List<String> smartconnects = null;
            IsilonNetworkPool isiNetworkPool = null;
            for (Map.Entry<String, List<String>> networkpool : networkPools.entrySet()) {
                smartconnects = networkpool.getValue();
                if (smartconnects != null) {
                    for (String smartconnect : smartconnects) {
                        isiNetworkPool = new IsilonNetworkPool();
                        isiNetworkPool.setAccess_zone(networkpool.getKey());
                        isiNetworkPool.setSc_dns_zone(smartconnect);
                        isilonNetworkPoolList.add(isiNetworkPool);
                    }
                }
            }
        }
    } catch (Exception e) {
        _log.error("discover of NetworkPools is failed. %s", e.getMessage());
    }
    return isilonNetworkPoolList;
}
Also used : IsilonSshApi(com.emc.storageos.isilon.restapi.IsilonSshApi) ArrayList(java.util.ArrayList) 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) IsilonNetworkPool(com.emc.storageos.isilon.restapi.IsilonNetworkPool) IsilonList(com.emc.storageos.isilon.restapi.IsilonApi.IsilonList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) Map(java.util.Map) UnManagedSMBShareMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBShareMap) UnManagedFSExportMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExportMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) StringMap(com.emc.storageos.db.client.model.StringMap) CifsServerMap(com.emc.storageos.db.client.model.CifsServerMap)

Example 3 with IsilonNetworkPool

use of com.emc.storageos.isilon.restapi.IsilonNetworkPool 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)

Aggregations

IsilonNetworkPool (com.emc.storageos.isilon.restapi.IsilonNetworkPool)3 StringSet (com.emc.storageos.db.client.model.StringSet)2 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)2 IsilonApi (com.emc.storageos.isilon.restapi.IsilonApi)2 IsilonException (com.emc.storageos.isilon.restapi.IsilonException)2 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)2 IsilonCollectionException (com.emc.storageos.plugins.metering.isilon.IsilonCollectionException)2 IOException (java.io.IOException)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 ArrayList (java.util.ArrayList)2 JSONException (org.codehaus.jettison.json.JSONException)2 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 CifsServerMap (com.emc.storageos.db.client.model.CifsServerMap)1 PhysicalNAS (com.emc.storageos.db.client.model.PhysicalNAS)1 StoragePort (com.emc.storageos.db.client.model.StoragePort)1 StringMap (com.emc.storageos.db.client.model.StringMap)1 UnManagedFSExportMap (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExportMap)1 UnManagedSMBShareMap (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBShareMap)1 VirtualNAS (com.emc.storageos.db.client.model.VirtualNAS)1