use of com.emc.storageos.isilon.restapi.IsilonException in project coprhd-controller by CoprHD.
the class IsilonMirrorOperations method doEnablePolicy.
/**
* Enable the Isilon syncIQ policy
*
* @param system - storagesystem
* @param policyName
* @return
*/
BiosCommandResult doEnablePolicy(StorageSystem system, String policyName) {
IsilonApi isi = getIsilonDevice(system);
IsilonSyncPolicy policy = isi.getReplicationPolicy(policyName);
if (null != policy && !policy.getEnabled()) {
IsilonSyncPolicy modifiedPolicy = new IsilonSyncPolicy();
modifiedPolicy.setEnabled(true);
try {
isi.modifyReplicationPolicy(policyName, modifiedPolicy);
TimeUnit.SECONDS.sleep(33);
} catch (InterruptedException e) {
_log.warn("Enabling ReplicationPolicy - {} Interrupted", policyName);
ServiceError error = DeviceControllerErrors.isilon.jobFailed("Enabling ReplicationPolicy is Failed with Interrupt exception and message :" + e.getMessage());
return BiosCommandResult.createErrorResult(error);
} catch (IsilonException ex) {
return BiosCommandResult.createErrorResult(ex);
}
}
return BiosCommandResult.createSuccessfulResult();
}
use of com.emc.storageos.isilon.restapi.IsilonException in project coprhd-controller by CoprHD.
the class IsilonMirrorOperations method dodeleteReplicationPolicy.
/**
* Call to device to delete the policy
*
* @param system
* @param policyName
* @return
*/
public BiosCommandResult dodeleteReplicationPolicy(StorageSystem system, String policyName) {
try {
IsilonApi isi = getIsilonDevice(system);
IsilonSyncPolicy policy = isi.getReplicationPolicy(policyName);
JobState policyState = policy.getLastJobState();
if (policyState.equals(JobState.running) || policyState.equals(JobState.paused)) {
_log.info("Canceling Replication Policy -{} because policy is in - {} state ", policyName, policyState);
IsilonSyncPolicy modifiedPolicy = new IsilonSyncPolicy();
modifiedPolicy.setName(policyName);
modifiedPolicy.setLastJobState(JobState.canceled);
isi.modifyReplicationPolicy(policyName, modifiedPolicy);
}
isi.deleteReplicationPolicy(policyName);
_log.info("dodeleteReplicationPolicy - {} finished succesfully", policy.toString());
_log.info("Sleeping for 10 seconds for detach mirror to complete...");
TimeUnit.SECONDS.sleep(10);
return BiosCommandResult.createSuccessfulResult();
} catch (IsilonException e) {
return BiosCommandResult.createErrorResult(e);
} catch (InterruptedException e) {
_log.warn("dodeleteReplicationPolicy - {} Interrupted");
return BiosCommandResult.createSuccessfulResult();
}
}
use of com.emc.storageos.isilon.restapi.IsilonException in project coprhd-controller by CoprHD.
the class IsilonStatsRecorder method addUsageStat.
/**
* Adds a Stat for usage from the IsilonQuota.
*
* @param quota
* @param keyMap
* @param fsNativeGuid native Guid of the file share
* @param isilonApi
* @return the stat
*/
public Stat addUsageStat(IsilonSmartQuota quota, Map<String, Object> keyMap, String fsNativeGuid, IsilonApi isilonApi) {
Stat stat = zeroRecordGenerator.injectattr(keyMap, fsNativeGuid, FileShare.class);
if (stat != null) {
try {
DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
stat.setTimeInMillis((Long) keyMap.get(Constants._TimeCollected));
stat.setTimeCollected((Long) keyMap.get(Constants._TimeCollected));
statsColumnInjector.injectColumns(stat, dbClient);
long provisionedCapacity = 0L;
Thresholds threshold = quota.getThresholds();
if (threshold != null && threshold.getHard() != null) {
provisionedCapacity = threshold.getHard();
}
stat.setProvisionedCapacity(provisionedCapacity);
long usedCapacity = quota.getUsagePhysical();
stat.setAllocatedCapacity(usedCapacity);
URIQueryResultList snapURIList = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getFileshareSnapshotConstraint(stat.getResourceId()), snapURIList);
// Set snapshot count.
// Set snapshot size. Get current data for snapshot size (snapshot size changes dynamically).
int snapCount = 0;
long fsSnapshotSize = 0;
IsilonSnapshot isiSnap;
for (URI snapURI : snapURIList) {
Snapshot snap = dbClient.queryObject(Snapshot.class, snapURI);
// Filter out deleted Snapshot
if (snap != null && (!snap.getInactive())) {
String nativeId = snap.getNativeId();
try {
isiSnap = isilonApi.getSnapshot(nativeId);
} catch (IsilonException iex) {
_log.error(String.format("Stat: %s: can not get snapshot size for snapshot: %s", fsNativeGuid, nativeId), iex);
continue;
}
snapCount++;
fsSnapshotSize += Long.valueOf(isiSnap.getSize());
}
}
stat.setSnapshotCount(snapCount);
_log.debug(String.format("Stat: %s: snapshot count: %s", fsNativeGuid, snapCount));
stat.setSnapshotCapacity(fsSnapshotSize);
_log.debug(String.format("Stat: %s: snapshot size: %s", fsNativeGuid, fsSnapshotSize));
_log.debug(String.format("Stat: %s: %s: provisioned capacity(%s): used capacity(%s)", stat.getResourceId(), fsNativeGuid, provisionedCapacity, usedCapacity));
} catch (DatabaseException ex) {
_log.error("Query to db failed for FileShare id {}, skipping recording usage stat.", stat.getResourceId(), ex);
}
}
return stat;
}
use of com.emc.storageos.isilon.restapi.IsilonException in project coprhd-controller by CoprHD.
the class IsilonCommunicationInterface method discoverAllFileSystem.
private HashMap<String, Object> discoverAllFileSystem(StorageSystem storageSystem, String resumetoken, String umfsDiscoverPath) {
URI storageSystemId = storageSystem.getId();
try {
_log.info("discoverAllFileSystem for storage system {} - start", storageSystemId);
IsilonApi isilonApi = getIsilonDevice(storageSystem);
List<IsilonAccessZone> accessZones = isilonApi.getAccessZones(null);
List<String> tempAccessZonePath = new ArrayList<>();
for (IsilonAccessZone accessZone : accessZones) {
if (!accessZone.isSystem()) {
tempAccessZonePath.add(accessZone.getPath() + "/");
}
}
HashSet<String> fsPathSet = new HashSet<>();
HashSet<String> fsQuotaPathSet = new HashSet<>();
HashMap<String, IsilonSmartQuota> tempQuotaMap = new HashMap<>();
IsilonApi.IsilonList<FileShare> isilonFSList = new IsilonApi.IsilonList<>();
int accessZoneDiscPathLength = computeCustomConfigPathLengths(umfsDiscoverPath);
IsilonApi.IsilonList<IsilonSmartQuota> quotas = isilonApi.listQuotas(resumetoken, umfsDiscoverPath);
isilonFSList.setToken(quotas.getToken());
for (IsilonSmartQuota quota : quotas.getList()) {
if (quota.getType().compareTo("directory") != 0) {
_log.debug("ignore quota path {} with quota id {}:", quota.getPath(), quota.getId() + " and quota type" + quota.getType());
continue;
}
if ("/ifs/".equals(umfsDiscoverPath) && isQuotaUnderAccessZonePath(quota.getPath(), tempAccessZonePath)) {
continue;
}
String fsNativeId = quota.getPath();
if (isUnderUnmanagedDiscoveryPath(fsNativeId)) {
int fsPathType = isQuotaOrFile(fsNativeId, accessZoneDiscPathLength);
if (fsPathType == PATH_IS_FILE) {
tempQuotaMap.put(quota.getPath(), quota);
fsPathSet.add(fsNativeId);
}
if (fsPathType == PATH_IS_QUOTA) {
tempQuotaMap.put(quota.getPath(), quota);
fsQuotaPathSet.add(fsNativeId);
}
}
}
/*
* Associate Quota directories with correct File paths
*/
HashMap<String, Set<String>> fileQuotas = new HashMap<>();
for (String filePath : fsPathSet) {
HashSet<String> qdPaths = new HashSet<>();
for (String qdPath : fsQuotaPathSet) {
if (qdPath.startsWith(filePath + "/")) {
qdPaths.add(qdPath);
}
}
if (!qdPaths.isEmpty()) {
fsQuotaPathSet.removeAll(qdPaths);
fileQuotas.put(filePath, qdPaths);
}
}
HashMap<String, FileShare> fsWithQuotaMap = new HashMap<>();
HashMap<String, UnManagedFileQuotaDirectory> qdMap = new HashMap<>();
for (String fsNativeId : fsPathSet) {
IsilonSmartQuota fileFsQuota = tempQuotaMap.get(fsNativeId);
FileShare fs = extractFileShare(fsNativeId, fileFsQuota, storageSystem);
_log.debug("quota id {} with capacity {}", fsNativeId + ":QUOTA:" + fileFsQuota.getId(), fs.getCapacity() + " used capacity " + fs.getUsedCapacity());
fsWithQuotaMap.put(fsNativeId, fs);
Set<String> fsQuotaIds = fileQuotas.get(fsNativeId);
if (null != fsQuotaIds) {
for (String quotaNativeId : fsQuotaIds) {
IsilonSmartQuota qdQuota = tempQuotaMap.get(quotaNativeId);
if (null != qdQuota) {
UnManagedFileQuotaDirectory qd = getUnManagedFileQuotaDirectory(fs.getNativeGuid(), qdQuota, storageSystem);
qdMap.put(quotaNativeId, qd);
}
}
}
}
List<FileShare> discoveredFS = new ArrayList<>();
discoveredFS.addAll(fsWithQuotaMap.values());
isilonFSList.addList(discoveredFS);
List<UnManagedFileQuotaDirectory> discoverdQuotaDirectory = new ArrayList<>();
discoverdQuotaDirectory.addAll(qdMap.values());
HashMap<String, Object> discoveredFileDetails = new HashMap<>();
discoveredFileDetails.put(UMFS_DETAILS, isilonFSList);
discoveredFileDetails.put(UMFSQD_DETAILS, discoverdQuotaDirectory);
discoveredFileDetails.put(UMFS_QD_MAP, fileQuotas);
return discoveredFileDetails;
} catch (IsilonException ie) {
_log.error("discoverAllFileSystem failed. Storage system: {}", storageSystemId, ie);
throw ie;
} catch (Exception e) {
_log.error("discoverAllFileSystem failed. Storage system: {}", storageSystemId, e);
IsilonCollectionException ice = new IsilonCollectionException("discoverAllFileSystem failed. Storage system: " + storageSystemId);
ice.initCause(e);
throw ice;
}
}
use of com.emc.storageos.isilon.restapi.IsilonException in project coprhd-controller by CoprHD.
the class IsilonCommunicationInterface method discoverPools.
private Map<String, List<StoragePool>> discoverPools(StorageSystem storageSystem, List<StoragePool> poolsToMatchWithVpool) throws IsilonCollectionException {
// Discover storage pools
Map<String, List<StoragePool>> storagePools = new HashMap<String, List<StoragePool>>();
List<StoragePool> newPools = new ArrayList<StoragePool>();
List<StoragePool> existingPools = new ArrayList<StoragePool>();
URI storageSystemId = storageSystem.getId();
try {
_log.info("discoverPools for storage system {} - start", storageSystemId);
IsilonApi isilonApi = getIsilonDevice(storageSystem);
boolean isNfsV4Enabled = isilonApi.nfsv4Enabled(storageSystem.getFirmwareVersion());
boolean syncLicenseValid = isValidLicense(isilonApi.getReplicationLicenseInfo(), storageSystem);
boolean snapLicenseValid = isValidLicense(isilonApi.snapshotIQLicenseInfo(), storageSystem);
// Set file replication type for Isilon storage system!!!
if (syncLicenseValid) {
StringSet supportReplicationTypes = new StringSet();
supportReplicationTypes.add(SupportedFileReplicationTypes.REMOTE.name());
supportReplicationTypes.add(SupportedFileReplicationTypes.LOCAL.name());
storageSystem.setSupportedReplicationTypes(supportReplicationTypes);
}
_log.info("Isilon OneFS version: {}", storageSystem.getFirmwareVersion());
List<? extends IsilonPool> isilonPools = null;
if (VersionChecker.verifyVersionDetails(ONEFS_V7_2, storageSystem.getFirmwareVersion()) >= 0) {
_log.info("Querying for Isilon storage pools...");
isilonPools = isilonApi.getStoragePools();
} else {
_log.info("Querying for Isilon disk pools...");
isilonPools = isilonApi.getDiskPools();
}
for (IsilonPool isilonPool : isilonPools) {
// Check if this storage pool was already discovered
StoragePool storagePool = null;
String poolNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, isilonPool.getNativeId(), NativeGUIDGenerator.POOL);
@SuppressWarnings("deprecation") List<URI> poolURIs = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePoolByNativeGuidConstraint(poolNativeGuid));
for (URI poolUri : poolURIs) {
StoragePool pool = _dbClient.queryObject(StoragePool.class, poolUri);
if (!pool.getInactive() && pool.getStorageDevice().equals(storageSystemId)) {
storagePool = pool;
break;
}
}
if (storagePool == null) {
// New storage pool
storagePool = new StoragePool();
storagePool.setId(URIUtil.createId(StoragePool.class));
storagePool.setNativeGuid(poolNativeGuid);
storagePool.setLabel(poolNativeGuid);
storagePool.setPoolClassName(POOL_TYPE);
storagePool.setPoolServiceType(PoolServiceType.file.toString());
storagePool.setStorageDevice(storageSystemId);
StringSet protocols = new StringSet();
protocols.add("NFS");
protocols.add("CIFS");
storagePool.setProtocols(protocols);
storagePool.setPoolName(isilonPool.getNativeId());
storagePool.setNativeId(isilonPool.getNativeId());
storagePool.setLabel(poolNativeGuid);
storagePool.setSupportedResourceTypes(StoragePool.SupportedResourceTypes.THIN_AND_THICK.toString());
storagePool.setOperationalStatus(StoragePool.PoolOperationalStatus.READY.toString());
storagePool.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
_log.info("Creating new storage pool using NativeGuid : {}", poolNativeGuid);
newPools.add(storagePool);
} else {
existingPools.add(storagePool);
}
if (isNfsV4Enabled) {
storagePool.getProtocols().add(NFSv4);
} else {
storagePool.getProtocols().remove(NFSv4);
}
// Add the Copy type ASYNC, if the Isilon is enabled with SyncIQ service!!
StringSet copyTypesSupported = new StringSet();
if (syncLicenseValid) {
copyTypesSupported.add(CopyTypes.ASYNC.name());
storagePool.setSupportedCopyTypes(copyTypesSupported);
} else {
if (storagePool.getSupportedCopyTypes() != null && storagePool.getSupportedCopyTypes().contains(CopyTypes.ASYNC.name())) {
storagePool.getSupportedCopyTypes().remove(CopyTypes.ASYNC.name());
}
}
// Add the Copy type ScheduleSnapshot, if the Isilon is enabled with SnapshotIQ
if (snapLicenseValid) {
copyTypesSupported.add(CHECKPOINT_SCHEDULE);
storagePool.setSupportedCopyTypes(copyTypesSupported);
} else {
if (storagePool.getSupportedCopyTypes() != null && storagePool.getSupportedCopyTypes().contains(CHECKPOINT_SCHEDULE)) {
storagePool.getSupportedCopyTypes().remove(CHECKPOINT_SCHEDULE);
}
}
// scale capacity size
storagePool.setFreeCapacity(isilonPool.getAvailableBytes() / BYTESCONVERTER);
storagePool.setTotalCapacity(isilonPool.getTotalBytes() / BYTESCONVERTER);
storagePool.setSubscribedCapacity(isilonPool.getUsedBytes() / BYTESCONVERTER);
if (ImplicitPoolMatcher.checkPoolPropertiesChanged(storagePool.getCompatibilityStatus(), DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name()) || ImplicitPoolMatcher.checkPoolPropertiesChanged(storagePool.getDiscoveryStatus(), DiscoveryStatus.VISIBLE.name())) {
poolsToMatchWithVpool.add(storagePool);
}
storagePool.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
storagePool.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
}
_log.info("discoverPools for storage system {} - complete", storageSystemId);
storagePools.put(NEW, newPools);
storagePools.put(EXISTING, existingPools);
return storagePools;
} catch (IsilonException ie) {
_log.error("discoverPools failed. Storage system: {}", storageSystemId, ie);
IsilonCollectionException ice = new IsilonCollectionException("discoverPools failed. Storage system: " + storageSystemId);
ice.initCause(ie);
throw ice;
} catch (Exception e) {
_log.error("discoverPools failed. Storage system: {}", storageSystemId, e);
IsilonCollectionException ice = new IsilonCollectionException("discoverPools failed. Storage system: " + storageSystemId);
ice.initCause(e);
throw ice;
}
}
Aggregations