use of com.emc.storageos.db.client.model.StorageSystem in project coprhd-controller by CoprHD.
the class FileDeviceController method listSanpshotByPolicy.
@Override
public void listSanpshotByPolicy(URI storage, URI fsURI, URI policy, String opId) throws InternalException {
ControllerUtils.setThreadLocalLogData(fsURI, opId);
FileDeviceInputOutput args = new FileDeviceInputOutput();
FileShare fs = null;
try {
fs = _dbClient.queryObject(FileShare.class, fsURI);
FilePolicy fp = _dbClient.queryObject(FilePolicy.class, policy);
if (fs != null && fp != null) {
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
_log.info("Controller Recieved File Policy {}", policy);
args.addFSFileObject(fs);
args.setFileSystemPath(fs.getPath());
StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
args.addStoragePool(pool);
args.setFileProtectionPolicy(fp);
args.setFileOperation(true);
args.setOpId(opId);
// Do the Operation on device.
BiosCommandResult result = getDevice(storageObj.getSystemType()).listSanpshotByPolicy(storageObj, args);
fs.getOpStatus().updateTaskStatus(opId, result.toOperation());
} else {
throw DeviceControllerException.exceptions.invalidObjectNull();
}
} catch (Exception e) {
String[] params = { storage.toString(), fsURI.toString(), e.getMessage() };
_log.error("Unable to get schedule snapshots : storage {}, FS URI {},: Error {}", params);
updateTaskStatus(opId, fs, e);
}
}
use of com.emc.storageos.db.client.model.StorageSystem in project coprhd-controller by CoprHD.
the class FileDeviceController method performFileReplicationOperation.
@Override
public void performFileReplicationOperation(URI storage, URI sourceFSURI, String opType, String opId) throws ControllerException {
StorageSystem system = _dbClient.queryObject(StorageSystem.class, storage);
FileShare fileShare = _dbClient.queryObject(FileShare.class, sourceFSURI);
TaskCompleter completer = null;
BiosCommandResult result = new BiosCommandResult();
WorkflowStepCompleter.stepExecuting(opId);
_log.info("file replication operation {} started for file systerm {}", opType, fileShare.getName());
try {
if ("pause".equalsIgnoreCase(opType)) {
completer = new MirrorFilePauseTaskCompleter(FileShare.class, sourceFSURI, opId);
result = getDevice(system.getSystemType()).doPauseLink(system, fileShare);
} else if ("resume".equalsIgnoreCase(opType)) {
completer = new MirrorFileResumeTaskCompleter(FileShare.class, sourceFSURI, opId);
result = getDevice(system.getSystemType()).doResumeLink(system, fileShare, completer);
} else if ("start".equalsIgnoreCase(opType)) {
completer = new MirrorFileStartTaskCompleter(FileShare.class, sourceFSURI, opId);
result = getDevice(system.getSystemType()).doStartMirrorLink(system, fileShare, completer);
} else if ("refresh".equalsIgnoreCase(opType)) {
completer = new MirrorFileRefreshTaskCompleter(FileShare.class, sourceFSURI, opId);
result = getDevice(system.getSystemType()).doRefreshMirrorLink(system, fileShare);
} else if ("resync".equalsIgnoreCase(opType)) {
completer = new MirrorFileResyncTaskCompleter(FileShare.class, sourceFSURI, opId);
result = getDevice(system.getSystemType()).doResyncLink(system, fileShare, completer);
}
if (result.getCommandSuccess()) {
_log.info("file replication operation {} finished successfully for file systerm {}", opType, fileShare.getName());
completer.ready(_dbClient);
} else if (result.getCommandPending()) {
completer.statusPending(_dbClient, result.getMessage());
} else {
completer.error(_dbClient, result.getServiceCoded());
}
} catch (Exception e) {
_log.error("unable to perform mirror operation {} on file system {} ", opType, sourceFSURI, e);
updateTaskStatus(opId, fileShare, e);
ServiceError error = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, error);
}
}
use of com.emc.storageos.db.client.model.StorageSystem in project coprhd-controller by CoprHD.
the class FileDeviceController method createFS.
@Override
public void createFS(URI storage, URI pool, URI fs, String nativeId, String opId) throws ControllerException {
FileObject fileObject = null;
FileShare fsObj = null;
StorageSystem storageObj = null;
try {
ControllerUtils.setThreadLocalLogData(fs, opId);
storageObj = _dbClient.queryObject(StorageSystem.class, storage);
String[] params = { storage.toString(), pool.toString(), fs.toString() };
_log.info("Create FS: {}, {}, {}", params);
StoragePool poolObj = _dbClient.queryObject(StoragePool.class, pool);
fsObj = _dbClient.queryObject(FileShare.class, fs);
VirtualPool vPool = _dbClient.queryObject(VirtualPool.class, fsObj.getVirtualPool());
fileObject = fsObj;
FileDeviceInputOutput args = new FileDeviceInputOutput();
args.addFileShare(fsObj);
args.addStoragePool(poolObj);
args.setVPool(vPool);
args.setNativeDeviceFsId(nativeId);
args.setOpId(opId);
Project proj = _dbClient.queryObject(Project.class, fsObj.getProject());
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, fsObj.getTenant());
setVirtualNASinArgs(fsObj.getVirtualNAS(), args);
args.setTenantOrg(tenant);
args.setProject(proj);
// work flow and we need to add TaskCompleter(TBD for vnxfile)
WorkflowStepCompleter.stepExecuting(opId);
acquireStepLock(storageObj, opId);
BiosCommandResult result = getDevice(storageObj.getSystemType()).doCreateFS(storageObj, args);
if (!result.getCommandPending()) {
fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
} else {
// we need to add task completer
fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
}
if (result.isCommandSuccess()) {
fsObj.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(_dbClient, fsObj));
fsObj.setInactive(false);
WorkflowStepCompleter.stepSucceded(opId);
} else if (!result.getCommandPending()) {
fsObj.setInactive(true);
WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
}
_dbClient.updateObject(fsObj);
if (!result.getCommandPending()) {
recordFileDeviceOperation(_dbClient, OperationTypeEnum.CREATE_FILE_SYSTEM, result.isCommandSuccess(), "", "", fsObj);
}
} catch (Exception e) {
String[] params = { storage.toString(), pool.toString(), fs.toString(), e.getMessage() };
_log.error("Unable to create file system: storage {}, pool {}, FS {}: {}", params);
// work flow fail
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, serviceError);
if ((fsObj != null) && (storageObj != null)) {
fsObj.setInactive(true);
_dbClient.updateObject(fsObj);
recordFileDeviceOperation(_dbClient, OperationTypeEnum.CREATE_FILE_SYSTEM, false, e.getMessage(), "", fsObj, storageObj);
}
updateTaskStatus(opId, fileObject, e);
}
}
use of com.emc.storageos.db.client.model.StorageSystem 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.db.client.model.StorageSystem in project coprhd-controller by CoprHD.
the class FileDeviceController method deleteShare.
@Override
public void deleteShare(URI storage, URI uri, FileSMBShare smbShare, String opId) throws ControllerException {
ControllerUtils.setThreadLocalLogData(uri, opId);
FileObject fileObject = null;
StorageSystem storageObj = null;
FileShare fsObj = null;
Snapshot snapshotObj = null;
try {
storageObj = _dbClient.queryObject(StorageSystem.class, storage);
_log.info(String.format("Delete SMB share details --- name: %1$s, description: %2$s, permissionType: %3$s, permission: %4$s , maxUsers: %5$s ", smbShare.getName(), smbShare.getDescription(), smbShare.getPermissionType(), smbShare.getPermission(), (smbShare.getMaxUsers() > 0) ? smbShare.getMaxUsers() : "unlimited"));
// get db object for smb share
SMBFileShare smbFileShare = smbShare.getSMBFileShare();
FileDeviceInputOutput args = new FileDeviceInputOutput();
args.setShareName(smbShare.getName());
args.setOpId(opId);
if (URIUtil.isType(uri, FileShare.class)) {
fsObj = _dbClient.queryObject(FileShare.class, uri);
setVirtualNASinArgs(fsObj.getVirtualNAS(), args);
fileObject = fsObj;
args.addFSFileObject(fsObj);
args.setFileOperation(true);
// Acquire lock for VNXFILE Storage System
acquireStepLock(storageObj, opId);
WorkflowStepCompleter.stepExecuting(opId);
BiosCommandResult result = getDevice(storageObj.getSystemType()).doDeleteShare(storageObj, args, smbFileShare);
if (result.getCommandPending()) {
return;
}
if (!result.isCommandSuccess() && !result.getCommandPending()) {
WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
}
fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
_dbClient.updateObject(fsObj);
String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
List<SMBFileShare> shares = null;
if (result.isCommandSuccess()) {
SMBShareMap shareMap = fsObj.getSMBFileShares();
shares = new ArrayList<SMBFileShare>(shareMap.values());
deleteShareACLsFromDB(args);
WorkflowStepCompleter.stepSucceded(opId);
} else {
shares = new ArrayList<SMBFileShare>();
shares.add(smbFileShare);
}
recordFileDeviceOperation(_dbClient, OperationTypeEnum.DELETE_FILE_SYSTEM_SHARE, result.isCommandSuccess(), eventMsg, getShareNameExtensions(shares), fsObj, smbShare);
} else {
snapshotObj = _dbClient.queryObject(Snapshot.class, uri);
fileObject = snapshotObj;
args.addSnapshotFileObject(snapshotObj);
args.setFileOperation(false);
// Acquire lock for VNXFILE Storage System
acquireStepLock(storageObj, opId);
WorkflowStepCompleter.stepExecuting(opId);
BiosCommandResult result = getDevice(storageObj.getSystemType()).doDeleteShare(storageObj, args, smbFileShare);
if (result.getCommandPending()) {
return;
}
if (!result.isCommandSuccess() && !result.getCommandPending()) {
WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
}
snapshotObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
_dbClient.updateObject(snapshotObj);
fsObj = _dbClient.queryObject(FileShare.class, snapshotObj.getParent());
setVirtualNASinArgs(fsObj.getVirtualNAS(), args);
String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
List<SMBFileShare> shares = null;
if (result.isCommandSuccess()) {
SMBShareMap shareMap = snapshotObj.getSMBFileShares();
shares = new ArrayList<SMBFileShare>(shareMap.values());
deleteShareACLsFromDB(args);
WorkflowStepCompleter.stepSucceded(opId);
} else {
shares = new ArrayList<SMBFileShare>();
shares.add(smbFileShare);
}
recordFileDeviceOperation(_dbClient, OperationTypeEnum.DELETE_FILE_SNAPSHOT_SHARE, result.isCommandSuccess(), eventMsg, getShareNameExtensions(shares), snapshotObj, fsObj, smbShare);
}
} catch (Exception e) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, serviceError);
String[] params = { storage.toString(), uri.toString(), smbShare.getName(), e.getMessage() };
_log.error("Unable to delete file system or snapshot share: storage {}, FS/snapshot URI {}, SMB share {}: {}", params);
updateTaskStatus(opId, fileObject, e);
if (URIUtil.isType(uri, FileShare.class)) {
if ((fsObj != null) && (storageObj != null)) {
recordFileDeviceOperation(_dbClient, OperationTypeEnum.DELETE_FILE_SYSTEM_SHARE, false, e.getMessage(), "", fsObj, smbShare, storageObj);
}
} else {
if ((fsObj != null) && (storageObj != null) && (snapshotObj != null)) {
recordFileDeviceOperation(_dbClient, OperationTypeEnum.DELETE_FILE_SNAPSHOT_SHARE, false, e.getMessage(), "", snapshotObj, fsObj, smbShare, storageObj);
}
}
}
}
Aggregations