use of com.emc.storageos.db.client.model.FilePolicy 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.db.client.model.FilePolicy 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.FilePolicy in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method checkNewPolicyPathHasData.
/**
* Method to check if the path of the 'to be created' file policy on the target array contains data
*
* @param vpool
* @param project
* @param fs - Target Filesystem
* @param virtualNAS
* @param isi - Isilon Api Object
*/
private void checkNewPolicyPathHasData(VirtualPool vpool, Project project, FileShare fs, VirtualNAS virtualNAS, IsilonApi isi) {
if (fs.getPersonality() != null && fs.getPersonality().equalsIgnoreCase(PersonalityTypes.TARGET.name())) {
FileShare sourceFs = _dbClient.queryObject(FileShare.class, fs.getParentFileShare().getURI());
List<FilePolicy> replicationPolicies = FileOrchestrationUtils.getReplicationPolices(_dbClient, vpool, project, sourceFs);
if (replicationPolicies != null && !replicationPolicies.isEmpty()) {
if (replicationPolicies.size() > 1) {
_log.warn("More than one replication policy found {}", replicationPolicies.size());
throw DeviceControllerException.exceptions.failToCreateFileSystem(String.format("More than one replication policy found: %s for Fileshare %s", replicationPolicies.size(), sourceFs.getId()));
}
FilePolicy fileRepPolicy = replicationPolicies.get(0);
String policyPath = null;
FileDeviceInputOutput args = new FileDeviceInputOutput();
args.setVPool(vpool);
args.setProject(project);
args.setvNAS(virtualNAS);
policyPath = generatePathForPolicy(fileRepPolicy, fs, args);
// Add the suffix only for local replication policy at higher level
if (fileRepPolicy.getFileReplicationType().equalsIgnoreCase(FileReplicationType.LOCAL.name()) && !FilePolicyApplyLevel.file_system.name().equalsIgnoreCase(fileRepPolicy.getApplyAt())) {
policyPath = policyPath + "_localTarget";
}
// Policy path on target array will be checked at all levels
_log.info("Check if Policy path has data on Target array: " + policyPath);
if (StringUtils.isNotEmpty(policyPath) && isi.existsDir(policyPath) && isi.fsDirHasData(policyPath)) {
_log.error("File system creation failed due to directory path {} already exists and contains data", policyPath);
throw DeviceControllerException.exceptions.failToCreateFileSystem(policyPath);
} else {
_log.info("Policy path doesn't exist on target array. Proceeding with policy creation");
}
}
}
}
use of com.emc.storageos.db.client.model.FilePolicy in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method getReplicationPolicyAppliedOnFS.
public static FilePolicy getReplicationPolicyAppliedOnFS(FileShare fs, DbClient dbClient) {
StringSet existingFSPolicies = fs.getFilePolicies();
List<URI> existingFSPolicyURIs = new ArrayList<>();
for (String filePolicyURI : existingFSPolicies) {
existingFSPolicyURIs.add(URI.create(filePolicyURI));
}
Iterator<FilePolicy> iterator = dbClient.queryIterativeObjects(FilePolicy.class, existingFSPolicyURIs, true);
while (iterator.hasNext()) {
FilePolicy fp = iterator.next();
if (fp.getFilePolicyType().equals(FilePolicy.FilePolicyType.file_replication.name())) {
_log.info("Found replication policy :{} applied to the file system: {}.", fp.toString(), fs.getId());
return fp;
}
}
return null;
}
use of com.emc.storageos.db.client.model.FilePolicy in project coprhd-controller by CoprHD.
the class FileReplicationPolicyUpdateTargetPoolMigration method getRemoteReplicationPolicies.
private Map<String, FilePolicy> getRemoteReplicationPolicies() {
Map<String, FilePolicy> remoteReplPolicies = new HashMap<String, FilePolicy>();
List<URI> policies = dbClient.queryByType(FilePolicy.class, true);
List<FilePolicy> filePolicies = dbClient.queryObject(FilePolicy.class, policies);
for (FilePolicy policy : filePolicies) {
if (policy != null && policy.getFilePolicyType().equalsIgnoreCase(FilePolicy.FilePolicyType.file_replication.name()) && FileReplicationType.REMOTE.name().equalsIgnoreCase(policy.getFileReplicationType())) {
remoteReplPolicies.put(policy.getFilePolicyName(), policy);
}
}
return remoteReplPolicies;
}
Aggregations