use of com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi in project coprhd-controller by CoprHD.
the class VNXFileStorageDeviceXML method loadVNXFileCommunicationAPIs.
/**
* Loading context every time for each operation doesn't look right.
*
* TODO As of v1, adding this code, this definitely had to be changed.
*
* @return
*/
private VNXFileCommApi loadVNXFileCommunicationAPIs(ApplicationContext context) {
VNXFileCommApi vnxComm = null;
try {
vnxComm = (VNXFileCommApi) context.getBean(VNXCOMM_API);
vnxComm.setDbClient(_dbClient);
} catch (Exception e) {
throw new DeviceControllerException("VNXFile Provisioning context didn't get loaded properly.Terminating File System Provisioning operations.");
}
return vnxComm;
}
use of com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi in project coprhd-controller by CoprHD.
the class VNXFileStorageDeviceXML method extraExportRuleFromArray.
/**
* Get the export rule which are present in array but not in CoprHD Database.
*
* @param storage
* @param args
* @return map with security flavor and export rule
*/
private Map<String, ExportRule> extraExportRuleFromArray(StorageSystem storage, FileDeviceInputOutput args) {
// map to store the export rule grouped by sec flavor
Map<String, ExportRule> exportRuleMap = new HashMap<>();
Set<String> arrayReadOnlyHost = new HashSet<>();
Set<String> arrayReadWriteHost = new HashSet<>();
Set<String> arrayRootHost = new HashSet<>();
Set<String> dbReadOnlyHost = new HashSet<>();
Set<String> dbReadWriteHost = new HashSet<>();
Set<String> dbRootHost = new HashSet<>();
// get all export rule from CoprHD data base
List<ExportRule> existingDBExportRules = args.getExistingDBExportRules();
// get the all the export from the storage system.
ApplicationContext context = null;
context = loadContext();
VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
if (null == vnxComm) {
throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
}
for (ExportRule exportRule : existingDBExportRules) {
if (exportRule.getReadOnlyHosts() != null) {
dbReadOnlyHost.addAll(exportRule.getReadOnlyHosts());
}
if (exportRule.getReadWriteHosts() != null) {
dbReadWriteHost.addAll(exportRule.getReadWriteHosts());
}
if (exportRule.getRootHosts() != null) {
dbRootHost.addAll(exportRule.getRootHosts());
}
Map<String, String> vnxExportMap = null;
vnxExportMap = vnxComm.getNFSExport(storage, args);
String readOnlyList = vnxExportMap.get("ro");
String readWriteList = vnxExportMap.get("rw");
String rootList = vnxExportMap.get("root");
// we get multiple value each separated by :
if (readOnlyList != null) {
for (String readOnly : readOnlyList.split(":")) {
if (!readOnly.equals("null")) {
arrayReadOnlyHost.add(readOnly);
}
}
}
if (readWriteList != null) {
for (String readWrite : readWriteList.split(":")) {
if (!readWrite.equals("null")) {
arrayReadWriteHost.add(readWrite);
}
}
}
if (rootList != null) {
for (String root : rootList.split(":")) {
if (!root.equals("null")) {
arrayRootHost.add(root);
}
}
}
// find out the change between array and CoprHD database.
Set<String> arrayExtraReadOnlyHost = Sets.difference(arrayReadOnlyHost, dbReadOnlyHost);
Set<String> arrayExtraReadWriteHost = Sets.difference(arrayReadWriteHost, dbReadWriteHost);
Set<String> arrayExtraRootHost = Sets.difference(arrayRootHost, dbRootHost);
// if change found update the exportRuleMap
if (!arrayExtraReadOnlyHost.isEmpty() || !arrayExtraReadWriteHost.isEmpty() || !arrayExtraRootHost.isEmpty()) {
ExportRule extraRuleFromArray = new ExportRule();
extraRuleFromArray.setDeviceExportId(exportRule.getDeviceExportId());
extraRuleFromArray.setAnon(exportRule.getAnon());
extraRuleFromArray.setSecFlavor(exportRule.getSecFlavor());
extraRuleFromArray.setExportPath(exportRule.getExportPath());
extraRuleFromArray.setReadOnlyHosts(arrayExtraReadOnlyHost);
extraRuleFromArray.setReadWriteHosts(arrayExtraReadWriteHost);
extraRuleFromArray.setRootHosts(arrayExtraRootHost);
exportRuleMap.put(exportRule.getSecFlavor(), extraRuleFromArray);
}
}
return exportRuleMap;
}
use of com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi in project coprhd-controller by CoprHD.
the class VNXFileStorageDeviceXML method doRestoreFS.
@Override
public BiosCommandResult doRestoreFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
_log.info("FileShare, Snapshot {} {}", args.getFsUUID(), args.getSnapshotId());
_log.info("FSName: {}", args.getFsName());
_log.info("SnapShotName: {}", args.getSnapshotName());
int snapNativeId = 0;
XMLApiResult result = null;
ApplicationContext context = null;
try {
context = loadContext();
VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
if (null == vnxComm) {
throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
}
result = vnxComm.doRestoreSnapshot(storage, args.getFsNativeId(), args.getFsName(), args.getSnapNativeId(), args.getSnapshotName());
_log.info("restoreSnapshot call result : {}", result.isCommandSuccess());
} catch (NumberFormatException ne) {
// Call failed
result = new XMLApiResult();
result.setCommandFailed();
result.setMessage("Not valid snapshot Id " + args.getSnapNativeId());
} catch (VNXException e) {
throw new DeviceControllerException(e);
} finally {
clearContext(context);
}
_log.info("restoreSnapshot call result : {}", result.isCommandSuccess());
BiosCommandResult cmdResult = null;
if (result.isCommandSuccess()) {
cmdResult = BiosCommandResult.createSuccessfulResult();
} else {
cmdResult = BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToRestoreFileSystem(result.getMessage()));
}
return cmdResult;
}
use of com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi in project coprhd-controller by CoprHD.
the class VNXFileStorageDeviceXML method doCheckFSDependencies.
@Override
public BiosCommandResult doCheckFSDependencies(StorageSystem storage, FileDeviceInputOutput args) {
_log.info("Checking file system {} has dependencies in storage array: {}", args.getFsName(), storage.getLabel());
boolean hasDependency = true;
FileShare fs = args.getFs();
ApplicationContext context = null;
try {
context = loadContext();
VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
if (null == vnxComm) {
throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
}
String fsMountPath = args.getFsMountPath();
Map<String, String> nfsShares = vnxComm.getNFSExport(storage, args);
hasDependency = (nfsShares != null && !nfsShares.isEmpty());
if (!hasDependency) {
Map<String, String> cifsShares = vnxComm.getCIFSExport(storage, args);
hasDependency = (cifsShares != null && !cifsShares.isEmpty());
}
if (!hasDependency) {
List<Checkpoint> snapshots = vnxComm.getCheckpointsOfFilesystem(storage, fs.getNativeId());
hasDependency = (snapshots != null && !snapshots.isEmpty());
}
if (hasDependency) {
_log.error("File system has dependencies on array: {}", args.getFsName());
DeviceControllerException e = DeviceControllerException.exceptions.fileSystemHasDependencies(fsMountPath);
return BiosCommandResult.createErrorResult(e);
}
_log.info("File system has no dependencies on array: {}", args.getFsName());
return BiosCommandResult.createSuccessfulResult();
} catch (Exception ex) {
_log.error("Checking FS dependencies failed.", ex);
throw ex;
} finally {
clearContext(context);
}
}
use of com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi in project coprhd-controller by CoprHD.
the class VNXFileStorageDeviceXML method doExpandFS.
@Override
public BiosCommandResult doExpandFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
_log.info("Call FileSystem Expand");
// For the request to succeed to expand, the system must be mounted.
// Below snippet helps to verify whether FS Mounted or not.
// Note : Since, Every Export will mount the FileSystem at first, we
// should do cross check as below whether file system is already mounted or not
// using FSExportMap and SMBShareMap
// If FileShare mounted then Mount is not required
boolean isMountRequired = !(args.isFileShareMounted());
_log.info("Mount required or not, to expand requested FileSystem {}", isMountRequired);
Long newFsExpandSize = args.getNewFSCapacity();
if (args.getNewFSCapacity() % BYTESPERMB == 0) {
newFsExpandSize = newFsExpandSize / BYTESPERMB;
} else {
newFsExpandSize = newFsExpandSize / BYTESPERMB + 1;
}
_log.info("FileSystem new size translation : {} : {}", args.getNewFSCapacity(), args.getFsCapacity());
XMLApiResult result = null;
ApplicationContext context = null;
try {
context = loadContext();
VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
if (null == vnxComm) {
throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
}
result = vnxComm.expandFS(storage, args.getFs(), newFsExpandSize, isMountRequired, args.getThinProvision());
} 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.unableToExpandFileSystem(result.getMessage()));
}
return cmdResult;
}
Aggregations