use of com.emc.storageos.db.client.model.VirtualNAS in project coprhd-controller by CoprHD.
the class PortMetricsProcessor method dataMoverAvgPortMetrics.
/**
* Compute DataMover or Virtual Data Mover average port metrics. The answer is in percent.
* This is averaged over all the usable port in a VirtualNAS .The Computed
* value get stored in DB.
*
* @param storageSystemURI -- URI for the storage system.
*/
public void dataMoverAvgPortMetrics(URI storageSystemURI) {
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemURI);
StringSet storagePorts = null;
Double portPercentBusy = 0.0;
Double avgPortPercentBusy = 0.0;
Double percentBusy = 0.0;
Double avgPercentBusy = 0.0;
int noOfInterface = 0;
if (storageSystem != null) {
URIQueryResultList vNASURIs = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceVirtualNasConstraint(storageSystemURI), vNASURIs);
Iterator<VirtualNAS> virtualNASIterator = _dbClient.queryIterativeObjects(VirtualNAS.class, vNASURIs);
while (virtualNASIterator.hasNext()) {
VirtualNAS vNAS = virtualNASIterator.next();
if (vNAS != null && !vNAS.getInactive()) {
storagePorts = vNAS.getStoragePorts();
if (storagePorts != null && !storagePorts.isEmpty()) {
for (String sp : storagePorts) {
StoragePort storagePort = _dbClient.queryObject(StoragePort.class, URI.create(sp));
portPercentBusy = portPercentBusy + MetricsKeys.getDouble(MetricsKeys.avgPortPercentBusy, storagePort.getMetrics());
percentBusy = percentBusy + MetricsKeys.getDouble(MetricsKeys.avgPercentBusy, storagePort.getMetrics());
}
noOfInterface = storagePorts.size();
if (noOfInterface != 0) {
avgPortPercentBusy = portPercentBusy / noOfInterface;
avgPercentBusy = percentBusy / noOfInterface;
}
StringMap dbMetrics = vNAS.getMetrics();
MetricsKeys.putDouble(MetricsKeys.avgPortPercentBusy, avgPortPercentBusy, dbMetrics);
MetricsKeys.putDouble(MetricsKeys.avgPercentBusy, avgPercentBusy, dbMetrics);
_dbClient.updateObject(vNAS);
}
}
}
}
}
use of com.emc.storageos.db.client.model.VirtualNAS in project coprhd-controller by CoprHD.
the class VNXFileSystemStaticLoadProcessor method prepareDBMetrics.
/**
* get the DB metrics for each data mover or VDM
*
* @param storageSystem
* @param dbClient
* @param dmFsMountMap
* @param dmCapacityMap
* @param vdmFsMountMap
* @param vdmCapacityMap
*/
private void prepareDBMetrics(StorageSystem storageSystem, DbClient dbClient, final Map<String, List<String>> dmFsMountMap, final Map<String, Long> dmCapacityMap, final Map<String, List<String>> vdmFsMountMap, final Map<String, Long> vdmCapacityMap) {
List<VirtualNAS> modifiedVNas = new ArrayList<VirtualNAS>();
List<PhysicalNAS> modifiedPNas = new ArrayList<PhysicalNAS>();
for (Entry<String, List<String>> eachNas : dmFsMountMap.entrySet()) {
_logger.info(" Computing metrics for data mover {} ", eachNas.getKey());
// Get Physical NAS from db!!
PhysicalNAS pNAS = findPhysicalNasByNativeId(storageSystem, dbClient, eachNas.getKey());
List<VirtualNAS> vNasList = new ArrayList<VirtualNAS>();
if (null != pNAS) {
URIQueryResultList virtualNASUris = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getVirtualNASByParentConstraint(pNAS.getId()), virtualNASUris);
Long totalDmObjects = 0L;
Long totalDmCapacity = 0L;
Iterator<URI> virtualNASIter = virtualNASUris.iterator();
while (virtualNASIter.hasNext()) {
// Get Each vNAS on Physical NAS
VirtualNAS virtualNAS = dbClient.queryObject(VirtualNAS.class, virtualNASIter.next());
if (virtualNAS != null && !virtualNAS.getInactive()) {
vNasList.add(virtualNAS);
int vNasObjects = 0;
if (vdmFsMountMap.get(virtualNAS.getNativeId()) != null) {
vNasObjects = vdmFsMountMap.get(virtualNAS.getNativeId()).size();
totalDmObjects = totalDmObjects + vNasObjects;
}
Long vNasCapacity = 0L;
if (vdmCapacityMap.get(virtualNAS.getNativeId()) != null) {
vNasCapacity = vdmCapacityMap.get(virtualNAS.getNativeId());
totalDmCapacity = totalDmCapacity + vNasCapacity;
}
// Update dbMetrics for vNAS!!
StringMap vNasDbMetrics = virtualNAS.getMetrics();
vNasDbMetrics.put(MetricsKeys.storageObjects.name(), String.valueOf(vNasObjects));
vNasDbMetrics.put(MetricsKeys.usedStorageCapacity.name(), String.valueOf(vNasCapacity));
modifiedVNas.add(virtualNAS);
}
}
if (dmFsMountMap.get(pNAS.getNativeId()) != null) {
totalDmObjects = totalDmObjects + dmFsMountMap.get(pNAS.getNativeId()).size();
}
if (dmCapacityMap.get(pNAS.getNativeId()) != null) {
totalDmCapacity = totalDmCapacity + dmCapacityMap.get(pNAS.getNativeId());
}
for (VirtualNAS vNas : vNasList) {
// Update dbMetrics for vNAS!!
StringMap vNasDbMetrics = vNas.getMetrics();
long StorageObj = MetricsKeys.getLong(MetricsKeys.storageObjects, vNas.getMetrics());
double percentageLoad = ((double) StorageObj / totalDmObjects) * 100;
vNasDbMetrics.put(MetricsKeys.percentLoad.name(), String.valueOf(percentageLoad));
}
StringMap pNasDbMetrics = pNAS.getMetrics();
pNasDbMetrics.put(MetricsKeys.storageObjects.name(), String.valueOf(totalDmObjects));
pNasDbMetrics.put(MetricsKeys.usedStorageCapacity.name(), String.valueOf(totalDmCapacity));
long maxObjects = MetricsKeys.getLong(MetricsKeys.maxStorageObjects, pNasDbMetrics);
long maxCapacity = MetricsKeys.getLong(MetricsKeys.maxStorageCapacity, pNasDbMetrics);
double percentageLoad = ((double) totalDmObjects / maxObjects) * 100;
pNasDbMetrics.put(MetricsKeys.percentLoad.name(), String.valueOf(percentageLoad));
if (totalDmObjects >= maxObjects || totalDmCapacity >= maxCapacity) {
pNasDbMetrics.put(MetricsKeys.overLoaded.name(), "true");
// All vNas under should be updated!!!
for (VirtualNAS vNas : vNasList) {
// Update dbMetrics for vNAS!!
StringMap vNasDbMetrics = vNas.getMetrics();
vNasDbMetrics.put(MetricsKeys.overLoaded.name(), "true");
}
} else {
pNasDbMetrics.put(MetricsKeys.overLoaded.name(), "false");
// All vNas under should be updated!!!
for (VirtualNAS vNas : vNasList) {
// Update dbMetrics for vNAS!!
StringMap vNasDbMetrics = vNas.getMetrics();
vNasDbMetrics.put(MetricsKeys.overLoaded.name(), "false");
}
}
modifiedPNas.add(pNAS);
}
// Update the db
if (!modifiedVNas.isEmpty()) {
dbClient.persistObject(modifiedVNas);
}
if (!modifiedPNas.isEmpty()) {
dbClient.persistObject(modifiedPNas);
}
}
return;
}
use of com.emc.storageos.db.client.model.VirtualNAS in project coprhd-controller by CoprHD.
the class FileStorageScheduler method getUnassignedVNASServers.
/**
* Get list of unassigned VNAS servers
*
* @param vArrayURI
* @param vpool
* @return vNASList
*/
private List<VirtualNAS> getUnassignedVNASServers(URI vArrayURI, VirtualPool vpool, Project project, List<VirtualNAS> invalidNasServers) {
_log.info("Get vNAS servers from the unreserved list...");
_log.info("Get vNAS servers from the unreserved list...");
List<VirtualNAS> vNASList = new ArrayList<VirtualNAS>();
_log.debug("Get VNAS servers in the vArray {}", vArrayURI);
List<URI> vNASURIList = _dbClient.queryByConstraint(ContainmentConstraint.Factory.getVirtualNASInVirtualArrayConstraint(vArrayURI));
vNASList = _dbClient.queryObject(VirtualNAS.class, vNASURIList);
if (vNASList != null && !vNASList.isEmpty()) {
Set<String> projectDomains = ProjectUtility.getDomainsOfProject(permissionsHelper, project);
for (Iterator<VirtualNAS> iterator = vNASList.iterator(); iterator.hasNext(); ) {
VirtualNAS vNAS = iterator.next();
_log.info("Checking vNAS - {} : {}", vNAS.getNasName(), vNAS.getId());
if (!isVNASActive(vNAS)) {
_log.info("Removing vNAS {} as it is inactive", vNAS.getNasName());
iterator.remove();
invalidNasServers.add(vNAS);
} else if (MetricsKeys.getBoolean(MetricsKeys.overLoaded, vNAS.getMetrics())) {
_log.info("Removing vNAS {} as it is overloaded", vNAS.getNasName());
iterator.remove();
invalidNasServers.add(vNAS);
} else if (!vNAS.getProtocols().containsAll(vpool.getProtocols())) {
_log.info("Removing vNAS {} as it does not support vpool protocols: {}", vNAS.getNasName(), vpool.getProtocols());
iterator.remove();
invalidNasServers.add(vNAS);
} else if (!vNAS.isNotAssignedToProject()) {
if (project != null && !vNAS.getAssociatedProjects().contains(project.getId())) {
_log.info("Removing vNAS {} as it is assigned to project", vNAS.getNasName());
iterator.remove();
invalidNasServers.add(vNAS);
}
} else if (!ProjectUtility.doesProjectDomainMatchesWithVNASDomain(projectDomains, vNAS)) {
_log.info("Removing vNAS {} as its domain does not match with project's domain: {}", vNAS.getNasName(), projectDomains);
iterator.remove();
invalidNasServers.add(vNAS);
}
}
}
if (vNASList != null) {
_log.info("Got {} un-assigned vNas servers in the vArray {}", vNASList.size(), vArrayURI);
}
return vNASList;
}
use of com.emc.storageos.db.client.model.VirtualNAS in project coprhd-controller by CoprHD.
the class FileStorageScheduler method placeFileShare.
/**
* Schedule storage for fileshare in the varray with the given CoS
* capabilities.
*
* @param vArray
* @param vPool
* @param capabilities
* @param project
* @return list of recommended storage ports for VNAS
*/
public List<FileRecommendation> placeFileShare(VirtualArray vArray, VirtualPool vPool, VirtualPoolCapabilityValuesWrapper capabilities, Project project, Map<String, Object> optionalAttributes) {
_log.debug("Schedule storage for {} resource(s) of size {}.", capabilities.getResourceCount(), capabilities.getSize());
// create map object if null, it used to receive the error message
if (optionalAttributes == null) {
optionalAttributes = new HashMap<String, Object>();
}
if (capabilities.getFileProtectionSourceStorageDevice() != null || capabilities.getTargetStorageSystem() != null) {
Set<String> storageSystemSet = new HashSet<String>();
if (capabilities.getFileProtectionSourceStorageDevice() != null) {
storageSystemSet.add(capabilities.getFileProtectionSourceStorageDevice().toString());
} else if (capabilities.getTargetStorageSystem() != null) {
storageSystemSet.add(capabilities.getTargetStorageSystem().toString());
}
optionalAttributes.put(AttributeMatcher.Attributes.storage_system.name(), storageSystemSet);
}
// Get all storage pools that match the passed vpool params and
// protocols. In addition, the pool must have enough capacity
// to hold at least one resource of the requested size.
List<StoragePool> candidatePools = _scheduler.getMatchingPools(vArray, vPool, capabilities, optionalAttributes);
if (CollectionUtils.isEmpty(candidatePools)) {
StringBuffer errorMessage = new StringBuffer();
if (optionalAttributes.get(AttributeMatcher.ERROR_MESSAGE) != null) {
errorMessage = (StringBuffer) optionalAttributes.get(AttributeMatcher.ERROR_MESSAGE);
}
throw APIException.badRequests.noStoragePools(vArray.getLabel(), vPool.getLabel(), errorMessage.toString());
}
// Holds the invalid virtual nas servers from both
// assigned and un-assigned list.
// the invalid vnas server clould be
// over loaded or protocol not supported or
// the ports from these invalid vnas servers
// should not be considered for file provisioning!!!
List<VirtualNAS> invalidNasServers = new ArrayList<VirtualNAS>();
boolean provisioningOnVirtualNAS = true;
VirtualNAS sourcevNAsServer = null;
if (capabilities.getPersonality() != null && capabilities.getPersonality().equalsIgnoreCase(VirtualPoolCapabilityValuesWrapper.FILE_REPLICATION_TARGET)) {
// Get the source nas server, if no source vnas server, then need storage from physical nas server!!
URI sourceVNas = capabilities.getSourceVirtualNasServer();
if (sourceVNas == null) {
provisioningOnVirtualNAS = false;
} else {
sourcevNAsServer = _dbClient.queryObject(VirtualNAS.class, sourceVNas);
if (sourcevNAsServer == null || sourcevNAsServer.getInactive()) {
provisioningOnVirtualNAS = false;
}
}
}
List<FileRecommendation> fileRecommendations = new ArrayList<FileRecommendation>();
List<FileRecommendation> recommendations = null;
if (provisioningOnVirtualNAS) {
// Get the recommendation based on virtual nas servers
Map<VirtualNAS, List<StoragePool>> vNASPoolMap = getRecommendedVirtualNASBasedOnCandidatePools(vPool, vArray.getId(), candidatePools, project, invalidNasServers);
VirtualNAS currvNAS = null;
if (!vNASPoolMap.isEmpty()) {
for (Entry<VirtualNAS, List<StoragePool>> eachVNASEntry : vNASPoolMap.entrySet()) {
// If No storage pools recommended!!!
if (eachVNASEntry.getValue().isEmpty()) {
continue;
}
currvNAS = eachVNASEntry.getKey();
if (currvNAS != null) {
if (capabilities.getPersonality() != null && capabilities.getPersonality().equalsIgnoreCase(VirtualPoolCapabilityValuesWrapper.FILE_REPLICATION_TARGET)) {
if (sourcevNAsServer != null && sourcevNAsServer.getBaseDirPath().equalsIgnoreCase(currvNAS.getBaseDirPath())) {
_log.info("Target Nas server path {} is similar to source nas server {}, so considering this nas server", currvNAS.getBaseDirPath(), sourcevNAsServer.getBaseDirPath());
} else if (capabilities.getTargetNasServer() != null && capabilities.getTargetNasServer().equals(currvNAS.getId())) {
_log.info("Nas server {} is same as required target Nas server {}, so considering this nas server", currvNAS.getId(), capabilities.getTargetNasServer());
} else {
_log.info("Nas server {} is not the required target Nas server, so ignoring this nas server", currvNAS.getId());
continue;
}
}
_log.info("Best vNAS selected: {}", currvNAS.getNasName());
List<StoragePool> recommendedPools = eachVNASEntry.getValue();
// Get the recommendations for the current vnas pools.
List<Recommendation> poolRecommendations = _scheduler.getRecommendationsForPools(vArray.getId().toString(), recommendedPools, capabilities);
// Pick the pools from next available vNas recommended pools!!!
if (poolRecommendations.isEmpty()) {
_log.info("Skipping vNAS {}, as pools are not having enough resources", currvNAS.getNasName());
continue;
}
// Get the file recommendations for pool recommendation!!!
recommendations = getFileRecommendationsForVNAS(currvNAS, vArray.getId(), vPool, poolRecommendations);
if (!recommendations.isEmpty()) {
fileRecommendations.addAll(recommendations);
if (!capabilities.isVpoolProjectPolicyAssign() && !capabilities.getAllSourceRecommnedations()) {
_log.info("Selected vNAS {} for placement", currvNAS.getNasName());
break;
} else {
// Policy assignment required to create the policy on all applicable vNAS servers!!!
_log.info(" vNAS {} for Added to the list of recommendations", currvNAS.getNasName());
}
}
}
}
}
}
// Get the file recommendations
if (fileRecommendations == null || fileRecommendations.isEmpty() || capabilities.isVpoolProjectPolicyAssign() || capabilities.getAllSourceRecommnedations() || isTargetRequiredOnPhyscialNAS(capabilities)) {
// Get the recommendations for the candidate pools.
_log.info("Placement on HADomain matching pools");
List<Recommendation> poolRecommendations = _scheduler.getRecommendationsForPools(vArray.getId().toString(), candidatePools, capabilities);
recommendations = selectStorageHADomainMatchingVpool(vPool, vArray.getId(), poolRecommendations, invalidNasServers);
if (recommendations != null && !recommendations.isEmpty()) {
if (fileRecommendations != null) {
fileRecommendations.addAll(recommendations);
}
}
}
// log an error and clear the list of recommendations.
if (fileRecommendations == null || fileRecommendations.isEmpty()) {
_log.error("Could not find matching pools for virtual array {} & vpool {}", vArray.getId(), vPool.getId());
} else {
// add code for file for default recommendations for file data
for (FileRecommendation recommendation : fileRecommendations) {
FileRecommendation fileRecommendation = recommendation;
fileRecommendation.setFileType(FileType.FILE_SYSTEM_DATA);
StorageSystem system = _dbClient.queryObject(StorageSystem.class, recommendation.getSourceStorageSystem());
fileRecommendation.setDeviceType(system.getSystemType());
}
}
return fileRecommendations;
}
use of com.emc.storageos.db.client.model.VirtualNAS in project coprhd-controller by CoprHD.
the class DiscoveryUtils method checkVirtualNasNotVisible.
/**
* checkVirtualNasNotVisible - verifies that all existing virtual nas servers on
* given storage system are discovered or not.
* If any of the existing virtual nas server is not discovered,
* Change the discovered status as not visible.
*
* @param discoveredVNasServers
* @param dbClient
* @param storageSystemId
* @return
* @throws IOException
*/
public static List<VirtualNAS> checkVirtualNasNotVisible(List<VirtualNAS> discoveredVNasServers, DbClient dbClient, URI storageSystemId) {
List<VirtualNAS> modifiedVNas = new ArrayList<VirtualNAS>();
// Get the vnas servers previousy discovered
URIQueryResultList vNasURIs = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceVirtualNasConstraint(storageSystemId), vNasURIs);
Iterator<URI> vNasIter = vNasURIs.iterator();
List<URI> existingVNasURI = new ArrayList<URI>();
while (vNasIter.hasNext()) {
existingVNasURI.add(vNasIter.next());
}
List<URI> discoveredVNasURI = new ArrayList<URI>();
for (VirtualNAS vNas : discoveredVNasServers) {
discoveredVNasURI.add(vNas.getId());
}
Set<URI> vNasDiff = Sets.difference(new HashSet<URI>(existingVNasURI), new HashSet<URI>(discoveredVNasURI));
if (!vNasDiff.isEmpty()) {
Iterator<VirtualNAS> vNasIt = dbClient.queryIterativeObjects(VirtualNAS.class, vNasDiff, true);
while (vNasIt.hasNext()) {
VirtualNAS vnas = vNasIt.next();
modifiedVNas.add(vnas);
_log.info("Setting discovery status of vnas {} as NOTVISIBLE", vnas.getNasName());
vnas.setDiscoveryStatus(DiscoveredDataObject.DiscoveryStatus.NOTVISIBLE.name());
// Set the nas state to UNKNOWN!!!
vnas.setNasState(VirtualNAS.VirtualNasState.UNKNOWN.name());
}
}
// Persist the change!!!
if (!modifiedVNas.isEmpty()) {
dbClient.persistObject(modifiedVNas);
}
return modifiedVNas;
}
Aggregations