Skip to content

Commit fb1e903

Browse files
committed
Merge branch '4.14'
2 parents 5bea0a1 + 83ae6d7 commit fb1e903

8 files changed

Lines changed: 94 additions & 70 deletions

File tree

api/src/main/java/com/cloud/vm/NicProfile.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ public void setDeviceId(int deviceId) {
175175
this.deviceId = deviceId;
176176
}
177177

178+
public void setDeviceId(Integer deviceId) {
179+
this.deviceId = deviceId;
180+
}
181+
178182
public String getName() {
179183
return name;
180184
}

server/src/main/java/com/cloud/network/router/NicProfileHelperImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public NicProfile createPrivateNicProfileForGateway(final VpcGateway privateGate
8585
new NicProfile(privateNic, privateNetwork, privateNic.getBroadcastUri(), privateNic.getIsolationUri(), _networkModel.getNetworkRate(
8686
privateNetwork.getId(), router.getId()), _networkModel.isSecurityGroupSupportedInNetwork(privateNetwork), _networkModel.getNetworkTag(
8787
router.getHypervisorType(), privateNetwork));
88+
privateNicProfile.setDeviceId(null);
8889

8990
if (router.getIsRedundantRouter()) {
9091
String newMacAddress = NetUtils.long2Mac(NetUtils.createSequenceBasedMacAddress(ipVO.getMacAddress(), NetworkModel.MACIdentifier.value()));
@@ -137,4 +138,4 @@ public String acquireGuestIpAddressForVrouterRedundant(Network network) {
137138
return _ipAddrMgr.acquireGuestIpAddressByPlacement(network, null);
138139
}
139140

140-
}
141+
}

server/src/main/java/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,19 @@ public boolean finalizeCommandsOnStart(final Commands cmds, final VirtualMachine
314314
// 2) FORM PLUG NIC COMMANDS
315315
final List<Pair<Nic, Network>> guestNics = new ArrayList<Pair<Nic, Network>>();
316316
final List<Pair<Nic, Network>> publicNics = new ArrayList<Pair<Nic, Network>>();
317+
final List<Pair<Nic, Network>> privateGatewayNics = new ArrayList<Pair<Nic, Network>>();
317318
final Map<String, String> vlanMacAddress = new HashMap<String, String>();
318319

319320
final List<? extends Nic> routerNics = _nicDao.listByVmIdOrderByDeviceId(profile.getId());
320321
for (final Nic routerNic : routerNics) {
321322
final Network network = _networkModel.getNetwork(routerNic.getNetworkId());
322323
if (network.getTrafficType() == TrafficType.Guest) {
323324
final Pair<Nic, Network> guestNic = new Pair<Nic, Network>(routerNic, network);
324-
guestNics.add(guestNic);
325+
if (_networkModel.isPrivateGateway(routerNic.getNetworkId())) {
326+
privateGatewayNics.add(guestNic);
327+
} else {
328+
guestNics.add(guestNic);
329+
}
325330
} else if (network.getTrafficType() == TrafficType.Public) {
326331
final Pair<Nic, Network> publicNic = new Pair<Nic, Network>(routerNic, network);
327332
publicNics.add(publicNic);
@@ -375,43 +380,48 @@ public boolean finalizeCommandsOnStart(final Commands cmds, final VirtualMachine
375380
_commandSetupHelper.createVpcAssociatePublicIPCommands(domainRouterVO, sourceNat, cmds, vlanMacAddress);
376381
}
377382

383+
// add VPC router to private gateway networks
384+
for (final Pair<Nic, Network> nicNtwk : privateGatewayNics) {
385+
final Nic guestNic = updateNicWithDeviceId(nicNtwk.first().getId(), deviceId);
386+
deviceId ++;
387+
// plug guest nic
388+
final PlugNicCommand plugNicCmd = new PlugNicCommand(_nwHelper.getNicTO(domainRouterVO, guestNic.getNetworkId(), null), domainRouterVO.getInstanceName(), domainRouterVO.getType(), details);
389+
cmds.addCommand(plugNicCmd);
390+
// set private network
391+
final PrivateIpVO ipVO = _privateIpDao.findByIpAndSourceNetworkId(guestNic.getNetworkId(), guestNic.getIPv4Address());
392+
final Network network = _networkDao.findById(guestNic.getNetworkId());
393+
BroadcastDomainType.getValue(network.getBroadcastUri());
394+
final String netmask = NetUtils.getCidrNetmask(network.getCidr());
395+
final PrivateIpAddress ip = new PrivateIpAddress(ipVO, network.getBroadcastUri().toString(), network.getGateway(), netmask, guestNic.getMacAddress());
396+
397+
final List<PrivateIpAddress> privateIps = new ArrayList<PrivateIpAddress>(1);
398+
privateIps.add(ip);
399+
_commandSetupHelper.createVpcAssociatePrivateIPCommands(domainRouterVO, privateIps, cmds, true);
400+
401+
final Long privateGwAclId = _vpcGatewayDao.getNetworkAclIdForPrivateIp(ipVO.getVpcId(), ipVO.getNetworkId(), ipVO.getIpAddress());
402+
403+
if (privateGwAclId != null) {
404+
// set network acl on private gateway
405+
final List<NetworkACLItemVO> networkACLs = _networkACLItemDao.listByACL(privateGwAclId);
406+
s_logger.debug("Found " + networkACLs.size() + " network ACLs to apply as a part of VPC VR " + domainRouterVO + " start for private gateway ip = "
407+
+ ipVO.getIpAddress());
408+
409+
_commandSetupHelper.createNetworkACLsCommands(networkACLs, domainRouterVO, cmds, ipVO.getNetworkId(), true);
410+
}
411+
}
412+
378413
// add VPC router to guest networks
379414
for (final Pair<Nic, Network> nicNtwk : guestNics) {
380415
final Nic guestNic = updateNicWithDeviceId(nicNtwk.first().getId(), deviceId);
381416
deviceId ++;
382417
// plug guest nic
383418
final PlugNicCommand plugNicCmd = new PlugNicCommand(_nwHelper.getNicTO(domainRouterVO, guestNic.getNetworkId(), null), domainRouterVO.getInstanceName(), domainRouterVO.getType(), details);
384419
cmds.addCommand(plugNicCmd);
385-
if (!_networkModel.isPrivateGateway(guestNic.getNetworkId())) {
386-
// set guest network
387-
final VirtualMachine vm = _vmDao.findById(domainRouterVO.getId());
388-
final NicProfile nicProfile = _networkModel.getNicProfile(vm, guestNic.getNetworkId(), null);
389-
final SetupGuestNetworkCommand setupCmd = _commandSetupHelper.createSetupGuestNetworkCommand(domainRouterVO, true, nicProfile);
390-
cmds.addCommand(setupCmd);
391-
} else {
392-
393-
// set private network
394-
final PrivateIpVO ipVO = _privateIpDao.findByIpAndSourceNetworkId(guestNic.getNetworkId(), guestNic.getIPv4Address());
395-
final Network network = _networkDao.findById(guestNic.getNetworkId());
396-
BroadcastDomainType.getValue(network.getBroadcastUri());
397-
final String netmask = NetUtils.getCidrNetmask(network.getCidr());
398-
final PrivateIpAddress ip = new PrivateIpAddress(ipVO, network.getBroadcastUri().toString(), network.getGateway(), netmask, guestNic.getMacAddress());
399-
400-
final List<PrivateIpAddress> privateIps = new ArrayList<PrivateIpAddress>(1);
401-
privateIps.add(ip);
402-
_commandSetupHelper.createVpcAssociatePrivateIPCommands(domainRouterVO, privateIps, cmds, true);
403-
404-
final Long privateGwAclId = _vpcGatewayDao.getNetworkAclIdForPrivateIp(ipVO.getVpcId(), ipVO.getNetworkId(), ipVO.getIpAddress());
405-
406-
if (privateGwAclId != null) {
407-
// set network acl on private gateway
408-
final List<NetworkACLItemVO> networkACLs = _networkACLItemDao.listByACL(privateGwAclId);
409-
s_logger.debug("Found " + networkACLs.size() + " network ACLs to apply as a part of VPC VR " + domainRouterVO + " start for private gateway ip = "
410-
+ ipVO.getIpAddress());
411-
412-
_commandSetupHelper.createNetworkACLsCommands(networkACLs, domainRouterVO, cmds, ipVO.getNetworkId(), true);
413-
}
414-
}
420+
// set guest network
421+
final VirtualMachine vm = _vmDao.findById(domainRouterVO.getId());
422+
final NicProfile nicProfile = _networkModel.getNicProfile(vm, guestNic.getNetworkId(), null);
423+
final SetupGuestNetworkCommand setupCmd = _commandSetupHelper.createSetupGuestNetworkCommand(domainRouterVO, true, nicProfile);
424+
cmds.addCommand(setupCmd);
415425
}
416426
} catch (final Exception ex) {
417427
s_logger.warn("Failed to add router " + domainRouterVO + " to network due to exception ", ex);

test/integration/component/test_multiple_subnets_in_isolated_network.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ def test_01_acquire_public_ips_in_isolated_network_with_single_vr(self):
429429
# 6. create new public ip range 1
430430
self.services["publiciprange"]["zoneid"] = self.zone.id
431431
self.services["publiciprange"]["forvirtualnetwork"] = "true"
432-
random_subnet_number = random.randrange(10,20)
432+
random_subnet_number = random.randrange(10,50)
433433
self.services["publiciprange"]["vlan"] = get_free_vlan(
434434
self.apiclient,
435435
self.zone.id)[1]
@@ -753,7 +753,8 @@ def test_01_acquire_public_ips_in_isolated_network_with_single_vr(self):
753753
# 20. reboot router
754754
# verify the available nics in VR should be "eth0,eth1,eth2,eth3,"
755755
# verify the IPs in VR. eth0 -> guest nic, eth2 -> source nat IP, eth3 -> new ip 6
756-
for router in routers:
756+
if len(routers) > 0:
757+
router = routers[0]
757758
cmd = rebootRouter.rebootRouterCmd()
758759
cmd.id = router.id
759760
self.apiclient.rebootRouter(cmd)

test/integration/component/test_multiple_subnets_in_isolated_network_rvr.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ def test_02_acquire_public_ips_in_isolated_network_with_redundant_vrs(self):
429429
# 6. create new public ip range 1
430430
self.services["publiciprange"]["zoneid"] = self.zone.id
431431
self.services["publiciprange"]["forvirtualnetwork"] = "true"
432-
random_subnet_number = random.randrange(10,20)
432+
random_subnet_number = random.randrange(10,50)
433433
self.services["publiciprange"]["vlan"] = get_free_vlan(
434434
self.apiclient,
435435
self.zone.id)[1]
@@ -753,7 +753,8 @@ def test_02_acquire_public_ips_in_isolated_network_with_redundant_vrs(self):
753753
# 20. reboot router
754754
# verify the available nics in VR should be "eth0,eth1,eth2,eth3,"
755755
# verify the IPs in VR. eth0 -> guest nic, eth2 -> source nat IP, eth3 -> new ip 6
756-
for router in routers:
756+
if len(routers) > 0:
757+
router = routers[0]
757758
cmd = rebootRouter.rebootRouterCmd()
758759
cmd.id = router.id
759760
self.apiclient.rebootRouter(cmd)

test/integration/component/test_multiple_subnets_in_vpc.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -328,13 +328,13 @@ def test_03_acquire_public_ips_in_vpc_with_single_vr(self):
328328
# verify the IPs in VR. eth1 -> source nat IP, eth2 -> tier 1, eth4 -> tier 2, eth5 -> new ip 6, eth3-> private gateway
329329
# 24. reboot router
330330
# verify the available nics in VR should be "eth0,eth1,eth2,eth3,eth4,eth5,"
331-
# verify the IPs in VR. eth1 -> source nat IP, eth2 -> new ip 6, eth3 -> tier 1, eth4 -> private gateway, eth5 -> tier 2
331+
# verify the IPs in VR. eth1 -> source nat IP, eth2 -> new ip 6, eth3 -> private gateway, eth4 -> tier 1, eth5 -> tier 2
332332
# 25. restart VPC with cleanup
333333
# verify the available nics in VR should be "eth0,eth1,eth2,eth3,eth4,eth5,"
334-
# verify the IPs in VR. eth1 -> source nat IP, eth2 -> new ip 6, eth3 -> tier 1, eth4 -> private gateway, eth5 -> tier 2
334+
# verify the IPs in VR. eth1 -> source nat IP, eth2 -> new ip 6, eth3 -> private gateway, eth4 -> tier 1, eth5 -> tier 2
335335
# 26. restart VPC with cleanup, makeredundant=true
336336
# verify the available nics in VR should be "eth0,eth1,eth2,eth3,eth4,eth5,"
337-
# verify the IPs in VR. eth1 -> source nat IP, eth2 -> new ip 6, eth3 -> tier 1, eth4 -> private gateway, eth5 -> tier 2
337+
# verify the IPs in VR. eth1 -> source nat IP, eth2 -> new ip 6, eth3 -> private gateway, eth4 -> tier 1, eth5 -> tier 2
338338
"""
339339

340340
# Create new domain1
@@ -479,7 +479,7 @@ def test_03_acquire_public_ips_in_vpc_with_single_vr(self):
479479
# 6. create new public ip range 1
480480
self.services["publiciprange"]["zoneid"] = self.zone.id
481481
self.services["publiciprange"]["forvirtualnetwork"] = "true"
482-
random_subnet_number = random.randrange(10,20)
482+
random_subnet_number = random.randrange(10,50)
483483
self.services["publiciprange"]["vlan"] = get_free_vlan(
484484
self.apiclient,
485485
self.zone.id)[1]
@@ -900,9 +900,10 @@ def test_03_acquire_public_ips_in_vpc_with_single_vr(self):
900900

901901
# 24. reboot router
902902
# verify the available nics in VR should be "eth0,eth1,eth2,eth3,eth4,eth5,"
903-
# verify the IPs in VR. eth1 -> source nat IP, eth2 -> new ip 6, eth3 -> tier 1, eth4 -> private gateway, eth5 -> tier 2
903+
# verify the IPs in VR. eth1 -> source nat IP, eth2 -> new ip 6, eth3 -> private gateway, eth4 -> tier 1, eth5 -> tier 2
904904
routers = self.get_vpc_routers(self.vpc1.id)
905-
for router in routers:
905+
if len(routers) > 0:
906+
router = routers[0]
906907
cmd = rebootRouter.rebootRouterCmd()
907908
cmd.id = router.id
908909
self.apiclient.rebootRouter(cmd)
@@ -913,14 +914,14 @@ def test_03_acquire_public_ips_in_vpc_with_single_vr(self):
913914
self.verify_ip_address_in_router(router, host, controlIp, "eth0", True)
914915
self.verify_ip_address_in_router(router, host, sourcenatIp, "eth1", True)
915916
self.verify_ip_address_in_router(router, host, ipaddress_6.ipaddress.ipaddress, "eth2", True)
916-
self.verify_ip_address_in_router(router, host, tier1_Ip, "eth3", True)
917-
self.verify_ip_address_in_router(router, host, private_gateway_ip, "eth4", True)
917+
self.verify_ip_address_in_router(router, host, private_gateway_ip, "eth3", True)
918+
self.verify_ip_address_in_router(router, host, tier1_Ip, "eth4", True)
918919
self.verify_ip_address_in_router(router, host, tier2_Ip, "eth5", True)
919-
self.verify_router_publicnic_state(router, host, "eth1|eth2|eth4")
920+
self.verify_router_publicnic_state(router, host, "eth1|eth2|eth3")
920921

921922
# 25. restart VPC with cleanup
922923
# verify the available nics in VR should be "eth0,eth1,eth2,eth3,eth4,eth5,"
923-
# verify the IPs in VR. eth1 -> source nat IP, eth2 -> new ip 6, eth3 -> tier 1, eth4 -> private gateway, eth5 -> tier 2
924+
# verify the IPs in VR. eth1 -> source nat IP, eth2 -> new ip 6, eth3 -> private gateway, eth4 -> tier 1, eth5 -> tier 2
924925
self.vpc1.restart(self.apiclient, cleanup=True)
925926
routers = self.get_vpc_routers(self.vpc1.id)
926927
for router in routers:
@@ -930,14 +931,14 @@ def test_03_acquire_public_ips_in_vpc_with_single_vr(self):
930931
self.verify_ip_address_in_router(router, host, controlIp, "eth0", True)
931932
self.verify_ip_address_in_router(router, host, sourcenatIp, "eth1", True)
932933
self.verify_ip_address_in_router(router, host, ipaddress_6.ipaddress.ipaddress, "eth2", True)
933-
self.verify_ip_address_in_router(router, host, tier1_Ip, "eth3", True)
934-
self.verify_ip_address_in_router(router, host, private_gateway_ip, "eth4", True)
934+
self.verify_ip_address_in_router(router, host, private_gateway_ip, "eth3", True)
935+
self.verify_ip_address_in_router(router, host, tier1_Ip, "eth4", True)
935936
self.verify_ip_address_in_router(router, host, tier2_Ip, "eth5", True)
936-
self.verify_router_publicnic_state(router, host, "eth1|eth2|eth4")
937+
self.verify_router_publicnic_state(router, host, "eth1|eth2|eth3")
937938

938939
# 26. restart VPC with cleanup, makeredundant=true
939940
# verify the available nics in VR should be "eth0,eth1,eth2,eth3,eth4,eth5,"
940-
# verify the IPs in VR. eth1 -> source nat IP, eth2 -> new ip 6, eth3 -> tier 1, eth4 -> private gateway, eth5 -> tier 2
941+
# verify the IPs in VR. eth1 -> source nat IP, eth2 -> new ip 6, eth3 -> private gateway, eth4 -> tier 1, eth5 -> tier 2
941942
self.vpc1.restart(self.apiclient, cleanup=True, makeredundant=True)
942943
routers = self.get_vpc_routers(self.vpc1.id)
943944
for router in routers:
@@ -947,7 +948,7 @@ def test_03_acquire_public_ips_in_vpc_with_single_vr(self):
947948
self.verify_ip_address_in_router(router, host, controlIp, "eth0", True)
948949
self.verify_ip_address_in_router(router, host, sourcenatIp, "eth1", True)
949950
self.verify_ip_address_in_router(router, host, ipaddress_6.ipaddress.ipaddress, "eth2", True)
950-
self.verify_ip_address_in_router(router, host, tier1_Ip, "eth3", True)
951-
self.verify_ip_address_in_router(router, host, private_gateway_ip, "eth4", True)
951+
self.verify_ip_address_in_router(router, host, private_gateway_ip, "eth3", True)
952+
self.verify_ip_address_in_router(router, host, tier1_Ip, "eth4", True)
952953
self.verify_ip_address_in_router(router, host, tier2_Ip, "eth5", True)
953-
self.verify_router_publicnic_state(router, host, "eth1|eth2|eth4")
954+
self.verify_router_publicnic_state(router, host, "eth1|eth2|eth3")

0 commit comments

Comments
 (0)