use of com.iwave.ext.linux.LinuxSystemCLI in project coprhd-controller by CoprHD.
the class LinuxHostDiscoveryAdapter method getVersions.
protected List<LinuxVersion> getVersions(Host host) {
LinuxSystemCLI cli = createLinuxCLI(host);
List<LinuxVersion> versions = new ArrayList<LinuxVersion>();
LinuxVersionCommand[] commands = { new GetSuSEVersionCommand(), new GetRedhatVersionCommandOne(), new GetRedhatVersionCommandTwo(), new GetRedhatVersionCommandThree(), new GetLinuxVersionLSBReleaseCommand() };
for (LinuxVersionCommand command : commands) {
try {
cli.executeCommand(command);
LinuxVersion version = command.getResults();
if (version != null) {
versions.add(version);
}
} catch (CommandException e) {
warn("Could not retrieve linux version", e);
}
}
if (versions.isEmpty()) {
error("Could not determine version of linux host %s", host.getLabel());
versions.add(new LinuxVersion(LinuxDistribution.UNKNOWN, ""));
}
return versions;
}
use of com.iwave.ext.linux.LinuxSystemCLI in project coprhd-controller by CoprHD.
the class LinuxHostDiscoveryAdapter method discoverIpInterfaces.
@Override
protected void discoverIpInterfaces(Host host, List<IpInterface> oldIpInterfaces) {
LinuxSystemCLI linux = createLinuxCLI(host);
for (IPInterface nic : linux.listIPInterfaces()) {
if (StringUtils.isNotBlank(nic.getIpAddress())) {
IpInterface ipInterface = getOrCreateIpInterface(oldIpInterfaces, nic.getIpAddress());
discoverIp4Interface(host, ipInterface, nic);
}
if (StringUtils.isNotBlank(nic.getIP6Address())) {
IpInterface ipInterface = getOrCreateIpInterface(oldIpInterfaces, StringUtils.substringBefore(nic.getIP6Address(), "/"));
discoverIp6Interface(host, ipInterface, nic);
}
}
}
use of com.iwave.ext.linux.LinuxSystemCLI in project coprhd-controller by CoprHD.
the class CephStorageDevice method mapVolumes.
/**
* Map volumes to hosts on the hosts themselves.
*
* @param storage
* [in] - Storage System object
* @param volumeMap
* [in] - Volume URI to Integer LUN map
* @param initiators
* [in] - Collection of Initiator objects
* @param completer
* [in] - TaskCompleter
*/
private void mapVolumes(StorageSystem storage, Map<URI, Integer> volumeMap, Collection<Initiator> initiators, TaskCompleter completer) {
_log.info("mapVolumes: volumeMap: {}", volumeMap);
_log.info("mapVolumes: initiators: {}", initiators);
try {
for (Map.Entry<URI, Integer> volMapEntry : volumeMap.entrySet()) {
URI objectUri = volMapEntry.getKey();
BlockObject object = Volume.fetchExportMaskBlockObject(_dbClient, objectUri);
String monitorAddress = storage.getSmisProviderIP();
String monitorUser = storage.getSmisUserName();
String monitorKey = storage.getSmisPassword();
RBDMappingOptions rbdOptions = new RBDMappingOptions(object);
for (Initiator initiator : initiators) {
Host host = _dbClient.queryObject(Host.class, initiator.getHost());
if (initiator.getProtocol().equalsIgnoreCase(HostInterface.Protocol.RBD.name())) {
_log.info(String.format("mapVolume: host %s pool %s volume %s", host.getHostName(), rbdOptions.poolName, rbdOptions.volumeName));
LinuxSystemCLI linuxClient = getLinuxClient(host);
linuxClient.mapRBD(monitorAddress, monitorUser, monitorKey, rbdOptions.poolName, rbdOptions.volumeName, rbdOptions.snapshotName);
} else {
String msg = String.format("Unexpected initiator protocol %s, port %s, pool %s, volume %s", initiator.getProtocol(), initiator.getInitiatorPort(), rbdOptions.poolName, rbdOptions.volumeName);
ServiceCoded code = DeviceControllerErrors.ceph.operationFailed("mapVolumes", msg);
completer.error(_dbClient, code);
return;
}
}
}
completer.ready(_dbClient);
} catch (Exception e) {
_log.error("Encountered an exception", e);
ServiceCoded code = DeviceControllerErrors.ceph.operationFailed("mapVolumes", e.getMessage());
completer.error(_dbClient, code);
}
}
use of com.iwave.ext.linux.LinuxSystemCLI in project coprhd-controller by CoprHD.
the class VPlexPerpetualCSVFileCollector method collect.
@Override
public void collect(AccessProfile accessProfile, Map<String, Object> context) {
init();
DbClient dbClient = (DbClient) context.get(Constants.dbClient);
// Get which VPlex array that this applies to
URI storageSystemURI = accessProfile.getSystemId();
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, storageSystemURI);
if (storageSystem == null) {
log.error("Could not find StorageSystem '{}' in DB", storageSystemURI);
return;
}
StringSet providerIds = storageSystem.getProviders();
for (String providerId : providerIds) {
StorageProvider provider = dbClient.queryObject(StorageProvider.class, URI.create(providerId));
LinuxSystemCLI cli = new LinuxSystemCLI(provider.getIPAddress(), provider.getUserName(), provider.getPassword());
ListVPlexPerpetualCSVFileNames listDataFileNamesCmd = new ListVPlexPerpetualCSVFileNames();
cli.executeCommand(listDataFileNamesCmd);
// Process each of the data files that we found on the VPlex management station
List<String> fileNames = listDataFileNamesCmd.getResults();
for (String fileName : fileNames) {
log.info("Processing VPLEX performance statistics file {}", fileName);
// Extract and hold the data for this data file
ReadAndParseVPlexPerpetualCSVFile readDataFile = new ReadAndParseVPlexPerpetualCSVFile(fileName);
cli.executeCommand(readDataFile);
VPlexPerpetualCSVFileData fileData = readDataFile.getResults();
// Read the headers and extract those metric names that we're interested in and to which
// DataObject (StorageHADomain or StoragePort) that it should be associated with. This
// will be used as a way to look up the object when processing the actual metric data
Map<String, MetricHeaderInfo> metricNamesToHeaderInfo = processCSVFileDataHeader(dbClient, storageSystem, fileData.getDirectorName(), fileData.getHeaders());
List<Map<String, String>> dataLines = fileData.getDataLines();
int lineCount = dataLines.size();
// There is at least one data point
if (lineCount > 1) {
// Determine the last time that metrics were collected.
Long lastCollectionTimeUTC = getLastCollectionTime(metricNamesToHeaderInfo);
// Try to find the index into dataLines based on the last collection time.
// What we're trying to do here is determine the maximum value for the metrics
// from the last collection time in ViPR, until the last data line in the file.
int start = fileData.getDataIndexForTime(lastCollectionTimeUTC);
// Have a mapping of metrics to their maximum value found in the dataLines
Map<String, Double> maxValues = findMaxMetricValues(dataLines, start, lineCount);
// Process the metrics for this file
Map<String, String> last = dataLines.get(lineCount - 1);
processDirectorStats(metricNamesToHeaderInfo, maxValues, last);
processPortStats(context, metricNamesToHeaderInfo, maxValues, last);
}
// Clean up fileData resources
fileData.close();
}
// Clean out the cache data, so that it's not laying around
clearCaches();
}
}
use of com.iwave.ext.linux.LinuxSystemCLI 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();
}
}
Aggregations