use of com.emc.storageos.isilon.restapi.IsilonApi in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method getCustomPath.
/**
* Gets the file system custom path value from controller configuration
*
* @param storage
* Isilon storage system
* @param args
* FileDeviceInputOutput object
* @return evaluated custom path
*/
private String getCustomPath(StorageSystem storage, FileDeviceInputOutput args) {
String path = "";
IsilonApi isi = getIsilonDevice(storage);
String clusterName = isi.getClusterConfig().getName();
FileShare fs = args.getFs();
// source cluster name should be included in target path instead of target cluster name.
if (fs != null && fs.getPersonality() != null && fs.getPersonality().equalsIgnoreCase(PersonalityTypes.TARGET.name())) {
FileShare sourceFS = _dbClient.queryObject(FileShare.class, fs.getParentFileShare());
if (sourceFS != null && sourceFS.getStorageDevice() != null) {
StorageSystem sourceSystem = _dbClient.queryObject(StorageSystem.class, sourceFS.getStorageDevice());
if (sourceSystem != null) {
IsilonApi sourceCluster = getIsilonDevice(sourceSystem);
clusterName = sourceCluster.getClusterConfig().getName();
// if the replication happens from user defined access zone to system access zone!!
if (sourceFS.getVirtualNAS() != null) {
VirtualNAS sourcevNAS = _dbClient.queryObject(VirtualNAS.class, sourceFS.getVirtualNAS());
if (sourcevNAS != null) {
String vNASName = sourcevNAS.getNasName();
vNASName = getNameWithNoSpecialCharacters(vNASName, args);
clusterName = clusterName + vNASName;
_log.info("Source file system is on virtual NAS {}", vNASName);
}
}
_log.debug("Generating path for target and the source cluster is is {}", clusterName);
}
}
} else if (args.isTarget()) {
if (args.getSourceSystem() != null) {
IsilonApi sourceCluster = getIsilonDevice(args.getSourceSystem());
clusterName = sourceCluster.getClusterConfig().getName();
}
// if the replication happens from user defined access zone to system access zone!!
if (args.getSourceVNAS() != null && args.getvNAS() == null) {
VirtualNAS sourcevNAS = args.getSourceVNAS();
String vNASName = sourcevNAS.getNasName();
vNASName = getNameWithNoSpecialCharacters(vNASName, args);
clusterName = clusterName + vNASName;
}
_log.debug("Generating path for target and the source cluster is is {}", clusterName);
}
DataSource dataSource = dataSourceFactory.createIsilonFileSystemPathDataSource(args.getProject(), args.getVPool(), args.getTenantOrg(), storage);
dataSource.addProperty(CustomConfigConstants.ISILON_CLUSTER_NAME, clusterName);
String configPath = customConfigHandler.getComputedCustomConfigValue(CustomConfigConstants.ISILON_PATH_CUSTOMIZATION, "isilon", dataSource);
_log.debug("The isilon user defined custom path is {}", configPath);
if (configPath != null && !configPath.isEmpty()) {
path = args.getPathWithoutSpecialCharacters(configPath);
}
return path;
}
use of com.emc.storageos.isilon.restapi.IsilonApi in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method doesNFSExportExistsForFSPath.
private boolean doesNFSExportExistsForFSPath(StorageSystem storageSystem, String isilonAccessZone, String path) throws IsilonCollectionException {
URI storageSystemId = storageSystem.getId();
String resumeToken = null;
try {
_log.info("Checking NFS export for path {} on Isilon storage system: {} in access zone {} - start", path, storageSystem.getLabel(), isilonAccessZone);
IsilonApi isilonApi = getIsilonDevice(storageSystem);
do {
IsilonApi.IsilonList<IsilonExport> isilonExports = isilonApi.listExports(resumeToken, isilonAccessZone);
List<IsilonExport> exports = isilonExports.getList();
for (IsilonExport exp : exports) {
if (exp.getPaths() == null || exp.getPaths().isEmpty()) {
_log.info("Ignoring export {} as it is not having any path", exp);
continue;
}
// Ignore Export with multiple paths
if (exp.getPaths().size() > 1) {
_log.info("Isilon Export: {} has multiple paths. So ingnore it.", exp);
continue;
}
String exportPath = exp.getPaths().get(0);
if (exportPath.equals(path)) {
_log.info("Found NFS export with path {} on Ision: {} in access zone: {}", path, storageSystem.getLabel(), isilonAccessZone);
return true;
}
}
resumeToken = isilonExports.getToken();
} while (resumeToken != null);
_log.info("NFS export not found with path {} on Ision: {} in access zone: {}", path, storageSystem.getLabel(), isilonAccessZone);
return false;
} catch (IsilonException ie) {
_log.error("doesNFSExportExistsForFSPath failed. Storage system: {}", storageSystemId, ie);
IsilonCollectionException ice = new IsilonCollectionException("doesNFSExportExistsForFSPath failed. Storage system: " + storageSystemId);
ice.initCause(ie);
throw ice;
} catch (Exception e) {
_log.error("doesNFSExportExistsForFSPath failed. Storage system: {}", storageSystemId, e);
IsilonCollectionException ice = new IsilonCollectionException("doesNFSExportExistsForFSPath failed. Storage system: " + storageSystemId);
ice.initCause(e);
throw ice;
}
}
use of com.emc.storageos.isilon.restapi.IsilonApi in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method getSyncPolicyErrorReport.
/**
* get the error reports from device
*
* @param device - storage system
* @param syncPolicy - synciq policy name
* @return
*/
private BiosCommandResult getSyncPolicyErrorReport(StorageSystem device, IsilonSyncTargetPolicy policy) {
List<IsilonSyncPolicyReport> listMirrorPolicyReports = null;
StringBuffer errorMsgBuff = new StringBuffer();
errorMsgBuff.append(String.format("Policy details - failback-failover state : [%s] and policy status: [%s] ", policy.getFoFbState().toString(), policy.getLastJobState()));
// get policy reports from device.
IsilonApi isi = getIsilonDevice(device);
listMirrorPolicyReports = isi.getReplicationPolicyReports(policy.getName()).getList();
String errorMsg = mirrorOperations.isiGetReportErrMsg(listMirrorPolicyReports);
errorMsgBuff.append(String.format("Policy Error Report details: %s", errorMsg));
ServiceError serviceError = DeviceControllerErrors.isilon.unableToResyncPrepPolicy(device.getIpAddress(), policy.getName(), errorMsgBuff.toString());
_log.error(errorMsgBuff.toString());
return BiosCommandResult.createErrorResult(serviceError);
}
use of com.emc.storageos.isilon.restapi.IsilonApi in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method doReduceFS.
@Override
public BiosCommandResult doReduceFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
try {
_log.info("IsilonFileStorageDevice doReduceFS {} - start", args.getFsId());
IsilonApi isi = getIsilonDevice(storage);
String quotaId = null;
if (args.getFsExtensions() != null && args.getFsExtensions().get(QUOTA) != null) {
quotaId = args.getFsExtensions().get(QUOTA);
Long capacity = args.getNewFSCapacity();
IsilonSmartQuota quota = isi.getQuota(quotaId);
// new capacity should be less than usage capacity of a filehare
if (capacity.compareTo(quota.getUsagePhysical()) < 0) {
Double dUsageSize = SizeUtil.translateSize(quota.getUsagePhysical(), SizeUtil.SIZE_GB);
Double dNewCapacity = SizeUtil.translateSize(capacity, SizeUtil.SIZE_GB);
String msg = String.format("as requested reduced size [%.1fGB] is smaller than used capacity [%.1fGB] for filesystem %s", dNewCapacity, dUsageSize, args.getFs().getName());
_log.error(msg);
final ServiceError serviceError = DeviceControllerErrors.isilon.unableUpdateQuotaDirectory(msg);
return BiosCommandResult.createErrorResult(serviceError);
} else {
isiReduceFS(isi, quotaId, args);
}
} else {
// when policy is applied at higher level, we will ignore the target filesystem
FileShare fileShare = args.getFs();
if (null != fileShare.getPersonality() && PersonalityTypes.TARGET.name().equals(fileShare.getPersonality()) && null == fileShare.getExtensions()) {
_log.info("Quota id is not found, so ignore the reduce filesystem ", fileShare.getLabel());
return BiosCommandResult.createSuccessfulResult();
}
final ServiceError serviceError = DeviceControllerErrors.isilon.doReduceFSFailed(args.getFsId());
_log.error(serviceError.getMessage());
return BiosCommandResult.createErrorResult(serviceError);
}
_log.info("IsilonFileStorageDevice doReduceFS {} - complete", args.getFsId());
return BiosCommandResult.createSuccessfulResult();
} catch (IsilonException e) {
_log.error("doReduceFS failed.", e);
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.isilon.restapi.IsilonApi in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method updateStorageSystemFileProtectionPolicy.
@Override
public BiosCommandResult updateStorageSystemFileProtectionPolicy(StorageSystem storage, FileDeviceInputOutput args) {
FilePolicy existingPolicy = args.getFileProtectionPolicy();
PolicyStorageResource policyRes = args.getPolicyStorageResource();
FilePolicyUpdateParam policyUpdateParam = args.getFileProtectionPolicyUpdateParam();
IsilonApi isi = getIsilonDevice(storage);
BiosCommandResult result = null;
try {
if (existingPolicy.getFilePolicyType().equals(FilePolicy.FilePolicyType.file_replication.name())) {
boolean isVersion8above = false;
if (VersionChecker.verifyVersionDetails(ONEFS_V8, storage.getFirmwareVersion()) >= 0) {
isVersion8above = true;
}
return updateStorageSystemFileReplicationPolicy(isi, policyRes, existingPolicy, policyUpdateParam, isVersion8above);
} else if (existingPolicy.getFilePolicyType().equals(FilePolicy.FilePolicyType.file_snapshot.name())) {
return updateStorageSystemFileSnapshotPolicy(isi, policyRes, existingPolicy, policyUpdateParam);
} else {
String errorMsg = "Invalid policy type {} " + existingPolicy.getFilePolicyType();
_log.error(errorMsg);
final ServiceCoded serviceCoded = DeviceControllerException.errors.jobFailedOpMsg(OperationTypeEnum.UPDATE_STORAGE_SYSTEM_POLICY_BY_POLICY_RESOURCE.toString(), errorMsg);
result = BiosCommandResult.createErrorResult(serviceCoded);
existingPolicy.getOpStatus().updateTaskStatus(args.getOpId(), result.toOperation());
return result;
}
} catch (IsilonException e) {
_log.error("Update storage system policy for file policy failed.", e);
return BiosCommandResult.createErrorResult(e);
}
}
Aggregations