Search in sources :

Example 6 with VNXException

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

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

the class VNXFileCommApi method getCheckpointsOfFilesystem.

/**
 * Gets the list of file system checkpoints
 *
 * @param system storage system details
 * @param fsId the file system ID
 * @return List of checkpoints
 */
@SuppressWarnings("unchecked")
public List<Checkpoint> getCheckpointsOfFilesystem(StorageSystem system, String fsId) {
    _log.info("Check snapshot of file system : {}", fsId);
    List<Checkpoint> checkpoints = null;
    try {
        if (null == fsId || fsId.trim().equals("")) {
            _log.error("FS ID is null or empty: {}", fsId);
            throw VNXException.exceptions.getFileSystemSnapshotsFailed("FS ID is null or empty.");
        }
        Map<String, Object> reqAttributeMap = new ConcurrentHashMap<String, Object>();
        updateAttributes(reqAttributeMap, system);
        reqAttributeMap.put(VNXFileConstants.FILESYSTEM_ID, fsId);
        _provExecutor.setKeyMap(reqAttributeMap);
        _provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_FS_SNAPSHOT_QUERY));
        String cmdResult = (String) _provExecutor.getKeyMap().get(VNXFileConstants.CMD_RESULT);
        if (VNXFileConstants.CMD_SUCCESS.equals(cmdResult)) {
            checkpoints = (List<Checkpoint>) _provExecutor.getKeyMap().get(VNXFileConstants.SNAPSHOTS_LIST);
        } else {
            String errMsg = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_DESC);
            throw VNXException.exceptions.getFileSystemSnapshotsFailed(errMsg);
        }
    } catch (Exception e) {
        throw new VNXException("Failure", e);
    }
    return checkpoints;
}
Also used : Checkpoint(com.emc.nas.vnxfile.xmlapi.Checkpoint) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) FileObject(com.emc.storageos.db.client.model.FileObject) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) URISyntaxException(java.net.URISyntaxException) VNXException(com.emc.storageos.vnx.xmlapi.VNXException)

Example 8 with VNXException

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

the class VNXFileCommApi method deleteQuotaDirectory.

public XMLApiResult deleteQuotaDirectory(final StorageSystem system, final String fsName, final String quotaDirName, final Boolean forceDelete, Boolean isMountRequired) throws VNXException {
    _log.info("Delete VNX File System Quota dir: {} on file system {}", quotaDirName, fsName);
    XMLApiResult result = new XMLApiResult();
    Map<String, Object> reqAttributeMap = new ConcurrentHashMap<String, Object>();
    try {
        if (isMountRequired) {
            // means there is no fs export in Vipr and mount is needed.
            // just cross check with array fs have mount.
            isMountRequired = !isMountPresentOnArray(fsName, system);
        }
        updateAttributes(reqAttributeMap, system);
        reqAttributeMap.put(VNXFileConstants.FILESYSTEM_NAME, fsName);
        reqAttributeMap.put(VNXFileConstants.QUOTA_DIR_NAME, quotaDirName);
        reqAttributeMap.put(VNXFileConstants.QTREE_FORCE_DELETE, forceDelete);
        reqAttributeMap.put(VNXFileConstants.MOUNT_PATH, "/" + fsName);
        _provExecutor.setKeyMap(reqAttributeMap);
        if (isMountRequired) {
            _provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_FILE_QUOTA_DIR_DELETE_MOUNT));
        } else {
            _provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_FILE_QUOTA_DIR_DELETE));
        }
        String cmdResult = (String) _provExecutor.getKeyMap().get(VNXFileConstants.CMD_RESULT);
        if (cmdResult != null && cmdResult.equals(VNXFileConstants.CMD_SUCCESS)) {
            result.setCommandSuccess();
        } else {
            String errMsg = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_DESC);
            result.setCommandFailed();
            result.setMessage(errMsg);
        }
    } catch (Exception e) {
        throw new VNXException("Failure", e);
    }
    return result;
}
Also used : VNXException(com.emc.storageos.vnx.xmlapi.VNXException) FileObject(com.emc.storageos.db.client.model.FileObject) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult) URISyntaxException(java.net.URISyntaxException) VNXException(com.emc.storageos.vnx.xmlapi.VNXException)

Example 9 with VNXException

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

the class VNXFileCommApi method modifyQuotaDirectory.

public XMLApiResult modifyQuotaDirectory(final StorageSystem system, final String fsName, final String quotaDirName, final String securityStyle, final Long size, final Boolean oplocks, Boolean isMountRequired) throws VNXException {
    _log.info("Modify VNX File System Quota dir: {} on file system {}", quotaDirName, fsName);
    XMLApiResult result = new XMLApiResult();
    Map<String, Object> reqAttributeMap = new ConcurrentHashMap<String, Object>();
    try {
        updateAttributes(reqAttributeMap, system);
        reqAttributeMap.put(VNXFileConstants.FILESYSTEM_NAME, fsName);
        reqAttributeMap.put(VNXFileConstants.QUOTA_DIR_NAME, quotaDirName);
        reqAttributeMap.put(VNXFileConstants.HARD_QUOTA, size);
        reqAttributeMap.put(VNXFileConstants.MOUNT_PATH, "/" + fsName);
        reqAttributeMap.put(VNXFileConstants.SECURITY_STYLE, securityStyle);
        reqAttributeMap.put(VNXFileConstants.OPLOCKS, oplocks);
        _provExecutor.setKeyMap(reqAttributeMap);
        if (isMountRequired) {
            _provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_FILE_QUOTA_DIR_MODIFY_MOUNT));
        } else {
            _provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_FILE_QUOTA_DIR_MODIFY));
        }
        String cmdResult = (String) _provExecutor.getKeyMap().get(VNXFileConstants.CMD_RESULT);
        if (cmdResult != null && cmdResult.equals(VNXFileConstants.CMD_SUCCESS)) {
            String quotaDirId = (String) _provExecutor.getKeyMap().get(VNXFileConstants.QUOTA_DIR_ID);
            String fsysId = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FILESYSTEM_ID);
            if (quotaDirId != null) {
                int fsId = Integer.parseInt(fsysId);
                int qdId = Integer.parseInt(quotaDirId);
                VNXQuotaTree vnxQuotaTree = new VNXQuotaTree(quotaDirName, -1, fsId);
                vnxQuotaTree.setId(qdId);
                result.setObject(vnxQuotaTree);
                result.setCommandSuccess();
            } else {
                result.setCommandFailed();
                result.setMessage((String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_DESC));
            }
        } else {
            String errMsg = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_DESC);
            result.setCommandFailed();
            result.setMessage(errMsg);
        }
    } catch (Exception e) {
        throw new VNXException("Failure", e);
    }
    return result;
}
Also used : VNXException(com.emc.storageos.vnx.xmlapi.VNXException) VNXQuotaTree(com.emc.storageos.vnx.xmlapi.VNXQuotaTree) 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)

Example 10 with VNXException

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

the class VNXFileCommApi method expandFS.

public XMLApiResult expandFS(final StorageSystem system, String fsName, long extendSize, boolean isMountRequired, boolean isVirtualProvisioned) throws VNXException {
    _log.info("Expand File System {} : new size requested {}", fsName, extendSize);
    XMLApiResult result = new XMLApiResult();
    Map<String, Object> reqAttributeMap = new ConcurrentHashMap<String, Object>();
    long fsSize = Long.parseLong(getFSSize(system, fsName));
    try {
        updateAttributes(reqAttributeMap, system);
        reqAttributeMap.put(VNXFileConstants.FILESYSTEM_NAME, fsName);
        reqAttributeMap.put(VNXFileConstants.FILESYSTEM_SIZE, extendSize);
        reqAttributeMap.put(VNXFileConstants.MOUNT_PATH, "/" + fsName);
        reqAttributeMap.put(VNXFileConstants.FILESYSTEM_VIRTUAL_PROVISIONING, isVirtualProvisioned);
        reqAttributeMap.put(VNXFileConstants.ORIGINAL_FS_SIZE, fsSize);
        // calculate the thin fs allocation size
        Long thinProvFsSizeMBs = Long.parseLong(THIN_PROVISIONED_FS_SIZE_MB);
        if (isVirtualProvisioned) {
            thinProvFsSizeMBs = getThinFSAllocSize(extendSize, false);
        }
        reqAttributeMap.put(VNXFileConstants.THIN_FS_ALLOC_SIZE, thinProvFsSizeMBs);
        _provExecutor.setKeyMap(reqAttributeMap);
        if (isMountRequired) {
            _provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_FILE_MOUNT_EXPAND));
        } else {
            _provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_FILE_EXPAND));
        }
        String cmdResult = (String) _provExecutor.getKeyMap().get(VNXFileConstants.CMD_RESULT);
        if (cmdResult.equals(VNXFileConstants.CMD_SUCCESS)) {
            result.setCommandSuccess();
        } else {
            String errMsg = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_DESC);
            result.setCommandFailed();
            result.setMessage(errMsg);
        }
    } catch (Exception e) {
        throw new VNXException("File system expand exception: ", e);
    }
    return result;
}
Also used : VNXException(com.emc.storageos.vnx.xmlapi.VNXException) FileObject(com.emc.storageos.db.client.model.FileObject) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult) URISyntaxException(java.net.URISyntaxException) VNXException(com.emc.storageos.vnx.xmlapi.VNXException)

Aggregations

VNXException (com.emc.storageos.vnx.xmlapi.VNXException)43 XMLApiResult (com.emc.storageos.vnx.xmlapi.XMLApiResult)29 VNXFileCommApi (com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi)16 ApplicationContext (org.springframework.context.ApplicationContext)16 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)16 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)15 URISyntaxException (java.net.URISyntaxException)15 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)15 FileObject (com.emc.storageos.db.client.model.FileObject)14 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)14 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)11 ArrayList (java.util.ArrayList)11 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)10 UnManagedDiscoveredObject (com.emc.storageos.db.client.model.UnManagedDiscoveredObject)10 Checkpoint (com.emc.nas.vnxfile.xmlapi.Checkpoint)8 StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)8 VNXSnapshot (com.emc.storageos.vnx.xmlapi.VNXSnapshot)7 FileShare (com.emc.storageos.db.client.model.FileShare)6 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)6 VNXFileExport (com.emc.storageos.vnx.xmlapi.VNXFileExport)6