Search in sources :

Example 16 with NetAppClusterFacade

use of com.iwave.ext.netappc.NetAppClusterFacade in project coprhd-controller by CoprHD.

the class NetAppClusterApi method doShare.

public Boolean doShare(String mntpath, String shareName, String comment, int maxusers, String permission, String forcegroup) throws NetAppCException {
    try {
        String mountPath;
        if (mntpath.startsWith("/")) {
            mountPath = mntpath;
        } else {
            mountPath = "/" + mntpath;
        }
        netAppClusterFacade = new NetAppClusterFacade(_ipAddress, _portNumber, _userName, _password, _https, true, _svmName);
        if (!netAppClusterFacade.addCIFSShare(mountPath, shareName, comment, maxusers, forcegroup)) {
            return false;
        }
        List<Map<String, String>> ShareInfo = netAppClusterFacade.listCIFSShares(shareName);
        this.NetBIOSName = ShareInfo.get(0).get("cifs-server");
        return true;
    } catch (Exception e) {
        throw NetAppCException.exceptions.doShareFailed(mntpath, shareName, _ipAddress, e.getMessage());
    }
}
Also used : NetAppClusterFacade(com.iwave.ext.netappc.NetAppClusterFacade) HashMap(java.util.HashMap) Map(java.util.Map)

Example 17 with NetAppClusterFacade

use of com.iwave.ext.netappc.NetAppClusterFacade in project coprhd-controller by CoprHD.

the class NetAppClusterApi method deleteSnapshot.

public Boolean deleteSnapshot(String volumeName, String snapshotName) throws NetAppCException {
    try {
        netAppClusterFacade = new NetAppClusterFacade(_ipAddress, _portNumber, _userName, _password, _https, true, _svmName);
        List<String> snapshots = (List<String>) netAppClusterFacade.listSnapshots(volumeName);
        if ((null != snapshots) && (!snapshots.isEmpty())) {
            if (snapshots.toString().contains(snapshotName)) {
                return netAppClusterFacade.deleteVolumeSnapshot(volumeName, snapshotName);
            }
        }
        return true;
    } catch (Exception e) {
        throw NetAppCException.exceptions.deleteSnapshotFailed(volumeName, snapshotName, _ipAddress, e.getMessage());
    }
}
Also used : NetAppClusterFacade(com.iwave.ext.netappc.NetAppClusterFacade) ArrayList(java.util.ArrayList) List(java.util.List)

Example 18 with NetAppClusterFacade

use of com.iwave.ext.netappc.NetAppClusterFacade in project coprhd-controller by CoprHD.

the class NetAppClusterApi method exportFS.

public Boolean exportFS(String fsName, String qtreeName, String mountPath, String exportPath, List<String> rootHosts, List<String> rwHosts, List<String> roHosts, String root_user, String securityStyle) throws NetAppCException {
    try {
        if ((null == roHosts) && (null == rwHosts) && (null == rootHosts)) {
            _logger.debug("End points list is null...");
            return false;
        } else {
            // Add all root hosts to rw hosts as well (currently NTP GUI
            // takes care of this).
            addRootToHosts(rootHosts, rwHosts);
            // TODO: Handle multiple security Types here
            List<NFSSecurityStyle> secruityStyleList = new ArrayList<NFSSecurityStyle>();
            String lcaseSecruityStyle = securityStyle.toLowerCase();
            secruityStyleList.add(NFSSecurityStyle.valueOfName(lcaseSecruityStyle));
            // TODO: Handle all root and anonymous user mappings here.
            int rootMappingUid = 0;
            if (root_user.equals(ROOT_USER)) {
                rootMappingUid = 0;
            } else if (root_user.equals(NO_ROOT_USERS)) {
                rootMappingUid = DISABLE_ROOT_ACCESS_CODE;
            } else {
                // If UID is specified other than root or nobody default it
                // to this value.
                rootMappingUid = DEFAULT_ANONMOUS_ROOT_ACCESS;
            }
            // Finally fire up export.
            netAppClusterFacade = new NetAppClusterFacade(_ipAddress, _portNumber, _userName, _password, _https, true, _svmName);
            netAppClusterFacade.addNFSShare(fsName, qtreeName, null, mountPath, rootMappingUid, roHosts, rwHosts, rootHosts, secruityStyleList);
        }
    } catch (IllegalArgumentException e) {
        String msg = "Failed to create NFS share on path: " + (mountPath != null ? mountPath : exportPath);
        _logger.error(msg, e);
        throw NetAppCException.exceptions.exportFSFailed(mountPath, exportPath, e.getMessage());
    } catch (Exception e) {
        throw NetAppCException.exceptions.exportFSFailed(mountPath, exportPath, e.getMessage());
    }
    return true;
}
Also used : NFSSecurityStyle(com.iwave.ext.netappc.NFSSecurityStyle) ArrayList(java.util.ArrayList) NetAppClusterFacade(com.iwave.ext.netappc.NetAppClusterFacade)

Example 19 with NetAppClusterFacade

use of com.iwave.ext.netappc.NetAppClusterFacade in project coprhd-controller by CoprHD.

the class NetAppClusterApi method deleteFS.

public Boolean deleteFS(String volName) throws NetAppCException {
    try {
        netAppClusterFacade = new NetAppClusterFacade(_ipAddress, _portNumber, _userName, _password, _https, true, _svmName);
        List<String> volumes = netAppClusterFacade.listVolumes();
        if (!volumes.contains(volName)) {
            _logger.info("Volume not found on array to delete {}", volName);
            return true;
        }
        // Delete Qtrees and its quotas, if any.
        deleteAllQTrees(volName);
        netAppClusterFacade.unmountVolume(volName, false);
        if (offlineVol(volName)) {
            netAppClusterFacade.destroyVolume(volName, false);
            return true;
        } else {
            return false;
        }
    } catch (Exception e) {
        throw NetAppCException.exceptions.deleteFSFailed(volName, _ipAddress, e.getMessage());
    }
}
Also used : NetAppClusterFacade(com.iwave.ext.netappc.NetAppClusterFacade)

Example 20 with NetAppClusterFacade

use of com.iwave.ext.netappc.NetAppClusterFacade in project coprhd-controller by CoprHD.

the class NetAppClusterApi method modifyNFSShare.

public Boolean modifyNFSShare(String fsName, String qtreeName, String exportPath, ExportRule oldRule, ExportRule newRule) throws NetAppCException {
    try {
        netAppClusterFacade = new NetAppClusterFacade(_ipAddress, _portNumber, _userName, _password, _https, true, _svmName);
        _logger.info("NetApp Inputs for modifyNFSShare exportPath: {} ", exportPath);
        List<com.iwave.ext.netapp.utils.ExportRule> netAppCompatableRules = new ArrayList<>();
        com.iwave.ext.netapp.utils.ExportRule netAppOldRule = new com.iwave.ext.netapp.utils.ExportRule();
        copyPropertiesToSave(netAppOldRule, oldRule);
        netAppCompatableRules.add(netAppOldRule);
        com.iwave.ext.netapp.utils.ExportRule netAppNewRule = new com.iwave.ext.netapp.utils.ExportRule();
        copyPropertiesToSave(netAppNewRule, newRule);
        netAppCompatableRules.add(netAppNewRule);
        netAppClusterFacade.modifyNFSShare(fsName, qtreeName, exportPath, netAppOldRule, netAppNewRule);
    } catch (Exception e) {
        _logger.error("Error Occured {} ", e.getMessage(), e);
        throw NetAppCException.exceptions.exportFSFailed(exportPath, exportPath, e.getMessage());
    }
    return true;
}
Also used : NetAppClusterFacade(com.iwave.ext.netappc.NetAppClusterFacade) ArrayList(java.util.ArrayList) ExportRule(com.emc.storageos.model.file.ExportRule)

Aggregations

NetAppClusterFacade (com.iwave.ext.netappc.NetAppClusterFacade)27 ArrayList (java.util.ArrayList)6 CifsAcl (com.iwave.ext.netappc.model.CifsAcl)5 ExportRule (com.emc.storageos.model.file.ExportRule)3 HashMap (java.util.HashMap)3 QuotaStatus (com.iwave.ext.netapp.QuotaCommands.QuotaStatus)2 Map (java.util.Map)2 ExportsRuleInfo (com.iwave.ext.netapp.model.ExportsRuleInfo)1 Qtree (com.iwave.ext.netapp.model.Qtree)1 NFSSecurityStyle (com.iwave.ext.netappc.NFSSecurityStyle)1 StorageVirtualMachineInfo (com.iwave.ext.netappc.StorageVirtualMachineInfo)1 List (java.util.List)1