Search in sources :

Example 1 with FileSystem

use of com.emc.nas.vnxfile.xmlapi.FileSystem in project coprhd-controller by CoprHD.

the class VNXFileSystemIdProcessor method processFilesystemList.

/**
 * Process the fileSystemList which are received from XMLAPI server.
 *
 * @param filesystemList : List of FileSystem objects.
 * @param keyMap : keyMap.
 */
private void processFilesystemList(List<Object> filesystemList, Map<String, Object> keyMap) throws VNXFilePluginException {
    String fsName = (String) keyMap.get(VNXFileConstants.FILESYSTEM_NAME);
    String fsId = (String) keyMap.get(VNXFileConstants.FILESYSTEM_ID);
    boolean foundId = false;
    Iterator<Object> iterator = filesystemList.iterator();
    if (iterator.hasNext()) {
        Status status = (Status) iterator.next();
        if (status.getMaxSeverity() == Severity.OK) {
            while (iterator.hasNext()) {
                FileSystem fileSystem = (FileSystem) iterator.next();
                if (fileSystem.getName().equals(fsName) || fileSystem.getFileSystem().equals(fsId)) {
                    String id = fileSystem.getFileSystem();
                    _logger.info("Found matching file system: {}", id);
                    keyMap.put(VNXFileConstants.FILESYSTEM_ID, id);
                    keyMap.put(VNXFileConstants.FILESYSTEM, fileSystem);
                    keyMap.put(VNXFileConstants.IS_FILESYSTEM_AVAILABLE_ON_ARRAY, Boolean.TRUE);
                    foundId = true;
                    break;
                }
            }
            if (!foundId) {
                _logger.error("Did not find file system ID for {}", fsName);
                keyMap.put(VNXFileConstants.IS_FILESYSTEM_AVAILABLE_ON_ARRAY, Boolean.FALSE);
            }
        } else {
            throw new VNXFilePluginException("Fault response received from XMLAPI Server.", VNXFilePluginException.ERRORCODE_INVALID_RESPONSE);
        }
    }
}
Also used : Status(com.emc.nas.vnxfile.xmlapi.Status) FileSystem(com.emc.nas.vnxfile.xmlapi.FileSystem) VNXFilePluginException(com.emc.storageos.plugins.metering.vnxfile.VNXFilePluginException)

Example 2 with FileSystem

use of com.emc.nas.vnxfile.xmlapi.FileSystem in project coprhd-controller by CoprHD.

the class VNXFileSystemInfoProcessor method processFilesystemList.

/**
 * Process the fileSystemList which are received from XMLAPI server.
 *
 * @param filesystemList : List of FileSystem objects.
 * @param keyMap : keyMap.
 */
private void processFilesystemList(List<Object> filesystemList, Map<String, Object> keyMap) throws VNXFilePluginException {
    Iterator<Object> iterator = filesystemList.iterator();
    Map<String, String> volFilesystemMap = new HashMap<String, String>();
    Set<String> moverIds = new HashSet<String>();
    if (iterator.hasNext()) {
        Status status = (Status) iterator.next();
        if (status.getMaxSeverity() == Severity.OK) {
            while (iterator.hasNext()) {
                FileSystem fileSystem = (FileSystem) iterator.next();
                volFilesystemMap.put(fileSystem.getVolume(), fileSystem.getFileSystem());
                List<MoverOrVdmRef> roFileSysHosts = fileSystem.getRoFileSystemHosts();
                Iterator<MoverOrVdmRef> roFileSysHostItr = roFileSysHosts.iterator();
                while (roFileSysHostItr.hasNext()) {
                    MoverOrVdmRef mover = roFileSysHostItr.next();
                    moverIds.add(mover.getMover());
                }
            }
        } else {
            throw new VNXFilePluginException("Fault response received from XMLAPI Server.", VNXFilePluginException.ERRORCODE_INVALID_RESPONSE);
        }
    }
    keyMap.put(VNXFileConstants.MOVERLIST, moverIds);
    keyMap.put(VNXFileConstants.VOLFILESHAREMAP, volFilesystemMap);
}
Also used : Status(com.emc.nas.vnxfile.xmlapi.Status) HashMap(java.util.HashMap) VNXFilePluginException(com.emc.storageos.plugins.metering.vnxfile.VNXFilePluginException) FileSystem(com.emc.nas.vnxfile.xmlapi.FileSystem) MoverOrVdmRef(com.emc.nas.vnxfile.xmlapi.MoverOrVdmRef) HashSet(java.util.HashSet)

Example 3 with FileSystem

use of com.emc.nas.vnxfile.xmlapi.FileSystem in project coprhd-controller by CoprHD.

the class VNXFileSystemsProcessor method processFilesystemList.

/**
 * Process the fileSystemList which are received from XMLAPI server.
 *
 * @param filesystemList : List of FileSystem objects.
 * @param keyMap : keyMap.
 */
private List<VNXFileSystem> processFilesystemList(List<Object> filesystemList, Map<String, Object> keyMap) throws VNXFilePluginException {
    Iterator<Object> iterator = filesystemList.iterator();
    List<VNXFileSystem> processedFileSystem = new ArrayList<VNXFileSystem>();
    if (iterator.hasNext()) {
        Status status = (Status) iterator.next();
        if ((status.getMaxSeverity() == Severity.OK) || (status.getMaxSeverity() == Severity.WARNING)) {
            Map<String, FileSystem> fileSystems = new HashMap<String, FileSystem>();
            Map<String, FileSystemCapacityInfo> fileSysCapacityInfos = new HashMap<String, FileSystemCapacityInfo>();
            while (iterator.hasNext()) {
                Object obj = iterator.next();
                if (obj instanceof FileSystem) {
                    FileSystem fs = (FileSystem) obj;
                    if (fs.isInternalUse() == false) {
                        fileSystems.put(fs.getFileSystem(), fs);
                    }
                } else if (obj instanceof FileSystemCapacityInfo) {
                    FileSystemCapacityInfo fsCapacityInfo = (FileSystemCapacityInfo) obj;
                    fileSysCapacityInfos.put(fsCapacityInfo.getFileSystem(), fsCapacityInfo);
                }
            }
            Iterator it = fileSystems.keySet().iterator();
            while (it.hasNext()) {
                String fsId = (String) it.next();
                FileSystem fileSystem = fileSystems.get(fsId);
                FileSystemCapacityInfo fsCapacity = fileSysCapacityInfos.get(fsId);
                List<String> pools = new ArrayList<String>();
                if (null != fileSystem.getStoragePools()) {
                    pools = fileSystem.getStoragePools();
                }
                String poolId = "";
                if (null != pools) {
                    poolId = pools.get(0);
                }
                StringBuffer debugInfo = new StringBuffer();
                debugInfo.append("VNXFileSystem : " + fileSystem.getName());
                debugInfo.append(" Pool : " + poolId);
                long totalCapacity = 0;
                VNXFileSystem vnxFS = new VNXFileSystem(fileSystem.getName(), Integer.valueOf(fileSystem.getFileSystem()));
                if (fileSystem.isVirtualProvisioning()) {
                    vnxFS.setType(UnManagedDiscoveredObject.SupportedProvisioningType.THIN.name());
                    FileSystemAutoExtInfo autoExtInfo = fileSystem.getFileSystemAutoExtInfo();
                    if (null != autoExtInfo) {
                        totalCapacity = autoExtInfo.getAutoExtensionMaxSize();
                        totalCapacity = totalCapacity * MBTOBYTECONVERTER;
                    } else {
                        totalCapacity = fsCapacity.getVolumeSize() * MBTOBYTECONVERTER;
                    }
                } else {
                    vnxFS.setType(UnManagedDiscoveredObject.SupportedProvisioningType.THICK.name());
                    totalCapacity = fsCapacity.getVolumeSize() * MBTOBYTECONVERTER;
                }
                vnxFS.setStoragePool(poolId);
                debugInfo.append(" fsCapacity.getVolumeSize() : " + fsCapacity.getVolumeSize());
                vnxFS.setTotalCapacity(totalCapacity + "");
                vnxFS.setUsedCapcity("0");
                if (null != fsCapacity.getResourceUsage()) {
                    // We can get Used capacity
                    // Size is in MB, convert to Bytes
                    debugInfo.append(" fsCapacity.getUsedCapacity:" + fsCapacity.getResourceUsage().getSpaceUsed());
                    long usedCapacity = fsCapacity.getResourceUsage().getSpaceUsed() * MBTOBYTECONVERTER;
                    vnxFS.setUsedCapcity(usedCapacity + "");
                }
                debugInfo.append(" Total Capacity :" + vnxFS.getTotalCapacity());
                debugInfo.append(" Used Capacity :" + vnxFS.getUsedCapacity());
                _logger.debug(debugInfo.toString());
                processedFileSystem.add(vnxFS);
            }
        } else {
            throw new com.emc.storageos.plugins.metering.vnxfile.VNXFilePluginException("Fault response received from XMLAPI Server.", VNXFilePluginException.ERRORCODE_INVALID_RESPONSE);
        }
    }
    return processedFileSystem;
}
Also used : Status(com.emc.nas.vnxfile.xmlapi.Status) HashMap(java.util.HashMap) FileSystemCapacityInfo(com.emc.nas.vnxfile.xmlapi.FileSystemCapacityInfo) VNXFilePluginException(com.emc.storageos.plugins.metering.vnxfile.VNXFilePluginException) ArrayList(java.util.ArrayList) VNXFileSystem(com.emc.storageos.vnx.xmlapi.VNXFileSystem) VNXFileSystem(com.emc.storageos.vnx.xmlapi.VNXFileSystem) FileSystem(com.emc.nas.vnxfile.xmlapi.FileSystem) Iterator(java.util.Iterator) FileSystemAutoExtInfo(com.emc.nas.vnxfile.xmlapi.FileSystemAutoExtInfo) UnManagedDiscoveredObject(com.emc.storageos.db.client.model.UnManagedDiscoveredObject)

Example 4 with FileSystem

use of com.emc.nas.vnxfile.xmlapi.FileSystem in project coprhd-controller by CoprHD.

the class VNXFileArgsCreator method doModifyFS.

public InputStream doModifyFS(final Argument argument, final Map<String, Object> keyMap, int index) throws VNXFilePluginException {
    _logger.info("ArgsCreator: VNX File Modify");
    InputStream iStream = null;
    try {
        // Verify that the prior command executed properly.
        verifyPreviousResults(keyMap);
        Task task = new Task();
        ModifyFileSystem modifyFS = new ModifyFileSystem();
        FileSystem fsSystem = (FileSystem) keyMap.get(VNXFileConstants.FILESYSTEM);
        String fsName = (String) keyMap.get(VNXFileConstants.FILESYSTEM_NAME);
        String fsId = (String) keyMap.get(VNXFileConstants.FILESYSTEM_ID);
        Long size = (Long) keyMap.get(VNXFileConstants.FILESYSTEM_SIZE);
        Boolean isVirtualProvisioning = (Boolean) keyMap.get(VNXFileConstants.FILESYSTEM_VIRTUAL_PROVISIONING);
        if (null == fsSystem || isInValid(fsName) || isInValid(fsId) || null == size) {
            throw new VNXFilePluginException("Prior command did not execute successfully", VNXFilePluginException.ERRORCODE_ILLEGALARGUMENTEXCEPTION);
        }
        modifyFS.setVirtualProvisioning(isVirtualProvisioning);
        if (isVirtualProvisioning) {
            AutoExtend autoExtend = new AutoExtend();
            autoExtend.setHighWaterMark(EXT_HW_MARK);
            autoExtend.setAutoExtensionMaxSize(size);
            modifyFS.setAutoExtend(autoExtend);
        }
        _logger.info("Modifying File system max size : {}, name {}", size, fsName);
        modifyFS.setFileSystem(fsSystem.getFileSystem());
        task.setModifyFileSystem(modifyFS);
        iStream = _vnxFileInputRequestBuilder.getTaskParamPacket(task, true);
    } catch (JAXBException jaxbException) {
        throw new VNXFilePluginException("Exception occurred while fetching fileSystem info", jaxbException.getCause());
    }
    return iStream;
}
Also used : AutoExtend(com.emc.nas.vnxfile.xmlapi.ModifyFileSystem.AutoExtend) Task(com.emc.nas.vnxfile.xmlapi.Task) InputStream(java.io.InputStream) ModifyFileSystem(com.emc.nas.vnxfile.xmlapi.ModifyFileSystem) ExtendFileSystem(com.emc.nas.vnxfile.xmlapi.ExtendFileSystem) DeleteFileSystem(com.emc.nas.vnxfile.xmlapi.DeleteFileSystem) NewFileSystem(com.emc.nas.vnxfile.xmlapi.NewFileSystem) FileSystem(com.emc.nas.vnxfile.xmlapi.FileSystem) JAXBException(javax.xml.bind.JAXBException) ModifyFileSystem(com.emc.nas.vnxfile.xmlapi.ModifyFileSystem)

Example 5 with FileSystem

use of com.emc.nas.vnxfile.xmlapi.FileSystem in project coprhd-controller by CoprHD.

the class VNXFileArgsCreator method doExpand.

public InputStream doExpand(final Argument argument, final Map<String, Object> keyMap, int index) throws VNXFilePluginException {
    _logger.info("ArgsCreator: VNX File Expand");
    InputStream iStream = null;
    try {
        // Verify that the prior command executed properly.
        verifyPreviousResults(keyMap);
        Task task = new Task();
        ExtendFileSystem extendFS = new ExtendFileSystem();
        FileSystem fsSystem = (FileSystem) keyMap.get(VNXFileConstants.FILESYSTEM);
        String fsName = (String) keyMap.get(VNXFileConstants.FILESYSTEM_NAME);
        String fsId = (String) keyMap.get(VNXFileConstants.FILESYSTEM_ID);
        Long fsSize = (Long) keyMap.get(VNXFileConstants.FILESYSTEM_SIZE);
        Long fsAllocatedSize = (Long) keyMap.get(VNXFileConstants.ORIGINAL_FS_SIZE);
        Boolean isVirtualProvisioning = (Boolean) keyMap.get(VNXFileConstants.FILESYSTEM_VIRTUAL_PROVISIONING);
        Long fsThinPerAllocSize = (Long) keyMap.get(VNXFileConstants.THIN_FS_ALLOC_SIZE);
        if (null == fsSystem || isInValid(fsName) || isInValid(fsId) || null == fsSize || null == fsAllocatedSize) {
            throw new VNXFilePluginException("Prior command did not execute successfully", VNXFilePluginException.ERRORCODE_ILLEGALARGUMENTEXCEPTION);
        }
        Long fsExpandSize = fsSize - fsAllocatedSize;
        if (fsExpandSize < 0) {
            fsExpandSize = fsSize;
        }
        // How much more I should allocate for you?
        if (isVirtualProvisioning) {
            fsExpandSize = fsThinPerAllocSize;
            if (fsAllocatedSize < fsThinPerAllocSize) {
                fsExpandSize = fsThinPerAllocSize - fsAllocatedSize;
            }
        }
        _logger.info("Expanding File system size : {}, thin {}", fsExpandSize, isVirtualProvisioning);
        String pool = fsSystem.getStoragePools().get(0);
        String storage = fsSystem.getStorages().get(0);
        if (isInValid(pool) || isInValid(storage)) {
            throw new VNXFilePluginException("Prior command did not execute successfully", VNXFilePluginException.ERRORCODE_ILLEGALARGUMENTEXCEPTION);
        }
        ExtendFileSystem.StoragePool sp = new ExtendFileSystem.StoragePool();
        sp.setPool(pool);
        if (fsExpandSize > 0) {
            sp.setSize(fsExpandSize);
        }
        sp.setStorage(storage);
        _logger.info("Expanding File system using StoragePool : {}, storage {}", pool, storage);
        _logger.info("Expanding File system size : {}, name {}", fsExpandSize, fsName);
        extendFS.setFileSystem(fsSystem.getFileSystem());
        extendFS.setStoragePool(sp);
        task.setExtendFileSystem(extendFS);
        iStream = _vnxFileInputRequestBuilder.getTaskParamPacket(task);
    } catch (JAXBException jaxbException) {
        throw new VNXFilePluginException("Exception occurred while fetching fileSystem info", jaxbException.getCause());
    }
    return iStream;
}
Also used : Task(com.emc.nas.vnxfile.xmlapi.Task) StoragePool(com.emc.nas.vnxfile.xmlapi.ExtendFileSystem.StoragePool) StoragePool(com.emc.nas.vnxfile.xmlapi.ExtendFileSystem.StoragePool) InputStream(java.io.InputStream) ExtendFileSystem(com.emc.nas.vnxfile.xmlapi.ExtendFileSystem) ModifyFileSystem(com.emc.nas.vnxfile.xmlapi.ModifyFileSystem) ExtendFileSystem(com.emc.nas.vnxfile.xmlapi.ExtendFileSystem) DeleteFileSystem(com.emc.nas.vnxfile.xmlapi.DeleteFileSystem) NewFileSystem(com.emc.nas.vnxfile.xmlapi.NewFileSystem) FileSystem(com.emc.nas.vnxfile.xmlapi.FileSystem) JAXBException(javax.xml.bind.JAXBException)

Aggregations

FileSystem (com.emc.nas.vnxfile.xmlapi.FileSystem)6 Status (com.emc.nas.vnxfile.xmlapi.Status)4 VNXFilePluginException (com.emc.storageos.plugins.metering.vnxfile.VNXFilePluginException)4 DeleteFileSystem (com.emc.nas.vnxfile.xmlapi.DeleteFileSystem)2 ExtendFileSystem (com.emc.nas.vnxfile.xmlapi.ExtendFileSystem)2 ModifyFileSystem (com.emc.nas.vnxfile.xmlapi.ModifyFileSystem)2 MoverOrVdmRef (com.emc.nas.vnxfile.xmlapi.MoverOrVdmRef)2 NewFileSystem (com.emc.nas.vnxfile.xmlapi.NewFileSystem)2 Task (com.emc.nas.vnxfile.xmlapi.Task)2 InputStream (java.io.InputStream)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 JAXBException (javax.xml.bind.JAXBException)2 StoragePool (com.emc.nas.vnxfile.xmlapi.ExtendFileSystem.StoragePool)1 FileSystemAutoExtInfo (com.emc.nas.vnxfile.xmlapi.FileSystemAutoExtInfo)1 FileSystemCapacityInfo (com.emc.nas.vnxfile.xmlapi.FileSystemCapacityInfo)1 AutoExtend (com.emc.nas.vnxfile.xmlapi.ModifyFileSystem.AutoExtend)1 UnManagedDiscoveredObject (com.emc.storageos.db.client.model.UnManagedDiscoveredObject)1 VNXFileSystem (com.emc.storageos.vnx.xmlapi.VNXFileSystem)1 ArrayList (java.util.ArrayList)1