diff --git a/server/src/main/java/com/cloud/bgp/BGPServiceImpl.java b/server/src/main/java/com/cloud/bgp/BGPServiceImpl.java index 4236ca52b401..b78b7de6c7de 100644 --- a/server/src/main/java/com/cloud/bgp/BGPServiceImpl.java +++ b/server/src/main/java/com/cloud/bgp/BGPServiceImpl.java @@ -417,6 +417,13 @@ public boolean applyBgpPeers(Vpc vpc, boolean continueOnError) throws ResourceUn NetworkElement provider = networkModel.getElementImplementingProvider(gatewayProviderStr); if (provider != null && provider instanceof BgpServiceProvider) { List bgpPeers = bgpPeerDao.listNonRevokeByVpcId(vpc.getId()); + if (CollectionUtils.isEmpty(bgpPeers)) { + Account owner = accountDao.findByIdIncludingRemoved(vpc.getAccountId()); + List bgpPeerIds = routedIpv4Manager.getBgpPeerIdsForAccount(owner, vpc.getZoneId()); + bgpPeers = bgpPeerIds.stream() + .map(bgpPeerId -> bgpPeerDao.findById(bgpPeerId)) + .collect(Collectors.toList()); + } LOGGER.debug(String.format("Applying BPG Peers for VPC [%s]: [%s]", vpc, bgpPeers)); List networks = networkModel.listNetworksByVpc(vpc.getId()); if (CollectionUtils.isNotEmpty(networks)) { diff --git a/test/integration/smoke/test_ipv4_routing.py b/test/integration/smoke/test_ipv4_routing.py index c3f34d7a7765..5590a36f1290 100644 --- a/test/integration/smoke/test_ipv4_routing.py +++ b/test/integration/smoke/test_ipv4_routing.py @@ -1240,8 +1240,10 @@ def test_11_isolated_network_with_dynamic_routed_mode(self): # 5. Verify frr.conf in network VR # 6. Reboot VR # 7. Verify frr.conf in network VR - # 8. Update network BGP peers (to null) + # 8. Update network BGP peers (to bgppeer_2) # 9. Verify frr.conf in network VR + # 10. Update network BGP peers (to null) + # 11. Verify frr.conf in network VR """ self.message("Running test_11_isolated_network_with_dynamic_routed_mode") @@ -1255,15 +1257,6 @@ def test_11_isolated_network_with_dynamic_routed_mode(self): ) self.cleanup.append(bgppeer_1) - bgppeer_2 = BgpPeer.create( - self.apiclient, - zoneid=self.zone.id, - asnumber=ASN_2, - ipaddress=IP4_ADDR_2, - password=PASSWORD_2 - ) - self.cleanup.append(bgppeer_2) - # 1. Create Isolated network with Dynamic routing test_network_dynamic = Network.create( self.apiclient, @@ -1302,6 +1295,15 @@ def test_11_isolated_network_with_dynamic_routed_mode(self): self.verifyFrrConf(network_router, frr_configs) # 4. Update network BGP peers (to bgp_peer_1 and bgp_peer_2) + bgppeer_2 = BgpPeer.create( + self.apiclient, + zoneid=self.zone.id, + asnumber=ASN_2, + ipaddress=IP4_ADDR_2, + password=PASSWORD_2 + ) + self.cleanup.append(bgppeer_2) + test_network_dynamic.changeBgpPeers( self.apiclient, bgppeerids=[bgppeer_1.id, bgppeer_2.id] @@ -1327,10 +1329,10 @@ def test_11_isolated_network_with_dynamic_routed_mode(self): network_router = self.get_router(networkid=test_network_dynamic.id) self.verifyFrrConf(network_router, frr_configs) - # 8. Update network BGP peers (to null) + # 8. Update network BGP peers (to bgppeer_2) test_network_dynamic.changeBgpPeers( self.apiclient, - bgppeerids=[] + bgppeerids=[bgppeer_2.id] ) # 9. Verify frr.conf in network VR @@ -1339,13 +1341,31 @@ def test_11_isolated_network_with_dynamic_routed_mode(self): {"config": "neighbor %s password %s" % (bgppeer_1.ipaddress, PASSWORD_1), "exists": False}, {"config": "neighbor %s remote-as %s" % (bgppeer_2.ipaddress, bgppeer_2.asnumber), - "exists": False}, + "exists": True}, {"config": "neighbor %s password %s" % (bgppeer_2.ipaddress, PASSWORD_2), - "exists": False}, + "exists": True}, {"config": "network %s" % test_network_dynamic.cidr, - "exists": False}] + "exists": True}] self.verifyFrrConf(network_router, frr_configs) + # 10. Update network BGP peers (to null) + test_network_dynamic.changeBgpPeers( + self.apiclient, + bgppeerids=[] + ) + + # 11. Verify frr.conf in network VR + frr_configs = [{"config": "neighbor %s remote-as %s" % (bgppeer_1.ipaddress, bgppeer_1.asnumber), + "exists": True}, + {"config": "neighbor %s password %s" % (bgppeer_1.ipaddress, PASSWORD_1), + "exists": True}, + {"config": "neighbor %s remote-as %s" % (bgppeer_2.ipaddress, bgppeer_2.asnumber), + "exists": True}, + {"config": "neighbor %s password %s" % (bgppeer_2.ipaddress, PASSWORD_2), + "exists": True}, + {"config": "network %s" % test_network_dynamic.cidr, + "exists": True}] + self.verifyFrrConf(network_router, frr_configs) @attr(tags=['advanced'], required_hardware=False) def test_12_vpc_and_tier_with_dynamic_routed_mode(self): @@ -1364,8 +1384,10 @@ def test_12_vpc_and_tier_with_dynamic_routed_mode(self): # 11. Verify frr.conf in VPC VR # 12. Reboot VPC VR # 13. Verify frr.conf in VPC VR - # 14. Update network BGP peers (to null) + # 14. Update network BGP peers (to bgppeer_2) # 15. Verify frr.conf in VPC VR + # 16. Update network BGP peers (to null) + # 17. Verify frr.conf in VPC VR """ self.message("Running test_12_vpc_and_tier_with_dynamic_routed_mode") @@ -1379,15 +1401,6 @@ def test_12_vpc_and_tier_with_dynamic_routed_mode(self): ) self.cleanup.append(bgppeer_1) - bgppeer_2 = BgpPeer.create( - self.apiclient, - zoneid=self.zone.id, - asnumber=ASN_2, - ipaddress=IP4_ADDR_2, - password=PASSWORD_2 - ) - self.cleanup.append(bgppeer_2) - # 2.1 VPC offering for static routing vpc_offering_dynamic = VpcOffering.create( self.apiclient, @@ -1456,6 +1469,15 @@ def test_12_vpc_and_tier_with_dynamic_routed_mode(self): self.verifyFrrConf(vpc_router, frr_configs) # 7. Update VPC BGP peers (to bgp_peer_1 and bgp_peer_2) + bgppeer_2 = BgpPeer.create( + self.apiclient, + zoneid=self.zone.id, + asnumber=ASN_2, + ipaddress=IP4_ADDR_2, + password=PASSWORD_2 + ) + self.cleanup.append(bgppeer_2) + test_vpc_dynamic.changeBgpPeers( self.apiclient, bgppeerids=[bgppeer_1.id, bgppeer_2.id] @@ -1523,10 +1545,10 @@ def test_12_vpc_and_tier_with_dynamic_routed_mode(self): vpc_router = self.get_router(vpcid=test_vpc_dynamic.id) self.verifyFrrConf(vpc_router, frr_configs) - # 14. Update VPC BGP peers (to null) + # 14. Update VPC BGP peers (to bgppeer_2) test_vpc_dynamic.changeBgpPeers( self.apiclient, - bgppeerids=[] + bgppeerids=[bgppeer_2.id] ) # 15. Verify frr.conf in VPC VR @@ -1535,13 +1557,34 @@ def test_12_vpc_and_tier_with_dynamic_routed_mode(self): {"config": "neighbor %s password %s" % (bgppeer_1.ipaddress, PASSWORD_1), "exists": False}, {"config": "neighbor %s remote-as %s" % (bgppeer_2.ipaddress, bgppeer_2.asnumber), - "exists": False}, + "exists": True}, {"config": "neighbor %s password %s" % (bgppeer_2.ipaddress, PASSWORD_2), - "exists": False}, + "exists": True}, {"config": "network %s" % test_vpc_tier_dynamic_1.cidr, - "exists": False}, + "exists": True}, {"config": "network %s" % test_vpc_tier_dynamic_2.cidr, - "exists": False}] + "exists": True}] + self.verifyFrrConf(vpc_router, frr_configs) + + # 16. Update VPC BGP peers (to null) + test_vpc_dynamic.changeBgpPeers( + self.apiclient, + bgppeerids=[] + ) + + # 17. Verify frr.conf in VPC VR + frr_configs = [{"config": "neighbor %s remote-as %s" % (bgppeer_1.ipaddress, bgppeer_1.asnumber), + "exists": True}, + {"config": "neighbor %s password %s" % (bgppeer_1.ipaddress, PASSWORD_1), + "exists": True}, + {"config": "neighbor %s remote-as %s" % (bgppeer_2.ipaddress, bgppeer_2.asnumber), + "exists": True}, + {"config": "neighbor %s password %s" % (bgppeer_2.ipaddress, PASSWORD_2), + "exists": True}, + {"config": "network %s" % test_vpc_tier_dynamic_1.cidr, + "exists": True}, + {"config": "network %s" % test_vpc_tier_dynamic_2.cidr, + "exists": True}] self.verifyFrrConf(vpc_router, frr_configs) diff --git a/ui/public/locales/en.json b/ui/public/locales/en.json index d6df32f6cd2a..a2155aff263f 100644 --- a/ui/public/locales/en.json +++ b/ui/public/locales/en.json @@ -3398,6 +3398,7 @@ "message.success.assigned.vms": "Successfully assigned Instances", "message.success.certificate.upload": "Certificate successfully uploaded", "message.success.change.affinity.group": "Successfully changed affinity groups", +"message.success.change.bgp.peers": "Successfully changed BGP peers", "message.success.change.offering": "Successfully changed offering", "message.success.change.password": "Successfully changed password for User", "message.success.clear.webhook.deliveries": "Successfully cleared webhook deliveries",