For VirtualRouter apply networkThrottling rate of the GuestNetworkOffering to both Guest and Public networks.

This commit is contained in:
alena 2011-03-30 14:48:21 -07:00
parent 971915a26a
commit bb31bc779f
5 changed files with 22 additions and 9 deletions

View File

@ -34,6 +34,8 @@ import com.cloud.offering.DiskOffering;
import com.cloud.offering.NetworkOffering;
import com.cloud.offering.ServiceOffering;
import com.cloud.user.Account;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachine.Type;
public interface ConfigurationService {
@ -182,7 +184,7 @@ public interface ConfigurationService {
NetworkOffering getNetworkOffering(long id);
Integer getNetworkRate(long networkOfferingId);
Integer getNetworkRate(long networkOfferingId, Type vmType);
Account getVlanAccount(long vlanId);

View File

@ -524,7 +524,7 @@ public class ApiDBUtils {
}
public static Integer getNetworkRate(long networkOfferingId) {
return _configMgr.getNetworkRate(networkOfferingId);
return _configMgr.getNetworkRate(networkOfferingId, null);
}
public static Account getVlanAccount(long vlanId) {

View File

@ -127,6 +127,8 @@ import com.cloud.utils.db.Transaction;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.net.NetUtils;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachine.Type;
import com.cloud.vm.dao.ConsoleProxyDao;
import com.cloud.vm.dao.DomainRouterDao;
import com.cloud.vm.dao.SecondaryStorageVmDao;
@ -2779,7 +2781,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
}
@Override
public Integer getNetworkRate(long networkOfferingId) {
public Integer getNetworkRate(long networkOfferingId, Type vmType) {
//validate network offering information
NetworkOffering no = getNetworkOffering(networkOfferingId);
@ -2787,6 +2789,15 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
throw new InvalidParameterValueException("Unable to find network offering by id=" + networkOfferingId);
}
//For router's public network we use networkRate from guestNetworkOffering
if (vmType != null && vmType == VirtualMachine.Type.DomainRouter && no.getTrafficType() == TrafficType.Public && no.getGuestType() == null) {
List<? extends NetworkOffering> guestOfferings = _networkOfferingDao.listByTrafficTypeAndGuestType(false, TrafficType.Guest, GuestIpType.Virtual);
if (!guestOfferings.isEmpty()) {
//We have one default guest virtual network offering now
no = guestOfferings.get(0);
}
}
Integer networkRate;
if (no.getRateMbps() != null) {
networkRate = no.getRateMbps();

View File

@ -982,7 +982,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
nics.add(vo);
NetworkOffering no = _configMgr.getNetworkOffering(config.getNetworkOfferingId());
Integer networkRate = _configMgr.getNetworkRate(no.getId());
Integer networkRate = _configMgr.getNetworkRate(no.getId(), vm.getType());
vm.addNic(new NicProfile(vo, network.first(), vo.getBroadcastUri(), vo.getIsolationUri(), networkRate));
}
@ -1075,7 +1075,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
to.setDns2(profile.getDns2());
}
Integer networkRate = _configMgr.getNetworkRate(config.getNetworkOfferingId());
Integer networkRate = _configMgr.getNetworkRate(config.getNetworkOfferingId(), null);
to.setNetworkRateMbps(networkRate);
return to;
@ -1196,7 +1196,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
NetworkGuru guru = implemented.first();
NetworkVO network = implemented.second();
NetworkOffering no = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
Integer networkRate = _configMgr.getNetworkRate(no.getId());
Integer networkRate = _configMgr.getNetworkRate(no.getId(), vmProfile.getType());
NicProfile profile = null;
if (nic.getReservationStrategy() == Nic.ReservationStrategy.Start) {
nic.setState(Nic.State.Reserving);
@ -1246,7 +1246,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
for (NicVO nic : nics) {
NetworkVO network = _networksDao.findById(nic.getNetworkId());
NetworkOffering no = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
Integer networkRate = _configMgr.getNetworkRate(no.getId());
Integer networkRate = _configMgr.getNetworkRate(no.getId(), vm.getType());
NetworkGuru guru = _networkGurus.get(network.getGuruName());
NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), networkRate);
@ -1303,7 +1303,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
for (Nic nic : nics) {
NetworkVO network = _networksDao.findById(nic.getNetworkId());
NetworkOffering no = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
Integer networkRate = _configMgr.getNetworkRate(no.getId());
Integer networkRate = _configMgr.getNetworkRate(no.getId(), vm.getType());
NetworkGuru guru = _networkGurus.get(network.getGuruName());
NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), networkRate);

View File

@ -1417,7 +1417,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
//Get network rate - required for IpAssoc
Network network = _networkMgr.getNetwork(ipAddr.getNetworkId());
NetworkOffering no = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
Integer networkRate = _configMgr.getNetworkRate(no.getId());
Integer networkRate = _configMgr.getNetworkRate(no.getId(), null);
IpAddressTO ip = new IpAddressTO(ipAddr.getAddress().addr(), add, firstIP, sourceNat, vlanId, vlanGateway, vlanNetmask, vifMacAddress, vmGuestAddress, networkRate);
ipsToSend[i++] = ip;