use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.
the class NetAppFileStorageDevice method doDeleteSnapshot.
@Override
public BiosCommandResult doDeleteSnapshot(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
if (null == args.getFsName()) {
throw new DeviceControllerException("Filesystem name is either missing or empty", new Object[] {});
}
if (null == args.getSnapshotName()) {
throw new DeviceControllerException("Snapshot name is either missing or empty for filesystem name {0}", new Object[] { args.getFsName() });
}
_log.info("NetAppFileStorageDevice doDeleteSnapshot: {},{} - start", args.getSnapshotId(), args.getSnapshotName());
BiosCommandResult result = new BiosCommandResult();
NetAppApi nApi = new NetAppApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).build();
try {
if (!nApi.deleteSnapshot(args.getFsName(), args.getSnapshotName())) {
_log.error("NetAppFileStorageDevice doDeleteSnapshot {} - failed", args.getFsId());
result.setCommandSuccess(false);
result.setMessage("NetAppFileStorageDevice doDeleteSnapshot - failed");
result.setCommandStatus(Operation.Status.error.name());
} else {
_log.info("doDeleteSnapshot for snapshot {} on filesystem {} successful", args.getSnapshotName(), args.getFsName());
result.setCommandSuccess(true);
result.setCommandStatus(Operation.Status.ready.name());
result.setMessage("Snapshot," + args.getSnapshotName() + " has been successfully deleted");
}
} catch (NetAppException e) {
throw new DeviceControllerException("Failed to delete snapshot, {0} for filesystem, {1} with: {2}", new Object[] { args.getSnapshotName(), args.getFsName(), e.getMessage() });
}
return result;
}
use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.
the class NetAppClusterModeDevice method updateExportRules.
@Override
public BiosCommandResult updateExportRules(StorageSystem storage, FileDeviceInputOutput args) {
// Requested Export Rules
List<ExportRule> exportAdd = args.getExportRulesToAdd();
List<ExportRule> exportDelete = args.getExportRulesToDelete();
List<ExportRule> exportModify = args.getExportRulesToModify();
// To be processed export rules
List<ExportRule> exportsToRemove = new ArrayList<>();
List<ExportRule> exportsToAdd = new ArrayList<>();
List<ExportRule> exportsRemove = new ArrayList<>();
// ALL EXPORTS
List<ExportRule> exportsToprocess = args.getExistingDBExportRules();
String fsName = "";
if (exportsToprocess == null) {
exportsToprocess = new ArrayList<>();
}
_log.info("Number of existng Rules found {}", exportsToprocess.size());
String exportPath;
String subDir = args.getSubDirectory();
BiosCommandResult result = new BiosCommandResult();
if (!args.getFileOperation()) {
_log.error("NetAppClusterModeDevice::updateExportRules {} : Snapshot export/unexport is not Supported", args.getSnapshotId());
ServiceError serviceError = DeviceControllerErrors.netappc.unableToUnexportSnapshot();
serviceError.setMessage(genDetailedMessage("updateExportRules", args.getSnapshotId().toString(), "Snapshot export/unexport is not Supported"));
result = BiosCommandResult.createErrorResult(serviceError);
return result;
} else {
exportPath = args.getFs().getPath();
if (subDir != null && subDir.length() > 0) {
exportPath = args.getFs().getPath() + "/" + subDir;
}
}
// if only delete provided with no existing rules -- How do we handle this?
_log.info("Number of Export Rules to update after processing found {}", exportsToprocess.size());
try {
String portGroup = null;
if (args.getFileOperation() == true) {
FileShare fileshare = args.getFs();
fsName = fileshare.getName();
portGroup = findSVMName(fileshare);
}
NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
String qtreePath = "";
String qtreeName = null;
if (args.getFileOperation()) {
qtreePath = exportPath;
if (subDir != null && subDir.length() > 0) {
if (ncApi.isQtree(args.getFsName(), subDir)) {
qtreeName = subDir;
qtreePath = constructQtreePath(args.getFsName(), subDir);
} else {
_log.error("NetAppClusterModeDevice::updateExportRules {} : Sub-directory export/unexport is not Supported", args.getFsId());
ServiceError serviceError = DeviceControllerErrors.netappc.unableToExportFileSystem();
serviceError.setMessage(genDetailedMessage("updateExportRules", args.getFsId().toString(), "Sub-directory export/unexport is not Supported"));
result = BiosCommandResult.createErrorResult(serviceError);
return result;
}
}
}
_log.info("exportPath : {}", exportPath);
args.setExportPath(exportPath);
// Handle Modified export Rules
if (!exportsToprocess.isEmpty()) {
for (ExportRule existingRule : exportsToprocess) {
if (existingRule.getExportPath().equalsIgnoreCase(exportPath)) {
for (ExportRule modifiedrule : exportModify) {
if (modifiedrule.getSecFlavor().equals(existingRule.getSecFlavor())) {
_log.info("Modifying Export Rule from {}, To {}", existingRule, modifiedrule);
if (!ncApi.modifyNFSShare(fsName, qtreeName, qtreePath, existingRule, modifiedrule)) {
_log.error("NetAppClusterModeDevice updateFSExportRules {} - failed", args.getFsId());
result.setMessage("NetAppClusterModeDevice updateFSExportRules {} - failed");
result.setCommandStatus(Operation.Status.error.name());
return result;
}
}
}
}
}
// Handle Add export Rules
if (exportAdd != null && !exportAdd.isEmpty()) {
for (ExportRule newExport : exportAdd) {
_log.info("Adding Export Rule {}", newExport);
if (!ncApi.addNFSShare(fsName, qtreeName, qtreePath, newExport)) {
_log.error("NetAppClusterModeDevice updateFSExportRules {} - failed", args.getFsId());
result.setMessage("NetAppClusterModeDevice updateFSExportRules {} - failed");
result.setCommandStatus(Operation.Status.error.name());
return result;
}
}
}
// Handle Delete export Rules
if (exportDelete != null && !exportDelete.isEmpty()) {
for (ExportRule existingRule : exportsToprocess) {
if (existingRule.getExportPath().equalsIgnoreCase(exportPath)) {
exportsToRemove.add(existingRule);
for (ExportRule oldExport : exportDelete) {
if (oldExport.getSecFlavor().equals(existingRule.getSecFlavor())) {
_log.info("Deleting Export Rule {}", existingRule);
exportsRemove.add(existingRule);
if (!ncApi.deleteNFSShare(fsName, qtreeName, existingRule, qtreePath)) {
_log.error("NetAppClusterModeDevice updateFSExportRules {} - failed", args.getFsId());
result.setMessage("NetAppClusterModeDevice updateFSExportRules {} - failed");
result.setCommandStatus(Operation.Status.error.name());
return result;
}
}
}
}
}
}
// No of exports found to remove from the list
_log.info("No of exports found to remove from the existing exports list {}", exportsRemove.size());
exportsToRemove.removeAll(exportsRemove);
_log.info("No of exports found to add to the existing exports list {}", exportsToAdd.size());
// If we delete filesystem without deleting export policy. Export policy will not get cleared on Array.
if (exportsToRemove.isEmpty() && !exportsRemove.isEmpty()) {
ncApi.deleteNFSExport(qtreePath);
}
}
} catch (NetAppCException e) {
_log.info("Exception:" + e.getMessage());
throw new DeviceControllerException("Exception while performing export for {0} - {1} ", new Object[] { args.getFsId(), e.getMessage() });
}
_log.info("NetAppClusterModeDevice updateFSExportRules {} - complete", args.getFsId());
result.setCommandSuccess(true);
result.setCommandStatus(Operation.Status.ready.name());
return result;
}
use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.
the class NetAppClusterModeDevice method getFSSnapshotList.
@Override
public BiosCommandResult getFSSnapshotList(StorageSystem storage, FileDeviceInputOutput args, List<String> dbSnapshots) throws ControllerException {
if (null == args.getFsName()) {
throw new DeviceControllerException("Filesystem name is either missing or empty", new Object[] {});
}
_log.info("NetAppClusterModeDevice getFSSnapshotList: {} - start", args.getFsName());
BiosCommandResult result = new BiosCommandResult();
String portGroup = findSVMName(args.getFs());
NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
try {
List<String> deviceSnapshots = ncApi.listSnapshots(args.getFsName());
if (deviceSnapshots == null) {
_log.warn("NetAppClusterModeDevice getFSSnapshotList {} - failed", args.getFsId());
result.setCommandSuccess(false);
result.setMessage("NetAppClusterModeDevice getFSSnapshotList failed for FS {}" + args.getFsName());
result.setCommandStatus(Operation.Status.error.name());
} else {
for (String deviceSnapshotName : deviceSnapshots) {
dbSnapshots.add(deviceSnapshotName);
}
_log.info("NetAppClusterModeDevice getFSSnapshotList - successful for filesystem, {} ", args.getFsName());
result.setCommandSuccess(true);
result.setCommandStatus(Operation.Status.ready.name());
result.setMessage("List of snapshots for FS " + args.getFsName() + " was successfully retreived from device ");
}
} catch (NetAppCException e) {
String[] params = { storage.getId().toString(), args.getFsName() };
throw new DeviceControllerException("Failed to retrieve list of snapshots from device {1} for filesystem {2}", params);
}
return result;
}
use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.
the class NetAppClusterModeDevice method doDeleteSnapshot.
@Override
public BiosCommandResult doDeleteSnapshot(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
if (null == args.getFsName()) {
throw new DeviceControllerException("Filesystem name is either missing or empty", new Object[] {});
}
if (null == args.getSnapshotName()) {
throw new DeviceControllerException("Snapshot name is either missing or empty for filesystem name {0}", new Object[] { args.getFsName() });
}
_log.info("NetAppClusterModeDevice doDeleteSnapshot: {},{} - start", args.getSnapshotId(), args.getSnapshotName());
BiosCommandResult result = new BiosCommandResult();
String portGroup = findSVMName(args.getFs());
NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
try {
if (!ncApi.deleteSnapshot(args.getFsName(), args.getSnapshotName())) {
_log.error("NetAppClusterModeDevice doDeleteSnapshot {} - failed", args.getFsId());
result.setCommandSuccess(false);
result.setMessage("NetAppClusterModeDevice doDeleteSnapshot - failed");
result.setCommandStatus(Operation.Status.error.name());
} else {
_log.info("doDeleteSnapshot for snapshot {} on filesystem {} successful", args.getSnapshotName(), args.getFsName());
result.setCommandSuccess(true);
result.setCommandStatus(Operation.Status.ready.name());
result.setMessage("Snapshot," + args.getSnapshotName() + " has been successfully deleted");
}
} catch (NetAppCException e) {
throw new DeviceControllerException("Failed to delete snapshot, {0} for filesystem, {1} with: {2}", new Object[] { args.getSnapshotName(), args.getFsName(), e.getMessage() });
}
return result;
}
use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.
the class ScaleIOSnapshotOperations method createGroupSnapshots.
@Override
public void createGroupSnapshots(StorageSystem storage, List<URI> snapshotList, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
ScaleIORestClient scaleIOHandle = scaleIOHandleFactory.using(dbClient).getClientHandle(storage);
List<BlockSnapshot> blockSnapshots = dbClient.queryObject(BlockSnapshot.class, snapshotList);
Map<String, String> parent2snap = new HashMap<>();
Set<URI> poolsToUpdate = new HashSet<>();
for (BlockSnapshot blockSnapshot : blockSnapshots) {
Volume parent = dbClient.queryObject(Volume.class, blockSnapshot.getParent().getURI());
parent2snap.put(parent.getNativeId(), blockSnapshot.getLabel());
poolsToUpdate.add(parent.getPool());
}
String systemId = scaleIOHandle.getSystemId();
ScaleIOSnapshotVolumeResponse result = scaleIOHandle.snapshotMultiVolume(parent2snap, systemId);
List<String> nativeIds = result.getVolumeIdList();
Map<String, String> snapNameIdMap = scaleIOHandle.getVolumes(nativeIds);
ScaleIOHelper.updateSnapshotsWithSnapshotMultiVolumeResult(dbClient, blockSnapshots, systemId, snapNameIdMap, result.getSnapshotGroupId(), storage);
dbClient.persistObject(blockSnapshots);
List<StoragePool> pools = dbClient.queryObject(StoragePool.class, Lists.newArrayList(poolsToUpdate));
for (StoragePool pool : pools) {
ScaleIOHelper.updateStoragePoolCapacity(dbClient, scaleIOHandle, pool, storage);
}
taskCompleter.ready(dbClient);
} catch (Exception e) {
log.error("Encountered an exception", e);
ServiceCoded code = DeviceControllerErrors.scaleio.encounteredAnExceptionFromScaleIOOperation("createGroupVolumeSnapshot", e.getMessage());
taskCompleter.error(dbClient, code);
}
}
Aggregations