Search in sources :

Example 1 with VNXVdm

use of com.emc.storageos.vnx.xmlapi.VNXVdm in project coprhd-controller by CoprHD.

the class VNXFileCommunicationInterface method discoverPorts.

/**
 * Retrieve the Data Mover IP Interfaces (aka Storage Ports) for the specified VNX File Storage Array
 *
 * @param system storage system information including credentials.
 * @return Map of New and Existing Storage Ports
 * @throws VNXFileCollectionException
 * @throws IOException
 */
private HashMap<String, List<StoragePort>> discoverPorts(StorageSystem system, Set<StorageHADomain> movers) throws VNXFileCollectionException, VNXException, IOException {
    HashMap<String, List<StoragePort>> storagePorts = new HashMap<String, List<StoragePort>>();
    List<StoragePort> newStoragePorts = new ArrayList<StoragePort>();
    List<StoragePort> existingStoragePorts = new ArrayList<StoragePort>();
    List<PhysicalNAS> modifiedServers = new ArrayList<PhysicalNAS>();
    _logger.info("Start storage port discovery for storage system {}", system.getId());
    // Retrieve the list of data movers interfaces for the VNX File device.
    List<VNXDataMoverIntf> allDmIntfs = getPorts(system);
    List<VNXVdm> vdms = getVdmPortGroups(system);
    // Filter VDM ports
    List<VNXDataMoverIntf> dataMovers = null;
    Map<String, VNXDataMoverIntf> dmIntMap = new HashMap();
    for (VNXDataMoverIntf intf : allDmIntfs) {
        _logger.info("getPorts Adding {} : {}", intf.getName(), intf.getIpAddress());
        dmIntMap.put(intf.getName(), intf);
    }
    // Changes to fix Jira CTRL - 9151
    VNXFileSshApi sshDmApi = new VNXFileSshApi();
    sshDmApi.setConnParams(system.getIpAddress(), system.getUsername(), system.getPassword());
    // collect VDM interfaces
    for (VNXVdm vdm : vdms) {
        // Sometimes getVdmPortGroups(system) method does not collect all VDM interfaces,
        // So running Collect NFS/CIFS interfaces from nas_server -info command. This will return
        // Interfaces assigned to VDM and not thru CIFS servers
        Map<String, String> vdmIntfs = sshDmApi.getVDMInterfaces(vdm.getVdmName());
        for (String vdmIF : vdmIntfs.keySet()) {
            _logger.info("Remove VDM interface {}", vdmIF);
            dmIntMap.remove(vdmIF);
        }
    }
    // Got the filtered out DataMover Interfaces
    List<VNXDataMoverIntf> dmIntfs = new ArrayList(dmIntMap.values());
    _logger.info("Number unfiltered mover interfaces found: {}", allDmIntfs.size());
    _logger.info("Number mover interfaces found: {}", dmIntfs.size());
    // Create the list of storage ports.
    for (VNXDataMoverIntf intf : dmIntfs) {
        StoragePort port = null;
        StorageHADomain matchingHADomain = getMatchingMoverById(movers, intf.getDataMoverId());
        // Check for valid data mover
        if (null == matchingHADomain) {
            continue;
        }
        // Check if storage port was already discovered
        String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, intf.getIpAddress(), NativeGUIDGenerator.PORT);
        port = findExistingPort(portNativeGuid);
        if (null == port) {
            // Since a port was not found, attempt with previous naming convention (ADAPTER instead of PORT)
            String oldNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, intf.getIpAddress(), NativeGUIDGenerator.ADAPTER);
            port = findExistingPort(oldNativeGuid);
            if (null != port) {
                // found with old naming convention, therefore update name.
                port.setLabel(portNativeGuid);
                port.setNativeGuid(portNativeGuid);
            }
        }
        // If data mover interface was not previously discovered, add new storage port
        if (port == null) {
            port = new StoragePort();
            port.setId(URIUtil.createId(StoragePort.class));
            port.setLabel(portNativeGuid);
            port.setTransportType("IP");
            port.setNativeGuid(portNativeGuid);
            port.setStorageDevice(system.getId());
            port.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
            port.setPortName(intf.getName());
            port.setPortNetworkId(intf.getIpAddress());
            port.setPortGroup(intf.getDataMoverId());
            port.setStorageHADomain(matchingHADomain.getId());
            _logger.info("Creating new storage port using NativeGuid : {} name : {}, IP : {}", new Object[] { portNativeGuid, intf.getName(), intf.getIpAddress() });
            newStoragePorts.add(port);
        } else {
            port.setStorageHADomain(matchingHADomain.getId());
            existingStoragePorts.add(port);
        }
        port.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
        port.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
        // Set storage port details to vNas
        PhysicalNAS nas = findPhysicalNasByNativeId(system, intf.getDataMoverId());
        if (nas != null) {
            if (nas.getStoragePorts() != null && !nas.getStoragePorts().isEmpty()) {
                if (nas.getStoragePorts().contains(port.getId())) {
                    nas.getStoragePorts().remove(port.getId());
                }
            }
            nas.getStoragePorts().add(port.getId().toString());
            modifiedServers.add(nas);
            _logger.info("PhysicalNAS : {} : port : {} got modified", nas.getId(), port.getPortName());
        }
    }
    // Persist the changed nas servers!!!
    if (modifiedServers != null && !modifiedServers.isEmpty()) {
        _logger.info("Modified PhysicalNAS servers size {}", modifiedServers.size());
        _dbClient.persistObject(modifiedServers);
    }
    _logger.info("Storage port discovery for storage system {} complete", system.getId());
    for (StoragePort newPort : newStoragePorts) {
        _logger.info("New Storage Port : {} : {}", newPort.getNativeGuid(), newPort.getPortName() + ":" + newPort.getId());
    }
    for (StoragePort port : existingStoragePorts) {
        _logger.info("Old Storage Port : {} : {}", port.getNativeGuid(), port.getPortName() + ":" + port.getId());
    }
    storagePorts.put(NEW, newStoragePorts);
    storagePorts.put(EXISTING, existingStoragePorts);
    return storagePorts;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) VNXDataMoverIntf(com.emc.storageos.vnx.xmlapi.VNXDataMoverIntf) VNXVdm(com.emc.storageos.vnx.xmlapi.VNXVdm) VNXFileSshApi(com.emc.storageos.vnx.xmlapi.VNXFileSshApi) 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) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) PhysicalNAS(com.emc.storageos.db.client.model.PhysicalNAS)

Example 2 with VNXVdm

use of com.emc.storageos.vnx.xmlapi.VNXVdm in project coprhd-controller by CoprHD.

the class VNXFileCommunicationInterface method getVdmPortGroups.

private List<VNXVdm> getVdmPortGroups(final StorageSystem system) throws VNXException {
    List<VNXVdm> vdms = null;
    try {
        Map<String, Object> reqAttributeMap = getRequestParamsMap(system);
        _discExecutor.setKeyMap(reqAttributeMap);
        _discExecutor.execute((Namespace) _discNamespaces.getNsList().get("vnxfileVdm"));
        vdms = (ArrayList<VNXVdm>) _discExecutor.getKeyMap().get(VNXFileConstants.VDM_INFO);
    } catch (BaseCollectionException e) {
        throw new VNXException("Get Vdm Port Groups op failed", e);
    }
    return vdms;
}
Also used : VNXException(com.emc.storageos.vnx.xmlapi.VNXException) VNXVdm(com.emc.storageos.vnx.xmlapi.VNXVdm) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) UnManagedDiscoveredObject(com.emc.storageos.db.client.model.UnManagedDiscoveredObject) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 3 with VNXVdm

use of com.emc.storageos.vnx.xmlapi.VNXVdm in project coprhd-controller by CoprHD.

the class VNXFileCommunicationInterface method discoverVdmPorts.

/**
 * Retrieve the Data Mover IP Interfaces (aka Storage Ports) for the specified VNX File Storage Array
 *
 * @param system storage system information including credentials.
 * @return Map of New and Existing Storage Ports
 * @throws VNXFileCollectionException
 * @throws IOException
 */
private HashMap<String, List<StoragePort>> discoverVdmPorts(StorageSystem system, Set<StorageHADomain> movers) throws VNXFileCollectionException, VNXException, IOException {
    HashMap<String, List<StoragePort>> storagePorts = new HashMap<String, List<StoragePort>>();
    List<StoragePort> newStoragePorts = new ArrayList<StoragePort>();
    List<StoragePort> existingStoragePorts = new ArrayList<StoragePort>();
    _logger.info("Start storage port discovery for storage system {}", system.getId());
    HashMap<String, VNXDataMoverIntf> vdmIntMap = new HashMap();
    List<VirtualNAS> modifiedServers = new ArrayList<VirtualNAS>();
    // Retrieve VDMs
    List<VNXVdm> vdms = getVdmPortGroups(system);
    // Retrieve the list of data movers interfaces for the VNX File device.
    List<VNXDataMoverIntf> vdmIntfs = getVdmPorts(system, vdms);
    for (VNXDataMoverIntf intf : vdmIntfs) {
        _logger.info("getVdmPorts Adding {} : {}", intf.getName(), intf.getIpAddress());
        vdmIntMap.put(intf.getName(), intf);
    }
    _logger.info("Number VDM mover interfaces found: {}", vdmIntfs.size());
    for (VNXVdm vdm : vdms) {
        List<String> vNasStoragePorts = new ArrayList<String>();
        // Create the list of storage ports.
        for (String vdmIF : vdm.getInterfaces()) {
            VNXDataMoverIntf intf = vdmIntMap.get(vdmIF);
            StoragePort port = null;
            StorageHADomain matchingHADomain = getMatchingMoverByName(movers, vdm.getVdmName());
            // Check for valid data mover
            if (null == matchingHADomain) {
                continue;
            }
            // Check if storage port was already discovered
            String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, intf.getIpAddress(), NativeGUIDGenerator.PORT);
            port = findExistingPort(portNativeGuid);
            // If VDM interface was not previously discovered, add new storage port
            if (port == null) {
                port = new StoragePort();
                port.setId(URIUtil.createId(StoragePort.class));
                port.setLabel(portNativeGuid);
                port.setTransportType("IP");
                port.setNativeGuid(portNativeGuid);
                port.setStorageDevice(system.getId());
                port.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
                port.setPortName(intf.getName());
                port.setPortNetworkId(intf.getIpAddress());
                port.setPortGroup(vdm.getVdmId());
                port.setStorageHADomain(matchingHADomain.getId());
                _logger.info("Creating new storage port using NativeGuid : {} name : {}, IP : {}", new Object[] { portNativeGuid, intf.getName(), intf.getIpAddress(), intf.getDataMoverId(), vdm.getVdmId(), port.getPortName(), port.getPortGroup() });
                newStoragePorts.add(port);
            } else {
                port.setStorageHADomain(matchingHADomain.getId());
                port.setPortGroup(vdm.getVdmId());
                existingStoragePorts.add(port);
            }
            port.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
            port.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
            vNasStoragePorts.add(port.getId().toString());
        }
        // Set storage port details to vNas
        VirtualNAS vNas = findvNasByNativeId(system, vdm.getVdmId());
        if (vNas != null) {
            vNas.getStoragePorts().clear();
            vNas.getStoragePorts().addAll(vNasStoragePorts);
            modifiedServers.add(vNas);
        }
    }
    // Persist the changed nas servers!!!
    if (modifiedServers != null && !modifiedServers.isEmpty()) {
        _logger.info("Modified VirtualNAS servers size {}", modifiedServers.size());
        _dbClient.persistObject(modifiedServers);
    }
    _logger.info("Storage port discovery for storage system {} complete", system.getId());
    for (StoragePort newPort : newStoragePorts) {
        _logger.debug("New Storage Port : {} : {}", newPort.getNativeGuid(), newPort.getPortName() + ":" + newPort.getId());
    }
    for (StoragePort port : existingStoragePorts) {
        _logger.debug("Old Storage Port : {} : {}", port.getNativeGuid(), port.getPortName() + ":" + port.getId());
    }
    storagePorts.put(NEW, newStoragePorts);
    storagePorts.put(EXISTING, existingStoragePorts);
    return storagePorts;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) VNXDataMoverIntf(com.emc.storageos.vnx.xmlapi.VNXDataMoverIntf) VNXVdm(com.emc.storageos.vnx.xmlapi.VNXVdm) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) 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) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain)

Example 4 with VNXVdm

use of com.emc.storageos.vnx.xmlapi.VNXVdm in project coprhd-controller by CoprHD.

the class VNXVDMProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    final PostMethod result = (PostMethod) resultObj;
    _logger.info("processing vnx info response" + resultObj);
    try {
        ResponsePacket responsePacket = (ResponsePacket) _unmarshaller.unmarshal(result.getResponseBodyAsStream());
        if (null != responsePacket.getPacketFault()) {
            Status status = responsePacket.getPacketFault();
            processErrorStatus(status, keyMap);
        } else {
            List<Object> queryResponse = getQueryResponse(responsePacket);
            Iterator<Object> queryRespItr = queryResponse.iterator();
            List<VNXVdm> vdms = new ArrayList<VNXVdm>();
            while (queryRespItr.hasNext()) {
                Object responseObj = queryRespItr.next();
                if (responseObj instanceof Vdm) {
                    Vdm system = (Vdm) responseObj;
                    if (system.getState() == VdmState.LOADED) {
                        VNXVdm vdm = new VNXVdm(system.getName(), system.getMover(), system.getVdm(), system.getState().name());
                        vdm.setInterfaces(system.getInterfaces().getLi());
                        vdms.add(vdm);
                    } else {
                        _logger.info("Ignoring VDM {} because not LOADED {}", system.getName(), system.getState().value());
                    }
                }
            }
            keyMap.put(VNXFileConstants.VDM_INFO, vdms);
            // Extract session information from the response header.
            Header[] headers = result.getResponseHeaders(VNXFileConstants.CELERRA_SESSION);
            if (null != headers && headers.length > 0) {
                keyMap.put(VNXFileConstants.CELERRA_SESSION, headers[0].getValue());
                _logger.info("Recieved celerra session information from the Server.");
            }
        }
    } catch (final Exception ex) {
        _logger.error("Exception occurred while processing the vnx info response due to ", ex);
    } finally {
        result.releaseConnection();
    }
}
Also used : Status(com.emc.nas.vnxfile.xmlapi.Status) PostMethod(org.apache.commons.httpclient.methods.PostMethod) ArrayList(java.util.ArrayList) VNXVdm(com.emc.storageos.vnx.xmlapi.VNXVdm) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ResponsePacket(com.emc.nas.vnxfile.xmlapi.ResponsePacket) Header(org.apache.commons.httpclient.Header) VNXVdm(com.emc.storageos.vnx.xmlapi.VNXVdm) Vdm(com.emc.nas.vnxfile.xmlapi.Vdm)

Example 5 with VNXVdm

use of com.emc.storageos.vnx.xmlapi.VNXVdm in project coprhd-controller by CoprHD.

the class VNXFileCommunicationInterface method getVdmPorts.

private List<VNXDataMoverIntf> getVdmPorts(final StorageSystem system, final List<VNXVdm> vdms) throws VNXException {
    List<VNXDataMoverIntf> dataMoverInterfaces = null;
    List<VNXDataMoverIntf> vdmInterfaces = new ArrayList<VNXDataMoverIntf>();
    Map<String, VNXDataMoverIntf> dmIntMap = new HashMap();
    try {
        Map<String, Object> reqAttributeMap = getRequestParamsMap(system);
        _discExecutor.setKeyMap(reqAttributeMap);
        _discExecutor.execute((Namespace) _discNamespaces.getNsList().get("vnxfileStoragePort"));
        dataMoverInterfaces = (ArrayList<VNXDataMoverIntf>) _discExecutor.getKeyMap().get(VNXFileConstants.STORAGE_PORTS);
        // Make map
        for (VNXDataMoverIntf intf : dataMoverInterfaces) {
            dmIntMap.put(intf.getName(), intf);
        }
        VNXFileSshApi sshDmApi = new VNXFileSshApi();
        sshDmApi.setConnParams(system.getIpAddress(), system.getUsername(), system.getPassword());
        // collect VDM interfaces
        for (VNXVdm vdm : vdms) {
            for (String vdmIF : vdm.getInterfaces()) {
                VNXDataMoverIntf vdmInterface = dmIntMap.get(vdmIF);
                vdmInterfaces.add(vdmInterface);
                _logger.info("Use this VDM interface {}", vdmIF);
            }
            // Collect NFS/CIFS interfaces from nas_server -info command. This will return
            // Interfaces assigned to VDM and not thru CIFS servers
            Map<String, String> vdmIntfs = sshDmApi.getVDMInterfaces(vdm.getVdmName());
            for (String vdmNFSIf : vdmIntfs.keySet()) {
                VNXDataMoverIntf vdmInterface = dmIntMap.get(vdmNFSIf);
                if (vdmInterface != null) {
                    _logger.info("Use this NFS VDM interface {} for {}", vdmInterface, vdmNFSIf);
                    vdmInterfaces.add(vdmInterface);
                    // Check if the interface is already on the VDM, if not, add it.
                    if (!vdm.getInterfaces().contains(vdmInterface.getName())) {
                        vdm.getInterfaces().add(vdmInterface.getName());
                    }
                } else {
                    _logger.info("No interface found for {}", vdmNFSIf);
                }
            }
        }
    } catch (BaseCollectionException e) {
        throw new VNXException("Get VDM Port op failed", e);
    }
    return vdmInterfaces;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) VNXDataMoverIntf(com.emc.storageos.vnx.xmlapi.VNXDataMoverIntf) VNXVdm(com.emc.storageos.vnx.xmlapi.VNXVdm) VNXFileSshApi(com.emc.storageos.vnx.xmlapi.VNXFileSshApi) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) UnManagedDiscoveredObject(com.emc.storageos.db.client.model.UnManagedDiscoveredObject) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Aggregations

VNXVdm (com.emc.storageos.vnx.xmlapi.VNXVdm)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)3 StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)3 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)3 NamespaceList (com.emc.storageos.plugins.common.domainmodel.NamespaceList)3 VNXDataMoverIntf (com.emc.storageos.vnx.xmlapi.VNXDataMoverIntf)3 VNXFileSshApi (com.emc.storageos.vnx.xmlapi.VNXFileSshApi)3 LinkedList (java.util.LinkedList)3 List (java.util.List)3 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)2 PhysicalNAS (com.emc.storageos.db.client.model.PhysicalNAS)2 StoragePort (com.emc.storageos.db.client.model.StoragePort)2 UnManagedDiscoveredObject (com.emc.storageos.db.client.model.UnManagedDiscoveredObject)2 VirtualNAS (com.emc.storageos.db.client.model.VirtualNAS)2 VNXException (com.emc.storageos.vnx.xmlapi.VNXException)2 ResponsePacket (com.emc.nas.vnxfile.xmlapi.ResponsePacket)1 Status (com.emc.nas.vnxfile.xmlapi.Status)1