Pearl1594 commented on code in PR #6426:
URL: https://github.com/apache/cloudstack/pull/6426#discussion_r905970496
##########
engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java:
##########
@@ -993,16 +998,75 @@ public Pair<NicProfile, Integer> allocateNic(final
NicProfile requested, final N
}
deviceId = applyProfileToNic(vo, profile, deviceId);
-
+ if (vm.getType() == Type.DomainRouter) {
+ setMtuDetailsInVRNic(vm.getId(), network, vo);
+ }
vo = _nicDao.persist(vo);
final Integer networkRate =
_networkModel.getNetworkRate(network.getId(), vm.getId());
final NicProfile vmNic = new NicProfile(vo, network,
vo.getBroadcastUri(), vo.getIsolationUri(), networkRate,
_networkModel.isSecurityGroupSupportedInNetwork(network),
_networkModel.getNetworkTag(vm.getHypervisorType(), network));
-
+ if (vm.getType() == Type.DomainRouter) {
+ setMtuInVRNicProfile(vm.getId(), network.getTrafficType(), vmNic);
+ }
return new Pair<NicProfile, Integer>(vmNic, Integer.valueOf(deviceId));
}
+ private void setMtuDetailsInVRNic(final long vmId, Network network, NicVO
vo) {
+ if (TrafficType.Public == network.getTrafficType()) {
+ Pair<NetworkVO, VpcVO> networks =
getGuestNetworkRouterAndVpcDetails(vmId);
+ if (networks == null) {
+ return;
+ }
+ NetworkVO networkVO = networks.first();
+ VpcVO vpcVO = networks.second();
+ if (vpcVO != null) {
+ vo.setMtu(vpcVO.getPublicMtu());
+ } else {
+ vo.setMtu(networkVO.getPublicIfaceMtu());
+ }
+ } else if (TrafficType.Guest == network.getTrafficType()) {
+ vo.setMtu(network.getPrivateIfaceMtu());
+ }
+ }
+
+ private void setMtuInVRNicProfile(final long vmId, TrafficType
trafficType, NicProfile vmNic) {
+ Pair<NetworkVO, VpcVO> networks =
getGuestNetworkRouterAndVpcDetails(vmId);
+ if (networks == null) {
+ return;
+ }
+ NetworkVO networkVO = networks.first();
+ VpcVO vpcVO = networks.second();
+ if (networkVO != null) {
+ if (TrafficType.Public == trafficType) {
+ if (vpcVO != null) {
+ vmNic.setMtu(vpcVO.getPublicMtu());
+ } else {
+ vmNic.setMtu(networkVO.getPublicIfaceMtu());
+ }
+ } else if (TrafficType.Guest == trafficType) {
+ vmNic.setMtu(networkVO.getPrivateIfaceMtu());
+ }
+ }
+ }
+
+ private Pair<NetworkVO, VpcVO> getGuestNetworkRouterAndVpcDetails(long
routerId) {
+ List<DomainRouterJoinVO> routerVo =
routerJoinDao.getRouterByIdAndTrafficType(routerId, TrafficType.Guest);
+ if (routerVo.isEmpty()) {
+ routerVo = routerJoinDao.getRouterByIdAndTrafficType(routerId,
TrafficType.Public);
+ if (routerVo.isEmpty()) {
+ return null;
+ }
+ }
Review Comment:
Since it's domainRouterview records, to get the network details, I need the
Guest and Public nics to update the mtu details and not the control nics
##########
test/integration/smoke/test_network.py:
##########
@@ -2043,4 +2060,341 @@ def test_03_destroySharedNetwork(self):
len(nic_ip_address),
0,
"Failed to find the placeholder IP"
- )
\ No newline at end of file
+ )
+
+
+class TestNetworkWithMtuConfiguration(cloudstackTestCase):
Review Comment:
Sure , will do
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]