use of com.cloud.hypervisor.xenserver.resource.wrapper.xenbase.XenServerUtilitiesHelper in project cloudstack by apache.
the class CitrixResourceBase method fillHostInfo.
protected void fillHostInfo(final Connection conn, final StartupRoutingCommand cmd) {
final StringBuilder caps = new StringBuilder();
try {
final Host host = Host.getByUuid(conn, _host.getUuid());
final Host.Record hr = host.getRecord(conn);
Map<String, String> details = cmd.getHostDetails();
if (details == null) {
details = new HashMap<String, String>();
}
String productBrand = hr.softwareVersion.get("product_brand");
if (productBrand == null) {
productBrand = hr.softwareVersion.get("platform_name");
}
details.put("product_brand", productBrand);
details.put("product_version", _host.getProductVersion());
if (hr.softwareVersion.get("product_version_text_short") != null) {
details.put("product_version_text_short", hr.softwareVersion.get("product_version_text_short"));
cmd.setHypervisorVersion(hr.softwareVersion.get("product_version_text_short"));
cmd.setHypervisorVersion(_host.getProductVersion());
}
if (_privateNetworkName != null) {
details.put("private.network.device", _privateNetworkName);
}
cmd.setHostDetails(details);
cmd.setName(hr.nameLabel);
cmd.setGuid(_host.getUuid());
cmd.setPool(_host.getPool());
cmd.setDataCenter(Long.toString(_dcId));
for (final String cap : hr.capabilities) {
if (cap.length() > 0) {
caps.append(cap).append(" , ");
}
}
if (caps.length() > 0) {
caps.delete(caps.length() - 3, caps.length());
}
cmd.setCaps(caps.toString());
cmd.setSpeed(_host.getSpeed());
cmd.setCpuSockets(_host.getCpuSockets());
cmd.setCpus(_host.getCpus());
final HostMetrics hm = host.getMetrics(conn);
long ram = 0;
long dom0Ram = 0;
ram = hm.getMemoryTotal(conn);
final Set<VM> vms = host.getResidentVMs(conn);
for (final VM vm : vms) {
if (vm.getIsControlDomain(conn)) {
dom0Ram = vm.getMemoryStaticMax(conn);
break;
}
}
ram = (long) ((ram - dom0Ram - _xsMemoryUsed) * _xsVirtualizationFactor);
cmd.setMemory(ram);
cmd.setDom0MinMemory(dom0Ram);
if (s_logger.isDebugEnabled()) {
s_logger.debug("Total Ram: " + ram + " dom0 Ram: " + dom0Ram);
}
PIF pif = PIF.getByUuid(conn, _host.getPrivatePif());
PIF.Record pifr = pif.getRecord(conn);
if (pifr.IP != null && pifr.IP.length() > 0) {
cmd.setPrivateIpAddress(pifr.IP);
cmd.setPrivateMacAddress(pifr.MAC);
cmd.setPrivateNetmask(pifr.netmask);
} else {
cmd.setPrivateIpAddress(_host.getIp());
cmd.setPrivateMacAddress(pifr.MAC);
cmd.setPrivateNetmask("255.255.255.0");
}
pif = PIF.getByUuid(conn, _host.getPublicPif());
pifr = pif.getRecord(conn);
if (pifr.IP != null && pifr.IP.length() > 0) {
cmd.setPublicIpAddress(pifr.IP);
cmd.setPublicMacAddress(pifr.MAC);
cmd.setPublicNetmask(pifr.netmask);
}
if (_host.getStoragePif1() != null) {
pif = PIF.getByUuid(conn, _host.getStoragePif1());
pifr = pif.getRecord(conn);
if (pifr.IP != null && pifr.IP.length() > 0) {
cmd.setStorageIpAddress(pifr.IP);
cmd.setStorageMacAddress(pifr.MAC);
cmd.setStorageNetmask(pifr.netmask);
}
}
if (_host.getStoragePif2() != null) {
pif = PIF.getByUuid(conn, _host.getStoragePif2());
pifr = pif.getRecord(conn);
if (pifr.IP != null && pifr.IP.length() > 0) {
cmd.setStorageIpAddressDeux(pifr.IP);
cmd.setStorageMacAddressDeux(pifr.MAC);
cmd.setStorageNetmaskDeux(pifr.netmask);
}
}
final Map<String, String> configs = hr.otherConfig;
cmd.setIqn(configs.get("iscsi_iqn"));
cmd.setPod(_pod);
cmd.setVersion(CitrixResourceBase.class.getPackage().getImplementationVersion());
try {
final String cmdLine = "xe sm-list | grep \"resigning of duplicates\"";
final XenServerUtilitiesHelper xenServerUtilitiesHelper = getXenServerUtilitiesHelper();
Pair<Boolean, String> result = xenServerUtilitiesHelper.executeSshWrapper(_host.getIp(), 22, _username, null, getPwdFromQueue(), cmdLine);
boolean supportsClonedVolumes = result != null && result.first() != null && result.first() && result.second() != null && result.second().length() > 0;
cmd.setSupportsClonedVolumes(supportsClonedVolumes);
} catch (NumberFormatException ex) {
s_logger.warn("Issue sending 'xe sm-list' via SSH to XenServer host: " + ex.getMessage());
}
} catch (final XmlRpcException e) {
throw new CloudRuntimeException("XML RPC Exception: " + e.getMessage(), e);
} catch (final XenAPIException e) {
throw new CloudRuntimeException("XenAPIException: " + e.toString(), e);
} catch (final Exception e) {
throw new CloudRuntimeException("Exception: " + e.toString(), e);
}
}
Aggregations