Search in sources :

Example 6 with VNXFileSystem

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

the class VNXFileCommunicationInterface method getAllFileSystem.

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

Example 7 with VNXFileSystem

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

the class VNXFileStorageDeviceXML method doCreateFS.

@Override
public BiosCommandResult doCreateFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    Map<String, String> autoExtendAtts = getAutoExtendAttrs(args);
    Long fsSize = args.getFsCapacity() / BYTESPERMB;
    if (fsSize < 1) {
        // Invalid size throw an error
        String errMsg = "doCreateFS failed : FileSystem size in bytes is not valid " + args.getFsCapacity();
        _log.error(errMsg);
        return BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToCreateFileSystem(errMsg));
    }
    _log.info("FileSystem size translation : {} : {} ", args.getFsCapacity(), fsSize);
    XMLApiResult result = null;
    ApplicationContext context = null;
    try {
        context = loadContext();
        VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
        if (null == vnxComm) {
            throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
        }
        result = vnxComm.createFileSystem(storage, args.getFsName(), // This will be used for CLI create FS
        args.getPoolName(), "1", fsSize, args.getThinProvision(), args.getNativeDeviceFsId(), autoExtendAtts);
        if (result.isCommandSuccess()) {
            VNXFileSystem vnxFS = (VNXFileSystem) result.getObject();
            args.setFsNativeId(String.valueOf(vnxFS.getFsId()));
            String path = "/" + args.getFsName();
            // Set path & mountpath
            args.setFsMountPath(path);
            args.setFsPath(path);
        }
    } catch (VNXException e) {
        throw DeviceControllerException.exceptions.unableToCreateFileSystem(e.getMessage(Locale.getDefault()));
    } finally {
        clearContext(context);
    }
    BiosCommandResult cmdResult = null;
    if (result.isCommandSuccess()) {
        cmdResult = BiosCommandResult.createSuccessfulResult();
    } else {
        cmdResult = BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToCreateFileSystem(result.getMessage()));
    }
    return cmdResult;
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) VNXFileSystem(com.emc.storageos.vnx.xmlapi.VNXFileSystem) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) VNXFileCommApi(com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi) XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult)

Example 8 with VNXFileSystem

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

the class VNXFileCommApi method createFileSystem.

public XMLApiResult createFileSystem(final StorageSystem system, final String fileSys, final String pool, final String dataMover, final Long size, final boolean virtualProvisioning, final String nativeFsId, final Map autoAtts) throws VNXException {
    _log.info("Create VNX File System: {} on data mover {}", fileSys, dataMover);
    XMLApiResult result = new XMLApiResult();
    Map<String, Object> reqAttributeMap = new ConcurrentHashMap<String, Object>();
    try {
        updateAttributes(reqAttributeMap, system);
        reqAttributeMap.put(VNXFileConstants.FILESYSTEM_NAME, fileSys);
        reqAttributeMap.put(VNXFileConstants.MOUNT_PATH, "/" + fileSys);
        reqAttributeMap.put(VNXFileConstants.POOL_NAME, pool);
        reqAttributeMap.put(VNXFileConstants.FS_INIT_SIZE, size);
        reqAttributeMap.put(VNXFileConstants.MOVER_ID, dataMover);
        reqAttributeMap.put(VNXFileConstants.FILESYSTEM_VIRTUAL_PROVISIONING, virtualProvisioning);
        _provExecutor.setKeyMap(reqAttributeMap);
        String cmdResult = VNXFileConstants.CMD_SUCCESS;
        // CHeck for FSId provided
        // If provided query the array for the FSId in use
        // If in use error out
        // if not in use create the FS thin or thick
        Boolean foundFSwithId = false;
        if (null != nativeFsId && !nativeFsId.isEmpty()) {
            String fileSysId = nativeFsId;
            _log.info("Query file system query with id {}.", fileSysId);
            _provExecutor.getKeyMap().put(VNXFileConstants.FILESYSTEM_ID, fileSysId);
            _provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_FSIDQUERY_FILE));
            cmdResult = (String) _provExecutor.getKeyMap().get(VNXFileConstants.CMD_RESULT);
            if (cmdResult.equals(VNXFileConstants.CMD_SUCCESS)) {
                fileSysId = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FILESYSTEM_ID);
                foundFSwithId = (Boolean) _provExecutor.getKeyMap().get(VNXFileConstants.IS_FILESYSTEM_AVAILABLE_ON_ARRAY);
            }
            if (foundFSwithId) {
                _log.info("There is a FileSystem exist with the id {} so fail the create.", fileSysId);
                result.setCommandFailed();
                result.setMessage("File System creation failed because a File System with exist with id " + nativeFsId);
                return result;
            } else {
                _log.info("There is no FileSystem  with the id {} so proceed with create.", fileSysId);
            }
        } else {
            _log.info("FileSystem Id provided is null or empty so we will use system generated id");
        }
        // calculate the thin fs allocation size
        String thinProvFsSizeMBs = THIN_PROVISIONED_FS_SIZE_MB;
        if (virtualProvisioning) {
            thinProvFsSizeMBs = getThinFSAllocSize(size, true).toString();
        }
        // FileSystem doesnt exist on the array, so now create it
        sshApi.setConnParams(system.getIpAddress(), system.getUsername(), system.getPassword());
        String createFSCmd = sshApi.formatCreateFS(fileSys, FILE_SYSTEM_TYPE_DEF, thinProvFsSizeMBs, size.toString(), pool, "", virtualProvisioning, nativeFsId);
        _log.info("parsed createFSCmd {}.", createFSCmd);
        result = sshApi.executeSshRetry(VNXFileSshApi.NAS_FS, createFSCmd);
        if (!result.isCommandSuccess()) {
            cmdResult = VNXFileConstants.CMD_FAILURE;
        }
        if (cmdResult.equals(VNXFileConstants.CMD_SUCCESS)) {
            String fileSysId = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FILESYSTEM_ID);
            int fsId = 0;
            if (null == fileSysId || fileSysId.isEmpty()) {
                // Since there was no error but the file system id was not found, query for id again.
                _log.info("Second file system create query.");
                _provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_FSIDQUERY_FILE));
                cmdResult = (String) _provExecutor.getKeyMap().get(VNXFileConstants.CMD_RESULT);
                if (cmdResult.equals(VNXFileConstants.CMD_SUCCESS)) {
                    fileSysId = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FILESYSTEM_ID);
                    if (null != fileSysId && !fileSysId.isEmpty()) {
                        fsId = Integer.parseInt(fileSysId);
                    }
                }
            } else {
                fsId = Integer.parseInt(fileSysId);
            }
            if (0 < fsId) {
                _log.info("VNX File System create success!  ID: {}", fsId);
                String fsType = (String) autoAtts.get(FILE_SYSTEM_TYPE_ATTRIBUTE);
                String worm = (String) autoAtts.get(WORM_ATTRIBUTE);
                VNXFileSystem newFs = new VNXFileSystem(fileSys, -1, pool, fsType, worm, dataMover, Long.toString(size), autoAtts);
                result.setCommandSuccess();
                newFs.setFsId(fsId);
                result.setObject(newFs);
            } else {
                result.setCommandFailed();
                result.setMessage("File System creation failed");
            }
        } else {
            String errMsg = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_DESC);
            result.setCommandFailed();
            result.setMessage(errMsg);
        }
    } catch (Exception e) {
        throw VNXException.exceptions.createFileSystemFailed(e.getMessage());
    }
    return result;
}
Also used : VNXFileSystem(com.emc.storageos.vnx.xmlapi.VNXFileSystem) FileObject(com.emc.storageos.db.client.model.FileObject) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) Checkpoint(com.emc.nas.vnxfile.xmlapi.Checkpoint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) URISyntaxException(java.net.URISyntaxException) VNXException(com.emc.storageos.vnx.xmlapi.VNXException)

Aggregations

VNXFileSystem (com.emc.storageos.vnx.xmlapi.VNXFileSystem)8 UnManagedDiscoveredObject (com.emc.storageos.db.client.model.UnManagedDiscoveredObject)4 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)4 VNXException (com.emc.storageos.vnx.xmlapi.VNXException)4 ArrayList (java.util.ArrayList)3 Status (com.emc.nas.vnxfile.xmlapi.Status)2 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)2 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)2 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)2 VNXFileCollectionException (com.emc.storageos.plugins.metering.vnxfile.VNXFileCollectionException)2 VNXFilePluginException (com.emc.storageos.plugins.metering.vnxfile.VNXFilePluginException)2 XMLApiResult (com.emc.storageos.vnx.xmlapi.XMLApiResult)2 IOException (java.io.IOException)2 URISyntaxException (java.net.URISyntaxException)2 HashMap (java.util.HashMap)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Checkpoint (com.emc.nas.vnxfile.xmlapi.Checkpoint)1 FileSystem (com.emc.nas.vnxfile.xmlapi.FileSystem)1 FileSystemAutoExtInfo (com.emc.nas.vnxfile.xmlapi.FileSystemAutoExtInfo)1