use of com.emc.storageos.netappc.NetAppClusterApi 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.netappc.NetAppClusterApi 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.netappc.NetAppClusterApi 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;
}
use of com.emc.storageos.netappc.NetAppClusterApi 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.netappc.NetAppClusterApi in project coprhd-controller by CoprHD.
the class NetAppClusterModeDevice method modifyNtpShare.
/**
* modify NetAppC share with right permissions and other parameters
*
* @param StorageSystem mount path of the fileshare
* @param args containing input/out arguments of filedevice
* @param smbFileShare existingShare smbFileshare object that needs to be modified.
* @param forceGroup Name of the group the fileshare belongs.
* @return
*/
private Boolean modifyNtpShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare, String forceGroup, SMBFileShare existingShare) throws NetAppCException {
String portGroup = findSVMName(args.getFs());
NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
String shareId = smbFileShare.getPath();
if (!ncApi.modifyShare(shareId, smbFileShare.getName(), smbFileShare.getDescription(), smbFileShare.getMaxUsers(), smbFileShare.getPermission(), forceGroup)) {
_log.info("NetAppClusterModeDevice doShare (modification) for {} with id {} - failed", shareId, args.getFileObjId());
return false;
} else {
_log.info("NetAppClusterModeDevice doShare (modification) for {} with id {} - complete", shareId, args.getFileObjId());
return true;
}
}
Aggregations