use of com.iwave.ext.netapp.NetAppFacade in project coprhd-controller by CoprHD.
the class NetAppApi method createQtree.
// New QTree methods
public void createQtree(String qtreeName, String volumeName, Boolean opLocks, String securityStyle, Long size, String vfilerName) throws NetAppException {
try {
netAppFacade = new NetAppFacade(_ipAddress, _portNumber, _userName, _password, _https, vfilerName);
netAppFacade.createQtree(qtreeName, volumeName);
/*
* Set the security style; if input is default we do not set it.
* In that case, the qtree inherits the parent volume's security
* style.
*/
String qtreePath = null;
if (volumeName.contains(VOL_ROOT)) {
if (volumeName.endsWith("/")) {
// i.e. volume name is something like /vol/lookAtMe/
qtreePath = volumeName + qtreeName;
} else {
// i.e. volume name is something like /vol/lookAtMe
qtreePath = volumeName + "/" + qtreeName;
}
} else {
// i.e. volume name is something like "lookAtMe"
qtreePath = "/vol/" + volumeName + "/" + qtreeName;
}
_logger.info("NetAppApi::createQtree -> qtreePath = {}", qtreePath);
if (securityStyle.equalsIgnoreCase(UNIX)) {
netAppFacade.setQTreeSecurityStyle(qtreePath, UNIX);
} else if (securityStyle.equalsIgnoreCase(NTFS)) {
netAppFacade.setQTreeSecurityStyle(qtreePath, NTFS);
} else if (securityStyle.equalsIgnoreCase(MIXED)) {
netAppFacade.setQTreeSecurityStyle(qtreePath, MIXED);
}
/*
* Set qtree 'oplocks'
*/
if (opLocks.booleanValue() == true) {
netAppFacade.setQTreeOplocks(qtreePath, ENABLE);
} else {
netAppFacade.setQTreeOplocks(qtreePath, DISABLE);
}
/*
* Set the size - Quota
*/
if (size > 0) {
netAppFacade.addDiskLimitTreeQuota(volumeName, qtreePath, size / SIZE_KB, 0);
// especially, when we create quota on multi-store environment.
try {
QuotaStatus quotaStatus = netAppFacade.getQuotaStatus(volumeName);
if (quotaStatus.OFF == quotaStatus) {
netAppFacade.turnQuotaOn(volumeName);
} else {
// Resizing only works for certain types of changes to the quotas file.
// For other changes, you need to reinitialize quotas.
netAppFacade.reintializeQuota(volumeName);
}
// QuotaStatus quotaStatus = netAppFacade.getQuotaStatus(volumeName);
_logger.info("Quota status on volume {} is {}. ", volumeName, quotaStatus.toString());
} catch (Exception e) {
_logger.warn("Quota status on volume {} is not stable. ", volumeName);
}
}
} catch (Exception e) {
_logger.info("NetAppApi::createQtree -> e.getMessage() = {}", e.getMessage());
throw NetAppException.exceptions.createQtreeFailed(qtreeName, e.getMessage());
}
}
use of com.iwave.ext.netapp.NetAppFacade in project coprhd-controller by CoprHD.
the class NetAppApi method unexportFS.
public Boolean unexportFS(String mountPath, String exportPath) throws NetAppException {
try {
_logger.debug("Un-Exporting NFS share...");
netAppFacade = new NetAppFacade(_ipAddress, _portNumber, _userName, _password, _https, _vFilerName);
netAppFacade.deleteNFSShare(mountPath, false);
} catch (Exception e) {
throw NetAppException.exceptions.unexportFSFailed(mountPath, exportPath, e.getMessage());
}
return true;
}
use of com.iwave.ext.netapp.NetAppFacade in project coprhd-controller by CoprHD.
the class NetAppApi method deleteCIFSShareAcl.
public Boolean deleteCIFSShareAcl(String shareName, List<CifsAcl> acls) 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);
}
for (CifsAcl acl : acls) {
acl.setShareName(shareName);
netAppFacade.deleteCIFSAcl(acl);
}
} catch (Exception e) {
_logger.error("Error Occured {} ", e.getMessage(), e);
throw NetAppException.exceptions.deleteCIFSShareAclFailed(shareName, e.getMessage());
}
return true;
}
use of com.iwave.ext.netapp.NetAppFacade in project coprhd-controller by CoprHD.
the class NetAppApi method offlineVol.
public Boolean offlineVol(String volName) throws NetAppException {
try {
netAppFacade = new NetAppFacade(_ipAddress, _portNumber, _userName, _password, _https);
netAppFacade.setVolumeOffline(volName, 1);
return true;
} catch (Exception e) {
throw NetAppException.exceptions.deleteFSFailed(volName, _ipAddress, e.getMessage());
}
}
use of com.iwave.ext.netapp.NetAppFacade in project coprhd-controller by CoprHD.
the class NetAppApi method exportFS.
public Boolean exportFS(String mountPath, String exportPath, List<String> rootHosts, List<String> rwHosts, List<String> roHosts, String root_user, String securityStyle) throws NetAppException {
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.valueOfLabel(ntpSecMap.get(lcaseSecruityStyle)));
// Handle all the hosts permissions here.
boolean roAddAll = false;
boolean rwAddAll = false;
boolean rootAddAll = false;
// 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.
netAppFacade = new NetAppFacade(_ipAddress, _portNumber, _userName, _password, _https, _vFilerName);
List<String> FsList = netAppFacade.addNFSShare(null, mountPath, rootMappingUid, roHosts, roAddAll, rwHosts, rwAddAll, rootHosts, rootAddAll, secruityStyleList);
if (FsList.isEmpty()) {
return false;
}
}
} catch (Exception e) {
throw NetAppException.exceptions.exportFSFailed(mountPath, exportPath, e.getMessage());
}
return true;
}
Aggregations