use of com.emc.nas.vnxfile.xmlapi.Checkpoint in project coprhd-controller by CoprHD.
the class VNXSnapshotProcessor method fetchSnapShotDetails.
/**
* fetches the snapshot details from the checkpoint list.
*
* @param stat
* : Stat object.
* @param ckptList
* : List of checkpoints.
*/
private void fetchSnapShotDetails(final Stat stat, final List<Object> snapshotList) {
int snapCount = 0;
long snapCapacity = 0;
Checkpoint checkPoint = null;
// first element is stat object and remaining elem are snapshot's
Iterator<Object> snapshotItr = snapshotList.iterator();
snapshotItr.next();
// processing snapshot list
while (snapshotItr.hasNext()) {
checkPoint = (Checkpoint) snapshotItr.next();
if (fetchNativeId(stat.getNativeGuid()).equals(checkPoint.getCheckpointOf())) {
snapCount++;
snapCapacity += (Long.valueOf(checkPoint.getFileSystemSize()) * 1024);
}
}
stat.setSnapshotCount(snapCount);
stat.setSnapshotCapacity(snapCapacity);
}
use of com.emc.nas.vnxfile.xmlapi.Checkpoint in project coprhd-controller by CoprHD.
the class VNXFileCommApi method deleteFileSystem.
public XMLApiResult deleteFileSystem(final StorageSystem system, final String fileId, final String fileSys, final boolean isForceDelete, FileShare fs) throws VNXException {
_log.info("Delete VNX File System: fs id {}, Force Delete {}", fileId, isForceDelete);
XMLApiResult result = new XMLApiResult();
if (null == fileId || null == fileSys || fileId.trim().equals("") || fileSys.trim().equals("")) {
result.setCommandFailed();
result.setMessage("Invalid Input Parameters.");
return result;
}
Map<String, Object> reqAttributeMap = new ConcurrentHashMap<String, Object>();
try {
updateAttributes(reqAttributeMap, system);
reqAttributeMap.put(VNXFileConstants.FILESYSTEM_NAME, fileSys);
reqAttributeMap.put(VNXFileConstants.FILESYSTEM_ID, fileId);
_provExecutor.setKeyMap(reqAttributeMap);
// Before deleting check whether it is available or not on the array - This need to be done as part of
// deleting un-managed FS.
_provExecutor.setKeyMap(reqAttributeMap);
_provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_FSIDQUERY_FILE_DELETE));
boolean isFsAvailable = false;
_log.debug("Listing VNX File File Systems");
String cmdResult = (String) _provExecutor.getKeyMap().get(VNXFileConstants.CMD_RESULT);
if (null != cmdResult && cmdResult.equals(VNXFileConstants.CMD_SUCCESS)) {
isFsAvailable = (Boolean) _provExecutor.getKeyMap().get(VNXFileConstants.IS_FILESYSTEM_AVAILABLE_ON_ARRAY);
}
if (!isFsAvailable) {
_log.debug("File System **Not found on array which requested to delete.");
result.setCommandSuccess();
// No need to set Inactive and persist here as this will be done in upper layer(FileDeviceController)
}
if (isForceDelete) {
// handle snapshots
_provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_FS_FORCE_DEL_FILE));
cmdResult = (String) _provExecutor.getKeyMap().get(VNXFileConstants.CMD_RESULT);
StorageHADomain dataMover = getDataMover(fs);
if (cmdResult.equals(VNXFileConstants.CMD_SUCCESS)) {
List<Checkpoint> snaps = (List<Checkpoint>) _provExecutor.getKeyMap().get(VNXFileConstants.SNAPSHOTS_LIST);
int numSnapshots = (snaps != null) ? snaps.size() : 0;
_log.info("Number of Snapshots found {} for a file system {}", numSnapshots, fileId);
if (snaps != null && !snaps.isEmpty()) {
for (Checkpoint checkpoint : snaps) {
_log.info("Deleting Snapshot having name {} - and id {}", checkpoint.getName(), checkpoint.getCheckpoint());
String nativeGuid = NativeGUIDGenerator.getNativeGuidforSnapshot(system, system.getSerialNumber(), checkpoint.getCheckpoint());
_log.info("NativeGuid {} built for snapshot {}", nativeGuid, checkpoint.getCheckpoint());
Snapshot snapshot = null;
List<URI> snapShotUris = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getSnapshotNativeGuidConstraint(nativeGuid));
_log.info("{} Snapshots found with native guid : {} ", snapShotUris.size(), nativeGuid);
if (!snapShotUris.isEmpty()) {
_log.info("Retriving Snapshot using URI : {} ", snapShotUris.get(0));
snapshot = _dbClient.queryObject(Snapshot.class, snapShotUris.get(0));
}
if (snapshot != null) {
result = deleteAllExportsAndShares(system, dataMover, fs, snapshot);
XMLApiResult status = doDeleteSnapshot(system, checkpoint.getCheckpoint(), checkpoint.getName(), false);
if (!status.isCommandSuccess()) {
String errMsg = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_DESC);
result.setCommandFailed();
result.setMessage(errMsg);
return result;
}
}
}
}
// Delete All Quota directories of FileShare.
result = deleteAllQuotaDirs(system, dataMover, fs);
// Delete Exports/SMB Shares of FileShare
result = deleteAllExportsAndShares(system, dataMover, fs, null);
} else {
String errMsg = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_DESC);
result.setCommandFailed();
result.setMessage(errMsg);
return result;
}
}
if (isFsAvailable) {
_log.debug("File System found on array which requested to delete. Now, deleting on Array.");
// First unmount it
StorageHADomain dataMover = getDataMover(fs);
if (dataMover != null) {
Map<String, String> existingMounts = sshApi.getFsMountpathMap(dataMover.getAdapterName());
// is FS mount still exists?
if (existingMounts.get(fs.getName()) != null) {
// The File system is mounted and we need to unmount it before deleting it
String unMountCmd = sshApi.formatUnMountCmd(dataMover.getAdapterName(), fs.getMountPath(), "NFS");
_log.info("Unmount FS {}", unMountCmd);
sshApi.setConnParams(system.getIpAddress(), system.getUsername(), system.getPassword());
result = sshApi.executeSshRetry(VNXFileSshApi.SERVER_UNMOUNT_CMD, unMountCmd);
}
} else {
_log.info("No need to Unmount FS {} since there is no mount info", fs.getMountPath());
}
_provExecutor.setKeyMap(reqAttributeMap);
_provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_FSDEL_FILE));
cmdResult = (String) _provExecutor.getKeyMap().get(VNXFileConstants.CMD_RESULT);
if (null != cmdResult && cmdResult.equals(VNXFileConstants.CMD_SUCCESS)) {
result.setCommandSuccess();
} else {
String errMsg = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_DESC);
result.setCommandFailed();
result.setMessage(errMsg);
}
}
} catch (Exception e) {
throw new VNXException("File system delete exception: ", e);
}
return result;
}
Aggregations