use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.
the class NetAppFileStorageDevice method doModifyFS.
@Override
public BiosCommandResult doModifyFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
BiosCommandResult result = new BiosCommandResult();
result.setCommandSuccess(false);
result.setCommandStatus(Operation.Status.error.name());
result.setMessage("Modify FS NOT supported for NetApp.");
return result;
}
use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.
the class NetAppClusterModeDevice method updateExportRules.
@Override
public BiosCommandResult updateExportRules(StorageSystem storage, FileDeviceInputOutput args) {
// Requested Export Rules
List<ExportRule> exportAdd = args.getExportRulesToAdd();
List<ExportRule> exportDelete = args.getExportRulesToDelete();
List<ExportRule> exportModify = args.getExportRulesToModify();
// To be processed export rules
List<ExportRule> exportsToRemove = new ArrayList<>();
List<ExportRule> exportsToAdd = new ArrayList<>();
List<ExportRule> exportsRemove = new ArrayList<>();
// ALL EXPORTS
List<ExportRule> exportsToprocess = args.getExistingDBExportRules();
String fsName = "";
if (exportsToprocess == null) {
exportsToprocess = new ArrayList<>();
}
_log.info("Number of existng Rules found {}", exportsToprocess.size());
String exportPath;
String subDir = args.getSubDirectory();
BiosCommandResult result = new BiosCommandResult();
if (!args.getFileOperation()) {
_log.error("NetAppClusterModeDevice::updateExportRules {} : Snapshot export/unexport is not Supported", args.getSnapshotId());
ServiceError serviceError = DeviceControllerErrors.netappc.unableToUnexportSnapshot();
serviceError.setMessage(genDetailedMessage("updateExportRules", args.getSnapshotId().toString(), "Snapshot export/unexport is not Supported"));
result = BiosCommandResult.createErrorResult(serviceError);
return result;
} else {
exportPath = args.getFs().getPath();
if (subDir != null && subDir.length() > 0) {
exportPath = args.getFs().getPath() + "/" + subDir;
}
}
// if only delete provided with no existing rules -- How do we handle this?
_log.info("Number of Export Rules to update after processing found {}", exportsToprocess.size());
try {
String portGroup = null;
if (args.getFileOperation() == true) {
FileShare fileshare = args.getFs();
fsName = fileshare.getName();
portGroup = findSVMName(fileshare);
}
NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
String qtreePath = "";
String qtreeName = null;
if (args.getFileOperation()) {
qtreePath = exportPath;
if (subDir != null && subDir.length() > 0) {
if (ncApi.isQtree(args.getFsName(), subDir)) {
qtreeName = subDir;
qtreePath = constructQtreePath(args.getFsName(), subDir);
} else {
_log.error("NetAppClusterModeDevice::updateExportRules {} : Sub-directory export/unexport is not Supported", args.getFsId());
ServiceError serviceError = DeviceControllerErrors.netappc.unableToExportFileSystem();
serviceError.setMessage(genDetailedMessage("updateExportRules", args.getFsId().toString(), "Sub-directory export/unexport is not Supported"));
result = BiosCommandResult.createErrorResult(serviceError);
return result;
}
}
}
_log.info("exportPath : {}", exportPath);
args.setExportPath(exportPath);
// Handle Modified export Rules
if (!exportsToprocess.isEmpty()) {
for (ExportRule existingRule : exportsToprocess) {
if (existingRule.getExportPath().equalsIgnoreCase(exportPath)) {
for (ExportRule modifiedrule : exportModify) {
if (modifiedrule.getSecFlavor().equals(existingRule.getSecFlavor())) {
_log.info("Modifying Export Rule from {}, To {}", existingRule, modifiedrule);
if (!ncApi.modifyNFSShare(fsName, qtreeName, qtreePath, existingRule, modifiedrule)) {
_log.error("NetAppClusterModeDevice updateFSExportRules {} - failed", args.getFsId());
result.setMessage("NetAppClusterModeDevice updateFSExportRules {} - failed");
result.setCommandStatus(Operation.Status.error.name());
return result;
}
}
}
}
}
// Handle Add export Rules
if (exportAdd != null && !exportAdd.isEmpty()) {
for (ExportRule newExport : exportAdd) {
_log.info("Adding Export Rule {}", newExport);
if (!ncApi.addNFSShare(fsName, qtreeName, qtreePath, newExport)) {
_log.error("NetAppClusterModeDevice updateFSExportRules {} - failed", args.getFsId());
result.setMessage("NetAppClusterModeDevice updateFSExportRules {} - failed");
result.setCommandStatus(Operation.Status.error.name());
return result;
}
}
}
// Handle Delete export Rules
if (exportDelete != null && !exportDelete.isEmpty()) {
for (ExportRule existingRule : exportsToprocess) {
if (existingRule.getExportPath().equalsIgnoreCase(exportPath)) {
exportsToRemove.add(existingRule);
for (ExportRule oldExport : exportDelete) {
if (oldExport.getSecFlavor().equals(existingRule.getSecFlavor())) {
_log.info("Deleting Export Rule {}", existingRule);
exportsRemove.add(existingRule);
if (!ncApi.deleteNFSShare(fsName, qtreeName, existingRule, qtreePath)) {
_log.error("NetAppClusterModeDevice updateFSExportRules {} - failed", args.getFsId());
result.setMessage("NetAppClusterModeDevice updateFSExportRules {} - failed");
result.setCommandStatus(Operation.Status.error.name());
return result;
}
}
}
}
}
}
// No of exports found to remove from the list
_log.info("No of exports found to remove from the existing exports list {}", exportsRemove.size());
exportsToRemove.removeAll(exportsRemove);
_log.info("No of exports found to add to the existing exports list {}", exportsToAdd.size());
// If we delete filesystem without deleting export policy. Export policy will not get cleared on Array.
if (exportsToRemove.isEmpty() && !exportsRemove.isEmpty()) {
ncApi.deleteNFSExport(qtreePath);
}
}
} catch (NetAppCException e) {
_log.info("Exception:" + e.getMessage());
throw new DeviceControllerException("Exception while performing export for {0} - {1} ", new Object[] { args.getFsId(), e.getMessage() });
}
_log.info("NetAppClusterModeDevice updateFSExportRules {} - complete", args.getFsId());
result.setCommandSuccess(true);
result.setCommandStatus(Operation.Status.ready.name());
return result;
}
use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.
the class NetAppClusterModeDevice method doDeleteFS.
@Override
public BiosCommandResult doDeleteFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
BiosCommandResult result = new BiosCommandResult();
try {
_log.info("NetAppClusterModeDevice doDeleteFS - start");
if (null == args.getFsName()) {
_log.error("NetAppClusterModeDevice::doDeletFS failed: Filesystem name is either missing or empty");
ServiceError serviceError = DeviceControllerErrors.netappc.unableToDeleteFileSystem();
serviceError.setMessage("Filesystem name is either missing or empty");
result = BiosCommandResult.createErrorResult(serviceError);
return result;
}
// Now get the SVM from the fileShare
String portGroup = findSVMName(args.getFs());
if (null != args.getFsShares() && !args.getFsShares().isEmpty()) {
if (!netAppDeleteCIFSExports(storage, args.getFsShares(), portGroup)) {
_log.info("NetAppClusterModeDevice doDeletFS:netAppDeleteCIFSExports {} - failed", args.getFsName());
} else {
_log.info("NetAppClusterModeDevice doDeletFS:netAppDeleteCIFSExports {} - succeeded", args.getFsName());
}
}
boolean failedStatus = false;
NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
if (!ncApi.deleteFS(args.getFsName())) {
failedStatus = true;
}
if (failedStatus == true) {
_log.error("NetAppClusterModeDevice doDeletFS {} - failed", args.getFsName());
ServiceError serviceError = DeviceControllerErrors.netappc.unableToDeleteFileSystem();
result = BiosCommandResult.createErrorResult(serviceError);
} else {
_log.info("NetAppClusterModeDevice doDeletFS {} - complete", args.getFsName());
result = BiosCommandResult.createSuccessfulResult();
}
} catch (NetAppCException e) {
_log.error("NetAppClusterModeDevice::doDeleteFS failed with a NetAppCException", e);
ServiceError serviceError = DeviceControllerErrors.netappc.unableToDeleteFileSystem();
serviceError.setMessage(e.getLocalizedMessage());
result = BiosCommandResult.createErrorResult(serviceError);
} catch (Exception e) {
_log.error("NetAppClusterModeDevice::doDeleteFS failed with an Exception", e);
ServiceError serviceError = DeviceControllerErrors.netappc.unableToDeleteFileSystem();
serviceError.setMessage(e.getLocalizedMessage());
result = BiosCommandResult.createErrorResult(serviceError);
}
return result;
}
use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.
the class NetAppClusterModeDevice method doExpandFS.
@Override
public BiosCommandResult doExpandFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
BiosCommandResult result = new BiosCommandResult();
try {
_log.info("NetAppClusterModeDevice doExpandFS - start");
long newFsExpandSize = args.getNewFSCapacity();
String volumeName = args.getFsName();
if (args.getNewFSCapacity() % BYTESPERMB == 0) {
newFsExpandSize = newFsExpandSize / BYTESPERMB;
} else {
newFsExpandSize = newFsExpandSize / BYTESPERMB + 1;
}
_log.info("FileSystem new size translation : {} : {}", args.getNewFSCapacity(), newFsExpandSize);
String strNewFsSize = String.valueOf(newFsExpandSize) + "m";
String portGroup = findSVMName(args.getFs());
NetAppClusterApi nApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
if (!nApi.setVolumeSize(volumeName, strNewFsSize)) {
_log.error("NetAppClusterModeDevice doExpandFS - failed");
ServiceError serviceError = DeviceControllerErrors.netappc.unableToExpandFileSystem();
result = BiosCommandResult.createErrorResult(serviceError);
} else {
_log.info("NetAppClusterModeDevice doExpandFS - complete");
result = BiosCommandResult.createSuccessfulResult();
}
} catch (NetAppCException e) {
_log.error("NetAppClusterModeDevice::doExpandFS failed with a NetAppCException", e);
ServiceError serviceError = DeviceControllerErrors.netappc.unableToExpandFileSystem();
serviceError.setMessage(e.getLocalizedMessage());
result = BiosCommandResult.createErrorResult(serviceError);
} catch (Exception e) {
_log.error("NetAppClusterModeDevice::doExpandFS failed with an Exception", e);
ServiceError serviceError = DeviceControllerErrors.netappc.unableToExpandFileSystem();
serviceError.setMessage(e.getLocalizedMessage());
result = BiosCommandResult.createErrorResult(serviceError);
}
return result;
}
use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.
the class NetAppClusterModeDevice method doShare.
@Override
public BiosCommandResult doShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws ControllerException {
// To be in-sync with isilon implementation, currently forceGroup is
// set to null which will set the group name as "everyone" by default.
String forceGroup = null;
BiosCommandResult result = new BiosCommandResult();
try {
_log.info("NetAppClusterModeDevice doShare - start");
SMBShareMap smbShareMap = args.getFileObjShares();
SMBFileShare existingShare = (smbShareMap == null) ? null : smbShareMap.get(smbFileShare.getName());
Boolean modOrCreateShareSuccess = false;
if (existingShare != null) {
modOrCreateShareSuccess = modifyNtpShare(storage, args, smbFileShare, forceGroup, existingShare);
} else if (existingShare == null) {
modOrCreateShareSuccess = createNtpShare(storage, args, smbFileShare, forceGroup);
}
if (modOrCreateShareSuccess.booleanValue() == true) {
_log.info("NetAppClusterModeDevice doShare {} - complete", smbFileShare.getName());
// Update the collection.
if (args.getFileObjShares() == null) {
args.initFileObjShares();
}
// set Mount Point
smbFileShare.setMountPoint(smbFileShare.getNetBIOSName(), smbFileShare.getStoragePortNetworkId(), smbFileShare.getStoragePortName(), smbFileShare.getName());
args.getFileObjShares().put(smbFileShare.getName(), smbFileShare);
result = BiosCommandResult.createSuccessfulResult();
} else {
_log.error("NetAppClusterModeDevice doShare {} - failed", smbFileShare.getName());
ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateFileShare();
result = BiosCommandResult.createErrorResult(serviceError);
}
} catch (NetAppCException e) {
_log.error("NetAppClusterModeDevice::doShare failed with a NetAppCException", e);
ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateFileShare();
serviceError.setMessage(e.getLocalizedMessage());
result = BiosCommandResult.createErrorResult(serviceError);
} catch (Exception e) {
_log.error("NetAppClusterModeDevice::doShare failed with an Exception", e);
ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateFileShare();
serviceError.setMessage(e.getLocalizedMessage());
result = BiosCommandResult.createErrorResult(serviceError);
}
return result;
}
Aggregations