use of com.emc.nas.vnxfile.xmlapi.FileSystem in project coprhd-controller by CoprHD.
the class VNXFileSystemIdProcessor method processFilesystemList.
/**
* Process the fileSystemList which are received from XMLAPI server.
*
* @param filesystemList : List of FileSystem objects.
* @param keyMap : keyMap.
*/
private void processFilesystemList(List<Object> filesystemList, Map<String, Object> keyMap) throws VNXFilePluginException {
String fsName = (String) keyMap.get(VNXFileConstants.FILESYSTEM_NAME);
String fsId = (String) keyMap.get(VNXFileConstants.FILESYSTEM_ID);
boolean foundId = false;
Iterator<Object> iterator = filesystemList.iterator();
if (iterator.hasNext()) {
Status status = (Status) iterator.next();
if (status.getMaxSeverity() == Severity.OK) {
while (iterator.hasNext()) {
FileSystem fileSystem = (FileSystem) iterator.next();
if (fileSystem.getName().equals(fsName) || fileSystem.getFileSystem().equals(fsId)) {
String id = fileSystem.getFileSystem();
_logger.info("Found matching file system: {}", id);
keyMap.put(VNXFileConstants.FILESYSTEM_ID, id);
keyMap.put(VNXFileConstants.FILESYSTEM, fileSystem);
keyMap.put(VNXFileConstants.IS_FILESYSTEM_AVAILABLE_ON_ARRAY, Boolean.TRUE);
foundId = true;
break;
}
}
if (!foundId) {
_logger.error("Did not find file system ID for {}", fsName);
keyMap.put(VNXFileConstants.IS_FILESYSTEM_AVAILABLE_ON_ARRAY, Boolean.FALSE);
}
} else {
throw new VNXFilePluginException("Fault response received from XMLAPI Server.", VNXFilePluginException.ERRORCODE_INVALID_RESPONSE);
}
}
}
use of com.emc.nas.vnxfile.xmlapi.FileSystem in project coprhd-controller by CoprHD.
the class VNXFileSystemInfoProcessor method processFilesystemList.
/**
* Process the fileSystemList which are received from XMLAPI server.
*
* @param filesystemList : List of FileSystem objects.
* @param keyMap : keyMap.
*/
private void processFilesystemList(List<Object> filesystemList, Map<String, Object> keyMap) throws VNXFilePluginException {
Iterator<Object> iterator = filesystemList.iterator();
Map<String, String> volFilesystemMap = new HashMap<String, String>();
Set<String> moverIds = new HashSet<String>();
if (iterator.hasNext()) {
Status status = (Status) iterator.next();
if (status.getMaxSeverity() == Severity.OK) {
while (iterator.hasNext()) {
FileSystem fileSystem = (FileSystem) iterator.next();
volFilesystemMap.put(fileSystem.getVolume(), fileSystem.getFileSystem());
List<MoverOrVdmRef> roFileSysHosts = fileSystem.getRoFileSystemHosts();
Iterator<MoverOrVdmRef> roFileSysHostItr = roFileSysHosts.iterator();
while (roFileSysHostItr.hasNext()) {
MoverOrVdmRef mover = roFileSysHostItr.next();
moverIds.add(mover.getMover());
}
}
} else {
throw new VNXFilePluginException("Fault response received from XMLAPI Server.", VNXFilePluginException.ERRORCODE_INVALID_RESPONSE);
}
}
keyMap.put(VNXFileConstants.MOVERLIST, moverIds);
keyMap.put(VNXFileConstants.VOLFILESHAREMAP, volFilesystemMap);
}
use of com.emc.nas.vnxfile.xmlapi.FileSystem in project coprhd-controller by CoprHD.
the class VNXFileSystemsProcessor method processFilesystemList.
/**
* Process the fileSystemList which are received from XMLAPI server.
*
* @param filesystemList : List of FileSystem objects.
* @param keyMap : keyMap.
*/
private List<VNXFileSystem> processFilesystemList(List<Object> filesystemList, Map<String, Object> keyMap) throws VNXFilePluginException {
Iterator<Object> iterator = filesystemList.iterator();
List<VNXFileSystem> processedFileSystem = new ArrayList<VNXFileSystem>();
if (iterator.hasNext()) {
Status status = (Status) iterator.next();
if ((status.getMaxSeverity() == Severity.OK) || (status.getMaxSeverity() == Severity.WARNING)) {
Map<String, FileSystem> fileSystems = new HashMap<String, FileSystem>();
Map<String, FileSystemCapacityInfo> fileSysCapacityInfos = new HashMap<String, FileSystemCapacityInfo>();
while (iterator.hasNext()) {
Object obj = iterator.next();
if (obj instanceof FileSystem) {
FileSystem fs = (FileSystem) obj;
if (fs.isInternalUse() == false) {
fileSystems.put(fs.getFileSystem(), fs);
}
} else if (obj instanceof FileSystemCapacityInfo) {
FileSystemCapacityInfo fsCapacityInfo = (FileSystemCapacityInfo) obj;
fileSysCapacityInfos.put(fsCapacityInfo.getFileSystem(), fsCapacityInfo);
}
}
Iterator it = fileSystems.keySet().iterator();
while (it.hasNext()) {
String fsId = (String) it.next();
FileSystem fileSystem = fileSystems.get(fsId);
FileSystemCapacityInfo fsCapacity = fileSysCapacityInfos.get(fsId);
List<String> pools = new ArrayList<String>();
if (null != fileSystem.getStoragePools()) {
pools = fileSystem.getStoragePools();
}
String poolId = "";
if (null != pools) {
poolId = pools.get(0);
}
StringBuffer debugInfo = new StringBuffer();
debugInfo.append("VNXFileSystem : " + fileSystem.getName());
debugInfo.append(" Pool : " + poolId);
long totalCapacity = 0;
VNXFileSystem vnxFS = new VNXFileSystem(fileSystem.getName(), Integer.valueOf(fileSystem.getFileSystem()));
if (fileSystem.isVirtualProvisioning()) {
vnxFS.setType(UnManagedDiscoveredObject.SupportedProvisioningType.THIN.name());
FileSystemAutoExtInfo autoExtInfo = fileSystem.getFileSystemAutoExtInfo();
if (null != autoExtInfo) {
totalCapacity = autoExtInfo.getAutoExtensionMaxSize();
totalCapacity = totalCapacity * MBTOBYTECONVERTER;
} else {
totalCapacity = fsCapacity.getVolumeSize() * MBTOBYTECONVERTER;
}
} else {
vnxFS.setType(UnManagedDiscoveredObject.SupportedProvisioningType.THICK.name());
totalCapacity = fsCapacity.getVolumeSize() * MBTOBYTECONVERTER;
}
vnxFS.setStoragePool(poolId);
debugInfo.append(" fsCapacity.getVolumeSize() : " + fsCapacity.getVolumeSize());
vnxFS.setTotalCapacity(totalCapacity + "");
vnxFS.setUsedCapcity("0");
if (null != fsCapacity.getResourceUsage()) {
// We can get Used capacity
// Size is in MB, convert to Bytes
debugInfo.append(" fsCapacity.getUsedCapacity:" + fsCapacity.getResourceUsage().getSpaceUsed());
long usedCapacity = fsCapacity.getResourceUsage().getSpaceUsed() * MBTOBYTECONVERTER;
vnxFS.setUsedCapcity(usedCapacity + "");
}
debugInfo.append(" Total Capacity :" + vnxFS.getTotalCapacity());
debugInfo.append(" Used Capacity :" + vnxFS.getUsedCapacity());
_logger.debug(debugInfo.toString());
processedFileSystem.add(vnxFS);
}
} else {
throw new com.emc.storageos.plugins.metering.vnxfile.VNXFilePluginException("Fault response received from XMLAPI Server.", VNXFilePluginException.ERRORCODE_INVALID_RESPONSE);
}
}
return processedFileSystem;
}
use of com.emc.nas.vnxfile.xmlapi.FileSystem in project coprhd-controller by CoprHD.
the class VNXFileArgsCreator method doModifyFS.
public InputStream doModifyFS(final Argument argument, final Map<String, Object> keyMap, int index) throws VNXFilePluginException {
_logger.info("ArgsCreator: VNX File Modify");
InputStream iStream = null;
try {
// Verify that the prior command executed properly.
verifyPreviousResults(keyMap);
Task task = new Task();
ModifyFileSystem modifyFS = new ModifyFileSystem();
FileSystem fsSystem = (FileSystem) keyMap.get(VNXFileConstants.FILESYSTEM);
String fsName = (String) keyMap.get(VNXFileConstants.FILESYSTEM_NAME);
String fsId = (String) keyMap.get(VNXFileConstants.FILESYSTEM_ID);
Long size = (Long) keyMap.get(VNXFileConstants.FILESYSTEM_SIZE);
Boolean isVirtualProvisioning = (Boolean) keyMap.get(VNXFileConstants.FILESYSTEM_VIRTUAL_PROVISIONING);
if (null == fsSystem || isInValid(fsName) || isInValid(fsId) || null == size) {
throw new VNXFilePluginException("Prior command did not execute successfully", VNXFilePluginException.ERRORCODE_ILLEGALARGUMENTEXCEPTION);
}
modifyFS.setVirtualProvisioning(isVirtualProvisioning);
if (isVirtualProvisioning) {
AutoExtend autoExtend = new AutoExtend();
autoExtend.setHighWaterMark(EXT_HW_MARK);
autoExtend.setAutoExtensionMaxSize(size);
modifyFS.setAutoExtend(autoExtend);
}
_logger.info("Modifying File system max size : {}, name {}", size, fsName);
modifyFS.setFileSystem(fsSystem.getFileSystem());
task.setModifyFileSystem(modifyFS);
iStream = _vnxFileInputRequestBuilder.getTaskParamPacket(task, true);
} catch (JAXBException jaxbException) {
throw new VNXFilePluginException("Exception occurred while fetching fileSystem info", jaxbException.getCause());
}
return iStream;
}
use of com.emc.nas.vnxfile.xmlapi.FileSystem in project coprhd-controller by CoprHD.
the class VNXFileArgsCreator method doExpand.
public InputStream doExpand(final Argument argument, final Map<String, Object> keyMap, int index) throws VNXFilePluginException {
_logger.info("ArgsCreator: VNX File Expand");
InputStream iStream = null;
try {
// Verify that the prior command executed properly.
verifyPreviousResults(keyMap);
Task task = new Task();
ExtendFileSystem extendFS = new ExtendFileSystem();
FileSystem fsSystem = (FileSystem) keyMap.get(VNXFileConstants.FILESYSTEM);
String fsName = (String) keyMap.get(VNXFileConstants.FILESYSTEM_NAME);
String fsId = (String) keyMap.get(VNXFileConstants.FILESYSTEM_ID);
Long fsSize = (Long) keyMap.get(VNXFileConstants.FILESYSTEM_SIZE);
Long fsAllocatedSize = (Long) keyMap.get(VNXFileConstants.ORIGINAL_FS_SIZE);
Boolean isVirtualProvisioning = (Boolean) keyMap.get(VNXFileConstants.FILESYSTEM_VIRTUAL_PROVISIONING);
Long fsThinPerAllocSize = (Long) keyMap.get(VNXFileConstants.THIN_FS_ALLOC_SIZE);
if (null == fsSystem || isInValid(fsName) || isInValid(fsId) || null == fsSize || null == fsAllocatedSize) {
throw new VNXFilePluginException("Prior command did not execute successfully", VNXFilePluginException.ERRORCODE_ILLEGALARGUMENTEXCEPTION);
}
Long fsExpandSize = fsSize - fsAllocatedSize;
if (fsExpandSize < 0) {
fsExpandSize = fsSize;
}
// How much more I should allocate for you?
if (isVirtualProvisioning) {
fsExpandSize = fsThinPerAllocSize;
if (fsAllocatedSize < fsThinPerAllocSize) {
fsExpandSize = fsThinPerAllocSize - fsAllocatedSize;
}
}
_logger.info("Expanding File system size : {}, thin {}", fsExpandSize, isVirtualProvisioning);
String pool = fsSystem.getStoragePools().get(0);
String storage = fsSystem.getStorages().get(0);
if (isInValid(pool) || isInValid(storage)) {
throw new VNXFilePluginException("Prior command did not execute successfully", VNXFilePluginException.ERRORCODE_ILLEGALARGUMENTEXCEPTION);
}
ExtendFileSystem.StoragePool sp = new ExtendFileSystem.StoragePool();
sp.setPool(pool);
if (fsExpandSize > 0) {
sp.setSize(fsExpandSize);
}
sp.setStorage(storage);
_logger.info("Expanding File system using StoragePool : {}, storage {}", pool, storage);
_logger.info("Expanding File system size : {}, name {}", fsExpandSize, fsName);
extendFS.setFileSystem(fsSystem.getFileSystem());
extendFS.setStoragePool(sp);
task.setExtendFileSystem(extendFS);
iStream = _vnxFileInputRequestBuilder.getTaskParamPacket(task);
} catch (JAXBException jaxbException) {
throw new VNXFilePluginException("Exception occurred while fetching fileSystem info", jaxbException.getCause());
}
return iStream;
}
Aggregations