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;
}
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;
}
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());
}
}
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());
}
}
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());
}
}
Aggregations