Search in sources :

Example 1 with XMLApiResult

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

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

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

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

Example 5 with XMLApiResult

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

the class VNXFileCommApi method doRestoreSnapshot.

public XMLApiResult doRestoreSnapshot(final StorageSystem system, String fsId, String fsName, String id, String snapshotName) throws VNXException {
    _log.info("Restore Snapshot name :{} : file system : {}", snapshotName, 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.FILESYSTEM_ID, fsId);
        reqAttributeMap.put(VNXFileConstants.SNAPSHOT_NAME, snapshotName);
        reqAttributeMap.put(VNXFileConstants.SNAPSHOT_ID, id);
        _provExecutor.setKeyMap(reqAttributeMap);
        _provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_SNAP_RESTORE));
        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("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)

Aggregations

XMLApiResult (com.emc.storageos.vnx.xmlapi.XMLApiResult)30 VNXException (com.emc.storageos.vnx.xmlapi.VNXException)29 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)15 VNXFileCommApi (com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi)15 ApplicationContext (org.springframework.context.ApplicationContext)15 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)15 FileObject (com.emc.storageos.db.client.model.FileObject)14 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)14 URISyntaxException (java.net.URISyntaxException)14 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)13 ArrayList (java.util.ArrayList)9 Checkpoint (com.emc.nas.vnxfile.xmlapi.Checkpoint)8 StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)8 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)7 VNXFileExport (com.emc.storageos.vnx.xmlapi.VNXFileExport)7 VNXSnapshot (com.emc.storageos.vnx.xmlapi.VNXSnapshot)7 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)6 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)6 FileShare (com.emc.storageos.db.client.model.FileShare)6 Snapshot (com.emc.storageos.db.client.model.Snapshot)5