use of com.emc.storageos.isilon.restapi.IsilonException 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.IsilonException 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.IsilonException 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.IsilonException in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method createIsilonSnapshotPolicySchedule.
private void createIsilonSnapshotPolicySchedule(StorageSystem storageObj, FilePolicy filePolicy, String path, String snapshotSchedulePolicyName, FileDeviceInputOutput args, String filePolicyBasePath) {
String pattern = snapshotSchedulePolicyName + "_%Y-%m-%d_%H-%M";
String scheduleValue = getIsilonPolicySchedule(filePolicy);
Integer expireValue = getIsilonSnapshotExpireValue(filePolicy);
_log.info("File Policy : {} creation started", filePolicy.toString());
try {
IsilonApi isi = getIsilonDevice(storageObj);
isi.createDir(path, true);
String scheduleId = isi.createSnapshotSchedule(snapshotSchedulePolicyName, path, scheduleValue, pattern, expireValue);
_log.info("Isilon File Policy {} created successfully.", snapshotSchedulePolicyName);
FileOrchestrationUtils.updatePolicyStorageResource(_dbClient, storageObj, filePolicy, args, filePolicyBasePath, snapshotSchedulePolicyName, scheduleId, null, null, null);
} catch (IsilonException e) {
throw e;
}
}
use of com.emc.storageos.isilon.restapi.IsilonException in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method doesSnapshotExistsForFSPath.
private boolean doesSnapshotExistsForFSPath(StorageSystem storageSystem, String isilonAccessZone, String path) throws IsilonCollectionException {
URI storageSystemId = storageSystem.getId();
String resumeToken = null;
try {
_log.info("Checking snapshots for path {} on Isilon storage system: {} in access zone {} - start", path, storageSystem.getLabel(), isilonAccessZone);
IsilonApi isilonApi = getIsilonDevice(storageSystem);
do {
IsilonList<IsilonSnapshot> isilonSnapshots = isilonApi.listSnapshots(resumeToken, path);
List<IsilonSnapshot> snpashots = isilonSnapshots.getList();
for (IsilonSnapshot snapshot : snpashots) {
if (snapshot.getPath() == null || snapshot.getPath().isEmpty()) {
_log.info("Ignoring snapshot {} as it is not having any path", snapshot);
continue;
}
if (snapshot.getPath().equals(path)) {
_log.info("Found snapshot on path {} in Ision: {}", path, storageSystem.getLabel());
return true;
}
}
resumeToken = isilonSnapshots.getToken();
} while (resumeToken != null);
_log.info("Snapshots not found with path {} on Ision: {} in access zone: {}", path, storageSystem.getLabel(), isilonAccessZone);
return false;
} catch (IsilonException ie) {
_log.error("doesSnapshotExistsForFSPath failed. Storage system: {}", storageSystemId, ie);
IsilonCollectionException ice = new IsilonCollectionException("doesSnapshotExistsForFSPath failed. Storage system: " + storageSystemId);
ice.initCause(ie);
throw ice;
} catch (Exception e) {
_log.error("doesSnapshotExistsForFSPath failed. Storage system: {}", storageSystemId, e);
IsilonCollectionException ice = new IsilonCollectionException("doesSnapshotExistsForFSPath failed. Storage system: " + storageSystemId);
ice.initCause(e);
throw ice;
}
}
Aggregations