use of com.emc.storageos.isilon.restapi.IsilonApi in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method doUpdateQuotaDirectory.
@Override
public BiosCommandResult doUpdateQuotaDirectory(StorageSystem storage, FileDeviceInputOutput args, QuotaDirectory quotaDir) throws ControllerException {
// Get Parent FS mount path
// Get Quota Directory Name
// Get Quota Size
// Call Update Quota (Aways use that quota for updating the size)
QuotaDirectory quotaDirObj = null;
String fsMountPath = args.getFsMountPath();
Long qDirSize = quotaDir.getSize();
String qDirPath = fsMountPath + "/" + quotaDir.getName();
_log.info("IsilonFileStorageDevice doUpdateQuotaDirectory {} with size {} - start", qDirPath, qDirSize);
try {
IsilonApi isi = getIsilonDevice(storage);
URI qtreeURI = quotaDir.getId();
quotaDirObj = _dbClient.queryObject(QuotaDirectory.class, qtreeURI);
String quotaId = null;
if (quotaDirObj.getExtensions() != null) {
quotaId = quotaDirObj.getExtensions().get(QUOTA);
}
if (quotaId != null) {
// Isilon does not allow to update quota directory to zero.
IsilonSmartQuota isiCurrentSmartQuota = isi.getQuota(quotaId);
long quotaUsageSpace = isiCurrentSmartQuota.getUsagePhysical();
if (qDirSize > 0 && qDirSize.compareTo(quotaUsageSpace) > 0) {
_log.info("IsilonFileStorageDevice doUpdateQuotaDirectory , Update Quota {} with Capacity {}", quotaId, qDirSize);
IsilonSmartQuota expandedQuota = getQuotaDirectoryExpandedSmartQuota(quotaDir, qDirSize, args.getFsCapacity(), isi);
isi.modifyQuota(quotaId, expandedQuota);
} else {
Double dUsage = SizeUtil.translateSize(quotaUsageSpace, SizeUtil.SIZE_GB);
Double dQuotaSize = SizeUtil.translateSize(qDirSize, SizeUtil.SIZE_GB);
String msg = String.format("as requested reduced size [%.1fGB] is smaller than used capacity [%.1fGB] for filesystem %s", dQuotaSize, dUsage, args.getFs().getName());
_log.error("doUpdateQuotaDirectory : " + msg);
ServiceError error = DeviceControllerErrors.isilon.unableUpdateQuotaDirectory(msg);
return BiosCommandResult.createErrorResult(error);
}
} else {
// Create a new Quota
String qid = checkThresholdAndcreateQuota(quotaDir, qDirSize, qDirPath, null, isi);
if (args.getQuotaDirExtensions() == null) {
args.initQuotaDirExtensions();
}
args.getQuotaDirExtensions().put(QUOTA, qid);
}
_log.info("IsilonFileStorageDevice doUpdateQuotaDirectory {} with size {} - complete", qDirPath, qDirSize);
return BiosCommandResult.createSuccessfulResult();
} catch (IsilonException e) {
_log.error("doUpdateQuotaDirectory failed.", e);
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.isilon.restapi.IsilonApi in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method updateExportRules.
@Override
public BiosCommandResult updateExportRules(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
// Requested Export Rules
List<ExportRule> exportAdd = args.getExportRulesToAdd();
List<ExportRule> exportDelete = args.getExportRulesToDelete();
List<ExportRule> exportModify = args.getExportRulesToModify();
// To be processed export rules
List<ExportRule> exportsToRemove = new ArrayList<>();
List<ExportRule> exportsToModify = new ArrayList<>();
List<ExportRule> exportsToAdd = new ArrayList<>();
// Calculate Export Path
String exportPath;
String subDir = args.getSubDirectory();
// ".snapshot"
if (!args.getFileOperation()) {
exportPath = args.getSnapshotPath();
if (subDir != null && subDir.length() > 0) {
exportPath = args.getSnapshotPath() + "/" + subDir;
}
} else {
exportPath = args.getFs().getPath();
if (subDir != null && subDir.length() > 0) {
exportPath = args.getFs().getPath() + "/" + subDir;
}
}
_log.info("exportPath : {}", exportPath);
args.setExportPath(exportPath);
try {
// add the new export rule from the array into the update request.
Map<String, ExportRule> arrayExportRuleMap = extraExportRuleFromArray(storage, args);
if (!arrayExportRuleMap.isEmpty()) {
if (exportModify != null) {
// merge the end point for which sec flavor is common.
for (ExportRule exportRule : exportModify) {
ExportRule arrayExportRule = arrayExportRuleMap.remove(exportRule.getSecFlavor());
if (arrayExportRule != null) {
if (exportRule.getReadOnlyHosts() != null) {
exportRule.getReadOnlyHosts().addAll(arrayExportRule.getReadOnlyHosts());
} else {
exportRule.setReadOnlyHosts(arrayExportRule.getReadOnlyHosts());
}
if (exportRule.getReadWriteHosts() != null) {
exportRule.getReadWriteHosts().addAll(arrayExportRule.getReadWriteHosts());
} else {
exportRule.setReadWriteHosts(arrayExportRule.getReadWriteHosts());
}
if (exportRule.getRootHosts() != null) {
exportRule.getRootHosts().addAll(arrayExportRule.getRootHosts());
} else {
exportRule.setRootHosts(arrayExportRule.getRootHosts());
}
}
}
// now add the remaining export rule
exportModify.addAll(arrayExportRuleMap.values());
} else {
// if exportModify is null then create a new export rule and add
exportModify = new ArrayList<ExportRule>();
exportModify.addAll(arrayExportRuleMap.values());
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
_log.error("Not able to fetch latest Export rule from backend array.", e);
}
// ALL EXPORTS
List<ExportRule> existingDBExportRule = args.getExistingDBExportRules();
List<ExportRule> exportsToprocess = new ArrayList<>();
for (ExportRule rule : existingDBExportRule) {
if (rule.getExportPath().equalsIgnoreCase(exportPath)) {
exportsToprocess.add(rule);
}
}
_log.info("Number of existing Rules found {} for exportPath {}", exportsToprocess.size(), exportPath);
// list and add to read/Write list.
if (!exportsToprocess.isEmpty() || !exportAdd.isEmpty()) {
if (exportModify != null && !exportModify.isEmpty()) {
for (ExportRule existingRule : exportsToprocess) {
for (ExportRule newExportRule : exportModify) {
if (newExportRule.getSecFlavor().equals(existingRule.getSecFlavor())) {
newExportRule.setDeviceExportId(existingRule.getDeviceExportId());
exportsToModify.add(newExportRule);
}
}
}
}
// Handle Delete export Rules
if (exportDelete != null && !exportDelete.isEmpty()) {
for (ExportRule existingRule : exportsToprocess) {
for (ExportRule oldExport : exportDelete) {
if (oldExport.getSecFlavor().equals(existingRule.getSecFlavor())) {
_log.info("Deleting Export Rule {}", existingRule);
exportsToRemove.add(existingRule);
}
}
}
}
// No of exports found to remove from the list
_log.info("No of exports found to remove from the existing exports list {}", exportsToRemove.size());
exportsToprocess.removeAll(exportsToRemove);
// Handle Add Export Rules
if (exportAdd != null && !exportAdd.isEmpty()) {
for (ExportRule newExport : exportAdd) {
_log.info("Add Export Rule {}", newExport);
newExport.setExportPath(exportPath);
exportsToAdd.add(newExport);
}
}
exportsToprocess.addAll(exportAdd);
}
// Process Mods
IsilonApi isi = getIsilonDevice(storage);
for (ExportRule existingRule : exportsToModify) {
_log.info("Modify Export rule : {}", existingRule.toString());
}
processIsiExport(isi, args, exportsToModify);
for (ExportRule existingRule : exportsToRemove) {
_log.info("Remove Export rule : {}", existingRule.toString());
}
processRemoveIsiExport(isi, args, exportsToRemove);
for (ExportRule existingRule : exportsToAdd) {
_log.info("Add Export rule : {}", existingRule.toString());
}
processAddIsiExport(isi, args, exportsToAdd);
BiosCommandResult result = BiosCommandResult.createSuccessfulResult();
return result;
}
use of com.emc.storageos.isilon.restapi.IsilonApi in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method assignFilePolicy.
@Deprecated
@Override
public BiosCommandResult assignFilePolicy(StorageSystem storage, FileDeviceInputOutput args) {
// for isilon we need to create a new policy for each individual file system
SchedulePolicy fp = args.getFilePolicy();
String snapshotScheduleName = fp.getPolicyName() + "_" + args.getFsName();
String pattern = snapshotScheduleName + "_%Y-%m-%d_%H-%M";
String Schedulevalue = getIsilonScheduleString(fp);
Integer expireValue = getSnapshotExpireValue(fp);
_log.info("File Policy name : {}", snapshotScheduleName);
IsilonApi isi = getIsilonDevice(storage);
try {
isi.createSnapshotSchedule(snapshotScheduleName, args.getFileSystemPath(), Schedulevalue, pattern, expireValue);
} catch (IsilonException e) {
_log.error("assign file policy failed.", e);
return BiosCommandResult.createErrorResult(e);
}
return BiosCommandResult.createSuccessfulResult();
}
use of com.emc.storageos.isilon.restapi.IsilonApi in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method doDeleteShares.
@Override
public BiosCommandResult doDeleteShares(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
try {
_log.info("IsilonFileStorageDevice doDeleteShares: {} - start");
IsilonApi isi = getIsilonDevice(storage);
isiDeleteShares(isi, args);
_log.info("IsilonFileStorageDevice doDeleteShares {} - complete");
return BiosCommandResult.createSuccessfulResult();
} catch (IsilonException e) {
_log.error("doDeleteShares failed.", e);
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.isilon.restapi.IsilonApi 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();
}
}
Aggregations