use of com.emc.storageos.isilon.restapi.IsilonApi in project coprhd-controller by CoprHD.
the class IsilonMonitoringImpl method getIsilonDevice.
/**
* Get isilon device represented by the StorageDevice
*
* @param device Isilon's StorageSystem instance
* @return IsilonApi object
* @throws IsilonException
*/
private IsilonApi getIsilonDevice(StorageSystem device) throws IsilonException {
_logger.debug("Entering {}", Thread.currentThread().getStackTrace()[1].getMethodName());
IsilonApi isilonApi;
URI deviceURI;
try {
deviceURI = new URI("https", null, device.getIpAddress(), device.getPortNumber(), "/", null, null);
} catch (URISyntaxException ex) {
throw IsilonException.exceptions.errorCreatingServerURL(device.getIpAddress(), device.getPortNumber(), ex);
}
// if no username, assume its the isilon simulator device
if (device.getUsername() != null && !device.getUsername().isEmpty()) {
isilonApi = _isilonApiFactory.getRESTClient(deviceURI, device.getUsername(), device.getPassword());
} else {
isilonApi = _isilonApiFactory.getRESTClient(deviceURI);
}
_logger.debug("Exiting {}", Thread.currentThread().getStackTrace()[1].getMethodName());
return isilonApi;
}
use of com.emc.storageos.isilon.restapi.IsilonApi 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.isilon.restapi.IsilonApi in project coprhd-controller by CoprHD.
the class IsilonCommunicationInterface method computeStaticLoadMetrics.
private void computeStaticLoadMetrics(final URI storageSystemId) throws BaseCollectionException {
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
_log.info("started computeStaticLoadMetrics for storagesystem: {}", storageSystem.getLabel());
StringMap dbMetrics = null;
String accessZoneId = null;
try {
IsilonApi isilonApi = getIsilonDevice(storageSystem);
VirtualNAS virtualNAS = null;
// //step-1 process the dbmetrics for user define access zones
List<IsilonAccessZone> accessZoneList = isilonApi.getAccessZones(null);
for (IsilonAccessZone isAccessZone : accessZoneList) {
accessZoneId = isAccessZone.getZone_id().toString();
// get the total fs count and capacity for AZ
if (isAccessZone.isSystem() != true) {
virtualNAS = findvNasByNativeId(storageSystem, accessZoneId);
if (virtualNAS != null) {
_log.info("Process db metrics for access zone : {}", isAccessZone.getName());
dbMetrics = virtualNAS.getMetrics();
if (dbMetrics == null) {
dbMetrics = new StringMap();
}
// process db metrics
populateDbMetricsAz(isAccessZone, isilonApi, dbMetrics);
// set AZ dbMetrics in db
virtualNAS.setMetrics(dbMetrics);
_dbClient.updateObject(virtualNAS);
}
} else {
PhysicalNAS physicalNAS = findPhysicalNasByNativeId(storageSystem, accessZoneId);
if (physicalNAS == null) {
_log.error(String.format("computeStaticLoadMetrics is failed for Storagesystemid: %s", storageSystemId));
return;
}
dbMetrics = physicalNAS.getMetrics();
if (dbMetrics == null) {
dbMetrics = new StringMap();
}
/* process the system accesszone dbmetrics */
_log.info("process db metrics for access zone : {}", isAccessZone.getName());
populateDbMetricsAz(isAccessZone, isilonApi, dbMetrics);
physicalNAS.setMetrics(dbMetrics);
_dbClient.updateObject(physicalNAS);
}
}
} catch (Exception e) {
_log.error("CollectStatisticsInformation failed. Storage system: " + storageSystemId, e);
}
}
use of com.emc.storageos.isilon.restapi.IsilonApi 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.isilon.restapi.IsilonApi 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