use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method doApplyFilePolicy.
@Override
public BiosCommandResult doApplyFilePolicy(StorageSystem storageObj, FileDeviceInputOutput args) {
FileShare fs = args.getFs();
try {
FilePolicy filePolicy = args.getFileProtectionPolicy();
String policyPath = generatePathForPolicy(filePolicy, fs, args);
// Verify the ViPR resource on which the policy is applying is present in
// Isilon path definition.
// Otherwise, this method throws corresponding exception.
checkAppliedResourceNamePartOfFilePolicyPath(policyPath, filePolicy, args);
// Otherwise applied the policy on corresponding Isilon device path.
if (checkPolicyAppliedOnPath(storageObj, args, policyPath)) {
String msg = String.format("File Policy template %s is already applied on storage system %s path %s", filePolicy.getFilePolicyName(), storageObj.getLabel(), policyPath);
_log.info(msg);
return BiosCommandResult.createSuccessfulResult();
} else {
if (filePolicy.getFilePolicyType().equals(FilePolicy.FilePolicyType.file_replication.name())) {
doApplyFileReplicationPolicy(filePolicy, args, fs, storageObj);
} else if (filePolicy.getFilePolicyType().equals(FilePolicyType.file_snapshot.name())) {
doApplyFileSnapshotPolicy(filePolicy, args, fs, storageObj);
}
return BiosCommandResult.createSuccessfulResult();
}
} catch (IsilonException e) {
_log.error("apply file policy failed.", e);
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method doRollbackMirrorLink.
/**
* rollback the target filesystems
*/
@Override
public void doRollbackMirrorLink(StorageSystem system, List<URI> sources, List<URI> targets, TaskCompleter completer, String opId) {
BiosCommandResult biosCommandResult = null;
// delete the target objects
if (targets != null && !targets.isEmpty()) {
for (URI target : targets) {
FileShare fileShare = _dbClient.queryObject(FileShare.class, target);
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, fileShare.getStorageDevice());
URI uriParent = fileShare.getParentFileShare().getURI();
if (sources.contains(uriParent) == true) {
// Do not delete the file target file system with force flag
biosCommandResult = rollbackCreatedFilesystem(storageSystem, target, opId, false);
if (biosCommandResult.getCommandSuccess()) {
fileShare.getOpStatus().updateTaskStatus(opId, biosCommandResult.toOperation());
fileShare.setInactive(true);
_dbClient.updateObject(fileShare);
}
}
}
}
completer.ready(_dbClient);
}
use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method getCustomPath.
/**
* Gets the file system custom path value from controller configuration
*
* @param storage
* Isilon storage system
* @param args
* FileDeviceInputOutput object
* @return evaluated custom path
*/
private String getCustomPath(StorageSystem storage, FileDeviceInputOutput args) {
String path = "";
IsilonApi isi = getIsilonDevice(storage);
String clusterName = isi.getClusterConfig().getName();
FileShare fs = args.getFs();
// source cluster name should be included in target path instead of target cluster name.
if (fs != null && fs.getPersonality() != null && fs.getPersonality().equalsIgnoreCase(PersonalityTypes.TARGET.name())) {
FileShare sourceFS = _dbClient.queryObject(FileShare.class, fs.getParentFileShare());
if (sourceFS != null && sourceFS.getStorageDevice() != null) {
StorageSystem sourceSystem = _dbClient.queryObject(StorageSystem.class, sourceFS.getStorageDevice());
if (sourceSystem != null) {
IsilonApi sourceCluster = getIsilonDevice(sourceSystem);
clusterName = sourceCluster.getClusterConfig().getName();
// if the replication happens from user defined access zone to system access zone!!
if (sourceFS.getVirtualNAS() != null) {
VirtualNAS sourcevNAS = _dbClient.queryObject(VirtualNAS.class, sourceFS.getVirtualNAS());
if (sourcevNAS != null) {
String vNASName = sourcevNAS.getNasName();
vNASName = getNameWithNoSpecialCharacters(vNASName, args);
clusterName = clusterName + vNASName;
_log.info("Source file system is on virtual NAS {}", vNASName);
}
}
_log.debug("Generating path for target and the source cluster is is {}", clusterName);
}
}
} else if (args.isTarget()) {
if (args.getSourceSystem() != null) {
IsilonApi sourceCluster = getIsilonDevice(args.getSourceSystem());
clusterName = sourceCluster.getClusterConfig().getName();
}
// if the replication happens from user defined access zone to system access zone!!
if (args.getSourceVNAS() != null && args.getvNAS() == null) {
VirtualNAS sourcevNAS = args.getSourceVNAS();
String vNASName = sourcevNAS.getNasName();
vNASName = getNameWithNoSpecialCharacters(vNASName, args);
clusterName = clusterName + vNASName;
}
_log.debug("Generating path for target and the source cluster is is {}", clusterName);
}
DataSource dataSource = dataSourceFactory.createIsilonFileSystemPathDataSource(args.getProject(), args.getVPool(), args.getTenantOrg(), storage);
dataSource.addProperty(CustomConfigConstants.ISILON_CLUSTER_NAME, clusterName);
String configPath = customConfigHandler.getComputedCustomConfigValue(CustomConfigConstants.ISILON_PATH_CUSTOMIZATION, "isilon", dataSource);
_log.debug("The isilon user defined custom path is {}", configPath);
if (configPath != null && !configPath.isEmpty()) {
path = args.getPathWithoutSpecialCharacters(configPath);
}
return path;
}
use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method doReduceFS.
@Override
public BiosCommandResult doReduceFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
try {
_log.info("IsilonFileStorageDevice doReduceFS {} - start", args.getFsId());
IsilonApi isi = getIsilonDevice(storage);
String quotaId = null;
if (args.getFsExtensions() != null && args.getFsExtensions().get(QUOTA) != null) {
quotaId = args.getFsExtensions().get(QUOTA);
Long capacity = args.getNewFSCapacity();
IsilonSmartQuota quota = isi.getQuota(quotaId);
// new capacity should be less than usage capacity of a filehare
if (capacity.compareTo(quota.getUsagePhysical()) < 0) {
Double dUsageSize = SizeUtil.translateSize(quota.getUsagePhysical(), SizeUtil.SIZE_GB);
Double dNewCapacity = SizeUtil.translateSize(capacity, SizeUtil.SIZE_GB);
String msg = String.format("as requested reduced size [%.1fGB] is smaller than used capacity [%.1fGB] for filesystem %s", dNewCapacity, dUsageSize, args.getFs().getName());
_log.error(msg);
final ServiceError serviceError = DeviceControllerErrors.isilon.unableUpdateQuotaDirectory(msg);
return BiosCommandResult.createErrorResult(serviceError);
} else {
isiReduceFS(isi, quotaId, args);
}
} else {
// when policy is applied at higher level, we will ignore the target filesystem
FileShare fileShare = args.getFs();
if (null != fileShare.getPersonality() && PersonalityTypes.TARGET.name().equals(fileShare.getPersonality()) && null == fileShare.getExtensions()) {
_log.info("Quota id is not found, so ignore the reduce filesystem ", fileShare.getLabel());
return BiosCommandResult.createSuccessfulResult();
}
final ServiceError serviceError = DeviceControllerErrors.isilon.doReduceFSFailed(args.getFsId());
_log.error(serviceError.getMessage());
return BiosCommandResult.createErrorResult(serviceError);
}
_log.info("IsilonFileStorageDevice doReduceFS {} - complete", args.getFsId());
return BiosCommandResult.createSuccessfulResult();
} catch (IsilonException e) {
_log.error("doReduceFS failed.", e);
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method isiDeleteExports.
/**
* Delete isilon export
*
* @param isi
* IsilonApi object
* @param exportMap
* exports to be deleted
* @throws IsilonException
*/
private void isiDeleteExports(IsilonApi isi, FileDeviceInputOutput args) throws IsilonException {
FSExportMap exportMap = null;
if (args.getFileOperation()) {
FileShare fileObj = args.getFs();
if (fileObj != null) {
exportMap = fileObj.getFsExports();
}
} else {
Snapshot snap = args.getFileSnapshot();
if (snap != null) {
exportMap = snap.getFsExports();
}
}
if (exportMap == null || exportMap.isEmpty()) {
return;
}
String zoneName = getZoneName(args.getvNAS());
Set<String> deletedExports = new HashSet<String>();
Iterator<Map.Entry<String, FileExport>> it = exportMap.entrySet().iterator();
try {
while (it.hasNext()) {
Map.Entry<String, FileExport> entry = it.next();
String key = entry.getKey();
FileExport fsExport = entry.getValue();
if (zoneName != null) {
isi.deleteExport(fsExport.getIsilonId(), zoneName);
} else {
isi.deleteExport(fsExport.getIsilonId());
}
// Safe removal from the backing map. Can not do this through
// iterator since this does not track changes and is not
// reflected in the database.
deletedExports.add(key);
}
} finally {
// remove exports from the map in database.
for (String key : deletedExports) {
exportMap.remove(key);
}
}
}
Aggregations