use of com.iwave.ext.netapp.VolumeOptionType in project coprhd-controller by CoprHD.
the class NetAppApi method createVolume.
public Boolean createVolume(String volName, String aggregate, String size, Boolean isThin) {
netAppFacade = new NetAppFacade(_ipAddress, _portNumber, _userName, _password, _https);
String spaceReserve = "";
if (isThin) {
spaceReserve = SPACE_GUARANTEE_PARAM;
}
Boolean status = netAppFacade.createFlexibleVolume(volName, aggregate, false, null, size, null, spaceReserve, false, null);
if (status) {
Collection<String> attrs = new ArrayList<String>();
attrs.add(VOL_ATTR_NAME);
for (int i = 0; i <= 3; i++) {
List<Map<String, String>> fileSystemCharacterics = netAppFacade.listVolumeInfo(volName, attrs);
Map<String, String> fileSystemChar = fileSystemCharacterics.get(0);
String fsName = fileSystemChar.get(VOL_ATTR_RESULT_NAME);
if (volName.equals(fsName)) {
_logger.info("FS {} has been created successfully on the array", fsName);
status = true;
break;
} else {
_logger.info("FS not see on the array yet, check back in few seconds");
status = false;
try {
Thread.sleep(3);
} catch (InterruptedException e) {
_logger.info("Failed to sleep after FS creation");
}
continue;
}
}
} else {
_logger.info("FS creation failed");
status = false;
}
Map<VolumeOptionType, String> options = new HashMap<VolumeOptionType, String>();
options.put(VolumeOptionType.convert_ucode, CONVERT_UCODE_ON);
options.put(VolumeOptionType.create_ucode, CREATE_UCODE_ON);
netAppFacade.setVolumeOptions(volName, options);
// If vFiler enabled, need to add storage to vFiler.
if (status && _vFilerName != null && !_vFilerName.equals(DEFAULT_VFILER)) {
netAppFacade = new NetAppFacade(_ipAddress, _portNumber, _userName, _password, _https, DEFAULT_VFILER);
try {
status = netAppFacade.addStorage(VOL_ROOT + volName, _vFilerName);
// If adding a volume to a vfiler fails, then delete the volume.
if (!status) {
_logger.error("Adding volume {} to vfiler {} failed", volName, _vFilerName);
deleteFS(volName);
}
} catch (Exception e) {
// If adding a volume to a vfiler fails, then delete the volume.
_logger.error("Exception when adding volume {} to vfiler {}.", volName, _vFilerName);
deleteFS(volName);
throw e;
}
}
return status;
}
Aggregations