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;
}
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();
}
}
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));
}
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;
}
}
}
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);
}
Aggregations