use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class SMICommunicationInterface method discover.
/**
* {@inheritDoc}
*/
@Override
public void discover(AccessProfile accessProfile) throws BaseCollectionException {
URI storageSystemURI = null;
StorageSystem storageSystem = null;
String detailedStatusMessage = "Unknown Status";
long startTime = System.currentTimeMillis();
try {
_logger.info("Access Profile Details :" + accessProfile.toString());
storageSystemURI = accessProfile.getSystemId();
storageSystem = queryStorageSystem(accessProfile);
_keyMap = new ConcurrentHashMap<String, Object>();
_wbemClient = getCIMClient(accessProfile);
_logger.info("CIMClient initialized successfully");
_keyMap.put(Constants._cimClient, _wbemClient);
_keyMap.put(Constants.dbClient, _dbClient);
_keyMap.put(Constants.COORDINATOR_CLIENT, _coordinator);
if (_networkDeviceController != null) {
_keyMap.put(Constants.networkDeviceController, _networkDeviceController);
}
_keyMap.put(Constants.PROPS, accessProfile.getProps());
_keyMap.put(Constants._InteropNamespace, accessProfile.getInteropNamespace());
_keyMap.put(Constants.ACCESSPROFILE, accessProfile);
_keyMap.put(Constants.SYSTEMID, accessProfile.getSystemId());
_keyMap.put(Constants._serialID, accessProfile.getserialID());
_keyMap.put(Constants.STORAGEPOOLS, new LinkedList<CIMObjectPath>());
_keyMap.put(Constants.PROTOCOLS, new HashSet<String>());
_keyMap.put(Constants.STORAGEETHERNETPORTS, new LinkedList<CIMObjectPath>());
_keyMap.put(Constants.IPENDPOINTS, new LinkedList<CIMObjectPath>());
_keyMap.put(Constants.STORAGEVOLUMES, new LinkedList<CIMObjectPath>());
String providerVersion = getProviderVersionString(storageSystem);
if (null != providerVersion) {
_keyMap.put(Constants.VERSION, providerVersion);
_keyMap.put(Constants.IS_NEW_SMIS_PROVIDER, isSMIS8XProvider(providerVersion));
}
Map<URI, StoragePool> poolsToMatchWithVpool = new HashMap<URI, StoragePool>();
_keyMap.put(Constants.MODIFIED_STORAGEPOOLS, poolsToMatchWithVpool);
// need this nested structure to be able to minimize the changes on existing code.
List<List<StoragePort>> portsToRunNetworkConnectivity = new ArrayList<List<StoragePort>>();
_keyMap.put(Constants.STORAGE_PORTS, portsToRunNetworkConnectivity);
List<StoragePort> discoveredPorts = new ArrayList<StoragePort>();
_keyMap.put(Constants.DISCOVERED_PORTS, discoveredPorts);
_keyMap.put(Constants.SLO_NAMES, new HashSet<String>());
if (Type.ibmxiv.name().equals(accessProfile.getSystemType())) {
initIBMDiscoveryKeyMap(accessProfile);
} else {
initEMCDiscoveryKeyMap(accessProfile);
if (Type.vmax.name().equals(accessProfile.getSystemType())) {
// discover port group
_keyMap.put(Constants.PORTGROUP, CimObjectPathCreator.createInstance(Constants.SE_TARGETMASKINGGROUP, accessProfile.getInteropNamespace()));
}
}
executor.setKeyMap(_keyMap);
executor.execute((Namespace) namespaces.getNsList().get(DISCOVER));
} catch (Exception e) {
detailedStatusMessage = String.format("Discovery failed for Storage System: %s because %s", storageSystemURI.toString(), e.getMessage());
_logger.error(detailedStatusMessage, e);
throw new SMIPluginException(detailedStatusMessage);
} finally {
if (storageSystem != null) {
try {
// set detailed message
storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
_dbClient.persistObject(storageSystem);
} catch (DatabaseException ex) {
_logger.error("Error while persisting object to DB", ex);
}
}
releaseResources();
long totalTime = System.currentTimeMillis() - startTime;
_logger.info(String.format("Discovery of Storage System %s took %f seconds", storageSystemURI.toString(), (double) totalTime / (double) 1000));
}
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class VNXFileCommunicationInterface method discoverUmanagedFileSystems.
private void discoverUmanagedFileSystems(AccessProfile profile) throws BaseCollectionException {
_logger.info("Access Profile Details : IpAddress : PortNumber : {}, namespace : {}", profile.getIpAddress() + profile.getPortNumber(), profile.getnamespace());
URI storageSystemId = profile.getSystemId();
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
if (null == storageSystem) {
return;
}
List<UnManagedFileSystem> unManagedFileSystems = new ArrayList<UnManagedFileSystem>();
List<UnManagedFileSystem> existingUnManagedFileSystems = new ArrayList<UnManagedFileSystem>();
int newFileSystemsCount = 0;
int existingFileSystemsCount = 0;
Set<URI> allDiscoveredUnManagedFileSystems = new HashSet<URI>();
String detailedStatusMessage = "Discovery of VNXFile Unmanaged FileSystem started";
try {
URIQueryResultList storagePoolURIs = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePoolConstraint(storageSystem.getId()), storagePoolURIs);
HashMap<String, StoragePool> pools = new HashMap();
Iterator<URI> poolsItr = storagePoolURIs.iterator();
while (poolsItr.hasNext()) {
URI storagePoolURI = poolsItr.next();
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolURI);
if (storagePool != null && !storagePool.getInactive()) {
pools.put(storagePool.getNativeId(), storagePool);
}
}
StoragePort storagePort = this.getStoragePortPool(storageSystem);
List<VNXFileSystem> discoveredFS = discoverAllFileSystems(storageSystem);
StringSet umfsIds = new StringSet();
if (discoveredFS != null) {
for (VNXFileSystem fs : discoveredFS) {
String fsNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem.getSystemType(), storageSystem.getSerialNumber(), fs.getFsId() + "");
StoragePool pool = pools.get(fs.getStoragePool());
if (!checkStorageFileSystemExistsInDB(fsNativeGuid)) {
// Create UnManaged FS
String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), fs.getFsId() + "");
UnManagedFileSystem unManagedFs = checkUnManagedFileSystemExistsInDB(fsUnManagedFsNativeGuid);
boolean alreadyExist = unManagedFs == null ? false : true;
unManagedFs = createUnManagedFileSystem(unManagedFs, fsUnManagedFsNativeGuid, storageSystem, pool, storagePort, fs);
if (alreadyExist) {
existingUnManagedFileSystems.add(unManagedFs);
existingFileSystemsCount++;
} else {
unManagedFileSystems.add(unManagedFs);
newFileSystemsCount++;
}
allDiscoveredUnManagedFileSystems.add(unManagedFs.getId());
umfsIds.add(fs.getFsId() + "");
/**
* Persist 200 objects and clear them to avoid memory issue
*/
validateListSizeLimitAndPersist(unManagedFileSystems, existingUnManagedFileSystems, Constants.DEFAULT_PARTITION_SIZE * 2);
}
}
}
// Process those active unmanaged fs objects available in database but not in newly discovered items, to mark them inactive.
markUnManagedFSObjectsInActive(storageSystem, allDiscoveredUnManagedFileSystems);
_logger.info("New unmanaged VNXFile file systems count: {}", newFileSystemsCount);
_logger.info("Update unmanaged VNXFile file systems count: {}", existingFileSystemsCount);
if (!unManagedFileSystems.isEmpty()) {
// Add UnManagedFileSystem
_dbClient.createObject(unManagedFileSystems);
}
if (!existingUnManagedFileSystems.isEmpty()) {
// Update UnManagedFilesystem
_dbClient.updateAndReindexObject(existingUnManagedFileSystems);
}
// discovery succeeds
detailedStatusMessage = String.format("Discovery completed successfully for VNXFile: %s", storageSystemId.toString());
if (null != umfsIds && !umfsIds.isEmpty()) {
// Discovering unmanaged quota directories
discoverUmanagedFileQuotaDirectory(profile, umfsIds);
}
} catch (Exception e) {
if (storageSystem != null) {
cleanupDiscovery(storageSystem);
}
detailedStatusMessage = String.format("Discovery failed for VNXFile %s because %s", storageSystemId.toString(), e.getLocalizedMessage());
_logger.error(detailedStatusMessage, e);
throw new VNXFileCollectionException(detailedStatusMessage);
} finally {
if (storageSystem != null) {
try {
// set detailed message
storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
_dbClient.persistObject(storageSystem);
} catch (Exception ex) {
_logger.error("Error while persisting object to DB", ex);
}
}
}
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class VNXFileCommunicationInterface method discoverStoragePools.
/**
* Returns the list of storage pools for the specified VNX File storage system.
*
* @param system storage system information including credentials.
* @return Map of New and Existing known storage pools.
* @throws VNXFileCollectionException
*/
private Map<String, List<StoragePool>> discoverStoragePools(StorageSystem system, List<StoragePool> poolsToMatchWithVpool, StringSet fileSharingProtocols) throws VNXFileCollectionException, VNXException {
Map<String, List<StoragePool>> storagePools = new HashMap<String, List<StoragePool>>();
List<StoragePool> newPools = new ArrayList<StoragePool>();
List<StoragePool> existingPools = new ArrayList<StoragePool>();
_logger.info("Start storage pool discovery for storage system {}", system.getId());
try {
List<VNXStoragePool> pools = getStoragePools(system);
for (VNXStoragePool vnxPool : pools) {
StoragePool pool = null;
URIQueryResultList results = new URIQueryResultList();
String poolNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, vnxPool.getPoolId(), NativeGUIDGenerator.POOL);
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePoolByNativeGuidConstraint(poolNativeGuid), results);
Iterator<URI> iter = results.iterator();
while (iter.hasNext()) {
StoragePool tmpPool = _dbClient.queryObject(StoragePool.class, iter.next());
if (tmpPool != null && !tmpPool.getInactive() && tmpPool.getStorageDevice().equals(system.getId())) {
pool = tmpPool;
_logger.info("Found StoragePool {} at {}", pool.getPoolName(), poolNativeGuid);
break;
}
}
if (pool == null) {
pool = new StoragePool();
pool.setId(URIUtil.createId(StoragePool.class));
pool.setLabel(poolNativeGuid);
pool.setNativeGuid(poolNativeGuid);
pool.setOperationalStatus(StoragePool.PoolOperationalStatus.READY.toString());
pool.setPoolServiceType(PoolServiceType.file.toString());
pool.setStorageDevice(system.getId());
pool.setProtocols(fileSharingProtocols);
pool.setNativeId(vnxPool.getPoolId());
pool.setPoolName(vnxPool.getName());
// Supported resource type indicates what type of file systems are supported.
if ("true".equalsIgnoreCase(vnxPool.getVirtualProv())) {
pool.setSupportedResourceTypes(StoragePool.SupportedResourceTypes.THICK_ONLY.toString());
} else {
pool.setSupportedResourceTypes(StoragePool.SupportedResourceTypes.THIN_AND_THICK.toString());
}
pool.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
_logger.info("Creating new storage pool using NativeGuid : {}", poolNativeGuid);
newPools.add(pool);
} else {
// Set protocols if it has changed between discoveries or a upgrade scenario
pool.setProtocols(fileSharingProtocols);
existingPools.add(pool);
}
long size = 0;
if (vnxPool.getDynamic().equals("true")) {
_logger.info("Using auto size for capacity.");
size = Long.parseLong(vnxPool.getAutoSize());
} else {
size = Long.parseLong(vnxPool.getSize());
}
pool.setTotalCapacity(size * BYTESCONV);
long used = Long.parseLong(vnxPool.getUsedSize()) * BYTESCONV;
long free = pool.getTotalCapacity() - used;
if (0 > free) {
free = 0;
}
pool.setFreeCapacity(free);
pool.setSubscribedCapacity(used);
if (ImplicitPoolMatcher.checkPoolPropertiesChanged(pool.getCompatibilityStatus(), DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name()) || ImplicitPoolMatcher.checkPoolPropertiesChanged(pool.getDiscoveryStatus(), DiscoveryStatus.VISIBLE.name())) {
poolsToMatchWithVpool.add(pool);
}
pool.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
pool.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
}
_logger.info("Number of pools found {} : ", storagePools.size());
} catch (NumberFormatException e) {
_logger.error("Data Format Exception: Discovery of storage pools failed for storage system {} for {}", system.getId(), e.getMessage());
VNXFileCollectionException vnxe = new VNXFileCollectionException("Storage pool discovery data error for storage system " + system.getId());
vnxe.initCause(e);
throw vnxe;
}
_logger.info("Storage pool discovery for storage system {} complete", system.getId());
for (StoragePool newPool : newPools) {
_logger.info("New Storage Pool : " + newPool);
_logger.info("New Storage Pool : {} : {}", newPool.getNativeGuid(), newPool.getId());
}
for (StoragePool pool : existingPools) {
_logger.info("Old Storage Pool : " + pool);
_logger.info("Old Storage Pool : {} : {}", pool.getNativeGuid(), pool.getId());
}
// return storagePools;
storagePools.put(this.NEW, newPools);
storagePools.put(this.EXISTING, existingPools);
return storagePools;
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class VNXUnityCommunicationInterface method discoverStoragePools.
/**
* Returns the list of storage pools for the specified VNX Unity storage
* system.
*
* @param system
* storage system information.
* @param client
* VNX Unity service client
* @param supportedProtocols
* calculated supportedProtocols for the array
* @return Map of New and Existing known storage pools.
* @throws VNXeException
*/
private Map<String, List<StoragePool>> discoverStoragePools(StorageSystem system, VNXeApiClient client, StringSet supportedProtocols, List<StoragePool> poolsToMatchWithVpool) throws VNXeException {
Map<String, List<StoragePool>> storagePools = new HashMap<String, List<StoragePool>>();
List<StoragePool> newPools = new ArrayList<StoragePool>();
List<StoragePool> existingPools = new ArrayList<StoragePool>();
_logger.info("Start storage pool discovery for storage system {}", system.getId());
try {
List<VNXePool> pools = client.getPools();
for (VNXePool vnxePool : pools) {
StoragePool pool = null;
URIQueryResultList results = new URIQueryResultList();
String poolNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, vnxePool.getId(), NativeGUIDGenerator.POOL);
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePoolByNativeGuidConstraint(poolNativeGuid), results);
boolean isModified = false;
Iterator<URI> it = results.iterator();
if (it.hasNext()) {
StoragePool tmpPool = _dbClient.queryObject(StoragePool.class, it.next());
if (tmpPool.getStorageDevice().equals(system.getId())) {
pool = tmpPool;
_logger.info("Found StoragePool {} at {}", pool.getPoolName(), poolNativeGuid);
}
}
if (pool == null) {
pool = new StoragePool();
pool.setId(URIUtil.createId(StoragePool.class));
pool.setLabel(poolNativeGuid);
pool.setNativeGuid(poolNativeGuid);
pool.setPoolServiceType(PoolServiceType.block_file.toString());
pool.setStorageDevice(system.getId());
pool.setNativeId(vnxePool.getId());
pool.setPoolName(vnxePool.getName());
pool.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
pool.setDiscoveryStatus(DiscoveredDataObject.DiscoveryStatus.VISIBLE.name());
// Supported resource type indicates what type of file
// systems are supported.
pool.setSupportedResourceTypes(StoragePool.SupportedResourceTypes.THIN_AND_THICK.toString());
pool.setPoolClassName(StoragePool.PoolClassNames.VNXe_Pool.name());
pool.setPoolServiceType(StoragePool.PoolServiceType.block_file.name());
pool.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
_logger.info("Creating new storage pool using NativeGuid : {}", poolNativeGuid);
newPools.add(pool);
} else {
// update pool attributes
_logger.info("updating the pool: {}", poolNativeGuid);
if (ImplicitPoolMatcher.checkPoolPropertiesChanged(pool.getProtocols(), supportedProtocols)) {
isModified = true;
}
existingPools.add(pool);
}
Health poolHealth = vnxePool.getHealth();
if (poolHealth != null) {
int value = poolHealth.getValue();
if (value == Health.HealthEnum.OK.getValue() || value == Health.HealthEnum.OK_BUT.getValue()) {
pool.setOperationalStatus(StoragePool.PoolOperationalStatus.READY.name());
} else {
pool.setOperationalStatus(StoragePool.PoolOperationalStatus.NOTREADY.name());
}
}
pool.setProtocols(supportedProtocols);
StringSet raidLevels = new StringSet();
RaidTypeEnum raid = vnxePool.getRaidTypeEnum();
if (raid != null) {
raidLevels.add(vnxePool.getRaidTypeEnum().name());
pool.setSupportedRaidLevels(raidLevels);
}
pool.setAutoTieringEnabled(getPoolAutoTieringEnabled(vnxePool, system));
List<PoolTier> poolTiers = vnxePool.getTiers();
StringSet diskTypes = new StringSet();
if (poolTiers != null) {
for (PoolTier poolTier : poolTiers) {
List<RaidGroup> raidGroups = poolTier.getRaidGroups();
if (raidGroups != null) {
for (RaidGroup raidGroup : raidGroups) {
VNXeBase diskGroup = raidGroup.getDiskGroup();
if (diskGroup != null) {
DiskGroup diskgroupObj = client.getDiskGroup(diskGroup.getId());
diskTypes.add(diskgroupObj.getDiskTechnologyEnum().name());
}
}
}
}
}
// Get drive types from disks
List<Disk> disks = client.getDisksForPool(vnxePool.getId());
if (disks != null) {
for (Disk disk : disks) {
if (disk.getDiskTechnologyEnum() != null) {
diskTypes.add(disk.getDiskTechnologyEnum().name());
}
}
}
pool.setSupportedDriveTypes(diskTypes);
double size = vnxePool.getSizeTotal();
if (size > 0) {
// Convert to kb
pool.setTotalCapacity(VNXeUtils.convertDoubleSizeToViPRLong(size));
}
long free = VNXeUtils.convertDoubleSizeToViPRLong(vnxePool.getSizeFree());
if (free > 0) {
pool.setFreeCapacity(free);
pool.setMaximumThinVolumeSize(free);
pool.setMaximumThickVolumeSize(free);
}
long subscribed = VNXeUtils.convertDoubleSizeToViPRLong(vnxePool.getSizeSubscribed());
pool.setSubscribedCapacity(subscribed);
if (isModified || ImplicitPoolMatcher.checkPoolPropertiesChanged(pool.getCompatibilityStatus(), DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name()) || ImplicitPoolMatcher.checkPoolPropertiesChanged(pool.getDiscoveryStatus(), DiscoveryStatus.VISIBLE.name())) {
poolsToMatchWithVpool.add(pool);
}
pool.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
pool.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
}
} catch (VNXeException e) {
_logger.error("Discovery of storage pools failed for storage system {} for {}", system.getId(), e.getMessage());
throw e;
}
for (StoragePool newPool : newPools) {
_logger.info("New Storage Pool : " + newPool);
_logger.info("New Storage Pool : {} : {}", newPool.getNativeGuid(), newPool.getId());
}
for (StoragePool pool : existingPools) {
_logger.info("Old Storage Pool : " + pool);
_logger.info("Old Storage Pool : {} : {}", pool.getNativeGuid(), pool.getId());
}
storagePools.put(NEW, newPools);
storagePools.put(EXISTING, existingPools);
_logger.info("Number of pools found {} : ", storagePools.size());
_logger.info("Storage pool discovery for storage system {} complete", system.getId());
return storagePools;
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class VNXUnityCommunicationInterface method discover.
/**
* Implementation for VNX Unity storage systems discovery, both of block and
* file
*
* @param accessProfile
*
* @throws VNXeException
*/
@Override
public void discover(AccessProfile accessProfile) throws VNXeException {
URI storageSystemURI = accessProfile.getSystemId();
StorageSystem viprStorageSystem = null;
String detailedStatusMessage = "Unknown Status";
try {
_logger.info("Access Profile Details : IpAddress : {}, PortNumber : {}", accessProfile.getIpAddress(), accessProfile.getPortNumber());
if (null != accessProfile.getnamespace() && (accessProfile.getnamespace().equals(StorageSystem.Discovery_Namespaces.UNMANAGED_VOLUMES.toString()) || accessProfile.getnamespace().equals(StorageSystem.Discovery_Namespaces.UNMANAGED_FILESYSTEMS.toString()))) {
discoverUnmanagedObjects(accessProfile);
} else {
// Get the VNX Unity storage system from the database.
viprStorageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemURI);
_logger.info(String.format("Discover VnxUnity storage system %s at IP:%s, PORT:%s", storageSystemURI.toString(), accessProfile.getIpAddress(), accessProfile.getPortNumber()));
// Get the vnx unity service client for getting information
// about the Vnx Unity storage system.
VNXeApiClient client = getVnxUnityClient(accessProfile);
_logger.debug("Got handle to Vnx unity service client");
// Get the serial number and the native guid and set into the
// storage system.
_logger.info("Discovering storage system properties.");
VNXeStorageSystem system = client.getStorageSystem();
boolean isFASTVPEnabled = client.isFASTVPEnabled();
viprStorageSystem = discoverStorageSystemInfo(client, accessProfile, system, isFASTVPEnabled, viprStorageSystem);
StringSet arraySupportedProtocols = new StringSet();
// Discover the NasServers
Map<String, URI> nasServerIdMap = new HashMap<String, URI>();
Map<String, List<StorageHADomain>> nasServers = discoverNasServers(viprStorageSystem, client, nasServerIdMap, arraySupportedProtocols);
_logger.info("No of newly discovered NasServers {}", nasServers.get(NEW).size());
_logger.info("No of existing discovered NasServers {}", nasServers.get(EXISTING).size());
if (!nasServers.get(NEW).isEmpty()) {
_dbClient.createObject(nasServers.get(NEW));
}
if (!nasServers.get(EXISTING).isEmpty()) {
_dbClient.updateObject(nasServers.get(EXISTING));
}
_completer.statusPending(_dbClient, "Completed NAS Server discovery");
// Discover FileInterfaces
List<StoragePort> allExistingPorts = new ArrayList<StoragePort>();
List<StoragePort> allNewPorts = new ArrayList<StoragePort>();
Map<String, List<StoragePort>> ports = discoverFileStoragePorts(viprStorageSystem, client, nasServerIdMap);
if (ports.get(NEW) != null && !ports.get(NEW).isEmpty()) {
allNewPorts.addAll(ports.get(NEW));
_dbClient.createObject(ports.get(NEW));
}
if (ports.get(EXISTING) != null && !ports.get(EXISTING).isEmpty()) {
allExistingPorts.addAll(ports.get(EXISTING));
_dbClient.updateObject(ports.get(EXISTING));
}
_completer.statusPending(_dbClient, "Completed file ports discovery");
// discover storage processors
Map<String, URI> spIdMap = new HashMap<String, URI>();
Map<String, List<StorageHADomain>> sps = discoverStorageProcessors(viprStorageSystem, client, spIdMap);
if (!sps.get(NEW).isEmpty()) {
_dbClient.createObject(sps.get(NEW));
}
if (!sps.get(EXISTING).isEmpty()) {
_dbClient.updateObject(sps.get(EXISTING));
}
_completer.statusPending(_dbClient, "Completed storage processor discovery");
// discover iscsi ports
Map<String, List<StoragePort>> iscsiPorts = discoverIscsiPorts(viprStorageSystem, client, spIdMap);
boolean hasIscsiPorts = false;
if (iscsiPorts.get(NEW) != null && !iscsiPorts.get(NEW).isEmpty()) {
allNewPorts.addAll(iscsiPorts.get(NEW));
hasIscsiPorts = true;
_dbClient.createObject(iscsiPorts.get(NEW));
}
if (iscsiPorts.get(EXISTING) != null && !iscsiPorts.get(EXISTING).isEmpty()) {
allExistingPorts.addAll(iscsiPorts.get(EXISTING));
hasIscsiPorts = true;
_dbClient.updateObject(iscsiPorts.get(EXISTING));
}
if (hasIscsiPorts) {
arraySupportedProtocols.add(StorageProtocol.Block.iSCSI.name());
}
_completer.statusPending(_dbClient, "Completed iscsi ports discovery");
// discover fc ports
Map<String, List<StoragePort>> fcPorts = discoverFcPorts(viprStorageSystem, client, spIdMap);
boolean hasFcPorts = false;
if (fcPorts.get(NEW) != null && !fcPorts.get(NEW).isEmpty()) {
allNewPorts.addAll(fcPorts.get(NEW));
hasFcPorts = true;
_dbClient.createObject(fcPorts.get(NEW));
}
if (fcPorts.get(EXISTING) != null && !fcPorts.get(EXISTING).isEmpty()) {
allExistingPorts.addAll(fcPorts.get(EXISTING));
hasFcPorts = true;
_dbClient.updateObject(fcPorts.get(EXISTING));
}
if (hasFcPorts) {
arraySupportedProtocols.add(StorageProtocol.Block.FC.name());
}
_completer.statusPending(_dbClient, "Completed FC ports discovery");
List<StoragePort> allPorts = new ArrayList<StoragePort>(allNewPorts);
allPorts.addAll(allExistingPorts);
// check if any port not visible in this discovery
List<StoragePort> notVisiblePorts = DiscoveryUtils.checkStoragePortsNotVisible(allPorts, _dbClient, viprStorageSystem.getId());
if (notVisiblePorts != null && !notVisiblePorts.isEmpty()) {
allExistingPorts.addAll(notVisiblePorts);
}
/**
* Discover the VNX Unity pool information.
*/
_logger.info("Discovering storage pools.");
List<StoragePool> poolsToMatchWithVpool = new ArrayList<StoragePool>();
List<StoragePool> allPools = new ArrayList<StoragePool>();
Map<String, List<StoragePool>> pools = discoverStoragePools(viprStorageSystem, client, arraySupportedProtocols, poolsToMatchWithVpool);
_logger.info("No of newly discovered pools {}", pools.get(NEW).size());
_logger.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));
StoragePoolAssociationHelper.setStoragePoolVarrays(viprStorageSystem.getId(), pools.get(NEW), _dbClient);
}
if (!pools.get(EXISTING).isEmpty()) {
allPools.addAll(pools.get(EXISTING));
_dbClient.updateObject(pools.get(EXISTING));
}
List<StoragePool> notVisiblePools = DiscoveryUtils.checkStoragePoolsNotVisible(allPools, _dbClient, viprStorageSystem.getId());
if (notVisiblePools != null && !notVisiblePools.isEmpty()) {
poolsToMatchWithVpool.addAll(notVisiblePools);
}
StoragePortAssociationHelper.runUpdatePortAssociationsProcess(allNewPorts, allExistingPorts, _dbClient, _coordinator, poolsToMatchWithVpool);
_completer.statusPending(_dbClient, "Completed pool discovery");
// This associates the VNas with the virtual array
StoragePortAssociationHelper.runUpdateVirtualNasAssociationsProcess(allExistingPorts, null, _dbClient);
_logger.info("update virtual nas association for unity");
if (isFASTVPEnabled) {
_logger.info("FASTVP is enabled");
HashMap<String, List<AutoTieringPolicy>> policies = discoverAutoTierPolicies(viprStorageSystem, client);
if (!policies.get(NEW).isEmpty()) {
_dbClient.createObject(policies.get(NEW));
}
if (!policies.get(EXISTING).isEmpty()) {
_dbClient.updateObject(policies.get(EXISTING));
}
HashMap<String, List<StorageTier>> tiers = discoverStorageTier(viprStorageSystem, client);
if (!tiers.get(NEW).isEmpty()) {
_dbClient.createObject(tiers.get(NEW));
}
if (!tiers.get(EXISTING).isEmpty()) {
_dbClient.updateObject(tiers.get(EXISTING));
}
}
detailedStatusMessage = String.format("Discovery completed successfully for Storage System: %s", storageSystemURI.toString());
}
} catch (Exception e) {
detailedStatusMessage = String.format("Discovery failed for VNX Unity %s: %s", storageSystemURI.toString(), e.getLocalizedMessage());
_logger.error(detailedStatusMessage, e);
throw VNXeException.exceptions.discoveryError("Discovery error", e);
} finally {
if (viprStorageSystem != null) {
try {
// set detailed message
viprStorageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
_dbClient.updateObject(viprStorageSystem);
} catch (DatabaseException ex) {
_logger.error("Error while persisting object to DB", ex);
}
}
}
}
Aggregations