use of com.emc.storageos.db.client.model.PhysicalNAS in project coprhd-controller by CoprHD.
the class FileOrchestrationDeviceController method addStepsForApplyingPolicies.
public String addStepsForApplyingPolicies(Workflow workflow, String waitFor, List<FileDescriptor> fileDescriptors) {
FileDescriptor sourceDescriptors = FileDescriptor.filterByType(fileDescriptors, FileDescriptor.Type.FILE_DATA, FileDescriptor.Type.FILE_MIRROR_SOURCE).get(0);
FileShare sourceFS = s_dbClient.queryObject(FileShare.class, sourceDescriptors.getFsURI());
StorageSystem system = s_dbClient.queryObject(StorageSystem.class, sourceFS.getStorageDevice());
// applying policy is only supported by isilon
if (system != null && system.getSystemType().equalsIgnoreCase(Type.isilon.toString())) {
URI nasServer = null;
if (sourceFS.getVirtualNAS() != null) {
nasServer = sourceFS.getVirtualNAS();
} else {
// Get the physical NAS for the storage system!!
PhysicalNAS pNAS = FileOrchestrationUtils.getSystemPhysicalNAS(s_dbClient, system);
if (pNAS != null) {
nasServer = pNAS.getId();
}
}
if (nasServer == null) {
s_logger.error(String.format("Adding steps to apply policies failed : No Nas server found on system {}", system.getLabel()));
throw DeviceControllerException.exceptions.noNasServerFoundToAddStepsToApplyPolicy(system.getLabel());
}
// Add all the vpool and project level policies to the workflow steps.
// Verify the policy is already applied or not at device control level.
// Create storage device policy only if the policy was not applied for policy path on storage system!!
// Fail to create policy and/or file system, if any policy to be applied at path is invalid!!
VirtualPool vpool = s_dbClient.queryObject(VirtualPool.class, sourceFS.getVirtualPool());
List<FilePolicy> fileVpoolPolicies = getVpoolLevelPolices(vpool);
if (fileVpoolPolicies != null && !fileVpoolPolicies.isEmpty()) {
for (FilePolicy fileVpoolPolicy : fileVpoolPolicies) {
String stepDescription = String.format("creating file policy : %s at : %s level", fileVpoolPolicy.getId(), vpool.getLabel());
String applyFilePolicyStep = workflow.createStepId();
Object[] args = new Object[] { sourceFS.getStorageDevice(), sourceFS.getId(), fileVpoolPolicy.getId() };
waitFor = _fileDeviceController.createMethod(workflow, waitFor, APPLY_FILE_POLICY_METHOD, applyFilePolicyStep, stepDescription, system.getId(), args);
}
}
Project project = s_dbClient.queryObject(Project.class, sourceFS.getProject());
List<FilePolicy> fileProjectPolicies = getProjectLevelPolices(vpool, project);
if (fileProjectPolicies != null && !fileProjectPolicies.isEmpty()) {
for (FilePolicy fileProjectPolicy : fileProjectPolicies) {
String stepDescription = String.format("creating file policy : %s at : %s level", fileProjectPolicy.getId(), project.getLabel());
String applyFilePolicyStep = workflow.createStepId();
Object[] args = new Object[] { sourceFS.getStorageDevice(), sourceFS.getId(), fileProjectPolicy.getId() };
waitFor = _fileDeviceController.createMethod(workflow, waitFor, APPLY_FILE_POLICY_METHOD, applyFilePolicyStep, stepDescription, system.getId(), args);
}
}
}
return waitFor;
}
use of com.emc.storageos.db.client.model.PhysicalNAS in project coprhd-controller by CoprHD.
the class FileOrchestrationUtils method getSystemPhysicalNAS.
/**
* Get the physical nas server for storage system
*
* @param dbClient
* @param system
* @return
*/
public static PhysicalNAS getSystemPhysicalNAS(DbClient dbClient, StorageSystem system) {
List<URI> nasServers = dbClient.queryByType(PhysicalNAS.class, true);
List<PhysicalNAS> phyNasServers = dbClient.queryObject(PhysicalNAS.class, nasServers);
for (PhysicalNAS nasServer : phyNasServers) {
if (nasServer.getStorageDeviceURI().toString().equalsIgnoreCase(system.getId().toString())) {
return nasServer;
}
}
return null;
}
use of com.emc.storageos.db.client.model.PhysicalNAS in project coprhd-controller by CoprHD.
the class VNXFileCommunicationInterface method discoverPorts.
/**
* Retrieve the Data Mover IP Interfaces (aka Storage Ports) for the specified VNX File Storage Array
*
* @param system storage system information including credentials.
* @return Map of New and Existing Storage Ports
* @throws VNXFileCollectionException
* @throws IOException
*/
private HashMap<String, List<StoragePort>> discoverPorts(StorageSystem system, Set<StorageHADomain> movers) throws VNXFileCollectionException, VNXException, IOException {
HashMap<String, List<StoragePort>> storagePorts = new HashMap<String, List<StoragePort>>();
List<StoragePort> newStoragePorts = new ArrayList<StoragePort>();
List<StoragePort> existingStoragePorts = new ArrayList<StoragePort>();
List<PhysicalNAS> modifiedServers = new ArrayList<PhysicalNAS>();
_logger.info("Start storage port discovery for storage system {}", system.getId());
// Retrieve the list of data movers interfaces for the VNX File device.
List<VNXDataMoverIntf> allDmIntfs = getPorts(system);
List<VNXVdm> vdms = getVdmPortGroups(system);
// Filter VDM ports
List<VNXDataMoverIntf> dataMovers = null;
Map<String, VNXDataMoverIntf> dmIntMap = new HashMap();
for (VNXDataMoverIntf intf : allDmIntfs) {
_logger.info("getPorts Adding {} : {}", intf.getName(), intf.getIpAddress());
dmIntMap.put(intf.getName(), intf);
}
// Changes to fix Jira CTRL - 9151
VNXFileSshApi sshDmApi = new VNXFileSshApi();
sshDmApi.setConnParams(system.getIpAddress(), system.getUsername(), system.getPassword());
// collect VDM interfaces
for (VNXVdm vdm : vdms) {
// Sometimes getVdmPortGroups(system) method does not collect all VDM interfaces,
// So running Collect NFS/CIFS interfaces from nas_server -info command. This will return
// Interfaces assigned to VDM and not thru CIFS servers
Map<String, String> vdmIntfs = sshDmApi.getVDMInterfaces(vdm.getVdmName());
for (String vdmIF : vdmIntfs.keySet()) {
_logger.info("Remove VDM interface {}", vdmIF);
dmIntMap.remove(vdmIF);
}
}
// Got the filtered out DataMover Interfaces
List<VNXDataMoverIntf> dmIntfs = new ArrayList(dmIntMap.values());
_logger.info("Number unfiltered mover interfaces found: {}", allDmIntfs.size());
_logger.info("Number mover interfaces found: {}", dmIntfs.size());
// Create the list of storage ports.
for (VNXDataMoverIntf intf : dmIntfs) {
StoragePort port = null;
StorageHADomain matchingHADomain = getMatchingMoverById(movers, intf.getDataMoverId());
// Check for valid data mover
if (null == matchingHADomain) {
continue;
}
// Check if storage port was already discovered
String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, intf.getIpAddress(), NativeGUIDGenerator.PORT);
port = findExistingPort(portNativeGuid);
if (null == port) {
// Since a port was not found, attempt with previous naming convention (ADAPTER instead of PORT)
String oldNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, intf.getIpAddress(), NativeGUIDGenerator.ADAPTER);
port = findExistingPort(oldNativeGuid);
if (null != port) {
// found with old naming convention, therefore update name.
port.setLabel(portNativeGuid);
port.setNativeGuid(portNativeGuid);
}
}
// If data mover interface was not previously discovered, add new storage port
if (port == null) {
port = new StoragePort();
port.setId(URIUtil.createId(StoragePort.class));
port.setLabel(portNativeGuid);
port.setTransportType("IP");
port.setNativeGuid(portNativeGuid);
port.setStorageDevice(system.getId());
port.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
port.setPortName(intf.getName());
port.setPortNetworkId(intf.getIpAddress());
port.setPortGroup(intf.getDataMoverId());
port.setStorageHADomain(matchingHADomain.getId());
_logger.info("Creating new storage port using NativeGuid : {} name : {}, IP : {}", new Object[] { portNativeGuid, intf.getName(), intf.getIpAddress() });
newStoragePorts.add(port);
} else {
port.setStorageHADomain(matchingHADomain.getId());
existingStoragePorts.add(port);
}
port.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
port.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
// Set storage port details to vNas
PhysicalNAS nas = findPhysicalNasByNativeId(system, intf.getDataMoverId());
if (nas != null) {
if (nas.getStoragePorts() != null && !nas.getStoragePorts().isEmpty()) {
if (nas.getStoragePorts().contains(port.getId())) {
nas.getStoragePorts().remove(port.getId());
}
}
nas.getStoragePorts().add(port.getId().toString());
modifiedServers.add(nas);
_logger.info("PhysicalNAS : {} : port : {} got modified", nas.getId(), port.getPortName());
}
}
// Persist the changed nas servers!!!
if (modifiedServers != null && !modifiedServers.isEmpty()) {
_logger.info("Modified PhysicalNAS servers size {}", modifiedServers.size());
_dbClient.persistObject(modifiedServers);
}
_logger.info("Storage port discovery for storage system {} complete", system.getId());
for (StoragePort newPort : newStoragePorts) {
_logger.info("New Storage Port : {} : {}", newPort.getNativeGuid(), newPort.getPortName() + ":" + newPort.getId());
}
for (StoragePort port : existingStoragePorts) {
_logger.info("Old Storage Port : {} : {}", port.getNativeGuid(), port.getPortName() + ":" + port.getId());
}
storagePorts.put(NEW, newStoragePorts);
storagePorts.put(EXISTING, existingStoragePorts);
return storagePorts;
}
use of com.emc.storageos.db.client.model.PhysicalNAS 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.PhysicalNAS in project coprhd-controller by CoprHD.
the class SystemsMapper method map.
public static VirtualNASRestRep map(VirtualNAS from, DbClient dbClient) {
if (from == null) {
return null;
}
VirtualNASRestRep to = new VirtualNASRestRep();
mapDiscoveredDataObjectFields(from, to);
to.setAssignedVirtualArrays(from.getAssignedVirtualArrays());
to.setBaseDirPath(from.getBaseDirPath());
to.setCompatibilityStatus(from.getCompatibilityStatus());
to.setConnectedVirtualArrays(from.getConnectedVirtualArrays());
to.setDiscoveryStatus(from.getDiscoveryStatus());
to.setNasName(from.getNasName());
to.setName(from.getNasName());
to.setNasState(from.getNasState());
to.setNasTag(from.getNAStag());
if (from.getParentNasUri() != null) {
PhysicalNAS pNAS = dbClient.queryObject(PhysicalNAS.class, from.getParentNasUri());
// Self link will be empty as there is no Resource Type available
// for PhysicalNAS
to.setParentNASURI(toNamedRelatedResource(pNAS, pNAS.getNasName()));
}
to.setAssociatedProjects(from.getAssociatedProjects());
to.setProtocols(from.getProtocols());
to.setRegistrationStatus(from.getRegistrationStatus());
Set<String> cifsServers = new HashSet<String>();
Set<String> cifsDomains = new HashSet<String>();
if (from.getCifsServersMap() != null && !from.getCifsServersMap().isEmpty()) {
Set<Entry<String, NasCifsServer>> nasCifsServers = from.getCifsServersMap().entrySet();
for (Entry<String, NasCifsServer> nasCifsServer : nasCifsServers) {
String serverDomain = nasCifsServer.getKey();
NasCifsServer cifsServer = nasCifsServer.getValue();
if (cifsServer.getDomain() != null) {
serverDomain = serverDomain + " = " + cifsServer.getDomain();
cifsDomains.add(cifsServer.getDomain());
}
cifsServers.add(serverDomain);
}
if (cifsServers != null && !cifsServers.isEmpty()) {
to.setCifsServers(cifsServers);
to.setStorageDomain(cifsDomains);
}
}
for (String port : from.getStoragePorts()) {
to.getStoragePorts().add(toRelatedResource(ResourceTypeEnum.STORAGE_PORT, URI.create(port)));
}
to.setTaggedVirtualArrays(from.getTaggedVirtualArrays());
to.setStorageDeviceURI(toRelatedResource(ResourceTypeEnum.STORAGE_SYSTEM, from.getStorageDeviceURI()));
DecimalFormat df = new DecimalFormat("0.00");
// Set the metrics!!!
Double maxStorageCapacity = MetricsKeys.getDouble(MetricsKeys.maxStorageCapacity, from.getMetrics()) / GBsINKB;
to.setMaxStorageCapacity(df.format(maxStorageCapacity));
to.setMaxStorageObjects(MetricsKeys.getLong(MetricsKeys.maxStorageObjects, from.getMetrics()).toString());
to.setStorageObjects(MetricsKeys.getLong(MetricsKeys.storageObjects, from.getMetrics()).toString());
Double usedStorageCapacity = MetricsKeys.getDouble(MetricsKeys.usedStorageCapacity, from.getMetrics()) / GBsINKB;
to.setUsedStorageCapacity(df.format(usedStorageCapacity));
Double percentLoad = MetricsKeys.getDoubleOrNull(MetricsKeys.percentLoad, from.getMetrics());
if (percentLoad != null) {
to.setPercentLoad(df.format(percentLoad));
}
to.setIsOverloaded(MetricsKeys.getBoolean(MetricsKeys.overLoaded, from.getMetrics()));
Double percentBusy = MetricsKeys.getDoubleOrNull(MetricsKeys.emaPercentBusy, from.getMetrics());
if (percentBusy != null) {
to.setAvgEmaPercentagebusy(df.format(percentBusy));
}
percentBusy = MetricsKeys.getDoubleOrNull(MetricsKeys.avgPortPercentBusy, from.getMetrics());
if (percentBusy != null) {
to.setAvgPercentagebusy(df.format(percentBusy));
}
return to;
}
Aggregations