Search in sources :

Example 6 with LinuxSystemCLI

use of com.iwave.ext.linux.LinuxSystemCLI in project coprhd-controller by CoprHD.

the class LinuxUtils method convertHost.

public static LinuxSystemCLI convertHost(Host host) {
    LinuxSystemCLI cli = new LinuxSystemCLI();
    cli.setHost(host.getHostName());
    cli.setPort(host.getPortNumber());
    cli.setUsername(host.getUsername());
    cli.setPassword(host.getPassword());
    cli.setHostId(host.getId());
    return cli;
}
Also used : LinuxSystemCLI(com.iwave.ext.linux.LinuxSystemCLI)

Example 7 with LinuxSystemCLI

use of com.iwave.ext.linux.LinuxSystemCLI 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)

Example 8 with LinuxSystemCLI

use of com.iwave.ext.linux.LinuxSystemCLI in project coprhd-controller by CoprHD.

the class VPlexMeteringTest method testListingPerpetualDataFilenames.

@Test
public void testListingPerpetualDataFilenames() {
    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());
    out("Following files were found {}", filenames);
    Matcher matcher = Pattern.compile(".*?/([\\w\\-_]+)_PERPETUAL_vplex_sys_perf_mon.log").matcher(filenames.get(0));
    Assert.assertTrue("Expected filename matcher to match", matcher.matches());
    out("The director name for file '{}' is '{}'", filenames.get(0), matcher.group(1));
}
Also used : LinuxSystemCLI(com.iwave.ext.linux.LinuxSystemCLI) ListVPlexPerpetualCSVFileNames(com.emc.storageos.volumecontroller.impl.plugins.metering.vplex.ListVPlexPerpetualCSVFileNames) Matcher(java.util.regex.Matcher) Test(org.junit.Test)

Example 9 with LinuxSystemCLI

use of com.iwave.ext.linux.LinuxSystemCLI in project coprhd-controller by CoprHD.

the class LinuxHostDiscoveryAdapter method setNativeGuid.

@Override
protected void setNativeGuid(Host host) {
    LinuxSystemCLI linux = createLinuxCLI(host);
    for (IPInterface nic : linux.listIPInterfaces()) {
        if (nic.getInterfaceName().equalsIgnoreCase(ETH0)) {
            if (!host.getNativeGuid().equalsIgnoreCase(nic.getMacAddress())) {
                checkDuplicateHost(host, nic.getMacAddress());
                info("Setting nativeGuid for " + host.getId() + " as " + nic.getMacAddress());
                host.setNativeGuid(nic.getMacAddress());
                save(host);
            }
            break;
        }
    }
}
Also used : LinuxSystemCLI(com.iwave.ext.linux.LinuxSystemCLI) IPInterface(com.iwave.ext.linux.model.IPInterface)

Example 10 with LinuxSystemCLI

use of com.iwave.ext.linux.LinuxSystemCLI in project coprhd-controller by CoprHD.

the class LinuxHostDiscoveryAdapter method checkMultipathSoftwareCompatibility.

private void checkMultipathSoftwareCompatibility(Host host) {
    LinuxSystemCLI cli = createLinuxCLI(host);
    String powerpathMessage = null;
    String multipathMessage = null;
    try {
        PowermtCheckRegistrationCommand command = new PowermtCheckRegistrationCommand();
        cli.executeCommand(command, SecureShellSupport.SHORT_TIMEOUT);
        // powerpath is installed
        LOG.info("PowerPath is installed");
        return;
    } catch (PowerPathException e) {
        powerpathMessage = e.getMessage();
        LOG.info("PowerPath is unavailable: " + powerpathMessage);
    } catch (Exception e) {
        LOG.info("Error while checking for powerpath: " + e.getMessage(), e);
    }
    try {
        MultipathCommand command = new MultipathCommand();
        command.addArgument("-l");
        cli.executeCommand(command, SecureShellSupport.SHORT_TIMEOUT);
        // multipath is installed
        LOG.info("Multipath is installed");
        return;
    } catch (MultipathException e) {
        multipathMessage = e.getMessage();
        LOG.info("Multipath is unavailable: " + multipathMessage);
    } catch (Exception e) {
        LOG.info("Error while checking for multipath: " + e.getMessage(), e);
    }
    throw new CompatibilityException("No multipath software available: \n" + powerpathMessage + "\n" + multipathMessage);
}
Also used : LinuxSystemCLI(com.iwave.ext.linux.LinuxSystemCLI) CompatibilityException(com.emc.storageos.computesystemcontroller.exceptions.CompatibilityException) PowermtCheckRegistrationCommand(com.iwave.ext.linux.command.powerpath.PowermtCheckRegistrationCommand) MultipathCommand(com.iwave.ext.linux.command.MultipathCommand) MultipathException(com.iwave.ext.linux.command.MultipathException) PowerPathException(com.iwave.ext.linux.command.powerpath.PowerPathException) MultipathException(com.iwave.ext.linux.command.MultipathException) PowerPathException(com.iwave.ext.linux.command.powerpath.PowerPathException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CompatibilityException(com.emc.storageos.computesystemcontroller.exceptions.CompatibilityException) CommandException(com.iwave.ext.command.CommandException) JSchException(com.jcraft.jsch.JSchException) ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)

Aggregations

LinuxSystemCLI (com.iwave.ext.linux.LinuxSystemCLI)16 URI (java.net.URI)5 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)4 Initiator (com.emc.storageos.db.client.model.Initiator)3 ListVPlexPerpetualCSVFileNames (com.emc.storageos.volumecontroller.impl.plugins.metering.vplex.ListVPlexPerpetualCSVFileNames)3 CommandException (com.iwave.ext.command.CommandException)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Test (org.junit.Test)3 CompatibilityException (com.emc.storageos.computesystemcontroller.exceptions.CompatibilityException)2 ComputeSystemControllerException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)2 BlockObject (com.emc.storageos.db.client.model.BlockObject)2 Host (com.emc.storageos.db.client.model.Host)2 ServiceCoded (com.emc.storageos.svcs.errorhandling.model.ServiceCoded)2 ReadAndParseVPlexPerpetualCSVFile (com.emc.storageos.volumecontroller.impl.plugins.metering.vplex.ReadAndParseVPlexPerpetualCSVFile)2 VPlexPerpetualCSVFileData (com.emc.storageos.volumecontroller.impl.plugins.metering.vplex.VPlexPerpetualCSVFileData)2 MultipathException (com.iwave.ext.linux.command.MultipathException)2 PowerPathException (com.iwave.ext.linux.command.powerpath.PowerPathException)2 IPInterface (com.iwave.ext.linux.model.IPInterface)2 JSchException (com.jcraft.jsch.JSchException)2