use of com.emc.storageos.plugins.metering.isilon.IsilonCollectionException in project coprhd-controller by CoprHD.
the class IsilonCommunicationInterface method discoverAccessZoneExports.
private HashMap<String, HashSet<Integer>> discoverAccessZoneExports(StorageSystem storageSystem, String isilonAccessZone) throws IsilonCollectionException {
HashMap<String, HashSet<Integer>> allExports = new HashMap<>();
URI storageSystemId = storageSystem.getId();
String resumeToken = null;
try {
_log.info("discoverAllExports for storage system {} - start", storageSystemId);
IsilonApi isilonApi = getIsilonDevice(storageSystem);
do {
IsilonApi.IsilonList<IsilonExport> isilonExports = isilonApi.listExports(resumeToken, isilonAccessZone);
List<IsilonExport> exports = isilonExports.getList();
for (IsilonExport exp : exports) {
_log.info("Discovered fS export {}", exp.toString());
if (exp.getPaths() == null || exp.getPaths().isEmpty()) {
_log.info("Ignoring export {} as it is not having any path", exp.getId().toString());
continue;
}
HashSet<Integer> exportIds = new HashSet<>();
// Ignore Export with multiple paths
if (exp.getPaths().size() > 1) {
_log.info("Discovered Isilon Export: {} has multiple paths so ingnoring it", exp.toString());
continue;
}
String path = exp.getPaths().get(0);
exportIds = allExports.get(path);
if (exportIds == null) {
exportIds = new HashSet<>();
}
exportIds.add(exp.getId());
allExports.put(path, exportIds);
_log.debug("Discovered fS put export Path {} Export id {}", path, exportIds.size() + ":" + exportIds);
}
resumeToken = isilonExports.getToken();
} while (resumeToken != null);
_log.info("discoverd All NFS Exports for access zone {} ", isilonAccessZone);
return allExports;
} catch (IsilonException ie) {
_log.error("discoverAllExports failed. Storage system: {}", storageSystemId, ie);
IsilonCollectionException ice = new IsilonCollectionException("discoverAllExports failed. Storage system: " + storageSystemId);
ice.initCause(ie);
throw ice;
} catch (Exception e) {
_log.error("discoverAllExports failed. Storage system: {}", storageSystemId, e);
IsilonCollectionException ice = new IsilonCollectionException("discoverAllExports failed. Storage system: " + storageSystemId);
ice.initCause(e);
throw ice;
}
}
use of com.emc.storageos.plugins.metering.isilon.IsilonCollectionException in project coprhd-controller by CoprHD.
the class IsilonCommunicationInterface method updateDiscoveryPathForUnManagedFS.
/**
* Add custom discovery directory paths from controller configuration
*/
private void updateDiscoveryPathForUnManagedFS(Map<String, NASServer> nasServer, StorageSystem storage) throws IsilonCollectionException {
String paths = "";
String systemAccessZone = "";
String userAccessZone = "";
String namespace = "";
String customLocations = ",";
// get the system access zones
DataSource ds = new DataSource();
ds.addProperty(CustomConfigConstants.ISILON_NO_DIR, "");
ds.addProperty(CustomConfigConstants.ISILON_DIR_NAME, "");
namespace = customConfigHandler.getComputedCustomConfigValue(CustomConfigConstants.ISILON_SYSTEM_ACCESS_ZONE_NAMESPACE, "isilon", ds);
namespace = namespace.replaceAll("=", "");
if (namespace.isEmpty()) {
systemAccessZone = IFS_ROOT + "/";
} else {
systemAccessZone = IFS_ROOT + "/" + namespace + "/";
}
// get the user access zone
userAccessZone = getUserAccessZonePath(nasServer);
// create a dataSouce and place the value for system and user access zone
DataSource dataSource = dataSourceFactory.createIsilonUnmanagedFileSystemLocationsDataSource(storage);
dataSource.addProperty(CustomConfigConstants.ISILON_SYSTEM_ACCESS_ZONE, systemAccessZone);
dataSource.addProperty(CustomConfigConstants.ISILON_USER_ACCESS_ZONE, userAccessZone);
dataSource.addProperty(CustomConfigConstants.ISILON_CUSTOM_DIR_PATH, customLocations);
paths = customConfigHandler.getComputedCustomConfigValue(CustomConfigConstants.ISILON_UNMANAGED_FILE_SYSTEM_LOCATIONS, "isilon", dataSource);
// trim leading or trailing or multiple comma.
paths = paths.replaceAll("^,+", "").replaceAll(",+$", "").replaceAll(",+", ",");
if (paths.equals(",") || paths.isEmpty()) {
IsilonCollectionException ice = new IsilonCollectionException("computed unmanaged file system location is empty. Please verify Isilon controller config settings");
throw ice;
}
_log.info("Unmanaged file system locations are {}", paths);
List<String> pathList = Arrays.asList(paths.split(","));
Set<String> pathSet = new HashSet<>();
pathSet.addAll(pathList);
setDiscPathsForUnManaged(pathSet);
_discCustomPath = getCustomConfigPath();
}
use of com.emc.storageos.plugins.metering.isilon.IsilonCollectionException in project coprhd-controller by CoprHD.
the class IsilonCommunicationInterface method discoverAll.
public void discoverAll(AccessProfile accessProfile) throws BaseCollectionException {
URI storageSystemId = null;
StorageSystem storageSystem = null;
String detailedStatusMessage = "Unknown Status";
try {
storageSystemId = accessProfile.getSystemId();
storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
// try to connect to the Isilon cluster first to check if cluster is available
IsilonApi isilonApi = getIsilonDevice(storageSystem);
isilonApi.getClusterInfo();
discoverCluster(storageSystem);
_dbClient.persistObject(storageSystem);
if (!storageSystem.getReachableStatus()) {
throw new IsilonCollectionException("Failed to connect to " + storageSystem.getIpAddress());
}
_completer.statusPending(_dbClient, "Completed cluster discovery");
List<StoragePool> poolsToMatchWithVpool = new ArrayList<StoragePool>();
List<StoragePool> allPools = new ArrayList<StoragePool>();
// discover pools
Map<String, List<StoragePool>> pools = discoverPools(storageSystem, poolsToMatchWithVpool);
_log.info("No of newly discovered pools {}", pools.get(NEW).size());
_log.info("No of existing discovered pools {}", pools.get(EXISTING).size());
if (!pools.get(NEW).isEmpty()) {
allPools.addAll(pools.get(NEW));
_dbClient.createObject(pools.get(NEW));
}
if (!pools.get(EXISTING).isEmpty()) {
allPools.addAll(pools.get(EXISTING));
_dbClient.persistObject(pools.get(EXISTING));
}
List<StoragePool> notVisiblePools = DiscoveryUtils.checkStoragePoolsNotVisible(allPools, _dbClient, storageSystemId);
poolsToMatchWithVpool.addAll(notVisiblePools);
_completer.statusPending(_dbClient, "Completed pool discovery");
// discover ports
List<StoragePort> allPorts = new ArrayList<StoragePort>();
Map<String, List<StoragePort>> ports = discoverPorts(storageSystem);
_log.info("No of newly discovered ports {}", ports.get(NEW).size());
_log.info("No of existing discovered ports {}", ports.get(EXISTING).size());
if (null != ports && !ports.get(NEW).isEmpty()) {
allPorts.addAll(ports.get(NEW));
_dbClient.createObject(ports.get(NEW));
}
if (null != ports && !ports.get(EXISTING).isEmpty()) {
allPorts.addAll(ports.get(EXISTING));
_dbClient.persistObject(ports.get(EXISTING));
}
List<StoragePort> notVisiblePorts = DiscoveryUtils.checkStoragePortsNotVisible(allPorts, _dbClient, storageSystemId);
List<StoragePort> allExistPorts = new ArrayList<StoragePort>(ports.get(EXISTING));
allExistPorts.addAll(notVisiblePorts);
_completer.statusPending(_dbClient, "Completed port discovery");
StoragePortAssociationHelper.runUpdatePortAssociationsProcess(ports.get(NEW), allExistPorts, _dbClient, _coordinator, poolsToMatchWithVpool);
// discover the access zone and its network interfaces
discoverAccessZones(storageSystem);
// Update the virtual nas association with virtual arrays!!!
// For existing virtual nas ports!!
StoragePortAssociationHelper.runUpdateVirtualNasAssociationsProcess(allExistPorts, null, _dbClient);
_completer.statusPending(_dbClient, "Completed Access Zone discovery");
// discovery succeeds
detailedStatusMessage = String.format("Discovery completed successfully for Isilon: %s", storageSystemId.toString());
} catch (Exception e) {
if (storageSystem != null) {
cleanupDiscovery(storageSystem);
}
detailedStatusMessage = String.format("Discovery failed for Isilon %s because %s", storageSystemId.toString(), e.getLocalizedMessage());
_log.error(detailedStatusMessage, e);
throw new IsilonCollectionException(detailedStatusMessage);
} finally {
if (storageSystem != null) {
try {
// set detailed message
storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
_dbClient.persistObject(storageSystem);
} catch (DatabaseException ex) {
_log.error("Error while persisting object to DB", ex);
}
}
}
}
use of com.emc.storageos.plugins.metering.isilon.IsilonCollectionException in project coprhd-controller by CoprHD.
the class IsilonCommunicationInterface method discoverNetworkPools.
/**
* discover the network interface of given Isilon storage cluster
*
* @param storageSystem
* @return
* @throws IsilonCollectionException
*/
private List<IsilonNetworkPool> discoverNetworkPools(StorageSystem storageSystem) throws IsilonCollectionException {
List<IsilonNetworkPool> isilonNetworkPoolList = new ArrayList<IsilonNetworkPool>();
URI storageSystemId = storageSystem.getId();
_log.info("discoverNetworkPools for storage system {} - start", storageSystemId);
List<IsilonNetworkPool> isilonNetworkPoolsTemp = null;
try {
if (VersionChecker.verifyVersionDetails(ONEFS_V8, storageSystem.getFirmwareVersion()) >= 0) {
_log.info("Isilon release version {} and storagesystem label {}", storageSystem.getFirmwareVersion(), storageSystem.getLabel());
IsilonApi isilonApi = getIsilonDevice(storageSystem);
isilonNetworkPoolsTemp = isilonApi.getNetworkPools(null);
if (isilonNetworkPoolsTemp != null) {
isilonNetworkPoolList.addAll(isilonNetworkPoolsTemp);
}
} else {
IsilonSshApi sshDmApi = new IsilonSshApi();
sshDmApi.setConnParams(storageSystem.getIpAddress(), storageSystem.getUsername(), storageSystem.getPassword());
Map<String, List<String>> networkPools = sshDmApi.getNetworkPools();
List<String> smartconnects = null;
IsilonNetworkPool isiNetworkPool = null;
for (Map.Entry<String, List<String>> networkpool : networkPools.entrySet()) {
smartconnects = networkpool.getValue();
if (smartconnects != null) {
for (String smartconnect : smartconnects) {
isiNetworkPool = new IsilonNetworkPool();
isiNetworkPool.setAccess_zone(networkpool.getKey());
isiNetworkPool.setSc_dns_zone(smartconnect);
isilonNetworkPoolList.add(isiNetworkPool);
}
}
}
}
} catch (Exception e) {
_log.error("discover of NetworkPools is failed. %s", e.getMessage());
}
return isilonNetworkPoolList;
}
use of com.emc.storageos.plugins.metering.isilon.IsilonCollectionException in project coprhd-controller by CoprHD.
the class IsilonCommunicationInterface method discoverAccessZones.
/**
* discover the access zone and add to vipr db
*
* @param storageSystem
*/
private void discoverAccessZones(StorageSystem storageSystem) {
URI storageSystemId = storageSystem.getId();
VirtualNAS virtualNAS = null;
PhysicalNAS physicalNAS = null;
List<VirtualNAS> newvNASList = new ArrayList<VirtualNAS>();
List<VirtualNAS> existingvNASList = new ArrayList<VirtualNAS>();
List<PhysicalNAS> newPhysicalNASList = new ArrayList<PhysicalNAS>();
List<PhysicalNAS> existingPhysicalNASList = new ArrayList<PhysicalNAS>();
List<VirtualNAS> discoveredVNASList = new ArrayList<VirtualNAS>();
// Discover storage ports
try {
_log.info("discoverAccessZones for storage system {} - start", storageSystemId);
IsilonApi isilonApi = getIsilonDevice(storageSystem);
// Make restapi call to get access zones
List<IsilonAccessZone> accessZoneList = isilonApi.getAccessZones(null);
if (accessZoneList == null || accessZoneList.isEmpty()) {
// No access zones defined. Throw an exception and fail the discovery
IsilonCollectionException ice = new IsilonCollectionException("discoverAccessZones failed. No Zones defined");
throw ice;
}
// Find the smart connect zones
List<IsilonNetworkPool> isilonNetworkPoolsSysAZ = new ArrayList<>();
// get the system access zone and use it later
List<IsilonNetworkPool> isilonNetworkPoolList = discoverNetworkPools(storageSystem);
for (IsilonNetworkPool isilonNetworkPool : isilonNetworkPoolList) {
if (isilonNetworkPool.getAccess_zone().equalsIgnoreCase(SYSTEM_ACCESS_ZONE_NAME)) {
isilonNetworkPoolsSysAZ.add(isilonNetworkPool);
}
}
// set the protocol based storagesystem version
// by default all version support CIFS and version above 7.2 NFS also
StringSet protocols = new StringSet();
protocols.add(CIFS);
boolean isNfsV4Enabled = isilonApi.nfsv4Enabled(storageSystem.getFirmwareVersion());
if (VersionChecker.verifyVersionDetails(ONEFS_V7_2, storageSystem.getFirmwareVersion()) >= 0) {
protocols.add(NFS);
if (isNfsV4Enabled) {
protocols.add(NFSv4);
}
}
List<IsilonNetworkPool> isilonNetworkPools = null;
// process the access zones list
for (IsilonAccessZone isilonAccessZone : accessZoneList) {
// add protocol to NAS servers
// is it a System access zone?
isilonNetworkPools = null;
if (isilonAccessZone.isSystem() == false) {
_log.info("Process the user defined access zone {} ", isilonAccessZone.toString());
isilonNetworkPools = new ArrayList<IsilonNetworkPool>();
// get the smart connect zone information
for (IsilonNetworkPool eachNetworkPool : isilonNetworkPoolList) {
if (eachNetworkPool.getAccess_zone().equalsIgnoreCase(isilonAccessZone.getName())) {
isilonNetworkPools.add(eachNetworkPool);
}
}
// find virtualNAS in db
virtualNAS = findvNasByNativeId(storageSystem, isilonAccessZone.getZone_id().toString());
if (virtualNAS == null) {
if (isilonNetworkPools != null && !isilonNetworkPools.isEmpty()) {
virtualNAS = createVirtualNas(storageSystem, isilonAccessZone);
newvNASList.add(virtualNAS);
}
} else {
copyUpdatedPropertiesInVNAS(storageSystem, isilonAccessZone, virtualNAS);
existingvNASList.add(virtualNAS);
}
// Set authentication providers
setCifsServerMapForNASServer(isilonAccessZone, virtualNAS);
// set protocol support
if (virtualNAS != null) {
virtualNAS.setProtocols(protocols);
}
// set the smart connect
setStoragePortsForNASServer(isilonNetworkPools, storageSystem, virtualNAS);
} else {
_log.info("Process the System access zone {} ", isilonAccessZone.toString());
// set protocols
StringSet protocolSet = new StringSet();
protocolSet.add(CIFS);
protocolSet.add(NFS);
if (isNfsV4Enabled) {
protocolSet.add(NFSv4);
}
physicalNAS = findPhysicalNasByNativeId(storageSystem, isilonAccessZone.getZone_id().toString());
if (physicalNAS == null) {
physicalNAS = createPhysicalNas(storageSystem, isilonAccessZone);
physicalNAS.setProtocols(protocolSet);
// add system access zone
newPhysicalNASList.add(physicalNAS);
} else {
setMaxDbMetricsAz(storageSystem, physicalNAS.getMetrics());
existingPhysicalNASList.add(physicalNAS);
}
// Set authentication providers
setCifsServerMapForNASServer(isilonAccessZone, physicalNAS);
// set the smart connect zone
setStoragePortsForNASServer(isilonNetworkPoolsSysAZ, storageSystem, physicalNAS);
}
}
// Persist the vNAS servers and
if (newvNASList != null && !newvNASList.isEmpty()) {
// add the parent system access zone to user defined access zones
if (physicalNAS != null) {
for (VirtualNAS vNas : newvNASList) {
// set the parent uri or system access zone uri to vNAS
vNas.setParentNasUri(physicalNAS.getId());
}
}
_log.info("New Virtual NAS servers size {}", newvNASList.size());
_dbClient.createObject(newvNASList);
discoveredVNASList.addAll(newvNASList);
}
if (existingvNASList != null && !existingvNASList.isEmpty()) {
_log.info("Modified Virtual NAS servers size {}", existingvNASList.size());
_dbClient.updateObject(existingvNASList);
discoveredVNASList.addAll(existingvNASList);
}
// Persist the NAS servers!!!
if (existingPhysicalNASList != null && !existingPhysicalNASList.isEmpty()) {
_log.info("Modified Physical NAS servers size {}", existingPhysicalNASList.size());
_dbClient.updateObject(existingPhysicalNASList);
}
if (newPhysicalNASList != null && !newPhysicalNASList.isEmpty()) {
_log.info("New Physical NAS servers size {}", newPhysicalNASList.size());
_dbClient.createObject(newPhysicalNASList);
}
DiscoveryUtils.checkVirtualNasNotVisible(discoveredVNASList, _dbClient, storageSystemId);
} catch (Exception e) {
_log.error("discoverAccessZones failed. Storage system: {}", storageSystemId, e);
IsilonCollectionException ice = new IsilonCollectionException("discoverAccessZones failed. Storage system: " + storageSystemId);
throw ice;
}
}
Aggregations