Search in sources :

Example 6 with TreeQuota

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

the class VNXFileCommApi method deleteAllQuotaDirs.

private XMLApiResult deleteAllQuotaDirs(StorageSystem system, StorageHADomain dataMover, FileShare fs) {
    XMLApiResult result = new XMLApiResult();
    result.setCommandSuccess();
    _log.info("deleteAllQuotaDirs for {}", fs.getName());
    try {
        // Process for quota dir delete on this file share.
        List<TreeQuota> quotaDirs = (List<TreeQuota>) _provExecutor.getKeyMap().get(VNXFileConstants.QUOTA_DIR_LIST);
        if (quotaDirs != null && !quotaDirs.isEmpty() && dataMover != null) {
            _log.info("Number of quota dirs found {} for a file system {}", quotaDirs.size(), fs.getName());
            // In the process of delete file system, we are unmounting the FileSystem.
            // In order to delete Quota Directory, file system should be mounted.
            // we just mount the file system temporarily. if it was un-mounted.
            sshApi.setConnParams(system.getIpAddress(), system.getUsername(), system.getPassword());
            Map<String, String> existingMounts = sshApi.getFsMountpathMap(dataMover.getAdapterName());
            if (existingMounts.get(fs.getName()) == null) {
                String mountCmdArgs = sshApi.formatMountCmd(dataMover.getAdapterName(), fs.getName(), fs.getMountPath());
                result = sshApi.executeSshRetry(VNXFileSshApi.SERVER_MOUNT_CMD, mountCmdArgs);
            }
            for (TreeQuota quota : quotaDirs) {
                if (quota != null) {
                    // exclude the "/" in the beginning of the
                    String quotaDirName = quota.getPath().substring(1);
                    // path.
                    XMLApiResult status = deleteQuotaDirectory(system, fs.getName(), quotaDirName, true, false);
                    if (!status.isCommandSuccess()) {
                        String errMsg = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_DESC);
                        result.setCommandFailed();
                        result.setMessage(errMsg);
                        return result;
                    }
                }
            }
        }
        return result;
    } catch (Exception e) {
        throw new VNXException("File system quota directory delete exception: ", e);
    }
}
Also used : VNXException(com.emc.storageos.vnx.xmlapi.VNXException) ArrayList(java.util.ArrayList) NamespaceList(com.emc.storageos.plugins.common.domainmodel.NamespaceList) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult) URISyntaxException(java.net.URISyntaxException) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) TreeQuota(com.emc.nas.vnxfile.xmlapi.TreeQuota)

Aggregations

TreeQuota (com.emc.nas.vnxfile.xmlapi.TreeQuota)6 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)5 ArrayList (java.util.ArrayList)5 ResponsePacket (com.emc.nas.vnxfile.xmlapi.ResponsePacket)3 Status (com.emc.nas.vnxfile.xmlapi.Status)3 VNXException (com.emc.storageos.vnx.xmlapi.VNXException)3 PostMethod (org.apache.commons.httpclient.methods.PostMethod)3 URISyntaxException (java.net.URISyntaxException)2 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)1 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 UnManagedDiscoveredObject (com.emc.storageos.db.client.model.UnManagedDiscoveredObject)1 UnManagedFileQuotaDirectory (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileQuotaDirectory)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 NamespaceList (com.emc.storageos.plugins.common.domainmodel.NamespaceList)1 VNXFileCollectionException (com.emc.storageos.plugins.metering.vnxfile.VNXFileCollectionException)1 XMLApiResult (com.emc.storageos.vnx.xmlapi.XMLApiResult)1 IOException (java.io.IOException)1 URI (java.net.URI)1 List (java.util.List)1