use of com.emc.storageos.db.client.model.PolicyStorageResource 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);
}
}
use of com.emc.storageos.db.client.model.PolicyStorageResource in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method doResumeLink.
@Override
public BiosCommandResult doResumeLink(StorageSystem system, FileShare source, TaskCompleter completer) {
IsilonSyncPolicy syncPolicy = null;
PolicyStorageResource policyStrRes = getEquivalentPolicyStorageResource(source, _dbClient);
if (policyStrRes != null) {
syncPolicy = policyNativeIdValidation(system, policyStrRes);
String policyId = syncPolicy.getId();
return mirrorOperations.doResumeReplicationPolicy(system, policyId);
}
ServiceError serviceError = DeviceControllerErrors.isilon.unableToCreateFileShare();
return BiosCommandResult.createErrorResult(serviceError);
}
use of com.emc.storageos.db.client.model.PolicyStorageResource in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method doUnassignFilePolicy.
@Override
public BiosCommandResult doUnassignFilePolicy(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
try {
IsilonApi isi = getIsilonDevice(storage);
FilePolicy filePolicy = args.getFileProtectionPolicy();
PolicyStorageResource policyResource = args.getPolicyStorageResource();
if (filePolicy.getFilePolicyType().equals(FilePolicyType.file_replication.name())) {
// Get the policy details by id
IsilonSyncPolicy isiSyncPolicy = isi.getReplicationPolicy(policyResource.getPolicyNativeId());
if (isiSyncPolicy != null) {
_log.info("deleting Isilon replication policy: {}", isiSyncPolicy.toString());
String policyName = isiSyncPolicy.getName();
JobState policyState = isiSyncPolicy.getLastJobState();
if (policyState.equals(JobState.running) || policyState.equals(JobState.paused)) {
_log.info("Canceling Replication Policy -{} because policy is in - {} state ", policyName, policyState);
// If the policy is running, Cancel the job before unassign policy!!
BiosCommandResult cmdResult = mirrorOperations.doCancelReplicationPolicy(isi, isiSyncPolicy.getName());
if (!cmdResult.isCommandSuccess()) {
return cmdResult;
} else {
// If the replication job still running through exception
isiSyncPolicy = isi.getReplicationPolicy(isiSyncPolicy.getName());
if (isiSyncPolicy.getLastJobState().equals(JobState.running)) {
ServiceError error = DeviceControllerErrors.isilon.jobFailed("Unable Stop Replication policy and policy state :" + isiSyncPolicy.getLastJobState().toString());
return BiosCommandResult.createErrorResult(error);
}
}
}
// delete replication policy using policy id
isi.deleteReplicationPolicy(isiSyncPolicy.getId());
} else {
_log.info("replication policy: {} doesn't exists on storage system", filePolicy.toString());
}
return BiosCommandResult.createSuccessfulResult();
} else if (filePolicy.getFilePolicyType().equals(FilePolicyType.file_snapshot.name())) {
IsilonSnapshotSchedule isiSchedulePolicy = getEquivalentIsilonSnapshotSchedule(isi, policyResource.getResourcePath());
if (isiSchedulePolicy != null) {
_log.info("deleting Isilon Snapshot schedule: {}", isiSchedulePolicy.toString());
isi.deleteSnapshotSchedule(policyResource.getPolicyNativeId());
} else {
_log.info("snapshot schedule: {} doesn't exists on storage system", filePolicy.toString());
}
return BiosCommandResult.createSuccessfulResult();
}
return BiosCommandResult.createSuccessfulResult();
} catch (IsilonException e) {
_log.error("unassign file policy failed.", e);
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.db.client.model.PolicyStorageResource in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method doApplyFileSnapshotPolicy.
private BiosCommandResult doApplyFileSnapshotPolicy(FilePolicy filePolicy, FileDeviceInputOutput args, FileShare fs, StorageSystem storageObj) {
IsilonApi isi = getIsilonDevice(storageObj);
String path = generatePathForPolicy(filePolicy, fs, args);
String clusterName = isi.getClusterConfig().getName();
String snapshotScheduleName = FileOrchestrationUtils.generateNameForSnapshotIQPolicy(clusterName, filePolicy, fs, args, path);
IsilonSnapshotSchedule isiSnapshotSchedule = getEquivalentIsilonSnapshotSchedule(isi, path);
if (isiSnapshotSchedule != null) {
String filePolicySnapshotSchedule = getIsilonPolicySchedule(filePolicy);
_log.info("Comparing snapshot schedule between CoprHD policy: {} and Isilon policy: {}.", filePolicySnapshotSchedule, isiSnapshotSchedule.getSchedule());
if (isiSnapshotSchedule.getSchedule() != null && isiSnapshotSchedule.getSchedule().equalsIgnoreCase(filePolicySnapshotSchedule)) {
// Verify the policy was mapped to FileStorageResource
if (null == FileOrchestrationUtils.findPolicyStorageResourceByNativeId(_dbClient, storageObj, filePolicy, args, path)) {
_log.info("Isilon snapshot policy found for {}, creating policy storage resouce to further management", filePolicy.getFilePolicyName());
PolicyStorageResource policyResource = FileOrchestrationUtils.updatePolicyStorageResource(_dbClient, storageObj, filePolicy, args, path, isiSnapshotSchedule.getName(), isiSnapshotSchedule.getId().toString(), null, null, null);
// for existing policy vipr generated label
policyResource.setLabel(filePolicySnapshotSchedule);
_dbClient.updateObject(policyResource);
_log.info("File Policy {} is already applied and running.", filePolicy.getFilePolicyName());
}
return 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, path, snapshotScheduleName, args, path);
return BiosCommandResult.createSuccessfulResult();
}
} else {
// Create snapshot policy.
createIsilonSnapshotPolicySchedule(storageObj, filePolicy, path, snapshotScheduleName, args, path);
return BiosCommandResult.createSuccessfulResult();
}
}
use of com.emc.storageos.db.client.model.PolicyStorageResource in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method doFailoverLink.
/**
* perform failover operation
* systemTarget - failover to target system
* fs - target filesystem
* completer - task completer
*
* return BiosCommandResult
*/
@Override
public BiosCommandResult doFailoverLink(StorageSystem systemTarget, FileShare fs, TaskCompleter completer) {
_log.info("IsilonFileStorageDevice - doFailoverLink started ");
FileShare sourceFS = null;
FileShare targetFS = null;
StorageSystem sourceSystem = null;
StorageSystem targetSystem = null;
boolean failback = false;
if (fs.getPersonality().equals(PersonalityTypes.TARGET.name())) {
sourceFS = _dbClient.queryObject(FileShare.class, fs.getParentFileShare());
targetFS = fs;
} else if (fs.getPersonality().equals(PersonalityTypes.SOURCE.name())) {
sourceFS = fs;
List<String> targetfileUris = new ArrayList<String>();
targetfileUris.addAll(fs.getMirrorfsTargets());
if (!targetfileUris.isEmpty()) {
targetFS = _dbClient.queryObject(FileShare.class, URI.create(targetfileUris.get(0)));
} else {
ServiceError serviceError = DeviceControllerErrors.isilon.unableToFailoverFileSystem(systemTarget.getIpAddress(), "Unable to get target filesystem for source filesystem " + fs.getName());
return BiosCommandResult.createErrorResult(serviceError);
}
failback = true;
}
sourceSystem = _dbClient.queryObject(StorageSystem.class, sourceFS.getStorageDevice());
targetSystem = _dbClient.queryObject(StorageSystem.class, targetFS.getStorageDevice());
PolicyStorageResource policyStrRes = getEquivalentPolicyStorageResource(sourceFS, _dbClient);
if (policyStrRes != null) {
IsilonSyncPolicy syncPolicy = policyNativeIdValidation(sourceSystem, policyStrRes);
String policyName = syncPolicy.getName();
BiosCommandResult cmdResult = null;
// In case of failback we do failover on the source file system, so we need to append _mirror
if (failback) {
String mirrorPolicyName = syncPolicy.getName();
mirrorPolicyName = mirrorPolicyName.concat(MIRROR_POLICY);
// prepared policy for failback
cmdResult = prepareFailbackOp(sourceSystem, policyName);
if (!cmdResult.isCommandSuccess()) {
return cmdResult;
}
// Call Isilon Api failback job
return doFailoverMirrorPolicy(sourceSystem, policyName, targetSystem, mirrorPolicyName, completer);
} else {
// prepared policy for failover
cmdResult = prepareFailoverOp(sourceSystem, policyName);
if (!cmdResult.isCommandSuccess()) {
_log.info("Unable to stop replication policy on source");
_log.info("Proceeding with failover anyway");
}
// Call Isilon Api failover job
return mirrorOperations.doFailover(targetSystem, syncPolicy.getId(), completer);
}
}
ServiceError serviceError = DeviceControllerErrors.isilon.unableToFailoverFileSystem(systemTarget.getIpAddress(), "Unable to get the policy details for filesystem :" + fs.getName());
return BiosCommandResult.createErrorResult(serviceError);
}
Aggregations