Search in sources :

Example 1 with ReadAndParseVPlexPerpetualCSVFile

use of com.emc.storageos.volumecontroller.impl.plugins.metering.vplex.ReadAndParseVPlexPerpetualCSVFile in project coprhd-controller by CoprHD.

the class VPlexMeteringTest method testReadingDataFiles.

@Test
public void testReadingDataFiles() {
    LinuxSystemCLI cli = new LinuxSystemCLI(HOST, USERNAME, PASSWORD);
    ListVPlexPerpetualCSVFileNames listDataFileNamesCmd = new ListVPlexPerpetualCSVFileNames();
    cli.executeCommand(listDataFileNamesCmd);
    List<String> filenames = listDataFileNamesCmd.getResults();
    Assert.assertFalse("Expected to find file names", filenames.isEmpty());
    for (String filename : filenames) {
        ReadAndParseVPlexPerpetualCSVFile readDataFile = new ReadAndParseVPlexPerpetualCSVFile(filename);
        cli.executeCommand(readDataFile);
        VPlexPerpetualCSVFileData fileData = readDataFile.getResults();
        Assert.assertNotNull("Expect file data to be non-null", fileData);
        out("For file {} these are the headers:\n{}", filename, Joiner.on('\n').join(fileData.getHeaders()));
        List<Map<String, String>> dataLines = fileData.getDataLines();
        Assert.assertTrue("Expect file data to have data values", !dataLines.isEmpty());
        out("For file {} there are {} data lines", filename, dataLines.size());
        fileData.close();
    }
}
Also used : LinuxSystemCLI(com.iwave.ext.linux.LinuxSystemCLI) ListVPlexPerpetualCSVFileNames(com.emc.storageos.volumecontroller.impl.plugins.metering.vplex.ListVPlexPerpetualCSVFileNames) ReadAndParseVPlexPerpetualCSVFile(com.emc.storageos.volumecontroller.impl.plugins.metering.vplex.ReadAndParseVPlexPerpetualCSVFile) Map(java.util.Map) HashMap(java.util.HashMap) StringMap(com.emc.storageos.db.client.model.StringMap) VPlexPerpetualCSVFileData(com.emc.storageos.volumecontroller.impl.plugins.metering.vplex.VPlexPerpetualCSVFileData) Test(org.junit.Test)

Example 2 with ReadAndParseVPlexPerpetualCSVFile

use of com.emc.storageos.volumecontroller.impl.plugins.metering.vplex.ReadAndParseVPlexPerpetualCSVFile in project coprhd-controller by CoprHD.

the class VPlexMeteringTest method testReadAndParseMetrics.

@Test
public void testReadAndParseMetrics() {
    LinuxSystemCLI cli = new LinuxSystemCLI(HOST, USERNAME, PASSWORD);
    ListVPlexPerpetualCSVFileNames listDataFileNamesCmd = new ListVPlexPerpetualCSVFileNames();
    cli.executeCommand(listDataFileNamesCmd);
    List<String> fileNames = listDataFileNamesCmd.getResults();
    for (String fileName : fileNames) {
        ReadAndParseVPlexPerpetualCSVFile readDataFile = new ReadAndParseVPlexPerpetualCSVFile(fileName);
        cli.executeCommand(readDataFile);
        VPlexPerpetualCSVFileData fileData = readDataFile.getResults();
        // Read each data line from the file
        int processedLines = 0;
        int headerCount = fileData.getHeaders().size();
        for (Map<String, String> dataLine : fileData.getDataLines()) {
            // Extract the metrics and their values, translate them into ViPR statistics
            Set<String> keys = dataLine.keySet();
            Assert.assertTrue("Expected number of data keys to match headers", headerCount == keys.size());
            for (String metricName : keys) {
                String value = dataLine.get(metricName);
                // If the value is not "no data" for the value, then parse it...
                if (!VPlexPerpetualCSVFileData.NO_DATA.equals(value)) {
                    readAndParseMetrics(metricName, value);
                }
            }
            processedLines++;
            alreadyPrinted = true;
        }
        Assert.assertTrue("Data lines processed does not match total expected", fileData.getTotalLines() == (processedLines + 1));
        // Clean up fileData resources
        fileData.close();
    }
}
Also used : LinuxSystemCLI(com.iwave.ext.linux.LinuxSystemCLI) ListVPlexPerpetualCSVFileNames(com.emc.storageos.volumecontroller.impl.plugins.metering.vplex.ListVPlexPerpetualCSVFileNames) ReadAndParseVPlexPerpetualCSVFile(com.emc.storageos.volumecontroller.impl.plugins.metering.vplex.ReadAndParseVPlexPerpetualCSVFile) Constraint(com.emc.storageos.db.client.constraint.Constraint) VPlexPerpetualCSVFileData(com.emc.storageos.volumecontroller.impl.plugins.metering.vplex.VPlexPerpetualCSVFileData) Test(org.junit.Test)

Aggregations

ListVPlexPerpetualCSVFileNames (com.emc.storageos.volumecontroller.impl.plugins.metering.vplex.ListVPlexPerpetualCSVFileNames)2 ReadAndParseVPlexPerpetualCSVFile (com.emc.storageos.volumecontroller.impl.plugins.metering.vplex.ReadAndParseVPlexPerpetualCSVFile)2 VPlexPerpetualCSVFileData (com.emc.storageos.volumecontroller.impl.plugins.metering.vplex.VPlexPerpetualCSVFileData)2 LinuxSystemCLI (com.iwave.ext.linux.LinuxSystemCLI)2 Test (org.junit.Test)2 Constraint (com.emc.storageos.db.client.constraint.Constraint)1 StringMap (com.emc.storageos.db.client.model.StringMap)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1