use of com.emc.storageos.db.client.model.Snapshot in project coprhd-controller by CoprHD.
the class VNXFileStorageDeviceXML method doDeleteShare.
@Override
public BiosCommandResult doDeleteShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws ControllerException {
_log.info("Call FileShare doDeleteShare");
XMLApiResult result = null;
ApplicationContext context = null;
try {
context = loadContext();
VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
if (null == vnxComm) {
throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
}
StorageHADomain dm = null;
String mountPoint = null;
if (args.getFileOperation()) {
mountPoint = args.getFs().getMountPath();
// Get DataMover
dm = this.getDataMover(args.getFs());
if (dm == null) {
Exception e = new Exception("VNX File Share creation Failed Data Mover not found");
throw VNXException.exceptions.createExportFailed("VNX File Delete Share Failed Data Mover not found", e);
}
} else {
// Get DataMover
URI snapshotId = args.getSnapshotId();
Snapshot snapshot = _dbClient.queryObject(Snapshot.class, snapshotId);
FileShare fileshare = _dbClient.queryObject(FileShare.class, snapshot.getParent().getURI());
mountPoint = fileshare.getMountPath();
dm = this.getDataMover(fileshare);
if (dm == null) {
Exception e = new Exception("VNX File Share creation Failed Data Mover not found");
throw VNXException.exceptions.createExportFailed("VNX File Delete Share Failed Data Mover not found", e);
}
}
result = vnxComm.doDeleteShare(storage, dm, smbFileShare.getName(), mountPoint, false, args);
args.getFileObjShares().remove(smbFileShare.getName());
} catch (VNXException e) {
throw new DeviceControllerException(e);
} finally {
clearContext(context);
}
BiosCommandResult cmdResult = null;
if (result.isCommandSuccess()) {
cmdResult = BiosCommandResult.createSuccessfulResult();
} else {
cmdResult = BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToDeleteFileShare(result.getMessage()));
}
return cmdResult;
}
use of com.emc.storageos.db.client.model.Snapshot in project coprhd-controller by CoprHD.
the class VNXeStorageDevice method doSnapshotFS.
@Override
public BiosCommandResult doSnapshotFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
_logger.info("creating file system {} snap {} ", args.getFsName(), args.getSnapshotLabel());
VNXeApiClient apiClient = getVnxeClient(storage);
VNXeCommandJob job = null;
VNXeFSSnapshotTaskCompleter completer = null;
try {
job = apiClient.createFileSystemSnap(args.getFsNativeId(), args.getSnapshotName());
if (job != null) {
completer = new VNXeFSSnapshotTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
VNXeCreateFileSystemSnapshotJob snapJob = new VNXeCreateFileSystemSnapshotJob(job.getId(), storage.getId(), completer);
ControllerServiceImpl.enqueueJob(new QueueJob(snapJob));
} else {
_logger.error("No job returned from createFileSystemSnap");
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("snapshotFileSystem", "No Job returned from createFileSystemSnap");
return BiosCommandResult.createErrorResult(error);
}
} catch (VNXeException e) {
_logger.error("Create file system snapshot got the exception", e);
if (completer != null) {
completer.error(_dbClient, e);
}
return BiosCommandResult.createErrorResult(e);
} catch (Exception ex) {
_logger.error("Create file system snpashot got the exception", ex);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateFileSystemSnapshot", ex.getMessage());
if (completer != null) {
completer.error(_dbClient, error);
}
return BiosCommandResult.createErrorResult(error);
}
StringBuilder logMsgBuilder = new StringBuilder(String.format("Create filesystem snapshot job submitted - Array:%s, fileSystem: %s", storage.getSerialNumber(), args.getFsName()));
_logger.info(logMsgBuilder.toString());
return BiosCommandResult.createPendingResult();
}
use of com.emc.storageos.db.client.model.Snapshot in project coprhd-controller by CoprHD.
the class VNXeDeleteFileSystemJob method updateSnapshots.
private void updateSnapshots(DbClient dbClient, FileShare fsObj) {
_logger.info(" Setting Snapshots to InActive with Force Delete ");
URIQueryResultList snapIDList = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getFileshareSnapshotConstraint(fsObj.getId()), snapIDList);
if (!snapIDList.isEmpty()) {
List<URI> idList = new ArrayList<URI>();
for (Iterator<URI> iter = snapIDList.iterator(); iter.hasNext(); ) {
URI id = iter.next();
idList.add(id);
}
List<Snapshot> snapList = dbClient.queryObject(Snapshot.class, snapIDList);
for (Snapshot snapshot : snapList) {
_logger.info("Marking Snapshot as InActive Snapshot Id {} Fs Id : {}", snapshot.getId(), snapshot.getParent());
snapshot.setInactive(true);
dbClient.persistObject(snapshot);
}
}
}
use of com.emc.storageos.db.client.model.Snapshot in project coprhd-controller by CoprHD.
the class VNXeExportFileSystemJob method updateSnapExport.
/**
* update snapshot if the export job is for snapshot export
*
* @param dbClient
* @param apiClient
* @return Snapshot instance
*/
private Snapshot updateSnapExport(DbClient dbClient, VNXeApiClient apiClient, FileExport newExport) {
_logger.info("upading snap export. ");
URI snapId = getTaskCompleter().getId();
Snapshot snapObj = dbClient.queryObject(Snapshot.class, snapId);
FSExportMap exports = snapObj.getFsExports();
if (exports == null) {
exports = new FSExportMap();
}
VNXeNfsShare nfsShare = apiClient.findSnapNfsShare(snapObj.getNativeId(), shareName);
String nfsShareId = nfsShare.getId();
newExport.setIsilonId(nfsShareId);
exports.put(newExport.getFileExportKey(), newExport);
snapObj.setFsExports(exports);
updateExportRules(snapObj.getId(), newExport, dbClient);
dbClient.persistObject(snapObj);
return snapObj;
}
use of com.emc.storageos.db.client.model.Snapshot in project coprhd-controller by CoprHD.
the class VNXeFSSnapshotTaskCompleter method complete.
@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
Snapshot snapshot = dbClient.queryObject(Snapshot.class, getId());
FileShare fsObj = dbClient.queryObject(FileShare.class, snapshot.getParent());
switch(status) {
case error:
dbClient.error(Snapshot.class, getId(), getOpId(), coded);
if (fsObj != null) {
dbClient.error(FileShare.class, fsObj.getId(), getOpId(), coded);
}
if (isNotifyWorkflow()) {
WorkflowStepCompleter.stepFailed(getOpId(), coded);
}
break;
case ready:
dbClient.ready(Snapshot.class, getId(), getOpId());
if (fsObj != null) {
dbClient.ready(FileShare.class, fsObj.getId(), getOpId());
}
if (isNotifyWorkflow()) {
WorkflowStepCompleter.stepSucceded(getOpId());
}
_logger.info("Done Snapshot operation {}, with Status: {}", getOpId(), status.name());
break;
default:
if (isNotifyWorkflow()) {
WorkflowStepCompleter.stepExecuting(getOpId());
}
break;
}
}
Aggregations