Search in sources :

Example 1 with StoragePool

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

the class VNXFileArgsCreator method createFileSystem.

public InputStream createFileSystem(final Argument argument, final Map<String, Object> keyMap, int index) throws VNXFilePluginException {
    _logger.info("Creating a new VNX File file system");
    InputStream iStream = null;
    try {
        // Verify that the prior command executed properly.
        verifyPreviousResults(keyMap);
        Task task = new Task();
        NewFileSystem newFs = new NewFileSystem();
        String fsName = (String) keyMap.get(VNXFileConstants.FILESYSTEM_NAME);
        String poolName = (String) keyMap.get(VNXFileConstants.POOL_NAME);
        Long fsSize = (Long) keyMap.get(VNXFileConstants.FS_INIT_SIZE);
        Set<String> movers = (Set<String>) keyMap.get(VNXFileConstants.MOVERLIST);
        Boolean virtualProvisioning = (Boolean) keyMap.get(VNXFileConstants.FILESYSTEM_VIRTUAL_PROVISIONING);
        if (isInValid(fsName) || isInValid(poolName) || null == fsSize || null == movers || (movers.isEmpty())) {
            throw new VNXFilePluginException("Prior command did not execute successfully", VNXFilePluginException.ERRORCODE_ILLEGALARGUMENTEXCEPTION);
        }
        String dataMover = null;
        if (!movers.isEmpty()) {
            Iterator<String> iter = movers.iterator();
            dataMover = iter.next();
        }
        _logger.debug("new file system name: {}", fsName);
        _logger.debug("using virtual prov: {}", virtualProvisioning);
        newFs.setName(fsName);
        StoragePool pool = new StoragePool();
        pool.setPool(poolName);
        pool.setVirtualProvisioning(virtualProvisioning);
        if (virtualProvisioning) {
            EnableAutoExt autoExt = new EnableAutoExt();
            autoExt.setAutoExtensionMaxSize(fsSize);
            autoExt.setHighWaterMark(EXT_HW_MARK);
            pool.setEnableAutoExt(autoExt);
            pool.setSize(MIN_FILESYSTEM_SIZE);
        } else {
            pool.setSize(fsSize);
        }
        newFs.setStoragePool(pool);
        newFs.setType(FileSystemType.UXFS);
        MoverRef mvRef = new MoverRef();
        mvRef.setMover(dataMover);
        newFs.setMover(mvRef);
        task.setNewFileSystem(newFs);
        iStream = _vnxFileInputRequestBuilder.getTaskParamPacket(task, true);
    } catch (JAXBException jaxbException) {
        throw new VNXFilePluginException("Exception occurred while generating input xml for creating new file system", jaxbException.getCause());
    }
    return iStream;
}
Also used : Task(com.emc.nas.vnxfile.xmlapi.Task) FileSystemUsageSet(com.emc.nas.vnxfile.xmlapi.FileSystemUsageSet) Set(java.util.Set) StoragePool(com.emc.nas.vnxfile.xmlapi.ExtendFileSystem.StoragePool) InputStream(java.io.InputStream) NewFileSystem(com.emc.nas.vnxfile.xmlapi.NewFileSystem) JAXBException(javax.xml.bind.JAXBException) MoverRef(com.emc.nas.vnxfile.xmlapi.MoverRef) EnableAutoExt(com.emc.nas.vnxfile.xmlapi.ExtendFileSystem.StoragePool.EnableAutoExt)

Example 2 with StoragePool

use of com.emc.nas.vnxfile.xmlapi.ExtendFileSystem.StoragePool 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

StoragePool (com.emc.nas.vnxfile.xmlapi.ExtendFileSystem.StoragePool)2 NewFileSystem (com.emc.nas.vnxfile.xmlapi.NewFileSystem)2 Task (com.emc.nas.vnxfile.xmlapi.Task)2 InputStream (java.io.InputStream)2 JAXBException (javax.xml.bind.JAXBException)2 DeleteFileSystem (com.emc.nas.vnxfile.xmlapi.DeleteFileSystem)1 ExtendFileSystem (com.emc.nas.vnxfile.xmlapi.ExtendFileSystem)1 EnableAutoExt (com.emc.nas.vnxfile.xmlapi.ExtendFileSystem.StoragePool.EnableAutoExt)1 FileSystem (com.emc.nas.vnxfile.xmlapi.FileSystem)1 FileSystemUsageSet (com.emc.nas.vnxfile.xmlapi.FileSystemUsageSet)1 ModifyFileSystem (com.emc.nas.vnxfile.xmlapi.ModifyFileSystem)1 MoverRef (com.emc.nas.vnxfile.xmlapi.MoverRef)1 Set (java.util.Set)1