Search in sources :

Example 11 with NetAppFacade

use of com.iwave.ext.netapp.NetAppFacade in project coprhd-controller by CoprHD.

the class NetAppApi method modifyNFSShare.

public Boolean modifyNFSShare(String exportPath, List<ExportRule> exportRules) throws NetAppException {
    try {
        if (netAppFacade == null) {
            _logger.warn("Invalid Facade found {} creating now...", netAppFacade);
            netAppFacade = new NetAppFacade(_ipAddress, _portNumber, _userName, _password, _https);
            _logger.warn("Facade created : {} ", netAppFacade);
        }
        _logger.info("NetApp Inputs for modifyNFSShare exportPath: {} , exportRules size {}", exportPath, exportRules.size());
        List<com.iwave.ext.netapp.utils.ExportRule> netAppCompatableRules = new ArrayList<>();
        for (ExportRule rule : exportRules) {
            com.iwave.ext.netapp.utils.ExportRule netAppRule = new com.iwave.ext.netapp.utils.ExportRule();
            copyPropertiesToSave(netAppRule, rule);
            netAppCompatableRules.add(netAppRule);
        }
        netAppFacade.modifyNFSShare(exportPath, netAppCompatableRules);
    } catch (Exception e) {
        _logger.error("Error Occured {} ", e.getMessage(), e);
        throw NetAppException.exceptions.exportFSFailed(exportPath, exportPath, e.getMessage());
    }
    return true;
}
Also used : NetAppFacade(com.iwave.ext.netapp.NetAppFacade) ArrayList(java.util.ArrayList) ExportRule(com.emc.storageos.model.file.ExportRule)

Example 12 with NetAppFacade

use of com.iwave.ext.netapp.NetAppFacade in project coprhd-controller by CoprHD.

the class NetAppApi method createVolume.

public Boolean createVolume(String volName, String aggregate, String size, Boolean isThin) {
    netAppFacade = new NetAppFacade(_ipAddress, _portNumber, _userName, _password, _https);
    String spaceReserve = "";
    if (isThin) {
        spaceReserve = SPACE_GUARANTEE_PARAM;
    }
    Boolean status = netAppFacade.createFlexibleVolume(volName, aggregate, false, null, size, null, spaceReserve, false, null);
    if (status) {
        Collection<String> attrs = new ArrayList<String>();
        attrs.add(VOL_ATTR_NAME);
        for (int i = 0; i <= 3; i++) {
            List<Map<String, String>> fileSystemCharacterics = netAppFacade.listVolumeInfo(volName, attrs);
            Map<String, String> fileSystemChar = fileSystemCharacterics.get(0);
            String fsName = fileSystemChar.get(VOL_ATTR_RESULT_NAME);
            if (volName.equals(fsName)) {
                _logger.info("FS {} has been created successfully on the array", fsName);
                status = true;
                break;
            } else {
                _logger.info("FS not see on the array yet, check back in few seconds");
                status = false;
                try {
                    Thread.sleep(3);
                } catch (InterruptedException e) {
                    _logger.info("Failed to sleep after FS creation");
                }
                continue;
            }
        }
    } else {
        _logger.info("FS creation failed");
        status = false;
    }
    Map<VolumeOptionType, String> options = new HashMap<VolumeOptionType, String>();
    options.put(VolumeOptionType.convert_ucode, CONVERT_UCODE_ON);
    options.put(VolumeOptionType.create_ucode, CREATE_UCODE_ON);
    netAppFacade.setVolumeOptions(volName, options);
    // If vFiler enabled, need to add storage to vFiler.
    if (status && _vFilerName != null && !_vFilerName.equals(DEFAULT_VFILER)) {
        netAppFacade = new NetAppFacade(_ipAddress, _portNumber, _userName, _password, _https, DEFAULT_VFILER);
        try {
            status = netAppFacade.addStorage(VOL_ROOT + volName, _vFilerName);
            // If adding a volume to a vfiler fails, then delete the volume.
            if (!status) {
                _logger.error("Adding volume {} to vfiler {} failed", volName, _vFilerName);
                deleteFS(volName);
            }
        } catch (Exception e) {
            // If adding a volume to a vfiler fails, then delete the volume.
            _logger.error("Exception when adding volume {} to vfiler {}.", volName, _vFilerName);
            deleteFS(volName);
            throw e;
        }
    }
    return status;
}
Also used : HashMap(java.util.HashMap) NetAppFacade(com.iwave.ext.netapp.NetAppFacade) ArrayList(java.util.ArrayList) VolumeOptionType(com.iwave.ext.netapp.VolumeOptionType) HashMap(java.util.HashMap) Map(java.util.Map)

Example 13 with NetAppFacade

use of com.iwave.ext.netapp.NetAppFacade in project coprhd-controller by CoprHD.

the class NetAppApi method deleteFS.

public Boolean deleteFS(String volName) throws NetAppException {
    try {
        netAppFacade = new NetAppFacade(_ipAddress, _portNumber, _userName, _password, _https);
        List<String> volumes = netAppFacade.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);
        if (offlineVol(volName)) {
            netAppFacade.destroyVolume(volName, false);
            return true;
        } else {
            return false;
        }
    } catch (Exception e) {
        throw NetAppException.exceptions.deleteFSFailed(volName, _ipAddress, e.getMessage());
    }
}
Also used : NetAppFacade(com.iwave.ext.netapp.NetAppFacade)

Example 14 with NetAppFacade

use of com.iwave.ext.netapp.NetAppFacade in project coprhd-controller by CoprHD.

the class NetAppApi method deleteSnapshot.

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

Example 15 with NetAppFacade

use of com.iwave.ext.netapp.NetAppFacade in project coprhd-controller by CoprHD.

the class NetAppApi method deleteShare.

public boolean deleteShare(String shareName) throws NetAppException {
    try {
        netAppFacade = new NetAppFacade(_ipAddress, _portNumber, _userName, _password, _https, _vFilerName);
        netAppFacade.deleteCIFSShare(shareName);
        return true;
    } catch (Exception e) {
        throw NetAppException.exceptions.deleteShareFailed(_ipAddress, e.getMessage());
    }
}
Also used : NetAppFacade(com.iwave.ext.netapp.NetAppFacade)

Aggregations

NetAppFacade (com.iwave.ext.netapp.NetAppFacade)24 ArrayList (java.util.ArrayList)5 CifsAcl (com.iwave.ext.netapp.model.CifsAcl)4 ExportRule (com.emc.storageos.model.file.ExportRule)2 QuotaStatus (com.iwave.ext.netapp.QuotaCommands.QuotaStatus)2 HashMap (java.util.HashMap)2 NFSSecurityStyle (com.iwave.ext.netapp.NFSSecurityStyle)1 VFilerInfo (com.iwave.ext.netapp.VFilerInfo)1 VolumeOptionType (com.iwave.ext.netapp.VolumeOptionType)1 Qtree (com.iwave.ext.netapp.model.Qtree)1 List (java.util.List)1 Map (java.util.Map)1