s_logger.debug("Network " + network.getId() + " is not configured for external networking, so skipping usage check.");
continue;
}
ExternalFirewallDeviceVO fwDeviceVO = getExternalFirewallForNetwork(network);
ExternalLoadBalancerDeviceVO lbDeviceVO = getExternalLoadBalancerForNetwork(network);
if (lbDeviceVO == null && fwDeviceVO == null) {
continue;
}
// Get network stats from the external firewall
ExternalNetworkResourceUsageAnswer firewallAnswer = null;
HostVO externalFirewall = null;
if (fwDeviceVO != null) {
externalFirewall = _hostDao.findById(fwDeviceVO.getHostId());
if (externalFirewall != null) {
Long fwDeviceId = new Long(externalFirewall.getId());
if (!fwDeviceUsageAnswerMap.containsKey(fwDeviceId)) {
try {
ExternalNetworkResourceUsageCommand cmd = new ExternalNetworkResourceUsageCommand();
firewallAnswer = (ExternalNetworkResourceUsageAnswer)_agentMgr.easySend(externalFirewall.getId(), cmd);
if (firewallAnswer == null || !firewallAnswer.getResult()) {
String details = (firewallAnswer != null) ? firewallAnswer.getDetails() : "details unavailable";
String msg = "Unable to get external firewall stats for network" + zone.getName() + " due to: " + details + ".";
s_logger.error(msg);
} else {
fwDeviceUsageAnswerMap.put(fwDeviceId, firewallAnswer);
}
} catch (Exception e) {
String msg = "Unable to get external firewall stats for network" + zone.getName();
s_logger.error(msg, e);
}
} else {
if (s_logger.isTraceEnabled()) {
s_logger.trace("Reusing usage Answer for device id " + fwDeviceId + "for Network " + network.getId());
}
firewallAnswer = fwDeviceUsageAnswerMap.get(fwDeviceId);
}
}
}
// Get network stats from the external load balancer
ExternalNetworkResourceUsageAnswer lbAnswer = null;
HostVO externalLoadBalancer = null;
if (lbDeviceVO != null) {
externalLoadBalancer = _hostDao.findById(lbDeviceVO.getHostId());
if (externalLoadBalancer != null) {
Long lbDeviceId = new Long(externalLoadBalancer.getId());
if (!lbDeviceUsageAnswerMap.containsKey(lbDeviceId)) {
try {
ExternalNetworkResourceUsageCommand cmd = new ExternalNetworkResourceUsageCommand();