mirror of https://github.com/apache/cloudstack.git
add rate limit for system VM, after you change rate limit, you need to restart managementserver to make it effect
This commit is contained in:
parent
0435d99247
commit
fb628a1929
|
|
@ -25,7 +25,9 @@ import com.cloud.vm.ConsoleProxyVO;
|
|||
|
||||
public class StartConsoleProxyCommand extends AbstractStartCommand {
|
||||
|
||||
private ConsoleProxyVO proxy;
|
||||
private ConsoleProxyVO proxy;
|
||||
int networkRateMbps;
|
||||
int networkRateMulticastMbps;
|
||||
private int proxyCmdPort;
|
||||
private String vncPort;
|
||||
private String urlPort;
|
||||
|
|
@ -36,9 +38,12 @@ public class StartConsoleProxyCommand extends AbstractStartCommand {
|
|||
protected StartConsoleProxyCommand() {
|
||||
}
|
||||
|
||||
public StartConsoleProxyCommand(int proxyCmdPort, ConsoleProxyVO proxy, String vmName, String storageHost,
|
||||
public StartConsoleProxyCommand(int networkRateMbps, int networkRateMulticastMbps, int proxyCmdPort,
|
||||
ConsoleProxyVO proxy, String vmName, String storageHost,
|
||||
List<VolumeVO> vols, String vncPort, String urlPort, String mgmtHost, int mgmtPort, boolean sslEnabled) {
|
||||
super(vmName, storageHost, vols);
|
||||
super(vmName, storageHost, vols);
|
||||
this.networkRateMbps = networkRateMbps;
|
||||
this.networkRateMulticastMbps = networkRateMulticastMbps;
|
||||
this.proxyCmdPort = proxyCmdPort;
|
||||
this.proxy = proxy;
|
||||
this.vncPort = vncPort;
|
||||
|
|
@ -57,7 +62,15 @@ public class StartConsoleProxyCommand extends AbstractStartCommand {
|
|||
return proxy;
|
||||
}
|
||||
|
||||
public int getProxyCmdPort() {
|
||||
public int getNetworkRateMbps() {
|
||||
return networkRateMbps;
|
||||
}
|
||||
|
||||
public int getNetworkRateMulticastMbps() {
|
||||
return networkRateMulticastMbps;
|
||||
}
|
||||
|
||||
public int getProxyCmdPort() {
|
||||
return proxyCmdPort;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ import com.cloud.vm.DomainRouter.Role;
|
|||
public class StartRouterCommand extends AbstractStartCommand {
|
||||
|
||||
DomainRouterVO router;
|
||||
int networkRateMbps;
|
||||
int networkRateMulticastMbps;
|
||||
|
||||
protected StartRouterCommand() {
|
||||
super();
|
||||
|
|
@ -38,16 +40,27 @@ public class StartRouterCommand extends AbstractStartCommand {
|
|||
return true;
|
||||
}
|
||||
|
||||
public StartRouterCommand(DomainRouterVO router, String routerName, String[] storageIps, List<VolumeVO> vols, boolean mirroredVols) {
|
||||
public StartRouterCommand(DomainRouterVO router, int networkRateMbps, int networkRateMulticastMbps,
|
||||
String routerName, String[] storageIps, List<VolumeVO> vols, boolean mirroredVols) {
|
||||
super(routerName, storageIps, vols, mirroredVols);
|
||||
this.router = router;
|
||||
this.networkRateMbps = networkRateMbps;
|
||||
this.networkRateMulticastMbps = networkRateMulticastMbps;
|
||||
}
|
||||
|
||||
public DomainRouter getRouter() {
|
||||
return router;
|
||||
}
|
||||
|
||||
public String getBootArgs() {
|
||||
public int getNetworkRateMbps() {
|
||||
return networkRateMbps;
|
||||
}
|
||||
|
||||
public int getNetworkRateMulticastMbps() {
|
||||
return networkRateMulticastMbps;
|
||||
}
|
||||
|
||||
public String getBootArgs() {
|
||||
String eth2Ip = router.getPublicIpAddress()==null?"0.0.0.0":router.getPublicIpAddress();
|
||||
String basic = " eth0ip=" + router.getGuestIpAddress() + " eth0mask=" + router.getGuestNetmask() + " eth1ip="
|
||||
+ router.getPrivateIpAddress() + " eth1mask=" + router.getPrivateNetmask() + " gateway=" + router.getGateway()
|
||||
|
|
|
|||
|
|
@ -27,7 +27,9 @@ import com.cloud.vm.SecondaryStorageVmVO;
|
|||
|
||||
public class StartSecStorageVmCommand extends AbstractStartCommand {
|
||||
|
||||
private SecondaryStorageVmVO secStorageVm;
|
||||
private SecondaryStorageVmVO secStorageVm;
|
||||
int networkRateMbps;
|
||||
int networkRateMulticastMbps;
|
||||
private int proxyCmdPort;
|
||||
private String mgmt_host;
|
||||
private int mgmt_port;
|
||||
|
|
@ -36,9 +38,12 @@ public class StartSecStorageVmCommand extends AbstractStartCommand {
|
|||
protected StartSecStorageVmCommand() {
|
||||
}
|
||||
|
||||
public StartSecStorageVmCommand(int proxyCmdPort, SecondaryStorageVmVO secStorageVm, String vmName, String storageHost,
|
||||
public StartSecStorageVmCommand(int networkRateMbps, int networkRateMulticastMbps, int proxyCmdPort,
|
||||
SecondaryStorageVmVO secStorageVm, String vmName, String storageHost,
|
||||
List<VolumeVO> vols, String mgmtHost, int mgmtPort, boolean sslCopy) {
|
||||
super(vmName, storageHost, vols);
|
||||
super(vmName, storageHost, vols);
|
||||
this.networkRateMbps = networkRateMbps;
|
||||
this.networkRateMulticastMbps = networkRateMulticastMbps;
|
||||
this.proxyCmdPort = proxyCmdPort;
|
||||
this.secStorageVm = secStorageVm;
|
||||
|
||||
|
|
@ -56,7 +61,15 @@ public class StartSecStorageVmCommand extends AbstractStartCommand {
|
|||
return secStorageVm;
|
||||
}
|
||||
|
||||
public int getProxyCmdPort() {
|
||||
public int getNetworkRateMbps() {
|
||||
return networkRateMbps;
|
||||
}
|
||||
|
||||
public int getNetworkRateMulticastMbps() {
|
||||
return networkRateMulticastMbps;
|
||||
}
|
||||
|
||||
public int getProxyCmdPort() {
|
||||
return proxyCmdPort;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -686,7 +686,8 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
|
|||
if (nic.getNetworkRateMbps() != null) {
|
||||
vifr.qosAlgorithmType = "ratelimit";
|
||||
vifr.qosAlgorithmParams = new HashMap<String, String>();
|
||||
vifr.qosAlgorithmParams.put("kbps", Integer.toString(nic.getNetworkRateMbps() * 1000));
|
||||
// convert mbs to kilobyte per second
|
||||
vifr.qosAlgorithmParams.put("kbps", Integer.toString(nic.getNetworkRateMbps() * 128));
|
||||
}
|
||||
|
||||
VIF vif = VIF.create(conn, vifr);
|
||||
|
|
@ -1119,7 +1120,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
|
|||
bootArgs += " pod=" + _pod;
|
||||
bootArgs += " localgw=" + _localGateway;
|
||||
String result = startSystemVM(vmName, storage.getVlanId(), network, cmd.getVolumes(), bootArgs, storage.getGuestMacAddress(), storage.getGuestIpAddress(), storage
|
||||
.getPrivateMacAddress(), storage.getPublicMacAddress(), cmd.getProxyCmdPort(), storage.getRamSize(), storage.getGuestOSId());
|
||||
.getPrivateMacAddress(), storage.getPublicMacAddress(), cmd.getProxyCmdPort(), storage.getRamSize(), storage.getGuestOSId(), cmd.getNetworkRateMbps());
|
||||
if (result == null) {
|
||||
return new StartSecStorageVmAnswer(cmd);
|
||||
}
|
||||
|
|
@ -2864,7 +2865,8 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
|
|||
if ( rate == 0 ) rate = 200;
|
||||
vifr.qosAlgorithmType = "ratelimit";
|
||||
vifr.qosAlgorithmParams = new HashMap<String, String>();
|
||||
vifr.qosAlgorithmParams.put("kbps", Integer.toString(rate * 1000));
|
||||
// convert mbs to kilobyte per second
|
||||
vifr.qosAlgorithmParams.put("kbps", Integer.toString(rate * 128));
|
||||
return VIF.create(conn, vifr);
|
||||
}
|
||||
|
||||
|
|
@ -3103,7 +3105,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
|
|||
String bootArgs = cmd.getBootArgs();
|
||||
|
||||
String result = startSystemVM(vmName, router.getVlanId(), network, cmd.getVolumes(), bootArgs, router.getGuestMacAddress(), router.getPrivateIpAddress(), router
|
||||
.getPrivateMacAddress(), router.getPublicMacAddress(), 3922, router.getRamSize(), router.getGuestOSId());
|
||||
.getPrivateMacAddress(), router.getPublicMacAddress(), 3922, router.getRamSize(), router.getGuestOSId(), cmd.getNetworkRateMbps());
|
||||
if (result == null) {
|
||||
networkUsage(router.getPrivateIpAddress(), "create", null);
|
||||
return new StartRouterAnswer(cmd);
|
||||
|
|
@ -3118,7 +3120,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
|
|||
}
|
||||
|
||||
protected String startSystemVM(String vmName, String vlanId, Network nw0, List<VolumeVO> vols, String bootArgs, String guestMacAddr, String privateIp, String privateMacAddr,
|
||||
String publicMacAddr, int cmdPort, long ramSize, long guestOsId) {
|
||||
String publicMacAddr, int cmdPort, long ramSize, long guestOsId, int networkRateMbps) {
|
||||
|
||||
setupLinkLocalNetwork();
|
||||
VM vm = null;
|
||||
|
|
@ -3191,7 +3193,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
|
|||
} else {
|
||||
network = nw0;
|
||||
}
|
||||
createVIF(conn, vm, guestMacAddr, 0, "0", network);
|
||||
createVIF(conn, vm, guestMacAddr, networkRateMbps, "0", network);
|
||||
|
||||
/* create VIF1 */
|
||||
/* For routing vm, set its network as link local bridge */
|
||||
|
|
@ -3200,7 +3202,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
|
|||
} else {
|
||||
network = Network.getByUuid(conn, _host.privateNetwork);
|
||||
}
|
||||
createVIF(conn, vm, privateMacAddr, 0, "1", network);
|
||||
createVIF(conn, vm, privateMacAddr, networkRateMbps, "1", network);
|
||||
|
||||
/* create VIF2 */
|
||||
if( !publicMacAddr.equalsIgnoreCase("FE:FF:FF:FF:FF:FF") ) {
|
||||
|
|
@ -3213,7 +3215,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
|
|||
throw new InternalErrorException("Failed to enable VLAN network with tag: " + vlanId);
|
||||
}
|
||||
}
|
||||
createVIF(conn, vm, publicMacAddr, 0, "2", network);
|
||||
createVIF(conn, vm, publicMacAddr, networkRateMbps, "2", network);
|
||||
}
|
||||
/* set up PV dom argument */
|
||||
String pvargs = vm.getPVArgs(conn);
|
||||
|
|
@ -3293,7 +3295,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
|
|||
bootArgs += " localgw=" + _localGateway;
|
||||
|
||||
String result = startSystemVM(vmName, proxy.getVlanId(), network, cmd.getVolumes(), bootArgs, proxy.getGuestMacAddress(), proxy.getGuestIpAddress(), proxy
|
||||
.getPrivateMacAddress(), proxy.getPublicMacAddress(), cmd.getProxyCmdPort(), proxy.getRamSize(), proxy.getGuestOSId());
|
||||
.getPrivateMacAddress(), proxy.getPublicMacAddress(), cmd.getProxyCmdPort(), proxy.getRamSize(), proxy.getGuestOSId(), cmd.getNetworkRateMbps());
|
||||
if (result == null) {
|
||||
return new StartConsoleProxyAnswer(cmd);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -240,6 +240,8 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
private ConsoleProxyListener _listener;
|
||||
|
||||
private ServiceOfferingVO _serviceOffering;
|
||||
private int _networkRate;
|
||||
private int _multicastRate;
|
||||
private VMTemplateVO _template;
|
||||
|
||||
NetworkOfferingVO _publicNetworkOffering;
|
||||
|
|
@ -646,9 +648,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
|
||||
// carry the console proxy port info over so that we don't
|
||||
// need to configure agent on this
|
||||
StartConsoleProxyCommand cmdStart = new StartConsoleProxyCommand(_proxyCmdPort, proxy, proxy.getName(), "", vols,
|
||||
Integer.toString(_consoleProxyPort), Integer.toString(_consoleProxyUrlPort), _mgmt_host, _mgmt_port, _sslEnabled);
|
||||
|
||||
StartConsoleProxyCommand cmdStart = new StartConsoleProxyCommand(_networkRate, _multicastRate,
|
||||
_proxyCmdPort, proxy, proxy.getName(), "", vols, Integer.toString(_consoleProxyPort),
|
||||
Integer.toString(_consoleProxyUrlPort), _mgmt_host, _mgmt_port, _sslEnabled);
|
||||
if (s_logger.isDebugEnabled())
|
||||
s_logger.debug("Sending start command for console proxy " + proxy.getName() + " to " + routingHost.getName());
|
||||
try {
|
||||
|
|
@ -2279,6 +2281,10 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
|||
}
|
||||
|
||||
boolean useLocalStorage = Boolean.parseBoolean((String) params.get(Config.SystemVMUseLocalStorage.key()));
|
||||
String networkRateStr = _configDao.getValue("network.throttling.rate");
|
||||
String multicastRateStr = _configDao.getValue("multicast.throttling.rate");
|
||||
_networkRate = ((networkRateStr == null) ? 200 : Integer.parseInt(networkRateStr));
|
||||
_multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr));
|
||||
_serviceOffering = new ServiceOfferingVO("Fake Offering For DomP", 1, _proxyRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized,
|
||||
useLocalStorage, true, null);
|
||||
_serviceOffering.setUniqueName("Cloud.com-ConsoleProxy");
|
||||
|
|
|
|||
|
|
@ -226,6 +226,8 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||
int _routerCleanupInterval = 3600;
|
||||
int _routerStatsInterval = 300;
|
||||
private ServiceOfferingVO _offering;
|
||||
private int _networkRate;
|
||||
private int _multicastRate;
|
||||
private HashMap<String, NetworkOfferingVO> _systemNetworks = new HashMap<String, NetworkOfferingVO>(5);
|
||||
|
||||
private VMTemplateVO _template;
|
||||
|
|
@ -979,7 +981,8 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||
|
||||
try {
|
||||
String[] storageIps = new String[2];
|
||||
final StartRouterCommand cmdStartRouter = new StartRouterCommand(router, name, storageIps, vols, mirroredVols);
|
||||
final StartRouterCommand cmdStartRouter = new StartRouterCommand(router, _networkRate,
|
||||
_multicastRate, name, storageIps, vols, mirroredVols);
|
||||
answer = _agentMgr.send(routingHost.getId(), cmdStartRouter);
|
||||
if (answer != null && answer.getResult()) {
|
||||
if (answer instanceof StartRouterAnswer){
|
||||
|
|
@ -1849,6 +1852,10 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||
_haMgr.registerHandler(VirtualMachine.Type.DomainRouter, this);
|
||||
|
||||
boolean useLocalStorage = Boolean.parseBoolean((String)params.get(Config.SystemVMUseLocalStorage.key()));
|
||||
String networkRateStr = _configDao.getValue("network.throttling.rate");
|
||||
String multicastRateStr = _configDao.getValue("multicast.throttling.rate");
|
||||
_networkRate = ((networkRateStr == null) ? 200 : Integer.parseInt(networkRateStr));
|
||||
_multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr));
|
||||
_offering = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, useLocalStorage, true, null);
|
||||
_offering.setUniqueName("Cloud.Com-SoftwareRouter");
|
||||
_offering = _serviceOfferingDao.persistSystemServiceOffering(_offering);
|
||||
|
|
|
|||
|
|
@ -198,6 +198,8 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||
private SecondaryStorageListener _listener;
|
||||
|
||||
private ServiceOfferingVO _serviceOffering;
|
||||
private int _networkRate;
|
||||
private int _multicastRate;
|
||||
private VMTemplateVO _template;
|
||||
@Inject private ConfigurationDao _configDao;
|
||||
@Inject private EventDao _eventDao;
|
||||
|
|
@ -372,9 +374,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||
|
||||
// carry the secondary storage vm port info over so that we don't
|
||||
// need to configure agent on this
|
||||
StartSecStorageVmCommand cmdStart = new StartSecStorageVmCommand(
|
||||
_secStorageVmCmdPort, secStorageVm, secStorageVm.getName(), "",
|
||||
vols, _mgmt_host, _mgmt_port, _useSSlCopy);
|
||||
StartSecStorageVmCommand cmdStart = new StartSecStorageVmCommand(_networkRate,
|
||||
_multicastRate, _secStorageVmCmdPort, secStorageVm,
|
||||
secStorageVm.getName(), "", vols, _mgmt_host, _mgmt_port, _useSSlCopy);
|
||||
|
||||
if (s_logger.isDebugEnabled())
|
||||
s_logger.debug("Sending start command for secondary storage vm "
|
||||
|
|
@ -1366,6 +1368,10 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||
}
|
||||
|
||||
boolean useLocalStorage = Boolean.parseBoolean((String)params.get(Config.SystemVMUseLocalStorage.key()));
|
||||
String networkRateStr = _configDao.getValue("network.throttling.rate");
|
||||
String multicastRateStr = _configDao.getValue("multicast.throttling.rate");
|
||||
_networkRate = ((networkRateStr == null) ? 200 : Integer.parseInt(networkRateStr));
|
||||
_multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr));
|
||||
_serviceOffering = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, useLocalStorage, true, null);
|
||||
_serviceOffering.setUniqueName("Cloud.com-SecondaryStorage");
|
||||
_serviceOffering = _offeringDao.persistSystemServiceOffering(_serviceOffering);
|
||||
|
|
|
|||
Loading…
Reference in New Issue