use of com.emc.storageos.isilon.restapi.IsilonException in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method doesCIFSShareExistsForFSPath.
private boolean doesCIFSShareExistsForFSPath(final StorageSystem storageSystem, String isilonAccessZone, String path) {
String resumeToken = null;
URI storageSystemId = storageSystem.getId();
_log.info("Checking CIFS share for path {} on Isilon storage system: {} in access zone {} - start", path, storageSystem.getLabel(), isilonAccessZone);
try {
IsilonApi isilonApi = getIsilonDevice(storageSystem);
do {
IsilonApi.IsilonList<IsilonSMBShare> isilonShares = isilonApi.listShares(resumeToken, isilonAccessZone);
List<IsilonSMBShare> isilonSMBShareList = isilonShares.getList();
for (IsilonSMBShare share : isilonSMBShareList) {
if (share.getPath().equals(path)) {
_log.info("Found CIFS share with path {} and name {} on Ision: {} in access zone: {}", path, share.getName(), storageSystem.getLabel(), isilonAccessZone);
return true;
}
}
resumeToken = isilonShares.getToken();
} while (resumeToken != null);
_log.info("CIFS share not found with path {} on Ision: {} in access zone: {}", path, storageSystem.getLabel(), isilonAccessZone);
return false;
} catch (IsilonException ie) {
_log.error("doesCIFSShareExistForFSPath failed. Storage system: {}", storageSystemId, ie);
IsilonCollectionException ice = new IsilonCollectionException("doesCIFSShareExistForFSPath failed. Storage system: " + storageSystemId);
ice.initCause(ie);
throw ice;
} catch (Exception e) {
_log.error("doesCIFSShareExistForFSPath failed. Storage system: {}", storageSystemId, e);
IsilonCollectionException ice = new IsilonCollectionException("doesCIFSShareExistForFSPath failed. Storage system: " + storageSystemId);
ice.initCause(e);
throw ice;
}
}
use of com.emc.storageos.isilon.restapi.IsilonException in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method checkFilePolicyExistsOrCreate.
@Override
public BiosCommandResult checkFilePolicyExistsOrCreate(StorageSystem storageObj, FileDeviceInputOutput args) {
FilePolicy filePolicy = args.getFileProtectionPolicy();
BiosCommandResult result = null;
try {
IsilonApi isi = getIsilonDevice(storageObj);
String clusterName = isi.getClusterConfig().getName();
String filePolicyBasePath = getFilePolicyPath(storageObj, filePolicy.getApplyAt(), args);
checkAppliedResourceNamePartOfFilePolicyPath(filePolicyBasePath, filePolicy, args);
String snapshotPolicyScheduleName = FileOrchestrationUtils.generateNameForSnapshotIQPolicy(clusterName, filePolicy, null, args, filePolicyBasePath);
IsilonSnapshotSchedule isilonSnapshotSchedule = getEquivalentIsilonSnapshotSchedule(isi, filePolicyBasePath);
if (isilonSnapshotSchedule != null) {
String filePolicySnapshotSchedule = getIsilonPolicySchedule(filePolicy);
_log.info("Comparing snapshot schedule between CoprHD policy: {} and Isilon policy: {}.", filePolicySnapshotSchedule, isilonSnapshotSchedule.getSchedule());
if (isilonSnapshotSchedule.getSchedule().equalsIgnoreCase(filePolicySnapshotSchedule)) {
// Verify the policy was mapped to FileStorageResource
if (null == FileOrchestrationUtils.findPolicyStorageResourceByNativeId(_dbClient, storageObj, filePolicy, args, filePolicyBasePath)) {
_log.info("Isilon policy found for {}, creating policy storage resouce to further management", filePolicy.getFilePolicyName());
FileOrchestrationUtils.updatePolicyStorageResource(_dbClient, storageObj, filePolicy, args, filePolicyBasePath, isilonSnapshotSchedule.getName(), isilonSnapshotSchedule.getId().toString(), null, null, null);
}
result = BiosCommandResult.createSuccessfulResult();
} else {
_log.info("Snapshot schedule differs between Isilon policy and CoprHD file policy. So, create policy in Isilon...");
// Create snapshot policy.
createIsilonSnapshotPolicySchedule(storageObj, filePolicy, filePolicyBasePath, snapshotPolicyScheduleName, args, filePolicyBasePath);
result = BiosCommandResult.createSuccessfulResult();
}
} else {
// Create snapshot policy.
createIsilonSnapshotPolicySchedule(storageObj, filePolicy, filePolicyBasePath, snapshotPolicyScheduleName, args, filePolicyBasePath);
result = BiosCommandResult.createSuccessfulResult();
}
} catch (IsilonException e) {
_log.error("Assigning file policy failed.", e);
result = BiosCommandResult.createErrorResult(e);
}
return result;
}
use of com.emc.storageos.isilon.restapi.IsilonException in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method updateStorageSystemFileReplicationPolicy.
private BiosCommandResult updateStorageSystemFileReplicationPolicy(IsilonApi isi, PolicyStorageResource policyRes, FilePolicy viprPolicy, FilePolicyUpdateParam policyUpdateParam, boolean isVersion8above) {
try {
IsilonSyncPolicy syncpolicyAtPath = getSyncPolicy(isi, policyRes);
if (syncpolicyAtPath != null) {
_log.info("Found SyncIQ policy{} for path {} ", syncpolicyAtPath.getName(), syncpolicyAtPath.getSourceRootPath());
boolean bModifyPolicy = false;
// Temp policy to store modified values.
IsilonSyncPolicy modifiedPolicy = new IsilonSyncPolicy();
modifiedPolicy.setName(syncpolicyAtPath.getName());
if (policyUpdateParam.getNumWorkerThreads() > 0 && syncpolicyAtPath.getWorkersPerNode() != policyUpdateParam.getNumWorkerThreads()) {
_log.debug("Changing NumWorkerThreads to {} ", policyUpdateParam.getNumWorkerThreads());
modifiedPolicy.setWorkersPerNode(policyUpdateParam.getNumWorkerThreads());
bModifyPolicy = true;
}
if (policyUpdateParam.getPolicyDescription() != null && !policyUpdateParam.getPolicyDescription().isEmpty() && !policyUpdateParam.getPolicyDescription().equalsIgnoreCase(syncpolicyAtPath.getDescription())) {
modifiedPolicy.setDescription(policyUpdateParam.getPolicyDescription());
bModifyPolicy = true;
}
if (policyUpdateParam.getReplicationPolicyParams() != null) {
FileReplicationPolicyParam replParam = policyUpdateParam.getReplicationPolicyParams();
if (replParam.getReplicationCopyMode() != null && !replParam.getReplicationCopyMode().isEmpty() && !FileReplicationCopyMode.ASYNC.name().equalsIgnoreCase(replParam.getReplicationCopyMode())) {
_log.warn("Replication copy mode {} is not supported by Isilon {} ", replParam.getReplicationCopyMode());
}
if (replParam.getPolicySchedule() != null) {
String strSchedule = getIsilonPolicySchedule(replParam.getPolicySchedule());
if (strSchedule != null && !strSchedule.isEmpty() && !strSchedule.equalsIgnoreCase(syncpolicyAtPath.getSchedule())) {
modifiedPolicy.setSchedule(strSchedule);
bModifyPolicy = true;
}
}
}
/*
* Changes made for addressing new fields added in sync Policy in OneFSv 8.0 and above
*/
IsilonSyncPolicy8Above modifiedPolicycopy = new IsilonSyncPolicy8Above();
IsilonSyncPolicy8Above syncpolicyAtPath8 = null;
if (isVersion8above && policyUpdateParam.getPriority() != null) {
syncpolicyAtPath8 = isi.getReplicationPolicy8above(syncpolicyAtPath.getName());
modifiedPolicycopy = modifiedPolicycopy.copy(modifiedPolicy);
if (syncpolicyAtPath8 != null) {
if (FilePolicyPriority.valueOf(policyUpdateParam.getPriority()).ordinal() != syncpolicyAtPath8.getPriority()) {
modifiedPolicycopy.setPriority(FilePolicyPriority.valueOf(policyUpdateParam.getPriority()).ordinal());
bModifyPolicy = true;
}
}
}
if (bModifyPolicy) {
JobState policyState = syncpolicyAtPath.getLastJobState();
if (!policyState.equals(JobState.running) && !policyState.equals(JobState.paused)) {
if (isVersion8above) {
// Possible NPE..syncpolicyAtPath8 can be null here if policyUpdateParam.getPriority() is NULL..
// Better to use syncpolicyAtPath.getName()..
isi.modifyReplicationPolicy8above(syncpolicyAtPath.getName(), modifiedPolicycopy);
_log.info("Modify Replication Policy- {} finished successfully", syncpolicyAtPath.getName());
} else {
isi.modifyReplicationPolicy(syncpolicyAtPath.getName(), modifiedPolicy);
_log.info("Modify Replication Policy- {} finished successfully", syncpolicyAtPath.getName());
}
// set native id and policy existing and then update the DB
if (null == policyRes.getName()) {
// before fix,
policyRes.setLabel(policyRes.getPolicyNativeId());
policyRes.setName(syncpolicyAtPath.getName());
policyRes.setPolicyNativeId(syncpolicyAtPath.getId());
_dbClient.updateObject(policyRes);
} else {
policyRes.setName(syncpolicyAtPath.getName());
_dbClient.updateObject(policyRes);
}
return BiosCommandResult.createSuccessfulResult();
} else {
_log.error("Replication Policy - {} can't be MODIFIED because policy has an active job", syncpolicyAtPath.getName());
ServiceError error = DeviceControllerErrors.isilon.jobFailed("doModifyReplicationPolicy as : The policy has an active job and cannot be modified.");
return BiosCommandResult.createErrorResult(error);
}
} else {
_log.info("No parameters changed to modify Replication Policy- {} finished successfully", syncpolicyAtPath.getName());
return BiosCommandResult.createSuccessfulResult();
}
} else {
_log.error("No SyncIQ policy found at path {} , Hence can't be MODIFIED", policyRes.getResourcePath());
ServiceError error = DeviceControllerErrors.isilon.jobFailed("doModifyReplicationPolicy as : No SyncIQ policy found at given path.");
return BiosCommandResult.createErrorResult(error);
}
} catch (IsilonException e) {
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.isilon.restapi.IsilonException in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method unassignFilePolicy.
@Deprecated
@Override
public BiosCommandResult unassignFilePolicy(StorageSystem storageObj, FileDeviceInputOutput args) {
SchedulePolicy fp = args.getFilePolicy();
String snapshotScheduleName = fp.getPolicyName() + "_" + args.getFsName();
IsilonApi isi = getIsilonDevice(storageObj);
try {
isi.deleteSnapshotSchedule(snapshotScheduleName);
} catch (IsilonException e) {
_log.error("unassign file policy failed.", e);
return BiosCommandResult.createErrorResult(e);
}
return BiosCommandResult.createSuccessfulResult();
}
use of com.emc.storageos.isilon.restapi.IsilonException in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method doDeleteQuotaDirectory.
@Override
public BiosCommandResult doDeleteQuotaDirectory(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
// Get Parent FS Mount Path
// Get Quota Directory Name
// Get Quota Size
// Call Delete Quota
// Call Delete Directory recursively
QuotaDirectory quotaDir = args.getQuotaDirectory();
String fsMountPath = args.getFsMountPath();
Long qDirSize = quotaDir.getSize();
String qDirPath = fsMountPath + "/" + quotaDir.getName();
_log.info("IsilonFileStorageDevice doDeleteQuotaDirectory {} with size {} - start", qDirPath, qDirSize);
try {
IsilonApi isi = getIsilonDevice(storage);
// if the quota directory has some data in it.
if (isi.fsDirHasData(qDirPath)) {
// Fail to delete quota directory which has data in it!!!
_log.error("Quota directory deletion failed as it's directory path {} has content in it", qDirPath);
throw DeviceControllerException.exceptions.failToDeleteQuotaDirectory(qDirPath);
}
String quotaId = null;
if (quotaDir.getExtensions() != null) {
quotaId = quotaDir.getExtensions().get(QUOTA);
}
if (quotaId != null) {
_log.info("IsilonFileStorageDevice doDeleteQuotaDirectory , Delete Quota {}", quotaId);
isi.deleteQuota(quotaId);
}
// delete directory for the Quota Directory
isi.deleteDir(qDirPath);
_log.info("IsilonFileStorageDevice doDeleteQuotaDirectory {} with size {} - complete", qDirPath, qDirSize);
return BiosCommandResult.createSuccessfulResult();
} catch (IsilonException e) {
_log.error("doDeleteQuotaDirectory failed.", e);
return BiosCommandResult.createErrorResult(e);
}
}
Aggregations