Skip to content

Commit 679ce1a

Browse files
weizhouapachenvazquezPearl1594harikrishna-patnalashwstppr
authored
feature: Dynamic and Static Routing (#9470)
This PR contains 3 features - IPv4 Static Routing (Routed mode) #9346 Design document: https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=306153967 - AS Numbers Management #9410 Design Document: https://cwiki.apache.org/confluence/display/CLOUDSTACK/BGP+AS+Numbers+Management - Dynamic routing Design Document: https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=315492858 - Document: apache/cloudstack-documentation#419 Rename nsx mode to routing mode by ``` git grep -l nsx_mode |xargs sed -i "s/nsx_mode/routing_mode/g" git grep -l nsxmode |xargs sed -i "s/nsxmode/routingmode/g" git grep -l nsxMode |xargs sed -i "s/nsxMode/routingMode/g" git grep -l NsxMode |xargs sed -i "s/NsxMode/RoutingMode/g" ``` - re-organize sql changes - fix NPE as rules do not have public ip - fix missing destination cidr in ingress rules - disable network usage for routed network - fix DB exception as network_id is -1 during network creation - apply ingress/egress routing rules - VR changes to configure nft rules for isolated network - VR: setup nft rule for control network - VR: flush all iptables rules - fix NPE which is because ingress rules do not have public ip associated - fix dest cidr is missing in nft tables - add ip4 routing and ip4 routes to list network and list vpc response - fix ingress rule is missing when vr is restarted - fix icmp types in nft rules - add tab to manage routing firewall rules - fix ingress rules are not applied when VR is restarted - add default rules in FORWARD chain - fix create vpc offerings - fix public ip is not assigned to vpc - fix network offering is not listed when create vpc tier - add is_routing to boot args of vpc vr - remove table ip4_firewall in vpc vr - release or remove subnet when remove a network - implemenent fw_vpcrouter_routing - fix wrong ip familty when flush ipv4 rules - fix acl rules are not applied due to wrong version (should be 6 which means ip6 rules are removed) - add default rules for vpc tiers so that tcp connections (e.g. ssh) work - append policy rules after default rules - remove /usr/local/cloud/systemvm/ in routers - throw an exception when allocate subnet with cidrsize - fix some TODOs - add new parameters to update API - return type Ipv4GuestSubnetNetworkMap when get or create subnet - fix firewall rules are broken - add domain_id and account_id to db - add domain/account/project to ipv4 subnet response - create ipv4 subnet for domain/account/project - check conflict when update ipv4 subnet - ui changes - add parent subnet to response - add list for ipv4 subnet - implement some methods - fix list subnets for guest networks by zoneid - UI changes - fix delete ipv4 subnet for network - fix ipv4 subnet is set to zone guest network cidr if cidrsize is specified - add zone info to response if parent subnet is null but network is not - fix gateway/cidr is not set when create network with cidrsize - fix order of nft rules in the VRs * Routed v24 - add classes in marvin base.py * Routed v25 - add test_01_subnet_zone - fix dedicate to domain/account failure - list subnets for network by keyword and subnet * Routed v26: implement subnet auto-allocation - add utils for split ip ranges into small subnets - add utils to get start/end ip of a cidr - implement subnet auto-generation - add global settings * Routed 27: add subnet for VPC - add db column for vpc_id - add db record for vpc - remove db record when delete a vpc - add checkConflicts methods - remove duplicated settings - check ipv4 cidr when create subnet * Routed v28: update smoke tests - update test_ipv4_routing.py - search subnets by networkid * Routed 29: fix vpc and add more tests - fix createnetwork in vpc - add vpc id/name to response - fix zone id/name are not displayed in some cases - add smoke test for vpc - add smoke tests for failed cases - add smoke test for connectivity checks - marvin: add "-q" to ssh command * Routed 31: ui and smoke tests - UI: add link to network in list view - add nftables rules check in VRs * Routed 32: add chain OUTPUT and more rules - fix the issue 80/443/8080 is not reachable from VR itself ``` 2024-06-27 10:21:52,121 INFO Executing: systemctl start [email protected] 2024-06-27 10:21:52,128 INFO Service [email protected] start 2024-06-27 10:21:52,129 INFO Executing: ps aux 2024-06-27 10:24:02,175 ERROR Failed to update password server due to: <urlopen error [Errno 110] Connection timed out> ``` * Routed: fix dns search from VMs in Isolated networks * Routed: fix VPC dns issue due to gateway IP is missing in cloud.conf This is caused by NSX integration, and fixed by #9102 * Routed: rename routing_mode to network_mode * Routed: replace centos5.5 template in smoke test as dhclient does not work in the vms // this does not work refer to https://dominikrys.com/posts/disable-udp-checksum-validation/#ignoring-udp-checksums-with-nftables and https://forum.openwrt.org/t/udp-checksum-with-nftables/161522/11 the vm should have checksum offloading disabled * Routed: fix smoke test due to wrong cidrlist of egress rules and missing ingress rule from VR * PR 9346: fix lint error schema-41910to42000.sql * PR 9346: ui polish v1 * PR 9346: create VPC with cidrsize * Routed: fix test failures with test_network_ipv6 and test_vpc_ipv6 due to 'ssh -q' * Routed: fix /usr/local/cloud/systemvm/ are removed after SSVM/CPVM reboot * Routed: fix IP of additional nics of VPC VR is not gateway * PR 9346: fix cidrsize check when create VPC with cidrsize * Routed: fix test/integration/smoke/test_ipv4_routing.py:279:16: E713 test for membership should be 'not in' * PR9346: fix/Update api * PR 9346: set response object name * PR9346: UI refactor and small fixes * PR9346: change return type of getNetworkMode * PR9346: move IPv4 subnet to seperated tab * PR9346: revert IpRangesTabGuest.vue back to original * PR9346: fix remove ipv4 subnet on UI * PR9346: fix test_ipv4_routing.py * AS Number Range Management * Create AS Number Range for a Zone * Fix build * Add ListASNRange and fix create ASN range * Add List AS numbers * Add UI for AS Numbers * Fix UI and filter AS Numbers * Add AS Number on Isolated network creation and refactor UI and response * Release AS Number * Add network offering new columns * Add UI support to view and add AS number and configure network offering * Automatically assign AS Number if not specify AS number * update variable name * Fix routing mode check * UI: Only allow selecting AS number when routing mode is Dynamic and specifyAsNumber is true * UI: Only pass AS number when supported by the network offering * Release AS number on network deletion * Add deleteASNRange command (#81) * API: List ASNumbers by asnumber (#83) --------- Co-authored-by: Pearl Dsilva <[email protected]> * AS number management extensions * Support AS number on VPC tier creation based on the offering * Fix delete AS Range * Fix UI values * UI: Minor fix for releasing AS number * UI: Move management of AS Range to Zone details view * Fix specify_as_number column in network_offering table to set the default false * Add events for AS number operations * Allow users to list AS Numbers and fix network form for Normal users * Add AS number details to list networks response * Fix Allocated time format * Fix Allocated time format * support in details view too * Fix: Do not release AS number if acquired network requires AS number * Fix: Do not release AS number if acquired network requires AS number * Fix typo * Fix allocated release * Fix event type * UI: Add Routing mode and Specify AS to the network offering details * UI: Add Routing mode and Specify AS to the network offering details * Address comment * Fix release AS number of network deletion * Fix release AS number of network deletion * Fix * Restore release to its place based on the boolean * Rename boolean * API: Add networkId as listASNumber parameter * Add Network name to the search view filter for AS numbers * Present allocated time in human readable format - Pubilc IP / AS Numbers * Add account / domain filter for AS numbers * Add support for AS numbers on VPC offerings * Refactor AS number allocation to VPC and non VPC isolated networks * Checkstyle * Add support for AS numbers on VPC offerings * extend vpc offering view and vpcoffering response * merge shapeblue/cloudstack-playtika#115 and change network_id of as_numbers to include vpc_id * Display AS number of VPC tiers as the AS number of the VPC * extend asnumber response and ui support * improve UI and as number response to view VPC details * List only dynamic offerings for vpc tiers with specify as numbers * Fix release AS number * Fix AS number displayed as 0 when no AS number assigned * Fix VPC offering creation without specify AS --------- Co-authored-by: nvazquez <[email protected]> * Fix release AS number on VPC deletion * Update server/src/main/java/com/cloud/dc/BGPServiceImpl.java * Update server/src/main/java/com/cloud/dc/BGPServiceImpl.java * Fix missing column on asnumber table * Fix listASNumbers API to support vpcid and obtain AS number from vpc for tiers * Prevent listing 0 AS number for VPC * Fix create Isolated Network form * Update server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java * Update server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java * Dynamic: move routingmode/specifyasn after networkmode in AddNetworkOffering.vue on UI * Dynamic: fix ip4routing in network response * Dynamic/systemvm: add FRR to systemvm template * Dynamic: BGP peers (DB,VO,Dao) * Dynamic: BGP peers (VR/server) * Dynamic: v3 - remove BgpPeer class - fix vpc vr has bgp peers of only 1 tier - rename ip4_cidr to guest_ip4_cidr - rename ip6_cidr to guest_ip6_cidr - generate /etc/frr/frr.conf - apply BGP peers on Dynamic-Routed network even if there is no BGP peers * Dynamic v4: fix vpc vr - fix duplicated guest cidr in frr.conf in vpc vr todo - restart frr / reload frr (reload will cause bgp session to Policy state) - apis for bgp peers - assign/release bgp peer from/to network * Dynamic v5: add apis for bgp peers * Dynamic v6: fix bugs - set response object name - remove required as number when update - fix checks when update - allow regular users to list bgp peers * Dynamic v7: move apis to bgp sub-dir * Dynamic v8: add tab for manage BGP peers on UI * Dynamic v9: fix update bgp with same config * Dynamiv v10: add changeBgpPeersForNetworkCmd * Dynamic v11: create network with bgppeerids - create network with bgppeerids - add marvin classes - add smoke tests - remove uuid from bgp_peer_network_map - fix created/removed in bgp_peer_network_map - remove bgppeers when remove a network - UI: fix delete bgp peer * Dynamic v12: add test for vpc tiers * Dynamic v13: bug fixes - fix change BGP peers for network in Allocated state - fix listing network returns removed record - fix all vpc tiers have the same settings - remove BGP peers as part of network removal - remove FRR settings for vpc tiers without any BGP peers - UI: fix no error msg when change BGP peers * Dynamic v14: assign BGP Peers for VPC instead of VPC tiers - create vpc with bgppeerids - do not allow create/update vpc tier with bgppeerids - apply all bgp peers when create/delete a vpc tier - UI: change bgp peers for vpc - test: update tests on vpc * Dynamic: fix build errors after merging as number PR * Dynamic: fix TODOs * Dynamic: fix smoke test on VPC * Allow creation of networks by users with as numbers * Address review comments * Move BGPService to bgp package and inject it on BaseCmd * Revert changes for CKS and address more comments * Display left side menu option for AS number only for root admin * Dynamic: create/update BGP peer with details refer to https://docs.frrouting.org/en/latest/bgp.html * Dynamic: fix build error and remove access to ListBgpPeers cmd for regular users * Dynamic: assign all zone BGP peers to user networks * Dynamic: show BGP peer info of networks only for root admin * AS number: disable specifyasnumber for non-NSX offerings * Dynamic: pass bgppeer details to command and fix typo with ip6 addr * Dynamic: list BGP peers by isdedicated, and fix change bgppeers for network/vpc * Dynamic: add UI labels * Dynamic: add bgp peers to vpc response * Dynamic: list bgp peers by keyword, fix list by asnumber * Dynamic: fix list bgppeers by keyword and db schema * Dynamic: fix list bgppeers do not return dedicated peers * Dynamic: update UI when create network/vpc offering * Update server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java Co-authored-by: Abhishek Kumar <[email protected]> * Update tools/marvin/setup.py * Dynamic: network mode must be same when update a network with new offering * Dynamic: add method networkModel.isAnyServiceSupportedInNetwork * Dynamic: rename APIs and classes * Dynamic: fix unit tests due to previous changes * Dynamic: validateNetworkCidrSize when auto-create subnet * Dynamic: check AS number overlap * Dynamic: add ActionEvent * Dynamic: small code optimization * Dynamic: fix ui bugs after api rename * Dynamic: add marvin and test for ASN ranges and AS numbers * Dynamic: add account setting use.system.bgp.peers also - change the default value of routed.ipv4.vpc.max.cidr.size and routed.ipv4.vpc.min.cidr.size - change the category of settings * static: fix ui error when delete zone ipv4 subnets * static: small UI polish * Dynamic: throw exception when as number is required but not passed * Dynamic: fix typo when create FRR directory which causes network deletion failures * Dynamic: connect to ALL (or ALL dedicated) BGP peers if no BGP peer mapping for the network/vpc * Dynamic: throw exception when as number is required for VPC but not passed * Dynamic: list bgp peers by useSystemBgpPeers * Dynamic: fix frr config in VPC VR when change bgp peers * Dynamic: create frr config even if there is no VPC tiers * Dynamic: list bgp peers by zoneid (required for account) and account * Dynamic: only apply FRR config for vpc tiers with dynamic routing * Dynamic: donot send commands to router if commands size is 0 * Dynamic: fix 'new IPv6 address is not valid' when update bgp peer without IPv6 * Dynamic: throw exception if fail to allocate AS number when create network/vpc with dynamic routing * Dynamic: enable ipv6 unicast and 'ip nht resolve-via-default' * Dynamic: delete network/vpc if fail to allocate AS number when create network/vpc with dynamic routing * test: add unit tests for ASN APIs * test: add unit tests for core module * test: add unit tests for API responses * test: add unit tests for BgpPeerTO * test: add minor changes * test: add tests for create/delete/update/list RoutingFirewallRuleCmd * Static: show ip4 routes for vpc tiers * test: fix smoke test failure caused by type change of as number * test: add test for Ipv4SubnetForZoneCmd * test: add test for Ipv4SubnetForGuestNetworkCmd and BgpPeerCmd * UI: do not show redundant router when network mode is ROUTED as RVR is not supported * UI: hide 'Conserve mode' when networkmode is ROUTED * test: add unit tests for ListASNumbersCmdTest * Static: remove allocated IPv4 subnet when delete a network or vpc * test: add unit tests for BgpPeersRules * Dynamic: set ipv4routing from network offering * server: list as numbers and ipv4 subnets by keyword * server: remove dedicated bgp peers and ipv4 subnets when delete an account or domain * server: fix dedicated ipv4 subnet is allocated to other accounts * UI: fix allocated time format * server: ignore project is projectid is -1 so bgppeers/ipv4subnets works in project view * UI: add project column to bgp peers and ipv4 subnets * server: fix list AS numbers by domain admin or normal user * server: fix network creation when ipv4 subnet is dedicated * UI: polish network.js * Dynamic: fix frr config for ipv6 routing * Static routing: support cks cluster * Static: get/create IPv4 subnet from dedicated subnets at first * Dynamic: add BGP peers tab * Static: remove redundant loops * api: add since to api and response * server: add unit tests --------- Co-authored-by: Nicolas Vazquez <[email protected]> Co-authored-by: Pearl Dsilva <[email protected]> Co-authored-by: Harikrishna Patnala <[email protected]> Co-authored-by: Abhishek Kumar <[email protected]> Co-authored-by: Rohit Yadav <[email protected]>
1 parent 85765c3 commit 679ce1a

File tree

264 files changed

+19882
-381
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

264 files changed

+19882
-381
lines changed

api/src/main/java/com/cloud/agent/api/to/FirewallRuleTO.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,7 @@ public FirewallRuleTO(FirewallRule rule, String srcVlanTag, String srcIp, Firewa
155155
rule.getIcmpType(),
156156
rule.getIcmpCode());
157157
this.trafficType = trafficType;
158-
if (FirewallRule.Purpose.Ipv6Firewall.equals(purpose)) {
159-
this.destCidrList = rule.getDestinationCidrList();
160-
}
158+
this.destCidrList = rule.getDestinationCidrList();
161159
}
162160

163161
public FirewallRuleTO(FirewallRule rule, String srcVlanTag, String srcIp, FirewallRule.Purpose purpose, FirewallRule.TrafficType trafficType,
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package com.cloud.bgp;
18+
19+
import org.apache.cloudstack.acl.InfrastructureEntity;
20+
import org.apache.cloudstack.api.Identity;
21+
import org.apache.cloudstack.api.InternalIdentity;
22+
23+
import java.util.Date;
24+
25+
public interface ASNumber extends InfrastructureEntity, InternalIdentity, Identity {
26+
27+
Long getAccountId();
28+
Long getDomainId();
29+
long getAsNumber();
30+
long getAsNumberRangeId();
31+
long getDataCenterId();
32+
Date getAllocatedTime();
33+
boolean isAllocated();
34+
Long getNetworkId();
35+
Long getVpcId();
36+
Date getCreated();
37+
Date getRemoved();
38+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package com.cloud.bgp;
18+
19+
import org.apache.cloudstack.acl.InfrastructureEntity;
20+
import org.apache.cloudstack.api.Identity;
21+
import org.apache.cloudstack.api.InternalIdentity;
22+
23+
import java.util.Date;
24+
25+
public interface ASNumberRange extends InfrastructureEntity, InternalIdentity, Identity {
26+
27+
long getStartASNumber();
28+
long getEndASNumber();
29+
long getDataCenterId();
30+
Date getCreated();
31+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package com.cloud.bgp;
18+
19+
import com.cloud.exception.ResourceUnavailableException;
20+
import com.cloud.network.Network;
21+
import com.cloud.network.vpc.Vpc;
22+
import com.cloud.utils.Pair;
23+
import org.apache.cloudstack.api.command.user.bgp.ListASNumbersCmd;
24+
25+
import java.util.List;
26+
27+
public interface BGPService {
28+
29+
ASNumberRange createASNumberRange(long zoneId, long startASNumber, long endASNumber);
30+
List<ASNumberRange> listASNumberRanges(Long zoneId);
31+
Pair<List<ASNumber>, Integer> listASNumbers(ListASNumbersCmd cmd);
32+
boolean allocateASNumber(long zoneId, Long asNumber, Long networkId, Long vpcId);
33+
Pair<Boolean, String> releaseASNumber(long zoneId, long asNumber, boolean isReleaseNetworkDestroy);
34+
boolean deleteASRange(long id);
35+
36+
boolean applyBgpPeers(Network network, boolean continueOnError) throws ResourceUnavailableException;
37+
38+
boolean applyBgpPeers(Vpc vpc, boolean continueOnError) throws ResourceUnavailableException;
39+
}

api/src/main/java/com/cloud/event/EventTypes.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828
import org.apache.cloudstack.api.response.PodResponse;
2929
import org.apache.cloudstack.api.response.ZoneResponse;
3030
import org.apache.cloudstack.config.Configuration;
31+
import org.apache.cloudstack.datacenter.DataCenterIpv4GuestSubnet;
3132
import org.apache.cloudstack.ha.HAConfig;
33+
import org.apache.cloudstack.network.BgpPeer;
34+
import org.apache.cloudstack.network.Ipv4GuestSubnetNetworkMap;
3235
import org.apache.cloudstack.quota.QuotaTariff;
3336
import org.apache.cloudstack.storage.sharedfs.SharedFS;
3437
import org.apache.cloudstack.storage.object.Bucket;
@@ -394,6 +397,11 @@ public class EventTypes {
394397
public static final String EVENT_VLAN_IP_RANGE_RELEASE = "VLAN.IP.RANGE.RELEASE";
395398
public static final String EVENT_VLAN_IP_RANGE_UPDATE = "VLAN.IP.RANGE.UPDATE";
396399

400+
// AS Number
401+
public static final String EVENT_AS_RANGE_CREATE = "AS.RANGE.CREATE";
402+
public static final String EVENT_AS_RANGE_DELETE = "AS.RANGE.DELETE";
403+
public static final String EVENT_AS_NUMBER_RELEASE = "AS.NUMBER.RELEASE";
404+
397405
public static final String EVENT_MANAGEMENT_IP_RANGE_CREATE = "MANAGEMENT.IP.RANGE.CREATE";
398406
public static final String EVENT_MANAGEMENT_IP_RANGE_DELETE = "MANAGEMENT.IP.RANGE.DELETE";
399407
public static final String EVENT_MANAGEMENT_IP_RANGE_UPDATE = "MANAGEMENT.IP.RANGE.UPDATE";
@@ -745,6 +753,25 @@ public class EventTypes {
745753
public static final String EVENT_QUOTA_TARIFF_DELETE = "QUOTA.TARIFF.DELETE";
746754
public static final String EVENT_QUOTA_TARIFF_UPDATE = "QUOTA.TARIFF.UPDATE";
747755

756+
// Routing
757+
public static final String EVENT_ZONE_IP4_SUBNET_CREATE = "ZONE.IP4.SUBNET.CREATE";
758+
public static final String EVENT_ZONE_IP4_SUBNET_UPDATE = "ZONE.IP4.SUBNET.UPDATE";
759+
public static final String EVENT_ZONE_IP4_SUBNET_DELETE = "ZONE.IP4.SUBNET.DELETE";
760+
public static final String EVENT_ZONE_IP4_SUBNET_DEDICATE = "ZONE.IP4.SUBNET.DEDICATE";
761+
public static final String EVENT_ZONE_IP4_SUBNET_RELEASE = "ZONE.IP4.SUBNET.RELEASE";
762+
public static final String EVENT_IP4_GUEST_SUBNET_CREATE = "IP4.GUEST.SUBNET.CREATE";
763+
public static final String EVENT_IP4_GUEST_SUBNET_DELETE = "IP4.GUEST.SUBNET.DELETE";
764+
public static final String EVENT_ROUTING_IPV4_FIREWALL_RULE_CREATE = "ROUTING.IPV4.FIREWALL.RULE.CREATE";
765+
public static final String EVENT_ROUTING_IPV4_FIREWALL_RULE_UPDATE = "ROUTING.IPV4.FIREWALL.RULE.UPDATE";
766+
public static final String EVENT_ROUTING_IPV4_FIREWALL_RULE_DELETE = "ROUTING.IPV4.FIREWALL.RULE.DELETE";
767+
public static final String EVENT_BGP_PEER_CREATE = "BGP.PEER.CREATE";
768+
public static final String EVENT_BGP_PEER_UPDATE = "BGP.PEER.UPDATE";
769+
public static final String EVENT_BGP_PEER_DELETE = "BGP.PEER.DELETE";
770+
public static final String EVENT_BGP_PEER_DEDICATE = "BGP.PEER.DEDICATE";
771+
public static final String EVENT_BGP_PEER_RELEASE = "BGP.PEER.RELEASE";
772+
public static final String EVENT_NETWORK_BGP_PEER_UPDATE = "NETWORK.BGP.PEER.UPDATE";
773+
public static final String EVENT_VPC_BGP_PEER_UPDATE = "VPC.BGP.PEER.UPDATE";
774+
748775
// SharedFS
749776
public static final String EVENT_SHAREDFS_CREATE = "SHAREDFS.CREATE";
750777
public static final String EVENT_SHAREDFS_START = "SHAREDFS.START";
@@ -1217,6 +1244,23 @@ public class EventTypes {
12171244
entityEventDetails.put(EVENT_QUOTA_TARIFF_DELETE, QuotaTariff.class);
12181245
entityEventDetails.put(EVENT_QUOTA_TARIFF_UPDATE, QuotaTariff.class);
12191246

1247+
// Routing
1248+
entityEventDetails.put(EVENT_ZONE_IP4_SUBNET_CREATE, DataCenterIpv4GuestSubnet.class);
1249+
entityEventDetails.put(EVENT_ZONE_IP4_SUBNET_UPDATE, DataCenterIpv4GuestSubnet.class);
1250+
entityEventDetails.put(EVENT_ZONE_IP4_SUBNET_DELETE, DataCenterIpv4GuestSubnet.class);
1251+
entityEventDetails.put(EVENT_ZONE_IP4_SUBNET_DEDICATE, DataCenterIpv4GuestSubnet.class);
1252+
entityEventDetails.put(EVENT_ZONE_IP4_SUBNET_RELEASE, DataCenterIpv4GuestSubnet.class);
1253+
entityEventDetails.put(EVENT_IP4_GUEST_SUBNET_CREATE, Ipv4GuestSubnetNetworkMap.class);
1254+
entityEventDetails.put(EVENT_IP4_GUEST_SUBNET_DELETE, Ipv4GuestSubnetNetworkMap.class);
1255+
entityEventDetails.put(EVENT_ROUTING_IPV4_FIREWALL_RULE_CREATE, FirewallRule.class);
1256+
entityEventDetails.put(EVENT_ROUTING_IPV4_FIREWALL_RULE_UPDATE, FirewallRule.class);
1257+
entityEventDetails.put(EVENT_ROUTING_IPV4_FIREWALL_RULE_DELETE, FirewallRule.class);
1258+
entityEventDetails.put(EVENT_BGP_PEER_CREATE, BgpPeer.class);
1259+
entityEventDetails.put(EVENT_BGP_PEER_UPDATE, BgpPeer.class);
1260+
entityEventDetails.put(EVENT_BGP_PEER_DELETE, BgpPeer.class);
1261+
entityEventDetails.put(EVENT_BGP_PEER_DEDICATE, BgpPeer.class);
1262+
entityEventDetails.put(EVENT_BGP_PEER_RELEASE, BgpPeer.class);
1263+
12201264
// SharedFS
12211265
entityEventDetails.put(EVENT_SHAREDFS_CREATE, SharedFS.class);
12221266
entityEventDetails.put(EVENT_SHAREDFS_START, SharedFS.class);

api/src/main/java/com/cloud/network/Network.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class Service {
103103
public static final Service Vpn = new Service("Vpn", Capability.SupportedVpnProtocols, Capability.VpnTypes);
104104
public static final Service Dhcp = new Service("Dhcp", Capability.ExtraDhcpOptions);
105105
public static final Service Dns = new Service("Dns", Capability.AllowDnsSuffixModification);
106-
public static final Service Gateway = new Service("Gateway");
106+
public static final Service Gateway = new Service("Gateway", Capability.RedundantRouter);
107107
public static final Service Firewall = new Service("Firewall", Capability.SupportedProtocols, Capability.MultipleIps, Capability.TrafficStatistics,
108108
Capability.SupportedTrafficDirection, Capability.SupportedEgressProtocols);
109109
public static final Service Lb = new Service("Lb", Capability.SupportedLBAlgorithms, Capability.SupportedLBIsolation, Capability.SupportedProtocols,
@@ -412,12 +412,16 @@ public void setIp6Address(String ip6Address) {
412412

413413
String getGateway();
414414

415+
void setGateway(String gateway);
416+
415417
// "cidr" is the Cloudstack managed address space, all CloudStack managed vms get IP address from "cidr",
416418
// In general "cidr" also serves as the network CIDR
417419
// But in case IP reservation is configured for a Guest network, "networkcidr" is the Effective network CIDR for that network,
418420
// "cidr" will still continue to be the effective address space for CloudStack managed vms in that Guest network
419421
String getCidr();
420422

423+
void setCidr(String cidr);
424+
421425
// "networkcidr" is the network CIDR of the guest network which uses IP reservation.
422426
// It is the summation of "cidr" and the reservedIPrange(the address space used for non CloudStack purposes).
423427
// For networks not configured with IP reservation, "networkcidr" is always null
@@ -503,4 +507,6 @@ public void setIp6Address(String ip6Address) {
503507
Integer getPublicMtu();
504508

505509
Integer getPrivateMtu();
510+
511+
Integer getNetworkCidrSize();
506512
}

api/src/main/java/com/cloud/network/NetworkModel.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ public interface NetworkModel {
173173

174174
boolean isProviderSupportServiceInNetwork(long networkId, Service service, Provider provider);
175175

176+
boolean isAnyServiceSupportedInNetwork(long networkId, Provider provider, Service... services);
177+
176178
boolean isProviderEnabledInPhysicalNetwork(long physicalNetowrkId, String providerName);
177179

178180
String getNetworkTag(HypervisorType hType, Network network);

api/src/main/java/com/cloud/network/NetworkProfile.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ public class NetworkProfile implements Network {
4141
private final Mode mode;
4242
private final BroadcastDomainType broadcastDomainType;
4343
private TrafficType trafficType;
44-
private final String gateway;
45-
private final String cidr;
44+
private String gateway;
45+
private String cidr;
4646
private final String networkCidr;
4747
private final String ip6Gateway;
4848
private final String ip6Cidr;
@@ -62,6 +62,7 @@ public class NetworkProfile implements Network {
6262
private final String guruName;
6363
private boolean strechedL2Subnet;
6464
private String externalId;
65+
private Integer networkCidrSize;
6566

6667
public NetworkProfile(Network network) {
6768
id = network.getId();
@@ -98,6 +99,7 @@ public NetworkProfile(Network network) {
9899
isRedundant = network.isRedundant();
99100
isRollingRestart = network.isRollingRestart();
100101
externalId = network.getExternalId();
102+
networkCidrSize = network.getNetworkCidrSize();
101103
}
102104

103105
@Override
@@ -210,11 +212,21 @@ public String getGateway() {
210212
return gateway;
211213
}
212214

215+
@Override
216+
public void setGateway(String gateway) {
217+
this.gateway = gateway;
218+
}
219+
213220
@Override
214221
public String getCidr() {
215222
return cidr;
216223
}
217224

225+
@Override
226+
public void setCidr(String cidr) {
227+
this.cidr = cidr;
228+
}
229+
218230
@Override
219231
public String getNetworkCidr() {
220232
return networkCidr;
@@ -367,4 +379,9 @@ public Integer getPrivateMtu() {
367379
return null;
368380
}
369381

382+
@Override
383+
public Integer getNetworkCidrSize() {
384+
return networkCidrSize;
385+
}
386+
370387
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package com.cloud.network.element;
18+
19+
import com.cloud.exception.ResourceUnavailableException;
20+
import com.cloud.network.Network;
21+
import com.cloud.network.vpc.Vpc;
22+
23+
import org.apache.cloudstack.network.BgpPeer;
24+
25+
import java.util.List;
26+
27+
public interface BgpServiceProvider extends NetworkElement {
28+
29+
boolean applyBgpPeers(Vpc vpc, Network network, List<? extends BgpPeer> bgpPeers) throws ResourceUnavailableException;
30+
31+
}

api/src/main/java/com/cloud/network/vpc/VpcOffering.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.util.Date;
2020

21+
import com.cloud.offering.NetworkOffering;
2122
import org.apache.cloudstack.api.Identity;
2223
import org.apache.cloudstack.api.InternalIdentity;
2324

@@ -57,7 +58,7 @@ public enum State {
5758

5859
boolean isForNsx();
5960

60-
String getNsxMode();
61+
NetworkOffering.NetworkMode getNetworkMode();
6162

6263
/**
6364
* @return service offering id used by VPC virtual router
@@ -79,4 +80,8 @@ public enum State {
7980
Date getRemoved();
8081

8182
Date getCreated();
83+
84+
NetworkOffering.RoutingMode getRoutingMode();
85+
86+
Boolean isSpecifyAsNumber();
8287
}

api/src/main/java/com/cloud/network/vpc/VpcProvisioningService.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.apache.cloudstack.api.command.admin.vpc.UpdateVPCOfferingCmd;
2525
import org.apache.cloudstack.api.command.user.vpc.ListVPCOfferingsCmd;
2626

27+
import com.cloud.offering.NetworkOffering;
2728
import com.cloud.utils.Pair;
2829
import com.cloud.utils.net.NetUtils;
2930

@@ -36,8 +37,10 @@ public interface VpcProvisioningService {
3637
VpcOffering createVpcOffering(String name, String displayText, List<String> supportedServices,
3738
Map<String, List<String>> serviceProviders,
3839
Map serviceCapabilitystList, NetUtils.InternetProtocol internetProtocol,
39-
Long serviceOfferingId, Boolean forNsx, String mode,
40-
List<Long> domainIds, List<Long> zoneIds, VpcOffering.State state);
40+
Long serviceOfferingId, Boolean forNsx, NetworkOffering.NetworkMode networkMode,
41+
List<Long> domainIds, List<Long> zoneIds, VpcOffering.State state,
42+
NetworkOffering.RoutingMode routingMode, boolean specifyAsNumber);
43+
4144

4245
Pair<List<? extends VpcOffering>,Integer> listVpcOfferings(ListVPCOfferingsCmd cmd);
4346

api/src/main/java/com/cloud/network/vpc/VpcService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ public interface VpcService {
5656
* @throws ResourceAllocationException TODO
5757
*/
5858
Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String displayText, String cidr, String networkDomain,
59-
String ip4Dns1, String ip4Dns2, String ip6Dns1, String ip6Dns2, Boolean displayVpc, Integer publicMtu)
59+
String ip4Dns1, String ip4Dns2, String ip6Dns1, String ip6Dns2, Boolean displayVpc, Integer publicMtu, Integer cidrSize,
60+
Long asNumber, List<Long> bgpPeerIds)
6061
throws ResourceAllocationException;
6162

6263
/**

0 commit comments

Comments
 (0)