use of com.emc.storageos.vnx.xmlapi.VNXFileSystem in project coprhd-controller by CoprHD.
the class VNXFileCommunicationInterface method getAllFileSystem.
private List<VNXFileSystem> getAllFileSystem(final StorageSystem system) throws VNXException {
List<VNXFileSystem> fileSystems = null;
try {
Map<String, Object> reqAttributeMap = getRequestParamsMap(system);
_discExecutor.setKeyMap(reqAttributeMap);
_discExecutor.execute((Namespace) _discNamespaces.getNsList().get("vnxfileSystem"));
fileSystems = (ArrayList<VNXFileSystem>) _discExecutor.getKeyMap().get(VNXFileConstants.FILESYSTEMS);
} catch (BaseCollectionException e) {
throw new VNXException("Get FileSystems op failed", e);
}
return fileSystems;
}
use of com.emc.storageos.vnx.xmlapi.VNXFileSystem in project coprhd-controller by CoprHD.
the class VNXFileStorageDeviceXML method doCreateFS.
@Override
public BiosCommandResult doCreateFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
Map<String, String> autoExtendAtts = getAutoExtendAttrs(args);
Long fsSize = args.getFsCapacity() / BYTESPERMB;
if (fsSize < 1) {
// Invalid size throw an error
String errMsg = "doCreateFS failed : FileSystem size in bytes is not valid " + args.getFsCapacity();
_log.error(errMsg);
return BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToCreateFileSystem(errMsg));
}
_log.info("FileSystem size translation : {} : {} ", args.getFsCapacity(), fsSize);
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.createFileSystem(storage, args.getFsName(), // This will be used for CLI create FS
args.getPoolName(), "1", fsSize, args.getThinProvision(), args.getNativeDeviceFsId(), autoExtendAtts);
if (result.isCommandSuccess()) {
VNXFileSystem vnxFS = (VNXFileSystem) result.getObject();
args.setFsNativeId(String.valueOf(vnxFS.getFsId()));
String path = "/" + args.getFsName();
// Set path & mountpath
args.setFsMountPath(path);
args.setFsPath(path);
}
} catch (VNXException e) {
throw DeviceControllerException.exceptions.unableToCreateFileSystem(e.getMessage(Locale.getDefault()));
} finally {
clearContext(context);
}
BiosCommandResult cmdResult = null;
if (result.isCommandSuccess()) {
cmdResult = BiosCommandResult.createSuccessfulResult();
} else {
cmdResult = BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToCreateFileSystem(result.getMessage()));
}
return cmdResult;
}
use of com.emc.storageos.vnx.xmlapi.VNXFileSystem in project coprhd-controller by CoprHD.
the class VNXFileCommApi method createFileSystem.
public XMLApiResult createFileSystem(final StorageSystem system, final String fileSys, final String pool, final String dataMover, final Long size, final boolean virtualProvisioning, final String nativeFsId, final Map autoAtts) throws VNXException {
_log.info("Create VNX File System: {} on data mover {}", fileSys, dataMover);
XMLApiResult result = new XMLApiResult();
Map<String, Object> reqAttributeMap = new ConcurrentHashMap<String, Object>();
try {
updateAttributes(reqAttributeMap, system);
reqAttributeMap.put(VNXFileConstants.FILESYSTEM_NAME, fileSys);
reqAttributeMap.put(VNXFileConstants.MOUNT_PATH, "/" + fileSys);
reqAttributeMap.put(VNXFileConstants.POOL_NAME, pool);
reqAttributeMap.put(VNXFileConstants.FS_INIT_SIZE, size);
reqAttributeMap.put(VNXFileConstants.MOVER_ID, dataMover);
reqAttributeMap.put(VNXFileConstants.FILESYSTEM_VIRTUAL_PROVISIONING, virtualProvisioning);
_provExecutor.setKeyMap(reqAttributeMap);
String cmdResult = VNXFileConstants.CMD_SUCCESS;
// CHeck for FSId provided
// If provided query the array for the FSId in use
// If in use error out
// if not in use create the FS thin or thick
Boolean foundFSwithId = false;
if (null != nativeFsId && !nativeFsId.isEmpty()) {
String fileSysId = nativeFsId;
_log.info("Query file system query with id {}.", fileSysId);
_provExecutor.getKeyMap().put(VNXFileConstants.FILESYSTEM_ID, fileSysId);
_provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_FSIDQUERY_FILE));
cmdResult = (String) _provExecutor.getKeyMap().get(VNXFileConstants.CMD_RESULT);
if (cmdResult.equals(VNXFileConstants.CMD_SUCCESS)) {
fileSysId = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FILESYSTEM_ID);
foundFSwithId = (Boolean) _provExecutor.getKeyMap().get(VNXFileConstants.IS_FILESYSTEM_AVAILABLE_ON_ARRAY);
}
if (foundFSwithId) {
_log.info("There is a FileSystem exist with the id {} so fail the create.", fileSysId);
result.setCommandFailed();
result.setMessage("File System creation failed because a File System with exist with id " + nativeFsId);
return result;
} else {
_log.info("There is no FileSystem with the id {} so proceed with create.", fileSysId);
}
} else {
_log.info("FileSystem Id provided is null or empty so we will use system generated id");
}
// calculate the thin fs allocation size
String thinProvFsSizeMBs = THIN_PROVISIONED_FS_SIZE_MB;
if (virtualProvisioning) {
thinProvFsSizeMBs = getThinFSAllocSize(size, true).toString();
}
// FileSystem doesnt exist on the array, so now create it
sshApi.setConnParams(system.getIpAddress(), system.getUsername(), system.getPassword());
String createFSCmd = sshApi.formatCreateFS(fileSys, FILE_SYSTEM_TYPE_DEF, thinProvFsSizeMBs, size.toString(), pool, "", virtualProvisioning, nativeFsId);
_log.info("parsed createFSCmd {}.", createFSCmd);
result = sshApi.executeSshRetry(VNXFileSshApi.NAS_FS, createFSCmd);
if (!result.isCommandSuccess()) {
cmdResult = VNXFileConstants.CMD_FAILURE;
}
if (cmdResult.equals(VNXFileConstants.CMD_SUCCESS)) {
String fileSysId = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FILESYSTEM_ID);
int fsId = 0;
if (null == fileSysId || fileSysId.isEmpty()) {
// Since there was no error but the file system id was not found, query for id again.
_log.info("Second file system create query.");
_provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_FSIDQUERY_FILE));
cmdResult = (String) _provExecutor.getKeyMap().get(VNXFileConstants.CMD_RESULT);
if (cmdResult.equals(VNXFileConstants.CMD_SUCCESS)) {
fileSysId = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FILESYSTEM_ID);
if (null != fileSysId && !fileSysId.isEmpty()) {
fsId = Integer.parseInt(fileSysId);
}
}
} else {
fsId = Integer.parseInt(fileSysId);
}
if (0 < fsId) {
_log.info("VNX File System create success! ID: {}", fsId);
String fsType = (String) autoAtts.get(FILE_SYSTEM_TYPE_ATTRIBUTE);
String worm = (String) autoAtts.get(WORM_ATTRIBUTE);
VNXFileSystem newFs = new VNXFileSystem(fileSys, -1, pool, fsType, worm, dataMover, Long.toString(size), autoAtts);
result.setCommandSuccess();
newFs.setFsId(fsId);
result.setObject(newFs);
} else {
result.setCommandFailed();
result.setMessage("File System creation failed");
}
} else {
String errMsg = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_DESC);
result.setCommandFailed();
result.setMessage(errMsg);
}
} catch (Exception e) {
throw VNXException.exceptions.createFileSystemFailed(e.getMessage());
}
return result;
}
Aggregations