use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.
the class NetAppClusterModeDevice method doCreateQuotaDirectory.
@Override
public BiosCommandResult doCreateQuotaDirectory(StorageSystem storage, FileDeviceInputOutput args, QuotaDirectory qtree) throws ControllerException {
BiosCommandResult result = new BiosCommandResult();
try {
_log.info("NetAppClusterModeDevice doCreateQuotaDirectory - start");
// Using NetApp terminology here
String volName = args.getFsName();
String qtreeName = args.getQuotaDirectoryName();
Boolean oplocks = qtree.getOpLock();
String securityStyle = qtree.getSecurityStyle();
Long size = qtree.getSize();
String method = new String("doCreateQuotaDirectory");
result = validateQuotaDirectoryParams(volName, qtreeName, method);
if (!result.isCommandSuccess()) {
return result;
}
String portGroup = findSVMName(args.getFs());
NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
ncApi.createQtree(qtreeName, volName, oplocks, securityStyle, size, portGroup);
result = BiosCommandResult.createSuccessfulResult();
} catch (NetAppCException e) {
_log.error("NetAppClusterModeDevice::doCreateQuotaDirectory failed with a NetAppCException", e);
_log.info("NetAppClusterModeDevice::doCreateQuotaDirectory e.getLocalizedMessage(): {}", e.getLocalizedMessage());
ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateQtree();
serviceError.setMessage(e.getLocalizedMessage());
result = BiosCommandResult.createErrorResult(serviceError);
} catch (Exception e) {
_log.error("NetAppClusterModeDevice::doCreateQuotaDirectory failed with an Exception", e);
ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateQtree();
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 doUnexport.
@Override
public BiosCommandResult doUnexport(StorageSystem storage, FileDeviceInputOutput args, List<FileExport> exportList) throws ControllerException {
BiosCommandResult result = new BiosCommandResult();
try {
_log.info("NetAppClusterModeDevice doUnexport: {} - start", args.getFileObjId());
if (!args.getFileOperation()) {
_log.error("NetAppClusterModeDevice::doUnexport {} : Snapshot unexport is not Supported", args.getSnapshotId());
ServiceError serviceError = DeviceControllerErrors.netappc.unableToUnexportSnapshot();
serviceError.setMessage(genDetailedMessage("doUnExport", args.getSnapshotId().toString(), "Snapshot unexport is not Supported"));
result = BiosCommandResult.createErrorResult(serviceError);
return result;
}
for (int expCount = 0; expCount < exportList.size(); expCount++) {
FileExport export = exportList.get(expCount);
String portGroup = findSVMName(args.getFs());
NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
if (export.getPermissions() == null) {
export.setPermissions(RO_PERM);
}
String mountPath = export.getMountPath();
String exportPath = export.getPath();
if (!ncApi.unexportFS(exportPath, mountPath)) {
_log.error("NetAppClusterModeDevice::doUnexport {} failed", args.getFsId());
ServiceError serviceError = DeviceControllerErrors.netappc.unableToUnexportFileSystem();
serviceError.setMessage(genDetailedMessage("doUnexport", args.getFsId().toString()));
result = BiosCommandResult.createErrorResult(serviceError);
return result;
} else {
_log.info("NetAppClusterModeDevice doUnexport {} - completed", args.getFsId());
result = BiosCommandResult.createSuccessfulResult();
}
}
} catch (NetAppCException e) {
_log.error("NetAppClusterModeDevice::doUnexport failed with a NetAppCException", e);
ServiceError serviceError = DeviceControllerErrors.netappc.unableToUnexportFileSystem();
serviceError.setMessage(e.getLocalizedMessage());
result = BiosCommandResult.createErrorResult(serviceError);
} catch (Exception e) {
_log.error("NetAppClusterModeDevice::doUnexport failed with an Exception", e);
ServiceError serviceError = DeviceControllerErrors.netappc.unableToUnexportFileSystem();
serviceError.setMessage(e.getLocalizedMessage());
result = BiosCommandResult.createErrorResult(serviceError);
}
_log.info("NetAppClusterModeDevice doUnexport {} - complete", args.getFileObjId());
return result;
}
use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.
the class NetAppClusterModeDevice method deleteExportRules.
@Override
public BiosCommandResult deleteExportRules(StorageSystem storage, FileDeviceInputOutput args) {
BiosCommandResult result = new BiosCommandResult();
String portGroup = findSVMName(args.getFs());
NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
List<ExportRule> allExports = args.getExistingDBExportRules();
String subDir = args.getSubDirectory();
boolean allDirs = args.isAllDir();
String exportPath;
String qtreePath = "";
if (!args.getFileOperation()) {
_log.error("NetAppClusterModeDevice::doUnexport {} : Snapshot unexport is not Supported", args.getSnapshotId());
ServiceError serviceError = DeviceControllerErrors.netappc.unableToUnexportSnapshot();
serviceError.setMessage(genDetailedMessage("doUnExport", args.getSnapshotId().toString(), "Snapshot unexport is not Supported"));
result = BiosCommandResult.createErrorResult(serviceError);
return result;
} else {
exportPath = args.getFs().getPath();
qtreePath = exportPath;
if (subDir != null && subDir.length() > 0) {
exportPath = args.getFs().getPath() + "/" + subDir;
if (ncApi.isQtree(args.getFsName(), subDir)) {
qtreePath = constructQtreePath(args.getFsName(), subDir);
} else {
_log.error("NetAppClusterModeDevice::doUnexport {} : Sub-directory unexport is not Supported", args.getFsId());
ServiceError serviceError = DeviceControllerErrors.netappc.unableToExportFileSystem();
serviceError.setMessage(genDetailedMessage("doUnExport", args.getFsId().toString(), "Sub-directory unexport is not Supported"));
result = BiosCommandResult.createErrorResult(serviceError);
return result;
}
}
}
_log.info("exportPath : {}", exportPath);
args.setExportPath(exportPath);
_log.info("Number of existing exports found {}", allExports.size());
try {
if (allDirs) {
Set<String> allPaths = new HashSet<String>();
// ALL EXPORTS
_log.info("Deleting all exports specific to filesystem at device and rules from DB including sub dirs rules and exports");
for (ExportRule rule : allExports) {
allPaths.add(rule.getExportPath());
}
for (String path : allPaths) {
boolean isSubDir = checkIfSubDirectory(args.getFsMountPath(), path);
if (isSubDir) {
subDir = getSubDirectory(args.getFsMountPath(), path);
if (ncApi.isQtree(args.getFsName(), subDir)) {
path = constructQtreePath(args.getFsName(), subDir);
}
}
_log.info("deleting export path : {} ", path);
ncApi.deleteNFSExport(path);
}
} else if (subDir != null && !subDir.isEmpty()) {
// Filter for a specific Sub Directory export
_log.info("Deleting all subdir exports rules at ViPR and sub directory export at device {}", subDir);
for (ExportRule rule : allExports) {
if (rule.getExportPath().endsWith("/" + subDir)) {
ncApi.deleteNFSExport(qtreePath);
break;
}
}
} else {
// Filter for No SUBDIR - main export rules with no sub dirs
_log.info("Deleting all export rules from DB and export at device not included sub dirs");
ncApi.deleteNFSExport(qtreePath);
}
} catch (NetAppCException e) {
_log.info("Exception:" + e.getMessage());
throw new DeviceControllerException("Exception while performing export for {0} ", new Object[] { args.getFsId() });
}
_log.info("NetAppClusterModeDevice unexportFS {} - 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 updateShareACLs.
@Override
public BiosCommandResult updateShareACLs(StorageSystem storage, FileDeviceInputOutput args) {
List<ShareACL> existingAcls = new ArrayList<ShareACL>();
existingAcls = args.getExistingShareAcls();
String portGroup = findSVMName(args.getFs());
BiosCommandResult result = new BiosCommandResult();
NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
try {
processAclsForShare(ncApi, args);
result = BiosCommandResult.createSuccessfulResult();
} catch (Exception e) {
_log.error("NetAppClusterModeDevice::updateShareACLs failed with an Exception", e);
ServiceError serviceError = DeviceControllerErrors.netappc.unableToUpdateCIFSShareAcl();
serviceError.setMessage(e.getLocalizedMessage());
result = BiosCommandResult.createErrorResult(serviceError);
// if delete or modify fails , revert to old acl
rollbackShareACLs(storage, args, existingAcls);
}
return result;
}
use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.
the class NetAppClusterModeDevice method doSnapshotFS.
@Override
public BiosCommandResult doSnapshotFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
BiosCommandResult result = new BiosCommandResult();
try {
_log.info("NetAppClusterModeDevice doSnapshotFS - start");
if (null == args.getFsName()) {
_log.error("NetAppClusterModeDevice::doSnapshotFS failed: Filesystem name is either missing or empty");
ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateSnapshot();
serviceError.setMessage(FileSystemConstants.FS_ERR_FS_NAME_MISSING_OR_EMPTY);
result = BiosCommandResult.createErrorResult(serviceError);
return result;
}
if (null == args.getSnapshotName()) {
_log.error("NetAppClusterModeDevice::doSnapshotFS failed: Snapshot name is either missing or empty");
ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateSnapshot();
serviceError.setMessage(FileSystemConstants.FS_ERR_SNAPSHOT_NAME_MISSING_OR_EMPTY);
result = BiosCommandResult.createErrorResult(serviceError);
return result;
}
boolean failedStatus = false;
String portGroup = findSVMName(args.getFs());
NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
if (!ncApi.createSnapshot(args.getFsName(), args.getSnapshotName())) {
failedStatus = true;
}
if (failedStatus == true) {
_log.error("NetAppClusterModeDevice doSnapshotFS {} - failed", args.getFsId());
ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateSnapshot();
serviceError.setMessage(genDetailedMessage("doSnapshotFS", args.getFsName()));
result = BiosCommandResult.createErrorResult(serviceError);
} else {
_log.info("doSnapshotFS - Snapshot, {} was successfully created for filesystem, {} ", args.getSnapshotName(), args.getFsName());
// Set snapshot Path and MountPath information
args.setSnapshotMountPath(getSnapshotMountPath(args.getFsMountPath(), args.getSnapshotName()));
args.setSnapshotPath(getSnapshotPath(args.getFsPath(), args.getSnapshotName()));
args.setSnapNativeId(args.getSnapshotName());
result = BiosCommandResult.createSuccessfulResult();
}
} catch (NetAppCException e) {
_log.error("NetAppClusterModeDevice::doSnapshotFS failed with a NetAppCException", e);
ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateSnapshot();
serviceError.setMessage(e.getLocalizedMessage());
result = BiosCommandResult.createErrorResult(serviceError);
} catch (Exception e) {
_log.error("NetAppClusterModeDevice::doSnapshotFS failed with an Exception", e);
ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateSnapshot();
serviceError.setMessage(e.getLocalizedMessage());
result = BiosCommandResult.createErrorResult(serviceError);
}
return result;
}
Aggregations