use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.
the class VNXUnityFileStorageDevice method doDeleteFS.
/*
* To get around the KH API delete file system async issues, using sync call for now.
*/
@Override
public BiosCommandResult doDeleteFS(StorageSystem storage, FileDeviceInputOutput fileInOut) throws ControllerException {
_logger.info("deleting file system: ", fileInOut.getFsName());
VNXeApiClient apiClient = getVnxUnityClient(storage);
BiosCommandResult result = null;
try {
apiClient.deleteFileSystemSync(fileInOut.getFsNativeId(), fileInOut.getForceDelete());
StringBuilder logMsgBuilder = new StringBuilder(String.format("Deleted filesystem - Array:%s, fileSystem: %s", storage.getSerialNumber(), fileInOut.getFsName()));
_logger.info(logMsgBuilder.toString());
result = BiosCommandResult.createSuccessfulResult();
} catch (VNXeException e) {
_logger.error("Delete file system got the exception", e);
result = BiosCommandResult.createErrorResult(e);
} catch (Exception ex) {
_logger.error("Delete file system got the exception", ex);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystem", ex.getMessage());
result = BiosCommandResult.createErrorResult(error);
}
return result;
}
use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.
the class NetAppClusterModeDevice method validateQuotaDirectoryParams.
public BiosCommandResult validateQuotaDirectoryParams(String volName, String qtreeName, String method) throws ControllerException {
BiosCommandResult result = new BiosCommandResult();
result = BiosCommandResult.createSuccessfulResult();
ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateQtree();
if (method.equals("doCreateQuotaDirectory")) {
serviceError = DeviceControllerErrors.netappc.unableToCreateQtree();
} else if (method.equals("doDeleteQuotaDirectory")) {
serviceError = DeviceControllerErrors.netappc.unableToDeleteQtree();
} else {
serviceError = DeviceControllerErrors.netappc.unableToUpdateQtree();
}
if (null == volName) {
_log.error("NetAppClusterModeDevice:: {} failed: Filesystem name is either missing or empty", method);
serviceError.setMessage(FileSystemConstants.FS_ERR_FS_NAME_MISSING_OR_EMPTY);
result = BiosCommandResult.createErrorResult(serviceError);
return result;
}
if (null == qtreeName) {
_log.error("NetAppClusterModeDevice::{} failed: Qtree name is either missing or empty", method);
serviceError.setMessage(FileSystemConstants.FS_ERR_QUOTADIR_NAME_MISSING_OR_EMPTY);
result = BiosCommandResult.createErrorResult(serviceError);
return result;
}
if (method.equals("doCreateQuotaDirectory") && !validQuotaDirectoryPath(volName, qtreeName)) {
_log.error("NetAppClusterModeDevice::{} failed: Qtree name or path is too long", method);
serviceError.setMessage(FileSystemConstants.FS_ERR_QUOTADIR_NAME_PATH_TOO_LONG);
result = BiosCommandResult.createErrorResult(serviceError);
return result;
}
return result;
}
use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.
the class NetAppClusterModeDevice method doDeleteShare.
@Override
public BiosCommandResult doDeleteShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws ControllerException {
BiosCommandResult result = new BiosCommandResult();
try {
_log.info("NetAppClusterModeDevice doDeleteShare - start");
FileShare fileshare = null;
if (args.getFileOperation() == true) {
fileshare = args.getFs();
} else {
URI snapShotUID = args.getSnapshotId();
Snapshot snapshot = _dbClient.queryObject(Snapshot.class, snapShotUID);
fileshare = _dbClient.queryObject(FileShare.class, snapshot.getParent().getURI());
}
// Now get the VFiler from the fileShare
String portGroup = findSVMName(fileshare);
NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
SMBShareMap shares = args.getFileObjShares();
if (shares == null || shares.isEmpty()) {
_log.error("NetAppClusterModeDevice::doDeleteShare failed: FileShare(s) is either missing or empty");
ServiceError serviceError = DeviceControllerErrors.netappc.unableToDeleteFileShare();
serviceError.setMessage("FileShare(s) is either missing or empty");
result = BiosCommandResult.createErrorResult(serviceError);
}
SMBFileShare fileShare = shares.get(smbFileShare.getName());
if (fileShare != null) {
if (!ncApi.deleteShare(smbFileShare.getName())) {
_log.error("NetAppClusterModeDevice doDeleteShare {} - failed", args.getFileObjId());
ServiceError serviceError = DeviceControllerErrors.netappc.unableToDeleteFileShare();
serviceError.setMessage("Deletion of CIFS File Share failed");
result = BiosCommandResult.createErrorResult(serviceError);
} else {
_log.info("NetAppClusterModeDevice doDeleteShare {} - complete", args.getFileObjId());
args.getFileObjShares().remove(smbFileShare.getName());
args.getFileObjShares().remove(smbFileShare.getNativeId());
result = BiosCommandResult.createSuccessfulResult();
}
}
} catch (NetAppCException e) {
_log.error("NetAppClusterModeDevice::doDeleteShare failed with a NetAppCException", e);
ServiceError serviceError = DeviceControllerErrors.netappc.unableToDeleteFileShare();
serviceError.setMessage(e.getLocalizedMessage());
result = BiosCommandResult.createErrorResult(serviceError);
} catch (Exception e) {
_log.error("NetAppClusterModeDevice::doDeleteShare failed with an Exception", e);
ServiceError serviceError = DeviceControllerErrors.netappc.unableToDeleteFileShare();
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 doCreateFS.
@Override
public BiosCommandResult doCreateFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
BiosCommandResult result = new BiosCommandResult();
try {
_log.info("NetAppClusterModeDevice doCreateFS - start");
if (null == args.getFsName()) {
_log.error("NetAppClusterModeDevice::doCreateFS failed: Filesystem name is either missing or empty");
ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateFileSystem();
serviceError.setMessage(FileSystemConstants.FS_ERR_FS_NAME_MISSING_OR_EMPTY);
result = BiosCommandResult.createErrorResult(serviceError);
return result;
}
if (null == args.getPoolNativeId()) {
_log.error("NetAppClusterModeDevice::doCreateFS failed: PoolNativeId either missing or empty");
ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateFileSystem();
serviceError.setMessage(FileSystemConstants.FS_ERR_POOL_NATIVE_ID_MISSING_OR_EMPTY);
result = BiosCommandResult.createErrorResult(serviceError);
return result;
}
if (null == args.getFsCapacity()) {
_log.error("NetAppClusterModeDevice::doCreateFS failed: Filesystem capacity is either missing or empty");
ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateFileSystem();
serviceError.setMessage(FileSystemConstants.FS_ERR_FS_CAPACITY_MISSING_OR_EMPTY);
result = BiosCommandResult.createErrorResult(serviceError);
return result;
}
String nativeId = "/" + args.getFsName();
args.setFsNativeId(nativeId);
String fsNativeGuid = NativeGUIDGenerator.generateNativeGuid(storage.getSystemType(), storage.getSerialNumber(), nativeId);
args.setFsNativeGuid(fsNativeGuid);
String portGroup = findSVMName(args.getFs());
NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
Long fsSize = args.getFsCapacity() / BYTESPERMB;
String strFsSize = fsSize.toString() + "m";
if (!ncApi.createFS(args.getFsName(), args.getPoolNativeId(), strFsSize, args.getThinProvision())) {
_log.error("NetAppClusterModeDevice doCreateFS {} - failed", args.getFsName());
BiosCommandResult rollbackResult = doDeleteFS(storage, args);
if (rollbackResult.isCommandSuccess()) {
_log.info("NetAppClusterModeDevice doCreateFS rollback completed failed for fs, {}", args.getFsName());
} else {
_log.error("NetAppClusterModeDevice doCreateFS rollback failed for fs, {} with {}.", args.getFsName(), rollbackResult.getMessage());
}
ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateFileSystem();
result = BiosCommandResult.createErrorResult(serviceError);
} else {
_log.info("NetAppClusterModeDevice doCreateFS {} - complete", args.getFsName());
// Set FS path and Mount Path information
args.setFsPath(nativeId);
args.setFsMountPath(nativeId);
result = BiosCommandResult.createSuccessfulResult();
}
} catch (NetAppCException e) {
_log.error("NetAppClusterModeDevice::doCreateFS failed with a NetAppCException", e);
ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateFileSystem();
serviceError.setMessage(e.getLocalizedMessage());
result = BiosCommandResult.createErrorResult(serviceError);
} catch (Exception e) {
_log.error("NetAppClusterModeDevice::doCreateFS failed with an Exception", e);
ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateFileSystem();
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 doRestoreFS.
@Override
public BiosCommandResult doRestoreFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
BiosCommandResult result = new BiosCommandResult();
try {
_log.info("NetAppClusterModeDevice doRestoreFS - start");
if (null == args.getFsName()) {
_log.error("NetAppClusterModeDevice::doRestoreFS failed: Filesystem name is either missing or empty");
ServiceError serviceError = DeviceControllerErrors.netappc.unableToRestoreFileSystem();
serviceError.setMessage(FileSystemConstants.FS_ERR_FS_NAME_MISSING_OR_EMPTY);
result = BiosCommandResult.createErrorResult(serviceError);
return result;
}
if (null == args.getSnapshotName()) {
_log.error("NetAppClusterModeDevice::doRestoreFS failed: Snapshot name is either missing or empty");
ServiceError serviceError = DeviceControllerErrors.netappc.unableToRestoreFileSystem();
serviceError.setMessage(FileSystemConstants.FS_ERR_SNAPSHOT_NAME_MISSING_OR_EMPTY);
result = BiosCommandResult.createErrorResult(serviceError);
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();
if (!ncApi.restoreSnapshot(args.getFsName(), args.getSnapshotName())) {
_log.error("NetAppClusterModeDevice doRestoreFS {} - failed", args.getFsName());
ServiceError serviceError = DeviceControllerErrors.netappc.unableToRestoreFileSystem();
result = BiosCommandResult.createErrorResult(serviceError);
} else {
_log.info("doRestoreFS - restore of snapshot, {} was successfully for filesystem, {} ", args.getSnapshotName(), args.getFsName());
result = BiosCommandResult.createSuccessfulResult();
}
} catch (NetAppCException e) {
_log.error("NetAppClusterModeDevice::doRestoreFS failed with a NetAppCException", e);
ServiceError serviceError = DeviceControllerErrors.netappc.unableToRestoreFileSystem();
serviceError.setMessage(e.getLocalizedMessage());
result = BiosCommandResult.createErrorResult(serviceError);
} catch (Exception e) {
_log.error("NetAppClusterModeDevice::doRestoreFS failed with an Exception", e);
ServiceError serviceError = DeviceControllerErrors.netappc.unableToRestoreFileSystem();
serviceError.setMessage(e.getLocalizedMessage());
result = BiosCommandResult.createErrorResult(serviceError);
}
return result;
}
Aggregations