use of com.emc.storageos.vnx.xmlapi.VNXSnapshot in project coprhd-controller by CoprHD.
the class VNXFileStorageDeviceXML method doSnapshotFS.
@Override
public BiosCommandResult doSnapshotFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
// generate checkpoint baseline name
args.setSnaphotCheckPointBaseline(args.getSnapshotName() + "_baseline");
args.setSnapshotMountPath("/" + args.getSnapshotName());
_log.info("FileShare, Snapshot {} {}", args.getFsUUID(), args.getSnapshotId());
_log.info("FSName: {}", args.getFsName());
_log.info("SnapShotName: {}", args.getSnapshotName());
XMLApiResult result = null;
ApplicationContext context = null;
try {
context = loadContext();
VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
if (null == vnxComm) {
throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
}
FileShare fileShare = args.getFs();
result = vnxComm.createSnapshot(storage, args.getFsName(), args.getSnapshotName(), fileShare);
_log.info("createSnapshot call result : {}", result.isCommandSuccess());
if (result.isCommandSuccess()) {
VNXSnapshot vnxSnap = (VNXSnapshot) result.getObject();
args.setSnapNativeId(String.valueOf(vnxSnap.getId()));
String path = "/" + args.getSnapshotName();
// Set path & mountpath
args.setSnapshotMountPath(path);
args.setSnapshotPath(path);
}
} catch (VNXException e) {
throw new DeviceControllerException(e);
} finally {
clearContext(context);
}
_log.info("Status of the result {}", (result != null) ? result.isCommandSuccess() : result);
BiosCommandResult cmdResult = null;
if (result.isCommandSuccess()) {
cmdResult = BiosCommandResult.createSuccessfulResult();
} else {
cmdResult = BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToCreateFileSnapshot(result.getMessage()));
}
return cmdResult;
}
use of com.emc.storageos.vnx.xmlapi.VNXSnapshot in project coprhd-controller by CoprHD.
the class VNXFileCommApi method createSnapshot.
public XMLApiResult createSnapshot(final StorageSystem system, final String fsName, final String snapshotName, final FileShare fileShare) throws VNXException {
_log.info("Create Snap for file sys : {} snap name : {}", fsName, snapshotName);
XMLApiResult result = new XMLApiResult();
Map<String, Object> reqAttributeMap = new ConcurrentHashMap<String, Object>();
try {
// get the data mover
StorageHADomain dataMover = this.getDataMover(fileShare);
if (null != dataMover) {
sshApi.setConnParams(system.getIpAddress(), system.getUsername(), system.getPassword());
Map<String, String> existingMounts = sshApi.getFsMountpathMap(dataMover.getAdapterName());
if (existingMounts.get(fileShare.getName()) == null) {
String mountCmdArgs = sshApi.formatMountCmd(dataMover.getAdapterName(), fileShare.getName(), fileShare.getMountPath());
result = sshApi.executeSshRetry(VNXFileSshApi.SERVER_MOUNT_CMD, mountCmdArgs);
_log.info("filesystem mount is successful for filesystem: {} mount path: {}", fileShare.getName(), fileShare.getMountPath());
}
} else {
Exception e = new Exception("VNX File snapshot creation failed because suitable Data mover to mount the File System not found");
throw VNXException.exceptions.createExportFailed("VNX File Snapshot create is Failed", e);
}
updateAttributes(reqAttributeMap, system);
reqAttributeMap.put(VNXFileConstants.FILESYSTEM_NAME, fsName);
reqAttributeMap.put(VNXFileConstants.SNAPSHOT_NAME, snapshotName);
_provExecutor.setKeyMap(reqAttributeMap);
_provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_CREATE_SNAP));
String cmdResult = (String) _provExecutor.getKeyMap().get(VNXFileConstants.CMD_RESULT);
if (cmdResult != null && cmdResult.equals(VNXFileConstants.CMD_SUCCESS)) {
String snapId = (String) _provExecutor.getKeyMap().get(VNXFileConstants.SNAPSHOT_ID);
String fsysId = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FILESYSTEM_ID);
if (snapId != null) {
int fsId = Integer.parseInt(fsysId);
int snId = Integer.parseInt(snapId);
VNXSnapshot vnxSnap = new VNXSnapshot(snapshotName, -1, fsId);
vnxSnap.setId(snId);
result.setObject(vnxSnap);
result.setCommandSuccess();
} else {
result.setCommandFailed();
result.setMessage((String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_MSG));
}
} else {
String errMsg = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_MSG);
result.setCommandFailed();
result.setMessage(errMsg);
}
} catch (Exception e) {
throw new VNXException("Failure", e);
}
return result;
}
Aggregations