use of com.emc.storageos.volumecontroller.FileStorageDevice in project coprhd-controller by CoprHD.
the class FileDeviceController method disconnectStorage.
/**
* Removes a connection that was previously established for monitoring
* events from the storage identified by the passed URI.
*
* @param storage
* A database client URI that identifies the storage to be
* disconnected.
*
* @throws ControllerException
* When errors occur disconnecting the storage
* for event monitoring.
*/
@Override
public void disconnectStorage(URI storage) throws ControllerException {
// Retrieve the storage device info from the database.
StorageSystem storageObj = null;
try {
storageObj = _dbClient.queryObject(StorageSystem.class, storage);
} catch (Exception e) {
throw DeviceControllerException.exceptions.unableToDisconnectStorageDeviceMonitoringDbException(storage.toString(), e);
}
// Verify non-null storage device returned from the database client.
if (storageObj == null) {
String msg = String.format("Failed disconnecting %1$s for monitoring. Database returned a null reference.", storage);
_log.error(msg);
throw DeviceControllerException.exceptions.unableToDisconnectStorageDeviceMonitoringDbNullRef(storage.toString());
}
// Get the file device reference for the type of file device managed
// by the controller.
FileStorageDevice storageDevice = getDevice(storageObj.getSystemType());
if (storageDevice == null) {
String devType = String.format("%1$s", getDevice(storageObj.getSystemType()));
String msg = String.format("Failed disconnecting %1$s for monitoring. No device for type %2$s.", storage, devType);
_log.error(msg);
throw DeviceControllerException.exceptions.unableToDisconnectStorageDeviceMonitoringNoDevice(storage.toString(), devType);
}
storageDevice.doDisconnect(storageObj);
_log.info("Removing storage device from work pool: {}", storageObj.getId());
}
use of com.emc.storageos.volumecontroller.FileStorageDevice in project coprhd-controller by CoprHD.
the class FileDeviceController method connectStorage.
/**
* Creates a connection to monitor events generated by the storage
* identified by the passed URI.
*
* @param storage
* A database client URI that identifies the storage to be
* monitored.
*
* @throws ControllerException
* When errors occur connecting the storage for
* event monitoring.
*/
@Override
public void connectStorage(URI storage) throws ControllerException {
// Retrieve the storage device info from the database.
StorageSystem storageObj = null;
try {
storageObj = _dbClient.queryObject(StorageSystem.class, storage);
} catch (Exception e) {
throw DeviceControllerException.exceptions.unableToConnectToStorageDeviceForMonitoringDbException(storage.toString(), e);
}
// Verify non-null storage device returned from the database client.
if (storageObj == null) {
throw DeviceControllerException.exceptions.unableToConnectToStorageDeviceForMonitoringDbNullRef(storage.toString());
}
// Get the file device reference for the type of file device managed
// by the controller.
FileStorageDevice storageDevice = getDevice(storageObj.getSystemType());
if (storageDevice == null) {
String devType = String.format("%1$s", storageDevice);
throw DeviceControllerException.exceptions.unableToConnectToStorageDeviceForMonitoringNoDevice(storage.toString(), devType);
}
storageDevice.doConnect(storageObj);
_log.info("Adding to storage device to work pool: {}", storageObj.getId());
}
use of com.emc.storageos.volumecontroller.FileStorageDevice in project coprhd-controller by CoprHD.
the class FileDeviceController method updateQuotaDirectory.
@Override
public void updateQuotaDirectory(URI storage, FileShareQuotaDirectory quotaDir, URI fs, String task) throws ControllerException {
ControllerUtils.setThreadLocalLogData(fs, task);
FileShare fsObj = null;
StorageSystem storageObj = null;
QuotaDirectory quotaDirObj = null;
FileDeviceInputOutput args = new FileDeviceInputOutput();
try {
String[] params = { storage.toString(), fs.toString(), quotaDir.toString() };
_log.info("FileDeviceController::updateQtree: storage : {}, fs : {}, quotaDir : {}", params);
fsObj = _dbClient.queryObject(FileShare.class, fs);
storageObj = _dbClient.queryObject(StorageSystem.class, storage);
quotaDirObj = _dbClient.queryObject(QuotaDirectory.class, quotaDir.getId());
if (null != quotaDir.getSize()) {
quotaDirObj.setSize(quotaDir.getSize());
}
quotaDirObj.setSoftLimit(quotaDir.getSoftLimit());
quotaDirObj.setSoftGrace(quotaDir.getSoftGrace());
quotaDirObj.setNotificationLimit(quotaDir.getNotificationLimit());
if (null != quotaDir.getOpLock()) {
quotaDirObj.setOpLock(quotaDir.getOpLock());
}
if (null != quotaDir.getSecurityStyle()) {
quotaDirObj.setSecurityStyle(quotaDir.getSecurityStyle());
}
// Set up args
args.addFileShare(fsObj);
args.addQuotaDirectory(quotaDirObj);
args.setOpId(task);
FileStorageDevice nasDevice = getDevice(storageObj.getSystemType());
BiosCommandResult result = nasDevice.doUpdateQuotaDirectory(storageObj, args, quotaDirObj);
if (result.getCommandPending()) {
return;
}
if (!result.isCommandSuccess() && !result.getCommandPending()) {
_log.error("FileDeviceController::updateQtree: QuotaDirectory update command is not successful");
// The quota object was already modified with changes.
// if it fail to update the quota directory,
// restore the object with the original quota directory!!!
quotaDirObj = _dbClient.queryObject(QuotaDirectory.class, quotaDir.getId());
}
quotaDirObj.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(_dbClient, quotaDirObj, fsObj.getName()));
fsObj.getOpStatus().updateTaskStatus(task, result.toOperation());
quotaDirObj.getOpStatus().updateTaskStatus(task, result.toOperation());
// save the task status into db
_dbClient.updateObject(quotaDirObj);
_dbClient.updateObject(fsObj);
fsObj = _dbClient.queryObject(FileShare.class, fs);
_log.debug("FileDeviceController::updateQtree: After QuotaDirectory updated and fs persisted, Task Stauts {} -- Operation Details : {}", fsObj.getOpStatus().get(task).getStatus(), result.toOperation());
String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
recordFileDeviceOperation(_dbClient, OperationTypeEnum.UPDATE_FILE_SYSTEM_QUOTA_DIR, result.isCommandSuccess(), eventMsg, "", quotaDirObj, fsObj);
} catch (Exception e) {
String[] params = { storage.toString(), fs.toString(), quotaDir.toString(), e.getMessage() };
_log.error("FileDeviceController::updateQtree: Unable to update file system quotaDir: storage {}, FS {}, snapshot {}: {}", params);
updateTaskStatus(task, fsObj, e);
updateTaskStatus(task, quotaDirObj, e);
if ((fsObj != null) && (quotaDirObj != null)) {
recordFileDeviceOperation(_dbClient, OperationTypeEnum.CREATE_FILE_SYSTEM_QUOTA_DIR, false, e.getMessage(), "", quotaDirObj, fsObj);
}
}
}
use of com.emc.storageos.volumecontroller.FileStorageDevice in project coprhd-controller by CoprHD.
the class FileDeviceController method createQuotaDirectory.
@Override
public void createQuotaDirectory(URI storage, FileShareQuotaDirectory quotaDir, URI fs, String task) throws ControllerException {
ControllerUtils.setThreadLocalLogData(fs, task);
FileShare fsObj = null;
QuotaDirectory quotaDirObj = null;
try {
String[] params = { storage.toString(), fs.toString(), quotaDir.toString() };
_log.info("FileDeviceController::createQtree: create QuotaDirectory: storage : {}, quotaDir : {}, fs : {}", params);
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
fsObj = _dbClient.queryObject(FileShare.class, fs);
URI qtreeURI = quotaDir.getId();
quotaDirObj = _dbClient.queryObject(QuotaDirectory.class, qtreeURI);
FileDeviceInputOutput args = new FileDeviceInputOutput();
// Set up args
args.addFileShare(fsObj);
args.addQuotaDirectory(quotaDirObj);
args.setOpId(task);
FileStorageDevice nasDevice = getDevice(storageObj.getSystemType());
BiosCommandResult result = nasDevice.doCreateQuotaDirectory(storageObj, args, quotaDirObj);
if (result.getCommandPending()) {
return;
}
fsObj.getOpStatus().updateTaskStatus(task, result.toOperation());
quotaDirObj.getOpStatus().updateTaskStatus(task, result.toOperation());
String fsName = fsObj.getName();
quotaDirObj.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(_dbClient, quotaDirObj, fsName));
// In case of an error, set the quotaDir to an 'inactive' state.
if (!result.isCommandSuccess()) {
quotaDirObj.setInactive(true);
_log.error("FileDeviceController::createQtree: QuotaDirectory create command is not successfull");
}
_dbClient.updateObject(quotaDirObj);
_dbClient.updateObject(fsObj);
fsObj = _dbClient.queryObject(FileShare.class, fs);
_log.debug("FileDeviceController::createQtree: After QuotaDirectory created and fs persisted, Task Stauts {} -- Operation Details : {}", fsObj.getOpStatus().get(task).getStatus(), result.toOperation());
String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
recordFileDeviceOperation(_dbClient, OperationTypeEnum.CREATE_FILE_SYSTEM_QUOTA_DIR, result.isCommandSuccess(), eventMsg, "", quotaDirObj, fsObj);
} catch (Exception e) {
String[] params = { storage.toString(), fs.toString(), quotaDir.toString(), e.getMessage() };
_log.error("FileDeviceController::createQtree: Unable to create file system quotaDir: storage {}, FS {}, snapshot {}: {}", params);
// remove from DB
if (quotaDirObj != null) {
quotaDirObj.setInactive(true);
_dbClient.updateObject(quotaDirObj);
}
updateTaskStatus(task, fsObj, e);
updateTaskStatus(task, quotaDirObj, e);
if ((fsObj != null) && (quotaDirObj != null)) {
recordFileDeviceOperation(_dbClient, OperationTypeEnum.CREATE_FILE_SYSTEM_QUOTA_DIR, false, e.getMessage(), "", quotaDirObj, fsObj);
}
}
}
use of com.emc.storageos.volumecontroller.FileStorageDevice in project coprhd-controller by CoprHD.
the class FileDeviceController method deleteQuotaDirectory.
@Override
public void deleteQuotaDirectory(URI storage, URI quotaDir, URI fs, String task) throws ControllerException {
FileShare fsObj = null;
QuotaDirectory quotaDirObj = null;
try {
String[] params = { storage.toString(), quotaDir.toString(), fs.toString() };
_log.info("FileDeviceController::deleteQuotaDirectory: storage : {}, quotadir : {}, fs : {}", params);
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
fsObj = _dbClient.queryObject(FileShare.class, fs);
quotaDirObj = _dbClient.queryObject(QuotaDirectory.class, quotaDir);
FileDeviceInputOutput args = new FileDeviceInputOutput();
args.addFSFileObject(fsObj);
args.addQuotaDirectory(quotaDirObj);
args.setOpId(task);
FileStorageDevice nasDevice = getDevice(storageObj.getSystemType());
BiosCommandResult result = nasDevice.doDeleteQuotaDirectory(storageObj, args);
if (result.getCommandPending()) {
return;
}
fsObj.getOpStatus().updateTaskStatus(task, result.toOperation());
quotaDirObj.getOpStatus().updateTaskStatus(task, result.toOperation());
String fsName = fsObj.getName();
quotaDirObj.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(_dbClient, quotaDirObj, fsName));
if (!result.isCommandSuccess()) {
_log.error("FileDeviceController::deleteQuotaDirectory: command is not successfull");
} else {
// If delete operation is successful, then remove obj from ViPR db by setting inactive=true
quotaDirObj.setInactive(true);
}
// save the task status in db
_dbClient.updateObject(quotaDirObj);
_dbClient.updateObject(fsObj);
fsObj = _dbClient.queryObject(FileShare.class, fs);
_log.debug("FileDeviceController::deleteQuotaDirectory: After deleteQuotaDirectory created and fs persisted, Task Stauts {} -- Operation Details : {}", fsObj.getOpStatus().get(task).getStatus(), result.toOperation());
String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
recordFileDeviceOperation(_dbClient, OperationTypeEnum.DELETE_FILE_SYSTEM_QUOTA_DIR, result.isCommandSuccess(), eventMsg, "", quotaDirObj, fsObj);
} catch (Exception e) {
String[] params = { storage.toString(), fs.toString(), quotaDir.toString(), e.getMessage() };
_log.error("FileDeviceController::deleteQuotaDirectory: Unable to create file system quota dir: storage {}, FS {}, quotadir {}: {}", params);
updateTaskStatus(task, fsObj, e);
updateTaskStatus(task, quotaDirObj, e);
if ((fsObj != null) && (quotaDirObj != null)) {
recordFileDeviceOperation(_dbClient, OperationTypeEnum.DELETE_FILE_SYSTEM_QUOTA_DIR, false, e.getMessage(), "", quotaDirObj, fsObj);
}
}
}
Aggregations