Search in sources :

Example 1 with VNXCifsServer

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

the class VNXFileCommunicationInterface method getCifServers.

private List<VNXCifsServer> getCifServers(final StorageSystem system, String moverId, String isVdm) throws VNXException {
    List<VNXCifsServer> cifsServers;
    try {
        Map<String, Object> reqAttributeMap = getRequestParamsMap(system);
        reqAttributeMap.put(VNXFileConstants.MOVER_ID, moverId);
        reqAttributeMap.put(VNXFileConstants.ISVDM, isVdm);
        _discExecutor.setKeyMap(reqAttributeMap);
        _discExecutor.execute((Namespace) _discNamespaces.getNsList().get(VNXFileConstants.VNX_FILE_CIFS_CONFIG));
        cifsServers = (List<VNXCifsServer>) _discExecutor.getKeyMap().get(VNXFileConstants.CIFS_SERVERS);
    } catch (BaseCollectionException e) {
        throw new VNXException("Get CifServers op failed", e);
    }
    return cifsServers;
}
Also used : VNXCifsServer(com.emc.storageos.vnx.xmlapi.VNXCifsServer) 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)

Example 2 with VNXCifsServer

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

the class VNXFileCommApi method doDeleteShare.

/**
 * Delete a CIFS Share
 *
 * @param system
 * @param moverOrVdm
 *            data mover the share is on.
 * @param shareName
 *            name of the CIFS share.
 * @return result of the operation.
 */
public XMLApiResult doDeleteShare(StorageSystem system, StorageHADomain moverOrVdm, String shareName, String mountPoint, boolean deleteMount, FileDeviceInputOutput args) {
    _log.info("CommApi: delete share {}", shareName);
    XMLApiResult result = new XMLApiResult();
    result.setCommandSuccess();
    Map<String, Object> reqAttributeMap = new ConcurrentHashMap<String, Object>();
    try {
        updateAttributes(reqAttributeMap, system);
        if (null == moverOrVdm) {
            result.setCommandFailed();
            result.setMessage("Export failed:  data mover or VDM not found.");
            return result;
        }
        String moverOrVdmName = moverOrVdm.getAdapterName();
        String isVdm = "false";
        String moverOrVdmId = moverOrVdm.getName();
        reqAttributeMap.put(VNXFileConstants.MOVER_ID, moverOrVdmId);
        reqAttributeMap.put(VNXFileConstants.ISVDM, isVdm);
        if (moverOrVdm.getVirtual() != null && moverOrVdm.getVirtual() == true) {
            isVdm = "true";
        }
        _log.info("Using Mover {} to Delete share {}", moverOrVdmId + ":" + moverOrVdmName, shareName);
        updateAttributes(reqAttributeMap, system);
        reqAttributeMap.put(VNXFileConstants.MOVER_ID, moverOrVdmId);
        reqAttributeMap.put(VNXFileConstants.DATAMOVER_NAME, moverOrVdmName);
        reqAttributeMap.put(VNXFileConstants.ISVDM, isVdm);
        _provExecutor.setKeyMap(reqAttributeMap);
        _provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_CIFS_SERVERS));
        List<VNXCifsServer> cifsServers = (List<VNXCifsServer>) _provExecutor.getKeyMap().get(VNXFileConstants.CIFS_SERVERS);
        for (VNXCifsServer cifsServer : cifsServers) {
            _log.info("CIFServer:" + cifsServer.toString());
        }
        if (cifsServers == null || cifsServers.isEmpty()) {
            _log.info("No CIFS Servers retrieved for mover {} with id {}", moverOrVdmName, moverOrVdmId);
        }
        String netBios = null;
        // Only set netbios for VDM CIFS exports
        if (cifsServers != null && !cifsServers.isEmpty() && moverOrVdm.getVirtual()) {
            netBios = cifsServers.get(0).getName();
        }
        sshApi.setConnParams(system.getIpAddress(), system.getUsername(), system.getPassword());
        String data = sshApi.formatDeleteShareCmd(moverOrVdmName, shareName, netBios);
        _log.info("doDeleteShare command {}", data);
        result = sshApi.executeSshRetry(VNXFileSshApi.SERVER_EXPORT_CMD, data);
        FileShare fileShare = null;
        if (!args.getFileOperation()) {
            Snapshot snapshot = _dbClient.queryObject(Snapshot.class, args.getSnapshotId());
            fileShare = _dbClient.queryObject(FileShare.class, snapshot.getParent().getURI());
        } else {
            fileShare = _dbClient.queryObject(FileShare.class, args.getFileObjId());
        }
        if (result.isCommandSuccess() && getVNXFSDependencies(fileShare, false) <= 1) {
            // FileSystem Mount Point
            // Delete the mount
            data = sshApi.formatUnMountCmd(moverOrVdmName, mountPoint, "CIFS");
            _log.info("Unmount filesystem command {}", data);
            result = sshApi.executeSshRetry(VNXFileSshApi.SERVER_UNMOUNT_CMD, data);
        }
        sshApi.clearConnParams();
    } catch (Exception e) {
        throw new VNXException("Failure", e);
    }
    return result;
}
Also used : VNXCifsServer(com.emc.storageos.vnx.xmlapi.VNXCifsServer) Snapshot(com.emc.storageos.db.client.model.Snapshot) VNXSnapshot(com.emc.storageos.vnx.xmlapi.VNXSnapshot) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) FileObject(com.emc.storageos.db.client.model.FileObject) ArrayList(java.util.ArrayList) NamespaceList(com.emc.storageos.plugins.common.domainmodel.NamespaceList) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) URISyntaxException(java.net.URISyntaxException) VNXException(com.emc.storageos.vnx.xmlapi.VNXException)

Example 3 with VNXCifsServer

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

the class VNXFileCommApi method doExport.

/**
 * Performs an export for a VNX File array. If this is the first export of a file system path,
 * then the path must be mounted on a data mover first. Also, if the root user mapping contains a
 * user account name, then it must be converted into a UID.
 *
 * @param system
 * @param exports
 * @param fsName
 * @param fsId
 * @param firstExport
 * @return
 * @throws VNXException
 */
public XMLApiResult doExport(final StorageSystem system, StorageHADomain dataMover, List<VNXFileExport> exports, List<String> newPaths, FileObject fileObject, String fsId, boolean firstExport) throws VNXException {
    VNXFileExport vnxExp = exports.get(0);
    String port = vnxExp.getStoragePortName();
    String storagePortNetworkId = vnxExp.getStoragePort();
    _log.info("Export for {}, data mover {}", fileObject.getLabel(), port + ":" + storagePortNetworkId);
    XMLApiResult result = new XMLApiResult();
    Map<String, Object> reqAttributeMap = new ConcurrentHashMap<String, Object>();
    FileShare fs = null;
    if (fileObject instanceof FileShare) {
        fs = _dbClient.queryObject(FileShare.class, fileObject.getId());
    }
    String moverOrVdmId = "";
    String moverOrVdmName = "";
    String parentDMName = "";
    String isVdm = "false";
    try {
        if (null == dataMover) {
            result.setCommandFailed();
            result.setMessage("Export failed:  data mover or vdm not found.");
            return result;
        }
        moverOrVdmId = dataMover.getName();
        moverOrVdmName = dataMover.getAdapterName();
        if (dataMover.getVirtual() != null && dataMover.getVirtual() == true) {
            isVdm = "true";
            parentDMName = getParentMoverName(dataMover.getParentHADomainURI());
        }
        sshApi.setConnParams(system.getIpAddress(), system.getUsername(), system.getPassword());
        Map<String, String> userInfo = sshApi.getUserInfo(parentDMName);
        _log.info("Using Mover {} to export FS mounted at {}", moverOrVdmId + ":" + moverOrVdmName, exports.get(0).getMountPoint());
        updateAttributes(reqAttributeMap, system);
        reqAttributeMap.put(VNXFileConstants.DATAMOVER_ID, port);
        reqAttributeMap.put(VNXFileConstants.MOVER_ID, moverOrVdmId);
        reqAttributeMap.put(VNXFileConstants.FILESYSTEM_ID, fsId);
        reqAttributeMap.put(VNXFileConstants.DATAMOVER_NAME, moverOrVdmName);
        reqAttributeMap.put(VNXFileConstants.ISVDM, isVdm);
        if (vnxExp.getComment() != null && !vnxExp.getComment().isEmpty()) {
            reqAttributeMap.put(VNXFileConstants.TASK_DESCRIPTION, vnxExp.getComment());
        }
        Set<String> moverIds = new HashSet<String>();
        moverIds.add(port);
        reqAttributeMap.put(VNXFileConstants.MOVERLIST, moverIds);
        _provExecutor.setKeyMap(reqAttributeMap);
        if (firstExport) {
            reqAttributeMap.put(VNXFileConstants.MOUNT_PATH, fs.getMountPath());
            _provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_FILE_EXPORT_MOUNT));
        } else {
            reqAttributeMap.put(VNXFileConstants.MOUNT_PATH, vnxExp.getMountPoint());
            _provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_FILE_EXPORT));
        }
        List<VNXCifsServer> cifsServers = (List<VNXCifsServer>) _provExecutor.getKeyMap().get(VNXFileConstants.CIFS_SERVERS);
        if (cifsServers == null || cifsServers.isEmpty()) {
            _log.info("No CIFS Servers retrieved for mover {} with id {}", moverOrVdmName, moverOrVdmId);
        } else {
            for (VNXCifsServer cifsServer : cifsServers) {
                _log.debug("CIFServer:" + cifsServer.toString());
            }
        }
        // Format and issue separate ssh api commands for each new file system and subdirectory
        List<VNXFileExport> newExportEntries = new ArrayList<VNXFileExport>();
        sshApi.setConnParams(system.getIpAddress(), system.getUsername(), system.getPassword());
        for (String newPath : newPaths) {
            String netBios = null;
            // Only set netbios for VDM CIFS exports
            if (cifsServers != null && !cifsServers.isEmpty() && dataMover.getVirtual()) {
                netBios = cifsServers.get(0).getName();
            }
            for (VNXFileExport export : exports) {
                if (export.getMountPoint().equals(newPath)) {
                    export.setNetBios(netBios);
                    newExportEntries.add(export);
                }
            }
            _log.info("Export info {} {}", moverOrVdmName, netBios);
            // Check for existance of share by name
            String shareNameCheckData = sshApi.formatCheckShareForExportCmd(moverOrVdmName, newExportEntries, userInfo, netBios);
            if (shareNameCheckData != null) {
                XMLApiResult shareNameCheckCommandResult = sshApi.executeSshRetry(VNXFileSshApi.SERVER_EXPORT_CMD, shareNameCheckData);
                if (shareNameCheckCommandResult.isCommandSuccess()) {
                    _log.error("Export command failed for share name {}", newExportEntries.get(0).getExportName());
                    StringBuilder errorMessageBuilder = new StringBuilder();
                    errorMessageBuilder.append("Share by the name ");
                    errorMessageBuilder.append(newExportEntries.get(0).getExportName());
                    errorMessageBuilder.append(" Already exists on server ");
                    errorMessageBuilder.append(moverOrVdmName);
                    result.setCommandFailed();
                    result.setMessage(errorMessageBuilder.toString());
                    return result;
                }
            }
            String data = sshApi.formatExportCmd(moverOrVdmName, newExportEntries, userInfo, netBios);
            _log.info("Export command {}", data);
            if (data != null) {
                result = sshApi.executeSshRetry(VNXFileSshApi.SERVER_EXPORT_CMD, data);
            }
            if (!result.isCommandSuccess()) {
                if (firstExport) {
                    data = sshApi.formatUnMountCmd(moverOrVdmName, fs.getMountPath(), "NFS");
                    XMLApiResult unmountResult = sshApi.executeSshRetry(VNXFileSshApi.SERVER_UNMOUNT_CMD, data);
                    if (!unmountResult.isCommandSuccess()) {
                        _log.warn("Unmounting the file system {} failed due to {}", fs.getId(), unmountResult.getMessage());
                    } else {
                        _log.info("Unmounted the file system {} successfully", fs.getId());
                    }
                }
                return result;
            }
            newExportEntries.clear();
        }
        sshApi.clearConnParams();
    } catch (Exception e) {
        throw VNXException.exceptions.createExportFailed(result.getMessage(), e);
    }
    _log.info("doExport result: " + result.getMessage());
    return result;
}
Also used : VNXCifsServer(com.emc.storageos.vnx.xmlapi.VNXCifsServer) ArrayList(java.util.ArrayList) XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) URISyntaxException(java.net.URISyntaxException) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) VNXFileExport(com.emc.storageos.vnx.xmlapi.VNXFileExport) FileObject(com.emc.storageos.db.client.model.FileObject) ArrayList(java.util.ArrayList) NamespaceList(com.emc.storageos.plugins.common.domainmodel.NamespaceList) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashSet(java.util.HashSet)

Example 4 with VNXCifsServer

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

the class VNXCifsConfigProcessor 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 cifs config response" + resultObj);
    try {
        ResponsePacket responsePacket = (ResponsePacket) _unmarshaller.unmarshal(result.getResponseBodyAsStream());
        // 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("Received celerra session info from the Server.");
        }
        if (null != responsePacket.getPacketFault()) {
            Status status = responsePacket.getPacketFault();
            processErrorStatus(status, keyMap);
        } else {
            List<Object> queryResponse = getQueryResponse(responsePacket);
            Iterator<Object> queryRespItr = queryResponse.iterator();
            Boolean enabled = false;
            List<VNXCifsServer> cifsServers = new ArrayList<>();
            while (queryRespItr.hasNext()) {
                Object responseObj = queryRespItr.next();
                if (responseObj instanceof CifsServer) {
                    CifsServer config = (CifsServer) responseObj;
                    _logger.info("CIFS Interfaces: {}, for VDM: {}", config.getInterfaces(), config.getMover());
                    enabled = true;
                    // Get the domain of cifs server!!!
                    String domain = new String();
                    if (config.getNT40ServerData() != null) {
                        domain = config.getNT40ServerData().getDomain();
                    } else if (config.getW2KServerData() != null) {
                        domain = config.getW2KServerData().getDomain();
                    } else if (config.getStandaloneServerData() != null) {
                        domain = config.getStandaloneServerData().getWorkgroup();
                    }
                    if (!domain.isEmpty()) {
                        _logger.info("domain cofigured for cifs : {}", domain);
                    }
                    VNXCifsServer server = new VNXCifsServer(config.getName(), config.getMover(), config.getType().toString(), config.isMoverIdIsVdm(), config.getInterfaces(), domain);
                    cifsServers.add(server);
                    _logger.info("Add : {}", server.toString());
                }
            }
            keyMap.put(VNXFileConstants.CIFS_SUPPORTED, enabled);
            keyMap.put(VNXFileConstants.CIFS_SERVERS, cifsServers);
        }
    } catch (final Exception ex) {
        _logger.error("Exception occurred while processing the vnx cifs config response due to ", ex);
        keyMap.put(VNXFileConstants.FAULT_DESC, ex.getMessage());
        keyMap.put(VNXFileConstants.CMD_RESULT, VNXFileConstants.CMD_FAILURE);
    } finally {
        result.releaseConnection();
    }
}
Also used : Status(com.emc.nas.vnxfile.xmlapi.Status) VNXCifsServer(com.emc.storageos.vnx.xmlapi.VNXCifsServer) VNXCifsServer(com.emc.storageos.vnx.xmlapi.VNXCifsServer) CifsServer(com.emc.nas.vnxfile.xmlapi.CifsServer) PostMethod(org.apache.commons.httpclient.methods.PostMethod) ArrayList(java.util.ArrayList) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ResponsePacket(com.emc.nas.vnxfile.xmlapi.ResponsePacket) Header(org.apache.commons.httpclient.Header)

Example 5 with VNXCifsServer

use of com.emc.storageos.vnx.xmlapi.VNXCifsServer 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

VNXCifsServer (com.emc.storageos.vnx.xmlapi.VNXCifsServer)7 ArrayList (java.util.ArrayList)5 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)4 NamespaceList (com.emc.storageos.plugins.common.domainmodel.NamespaceList)4 VNXException (com.emc.storageos.vnx.xmlapi.VNXException)4 List (java.util.List)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)3 CifsServerMap (com.emc.storageos.db.client.model.CifsServerMap)2 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)2 FileObject (com.emc.storageos.db.client.model.FileObject)2 FileShare (com.emc.storageos.db.client.model.FileShare)2 NasCifsServer (com.emc.storageos.db.client.model.NasCifsServer)2 PhysicalNAS (com.emc.storageos.db.client.model.PhysicalNAS)2 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)2 StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)2 StringSet (com.emc.storageos.db.client.model.StringSet)2 UnManagedDiscoveredObject (com.emc.storageos.db.client.model.UnManagedDiscoveredObject)2 XMLApiResult (com.emc.storageos.vnx.xmlapi.XMLApiResult)2 URI (java.net.URI)2