Search in sources :

Example 61 with StorageHADomain

use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.

the class XIVStoragePortProcessor method createStoragePort.

/**
 * create StoragePort Record, if not present already, else update only the
 * properties.
 *
 * @param port
 * @param portInstance
 * @param profile
 * @param isFCPort
 * @param transportType
 * @param device
 *
 * @throws URISyntaxException
 * @throws IOException
 *
 * @return StoragePort
 */
private StoragePort createStoragePort(StoragePort port, CIMInstance portInstance, AccessProfile profile, boolean isFCPort, String transportType, StorageSystem device) throws URISyntaxException, IOException {
    if (null == port) {
        port = new StoragePort();
        port.setId(URIUtil.createId(StoragePort.class));
        // Ethernet will be updated later in ProtocolEndPoint Processor
        if (isFCPort) {
            port.setPortNetworkId(WWNUtility.getWWNWithColons(getCIMPropertyValue(portInstance, PORTID)));
            _newPortList.add(port);
        }
        port.setStorageDevice(profile.getSystemId());
        String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(_dbClient, port);
        port.setNativeGuid(portNativeGuid);
        port.setLabel(portNativeGuid);
    } else {
        if (isFCPort) {
            _updatePortList.add(port);
        }
    }
    setPortType(port, portInstance);
    port.setTransportType(transportType);
    String[] identifiers = getCIMPropertyArrayValue(portInstance, IDENTIFYING_INFO);
    String moduleName = null;
    if (isFCPort) {
        moduleName = identifiers[0];
        String portName = getCIMPropertyValue(portInstance, PORTNAME);
        port.setPortName(portName);
    } else {
        moduleName = identifiers[1];
        port.setPortName(identifiers[1] + ":" + identifiers[0]);
        // port type is not set for ethernet port in SMI
        if (port.getPortType().equals(StoragePort.PortType.Unknown.name())) {
            port.setPortType(StoragePort.PortType.frontend.name());
        }
    }
    port.setPortGroup(moduleName);
    StorageHADomain adapter = getStorageAdapter(moduleName, device);
    port.setStorageHADomain(adapter.getId());
    port.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
    port.setDiscoveryStatus(DiscoveredDataObject.DiscoveryStatus.VISIBLE.name());
    UnsignedInteger16[] operationalStatusCodes = (UnsignedInteger16[]) portInstance.getPropertyValue(OPERATIONALSTATUS);
    OperationalStatus operationalStatus = StoragePortProcessor.getPortOperationalStatus(operationalStatusCodes);
    if (OperationalStatus.NOT_OK.equals(operationalStatus)) {
        _logger.info("StoragePort {} operationalStatus is NOT_OK. operationalStatusCodes collected from SMI-S :{}", port.getId(), operationalStatusCodes);
    } else {
        _logger.debug("operationalStatusCodes: {}", operationalStatusCodes);
    }
    port.setOperationalStatus(operationalStatus.name());
    String portSpeed = getCIMPropertyValue(portInstance, SPEED);
    if (null != portSpeed) {
        // SMI returns port speed in bits per sec
        Long portSpeedInBitsPerSec = Long.parseLong(portSpeed);
        Long portSpeedInGbps = portSpeedInBitsPerSec / GB;
        port.setPortSpeed(portSpeedInGbps);
    }
    return port;
}
Also used : StoragePort(com.emc.storageos.db.client.model.StoragePort) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) OperationalStatus(com.emc.storageos.db.client.model.StoragePort.OperationalStatus) UnsignedInteger16(javax.cim.UnsignedInteger16)

Example 62 with StorageHADomain

use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.

the class FEAdaptStatsProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        CIMArgument<?>[] outputArguments = (CIMArgument<?>[]) resultObj;
        DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
        AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        StorageSystem system = dbClient.queryObject(StorageSystem.class, profile.getSystemId());
        List<String> metricSequence = (List<String>) keyMap.get(Constants.STORAGEOS_FEADAPT_MANIFEST);
        String[] feadaptMetricValues = ((String[]) outputArguments[0].getValue())[0].split("\n");
        Map<String, StorageHADomain> haDomains = getHADomainOfSystem(dbClient, profile.getSystemId());
        if (null == metricSequence || metricSequence.isEmpty()) {
            _logger.error("No metric sequence for FEAdaptStatsProcessor; no processing will happen");
            return;
        }
        for (String metricValue : feadaptMetricValues) {
            if (metricValue.isEmpty()) {
                continue;
            }
            String[] metrics = metricValue.split(Constants.SEMI_COLON);
            String instanceId = metrics[0];
            String instanceName;
            if (instanceId.contains(Constants.SMIS80_DELIMITER)) {
                instanceName = instanceId.replaceAll(".*\\Q" + Constants.SMIS80_DELIMITER + "\\E", "");
            } else {
                instanceName = instanceId.replaceAll(".*\\+", "");
            }
            StorageHADomain haDomain = haDomains.get(instanceName);
            if (haDomain == null) {
                _logger.error("No StorageHADomain for instanceName: " + instanceName);
                continue;
            }
            updateMetrics(metrics, metricSequence, haDomain, system, keyMap);
        }
    } catch (Exception e) {
        _logger.error("Failed while extracting stats for FEAdapts: ", e);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) AccessProfile(com.emc.storageos.plugins.AccessProfile) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) CIMArgument(javax.cim.CIMArgument) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 63 with StorageHADomain

use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.

the class FEAdaptStatsProcessor method getHADomainOfSystem.

/**
 * Query the database to get all the HA Domains
 *
 * @param dbClient
 * @param systemURI
 * @return Map of adapterName to StorageHADomain objects
 */
public Map<String, StorageHADomain> getHADomainOfSystem(final DbClient dbClient, final URI systemURI) {
    Map<String, StorageHADomain> haDomains = new HashMap<String, StorageHADomain>();
    URIQueryResultList haDomainQueryResult = new URIQueryResultList();
    dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStorageHADomainConstraint(systemURI), haDomainQueryResult);
    for (Iterator<URI> haIter = haDomainQueryResult.iterator(); haIter.hasNext(); ) {
        StorageHADomain haDomain = dbClient.queryObject(StorageHADomain.class, haIter.next());
        // The replace all fixes up SP_A to SP-A so that it will match the metric records.
        haDomains.put(haDomain.getAdapterName().replaceAll("_", "-"), haDomain);
    }
    return haDomains;
}
Also used : HashMap(java.util.HashMap) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 64 with StorageHADomain

use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.

the class PortMetricsProcessor method computePortMetric.

/**
 * Compute the overall port metric given the port. The overall port metric is
 * a equally weighted average of the port%busy and cpu%busy (if both port and cpu metrics are supported)
 * normalized to a 0-100% scale. So 75% port busy and 25% cpu busy would be 100%/2 = 50% overall busy.
 * The port%busy and cpu%busy are computed from the combination of short term and long term averages for each (respectively).
 * This is (emaFactor * portAvgBusy + (1-emaFactor) * portEmaBusy) for example, where the first term is the short term
 * average and the second term is the longer term average.
 *
 * @param port -- StoragePort the metric is to be computed for
 * @return Double indicating the dbMetric b/w 0.0 < value <= 100.0
 */
Double computePortMetric(StoragePort port) {
    StorageSystem system = _dbClient.queryObject(StorageSystem.class, port.getStorageDevice());
    DiscoveredDataObject.Type type = DiscoveredDataObject.Type.valueOf(system.getSystemType());
    StringMap portMap = port.getMetrics();
    double emaFactor = getEmaFactor(DiscoveredDataObject.Type.valueOf(system.getSystemType()));
    // The port and cpu Busy Floor values were added as a way to remove background idle load from
    // the calculations. The idea is even with no traffic, the port (and especially the cpu) may show
    // a small load which should be ignored in favor of balancing the number of volumes.
    // If the percent busy is below the floor for either one, then the value is not added into the metric.
    // A volume term is added to the metric in computeStoragePortUsage and will dominate the usage value
    // on idle systems. The floors are expressed in percent from 0 - 100 %.
    double portBusyFloor = getPortBusyFloor(DiscoveredDataObject.Type.valueOf(system.getSystemType()));
    double cpuBusyFloor = getCpuBusyFloor(DiscoveredDataObject.Type.valueOf(system.getSystemType()));
    if (emaFactor > 1.0) {
        // in case of invalid user input
        emaFactor = 1.0;
    }
    Double portAvgBusy = MetricsKeys.getDouble(MetricsKeys.avgPercentBusy, portMap);
    Double portEmaBusy = MetricsKeys.getDouble(MetricsKeys.emaPercentBusy, portMap);
    Double portPercentBusy = (portAvgBusy * emaFactor) + ((1 - emaFactor) * portEmaBusy);
    MetricsKeys.putDouble(MetricsKeys.avgPortPercentBusy, portPercentBusy, port.getMetrics());
    // The port metric contains portPercentBusy if it's over the floor.
    // If the usage is less than the floor, don't count it in order to make volume component predominate.
    Double portMetricDouble = ((portPercentBusy >= portBusyFloor) ? portPercentBusy : 0.0);
    // Calculate the overall port metric, which is a percent 0-100%
    Double cpuAvgBusy = null;
    Double cpuEmaBusy = null;
    // compute port cpu busy if applicable
    if (type == DiscoveredDataObject.Type.vmax || type == DiscoveredDataObject.Type.vnxblock || type == DiscoveredDataObject.Type.vplex) {
        StorageHADomain haDomain = _dbClient.queryObject(StorageHADomain.class, port.getStorageHADomain());
        StringMap cpuMap = haDomain.getMetrics();
        cpuAvgBusy = MetricsKeys.getDouble(MetricsKeys.avgPercentBusy, cpuMap);
        cpuEmaBusy = MetricsKeys.getDouble(MetricsKeys.emaPercentBusy, cpuMap);
        // Update port bandwidth and cpu usage average. These are used by the UI.
        Double cpuPercentBusy = (cpuAvgBusy * emaFactor) + ((1 - emaFactor) * cpuEmaBusy);
        MetricsKeys.putDouble(MetricsKeys.avgCpuPercentBusy, cpuPercentBusy, port.getMetrics());
        // If cpuPercentBusy is greater than the cpuBusyFloor, average it in to port metric.
        if (cpuPercentBusy >= cpuBusyFloor) {
            portMetricDouble += cpuPercentBusy;
            portMetricDouble /= 2;
        }
    }
    _log.info(String.format("%s %s: portMetric %f port %f %f cpu %s %s", port.getNativeGuid(), portName(port), portMetricDouble, portAvgBusy, portEmaBusy, cpuAvgBusy == null ? "n/a" : cpuAvgBusy.toString(), cpuEmaBusy == null ? "n/a" : cpuEmaBusy.toString()));
    return portMetricDouble;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 65 with StorageHADomain

use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.

the class VNXFileCommApi method createSnapshot.

public XMLApiResult createSnapshot(final StorageSystem system, final String fsName, final String snapshotName, final FileShare fileShare) throws VNXException {
    _log.info("Create Snap for file sys : {} snap name : {}", fsName, snapshotName);
    XMLApiResult result = new XMLApiResult();
    Map<String, Object> reqAttributeMap = new ConcurrentHashMap<String, Object>();
    try {
        // get the data mover
        StorageHADomain dataMover = this.getDataMover(fileShare);
        if (null != dataMover) {
            sshApi.setConnParams(system.getIpAddress(), system.getUsername(), system.getPassword());
            Map<String, String> existingMounts = sshApi.getFsMountpathMap(dataMover.getAdapterName());
            if (existingMounts.get(fileShare.getName()) == null) {
                String mountCmdArgs = sshApi.formatMountCmd(dataMover.getAdapterName(), fileShare.getName(), fileShare.getMountPath());
                result = sshApi.executeSshRetry(VNXFileSshApi.SERVER_MOUNT_CMD, mountCmdArgs);
                _log.info("filesystem mount is successful for filesystem: {} mount path: {}", fileShare.getName(), fileShare.getMountPath());
            }
        } else {
            Exception e = new Exception("VNX File snapshot creation failed because suitable Data mover to mount the File System not found");
            throw VNXException.exceptions.createExportFailed("VNX File Snapshot create is Failed", e);
        }
        updateAttributes(reqAttributeMap, system);
        reqAttributeMap.put(VNXFileConstants.FILESYSTEM_NAME, fsName);
        reqAttributeMap.put(VNXFileConstants.SNAPSHOT_NAME, snapshotName);
        _provExecutor.setKeyMap(reqAttributeMap);
        _provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_CREATE_SNAP));
        String cmdResult = (String) _provExecutor.getKeyMap().get(VNXFileConstants.CMD_RESULT);
        if (cmdResult != null && cmdResult.equals(VNXFileConstants.CMD_SUCCESS)) {
            String snapId = (String) _provExecutor.getKeyMap().get(VNXFileConstants.SNAPSHOT_ID);
            String fsysId = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FILESYSTEM_ID);
            if (snapId != null) {
                int fsId = Integer.parseInt(fsysId);
                int snId = Integer.parseInt(snapId);
                VNXSnapshot vnxSnap = new VNXSnapshot(snapshotName, -1, fsId);
                vnxSnap.setId(snId);
                result.setObject(vnxSnap);
                result.setCommandSuccess();
            } else {
                result.setCommandFailed();
                result.setMessage((String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_MSG));
            }
        } else {
            String errMsg = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_MSG);
            result.setCommandFailed();
            result.setMessage(errMsg);
        }
    } catch (Exception e) {
        throw new VNXException("Failure", e);
    }
    return result;
}
Also used : VNXException(com.emc.storageos.vnx.xmlapi.VNXException) FileObject(com.emc.storageos.db.client.model.FileObject) VNXSnapshot(com.emc.storageos.vnx.xmlapi.VNXSnapshot) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult) URISyntaxException(java.net.URISyntaxException) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) Checkpoint(com.emc.nas.vnxfile.xmlapi.Checkpoint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint)

Aggregations

StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)80 URI (java.net.URI)41 StoragePort (com.emc.storageos.db.client.model.StoragePort)35 ArrayList (java.util.ArrayList)33 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)26 HashMap (java.util.HashMap)22 List (java.util.List)20 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)19 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)18 StringSet (com.emc.storageos.db.client.model.StringSet)17 VNXException (com.emc.storageos.vnx.xmlapi.VNXException)12 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)11 NamespaceList (com.emc.storageos.plugins.common.domainmodel.NamespaceList)11 URISyntaxException (java.net.URISyntaxException)11 LinkedList (java.util.LinkedList)10 IOException (java.io.IOException)9 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)8 XMLApiResult (com.emc.storageos.vnx.xmlapi.XMLApiResult)8 HashSet (java.util.HashSet)8 Map (java.util.Map)7