Skip to content

Commit dfff32e

Browse files
Pearl1594Pearl Dsilvanvazquezweizhouapache
authored
Netris: Improvements and fixes to the Netris plugin (apache#13591)
* Netris CloudStack Integration Enhancements * Netris - Support NAT, PF for Secondary IP * Allow PF rules to be correctly created on secondary IP of a VM on netris * unique static nat names on netris by adding public IP - handle backward compatibility --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> * Netris - Support for L2 networks * Add support for L2 networks in Netris * remove the need to add connectivity to identify netris provider, remove changes to ui and create net offering * create vpc network and use it for l2 networks * dont fail if deletion on netris doesnt succeed * remove connectivity capability * update vpc name when l2 name is updated --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> * Netris - CKS support Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> * Netris - Enable Global Routing Flag for NATTED Dual-Stack VPCs * Set globalRouting = true, when network offering is NATTED, dual-stack * update global routing based on routing mode and ip protocol type --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> Co-authored-by: nvazquez <nicovazquez90@gmail.com> * Netris - Fix allocate vnets with the correct account ID so that release succeeds on network deletion * Fix allocate vnets with the correct account ID so that release succeeds on network deletion * add fix for vpc tiers as well * move entire vnet cleanup logic to trash from shutdown, so that it works for all network types for netris * cleanup vnets when reservation id is null --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> * Netris - Add support to include VPN service for NATTED Netris offerings * Add support to include VPN service for NATTED Netris offerings * missing changes of global routing * Remove extra space --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> Co-authored-by: nvazquez <nicovazquez90@gmail.com> * Netris - Support Redundant Virtual Routers for Netris VPC networks * Add support for redundant routers for Netris VPC networks * address comment * default null network mode to natted for netris * preventing vpc and ipam creation if already exists --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> * Netris - Enable autoscaling groups for Netris network offerings * Enable autoscaling groups for Netris network offerings * Fix UI loading for services when network mode changes for external providers and show vm autoscaling always set to true / non-editable for netris when LB is selected i.e, natted mode * Revert removed comment --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> Co-authored-by: nvazquez <nicovazquez90@gmail.com> * merge conflict * systemvm: fix VPC VPN issue when network id is bigger than 1000 on Netris * show networks for vnf nic mappings --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> Co-authored-by: nvazquez <nicovazquez90@gmail.com> Co-authored-by: Wei Zhou <weizhou@apache.org> * Add a check to prevent re-adding existing ACLs * Netris - Support NAT, PF for Secondary IP * Allow PF rules to be correctly created on secondary IP of a VM on netris * unique static nat names on netris by adding public IP - handle backward compatibility --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> * Netris - Support for L2 networks * Add support for L2 networks in Netris * remove the need to add connectivity to identify netris provider, remove changes to ui and create net offering * create vpc network and use it for l2 networks * dont fail if deletion on netris doesnt succeed * remove connectivity capability * update vpc name when l2 name is updated --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> * Netris - CKS support Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> * Netris - Enable Global Routing Flag for NATTED Dual-Stack VPCs * Set globalRouting = true, when network offering is NATTED, dual-stack * update global routing based on routing mode and ip protocol type --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> Co-authored-by: nvazquez <nicovazquez90@gmail.com> * Netris - Fix allocate vnets with the correct account ID so that release succeeds on network deletion * Fix allocate vnets with the correct account ID so that release succeeds on network deletion * add fix for vpc tiers as well * move entire vnet cleanup logic to trash from shutdown, so that it works for all network types for netris * cleanup vnets when reservation id is null --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> * Netris - Add support to include VPN service for NATTED Netris offerings * Add support to include VPN service for NATTED Netris offerings * missing changes of global routing * Remove extra space --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> Co-authored-by: nvazquez <nicovazquez90@gmail.com> * Netris - Support Redundant Virtual Routers for Netris VPC networks * Add support for redundant routers for Netris VPC networks * address comment * default null network mode to natted for netris * preventing vpc and ipam creation if already exists --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> * Netris - Enable autoscaling groups for Netris network offerings * Enable autoscaling groups for Netris network offerings * Fix UI loading for services when network mode changes for external providers and show vm autoscaling always set to true / non-editable for netris when LB is selected i.e, natted mode * Revert removed comment --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> Co-authored-by: nvazquez <nicovazquez90@gmail.com> * merge conflict * systemvm: fix VPC VPN issue when network id is bigger than 1000 on Netris * show networks for vnf nic mappings * Add a check to prevent re-adding existing ACLs * Add a check to prevent re-adding existing ACLs * change message compare statement --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> Co-authored-by: nvazquez <nicovazquez90@gmail.com> Co-authored-by: Wei Zhou <weizhou@apache.org> * Add check for vnet name length and cleanup vpc and vnet resources on failure of creation of allocation * Netris - Support NAT, PF for Secondary IP * Allow PF rules to be correctly created on secondary IP of a VM on netris * unique static nat names on netris by adding public IP - handle backward compatibility --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> * Netris - Support for L2 networks * Add support for L2 networks in Netris * remove the need to add connectivity to identify netris provider, remove changes to ui and create net offering * create vpc network and use it for l2 networks * dont fail if deletion on netris doesnt succeed * remove connectivity capability * update vpc name when l2 name is updated --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> * Netris - CKS support Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> * Netris - Enable Global Routing Flag for NATTED Dual-Stack VPCs * Set globalRouting = true, when network offering is NATTED, dual-stack * update global routing based on routing mode and ip protocol type --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> Co-authored-by: nvazquez <nicovazquez90@gmail.com> * Netris - Fix allocate vnets with the correct account ID so that release succeeds on network deletion * Fix allocate vnets with the correct account ID so that release succeeds on network deletion * add fix for vpc tiers as well * move entire vnet cleanup logic to trash from shutdown, so that it works for all network types for netris * cleanup vnets when reservation id is null --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> * Netris - Add support to include VPN service for NATTED Netris offerings * Add support to include VPN service for NATTED Netris offerings * missing changes of global routing * Remove extra space --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> Co-authored-by: nvazquez <nicovazquez90@gmail.com> * Netris - Support Redundant Virtual Routers for Netris VPC networks * Add support for redundant routers for Netris VPC networks * address comment * default null network mode to natted for netris * preventing vpc and ipam creation if already exists --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> * Netris - Enable autoscaling groups for Netris network offerings * Enable autoscaling groups for Netris network offerings * Fix UI loading for services when network mode changes for external providers and show vm autoscaling always set to true / non-editable for netris when LB is selected i.e, natted mode * Revert removed comment --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> Co-authored-by: nvazquez <nicovazquez90@gmail.com> * merge conflict * systemvm: fix VPC VPN issue when network id is bigger than 1000 on Netris * show networks for vnf nic mappings * Add a check to prevent re-adding existing ACLs * Add a check to prevent re-adding existing ACLs * change message compare statement * Add check for vnet name length and cleanup vpc and vnet resources on failure of creation of allocation * add name length validation to update path --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> Co-authored-by: nvazquez <nicovazquez90@gmail.com> Co-authored-by: Wei Zhou <weizhou@apache.org> * Add support to the VPC response to display if redundant routers are supported Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> * Hide VPN sections and prevent enabling it when service isn't enabled in the vpc offering * Hide VPN sections and prevent enabling it when service isn't enabled in the vpc offering * update --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> * Fix issue with adding external node to a CKS cluster with Netris offering Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> * Update upgrade path to reclaim vnets of deleted netris networks, improve log and hide add upstream route for Netris routed networks * Update upgrade path to reclaim vnets of deleted netris networks, improve log and hide add upstream route for Netris routed networks * Apply suggestions from code review * hide upstream route banner for netris networks altogether * fix migration of netris VRs and fix reclaim vnet query --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> Co-authored-by: Nicolas Vazquez <nicovazquez90@gmail.com> * Allocate IP from Netris (Provider) range when IP is not specified during associate * Allocate IP from Netris (Provider) range when IP is not specified during associate * update javadoc and method name --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> * Fix VRRP gateway IP conflict on redundant VPC routers with external network providers (Netris/NSX) Co-authored-by: Pearl Dsilva <pearl1594@gmail.com> * VPN: Reconfigure static nat and static route on fail over to backup VR - for redundant VPC VRs * VPN: Reconfigure static nat and static route on fail over to backup VR - for redundant VPC VRs * address comment * add stacktrace to the log --------- * Fix issue with deletion of vpn connection for DualStack redundant VPCs * fix precommit ci issue * Add Netris to the range limit check (apache#129) Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> * Netris: address review comments on static NAT, L2 and offering form - Match the legacy static NAT rule only when it was created for the requested public IP, on both create and delete - Roll back the dedicated L2 VPC if vNet creation fails - Hide the L2 guest type for Netris in the add offering form - Add VPN to the external provider service map for Netris only - Fix the L2 offering services javadoc * Update Netris SDK version to 1.0.1 * Move to the correct schema file * systemvm: bind dnsmasq and password server to router IP when external provider owns the gateway --------- Co-authored-by: Pearl Dsilva <pearl1954@gmail.com> Co-authored-by: nvazquez <nicovazquez90@gmail.com> Co-authored-by: Wei Zhou <weizhou@apache.org>
1 parent 0883185 commit dfff32e

50 files changed

Lines changed: 1236 additions & 349 deletions

File tree

Some content is hidden

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

‎api/src/main/java/com/cloud/network/netris/NetrisService.java‎

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import com.cloud.network.SDNProviderNetworkRule;
2222
import com.cloud.network.vpc.StaticRoute;
2323
import com.cloud.network.vpc.Vpc;
24+
import com.cloud.offering.NetworkOffering;
25+
import com.cloud.utils.net.NetUtils;
2426

2527
import java.util.List;
2628

@@ -81,18 +83,20 @@ public interface NetrisService {
8183
/**
8284
* Creates a virtual network (vNet) resource.
8385
*
84-
* @param zoneId the ID of the zone
85-
* @param accountId the ID of the account
86-
* @param domainId the ID of the domain
87-
* @param vpcName the name of the VPC
88-
* @param vpcId the ID of the VPC
89-
* @param networkName the name of the network
90-
* @param networkId the ID of the network
91-
* @param cidr the CIDR of the network
92-
* @param globalRouting true if global routing is enabled
86+
* @param zoneId the ID of the zone
87+
* @param accountId the ID of the account
88+
* @param domainId the ID of the domain
89+
* @param vpcName the name of the VPC
90+
* @param vpcId the ID of the VPC
91+
* @param networkName the name of the network
92+
* @param networkId the ID of the network
93+
* @param cidr the CIDR of the network
94+
* @param networkMode the network mode
95+
* @param internetProtocol the internet protocol
96+
* @param isL2 true if it is an L2 network
9397
* @return true if the operation is successful, false otherwise
9498
*/
95-
boolean createVnetResource(Long zoneId, long accountId, long domainId, String vpcName, Long vpcId, String networkName, Long networkId, String cidr, Boolean globalRouting);
99+
boolean createVnetResource(Long zoneId, long accountId, long domainId, String vpcName, Long vpcId, String networkName, Long networkId, String cidr, NetworkOffering.NetworkMode networkMode, NetUtils.InternetProtocol internetProtocol, boolean isL2);
96100

97101
/**
98102
* Updates an existing vNet resource.
@@ -105,9 +109,10 @@ public interface NetrisService {
105109
* @param networkName the new name of the network
106110
* @param networkId the ID of the network
107111
* @param prevNetworkName the previous name of the network
112+
* @param isL2 true if it is an L2 network
108113
* @return true if the operation is successful, false otherwise
109114
*/
110-
boolean updateVnetResource(Long zoneId, long accountId, long domainId, String vpcName, Long vpcId, String networkName, Long networkId, String prevNetworkName);
115+
boolean updateVnetResource(Long zoneId, long accountId, long domainId, String vpcName, Long vpcId, String networkName, Long networkId, String prevNetworkName, boolean isL2);
111116

112117
/**
113118
* Deletes an existing vNet resource.
@@ -120,9 +125,10 @@ public interface NetrisService {
120125
* @param networkName the name of the network
121126
* @param networkId the ID of the network
122127
* @param cidr the CIDR of the network
128+
* @param isL2 true if it is an L2 network
123129
* @return true if the operation is successful, false otherwise
124130
*/
125-
boolean deleteVnetResource(long zoneId, long accountId, long domainId, String vpcName, Long vpcId, String networkName, Long networkId, String cidr);
131+
boolean deleteVnetResource(long zoneId, long accountId, long domainId, String vpcName, Long vpcId, String networkName, Long networkId, String cidr, boolean isL2);
126132

127133
/**
128134
* Creates a source NAT rule for a VPC or network.

‎api/src/main/java/org/apache/cloudstack/api/ApiConstants.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,7 @@ public class ApiConstants {
12891289
public static final String HAS_RULES = "hasrules";
12901290
public static final String NSX_DETAIL_KEY = "forNsx";
12911291
public static final String NETRIS_DETAIL_KEY = "forNetris";
1292+
public static final String NETRIS_NAT_PUBLIC_IP_ID = "netrisnatpublicipid";
12921293
public static final String NETRIS_TAG = "netristag";
12931294
public static final String NETRIS_VXLAN_ID = "netrisvxlanid";
12941295
public static final String NETRIS_URL = "netrisurl";

‎api/src/main/java/org/apache/cloudstack/api/command/admin/network/CreateNetworkOfferingCmd.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import static com.cloud.network.Network.Service.NetworkACL;
6161
import static com.cloud.network.Network.Service.UserData;
6262
import static com.cloud.network.Network.Service.Firewall;
63+
import static com.cloud.network.Network.Service.Vpn;
6364

6465
import static org.apache.cloudstack.api.command.utils.OfferingUtils.isNetrisNatted;
6566
import static org.apache.cloudstack.api.command.utils.OfferingUtils.isNetrisRouted;
@@ -309,6 +310,10 @@ public List<String> getSupportedServices() {
309310
} else {
310311
services.add(Firewall.getName());
311312
}
313+
314+
if (isNetrisNatted(getProvider(), getNetworkMode())) {
315+
services.add(Vpn.getName());
316+
}
312317
return services;
313318
}
314319
}
@@ -418,6 +423,9 @@ else if (NetworkOffering.NetworkMode.NATTED.name().equalsIgnoreCase(getNetworkMo
418423
serviceProviderMap.remove(Lb.getName());
419424
}
420425
}
426+
if (isNetrisNatted(getProvider(), getNetworkMode())) {
427+
serviceProviderMap.put(Vpn.getName(), List.of(routerProvider));
428+
}
421429
}
422430

423431
public Map<Capability, String> getServiceCapabilities(Service service) {

‎api/src/main/java/org/apache/cloudstack/api/command/admin/vpc/CreateVPCOfferingCmd.java‎

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.LinkedHashSet;
2525
import java.util.List;
2626
import java.util.Map;
27+
import java.util.Objects;
2728
import java.util.Set;
2829
import java.util.stream.Collectors;
2930
import java.util.stream.Stream;
@@ -61,7 +62,9 @@
6162
import static com.cloud.network.Network.Service.NetworkACL;
6263
import static com.cloud.network.Network.Service.UserData;
6364
import static com.cloud.network.Network.Service.Gateway;
65+
import static com.cloud.network.Network.Service.Vpn;
6466

67+
import static org.apache.cloudstack.api.command.utils.OfferingUtils.isNetris;
6568
import static org.apache.cloudstack.api.command.utils.OfferingUtils.isNetrisNatted;
6669
import static org.apache.cloudstack.api.command.utils.OfferingUtils.isNetrisRouted;
6770
import static org.apache.cloudstack.api.command.utils.OfferingUtils.isNsxWithoutLb;
@@ -189,7 +192,7 @@ public List<String> getSupportedServices() {
189192
NetworkACL.getName(),
190193
UserData.getName()
191194
));
192-
if (NetworkOffering.NetworkMode.NATTED.name().equalsIgnoreCase(getNetworkMode())) {
195+
if (isNetrisNatted(getProvider(), getNetworkMode())) {
193196
supportedServices.addAll(Arrays.asList(
194197
StaticNat.getName(),
195198
SourceNat.getName(),
@@ -198,9 +201,13 @@ public List<String> getSupportedServices() {
198201
if (NetworkOffering.NetworkMode.ROUTED.name().equalsIgnoreCase(getNetworkMode())) {
199202
supportedServices.add(Gateway.getName());
200203
}
204+
201205
if (getNsxSupportsLbService() || isNetrisNatted(getProvider(), getNetworkMode())) {
202206
supportedServices.add(Lb.getName());
203207
}
208+
if (isNetrisNatted(getProvider(), getNetworkMode())) {
209+
supportedServices.add(Vpn.getName());
210+
}
204211
}
205212
return supportedServices;
206213
}
@@ -210,7 +217,7 @@ public String getProvider() {
210217
}
211218

212219
public String getNetworkMode() {
213-
return networkMode;
220+
return isNetris(getProvider()) && Objects.isNull(networkMode) ? NetworkOffering.NetworkMode.NATTED.name() : networkMode;
214221
}
215222

216223
public boolean getNsxSupportsLbService() {
@@ -248,7 +255,7 @@ public Map<String, List<String>> getServiceProviders() {
248255

249256
private void getServiceProviderMapForExternalProvider(Map<String, List<String>> serviceProviderMap, String provider) {
250257
List<String> unsupportedServices = new ArrayList<>(List.of("Vpn", "BaremetalPxeService", "SecurityGroup", "Connectivity", "Firewall"));
251-
if (NetworkOffering.NetworkMode.NATTED.name().equalsIgnoreCase(getNetworkMode())) {
258+
if (isNetrisNatted(getProvider(), getNetworkMode())) {
252259
unsupportedServices.add("Gateway");
253260
}
254261
List<String> routerSupported = List.of("Dhcp", "Dns", "UserData");
@@ -258,7 +265,7 @@ private void getServiceProviderMapForExternalProvider(Map<String, List<String>>
258265
continue;
259266
if (routerSupported.contains(service))
260267
serviceProviderMap.put(service, List.of(VirtualRouterProvider.Type.VPCVirtualRouter.name()));
261-
else if (NetworkOffering.NetworkMode.NATTED.name().equalsIgnoreCase(getNetworkMode()) ||
268+
else if (isNetrisNatted(getProvider(), getNetworkMode()) ||
262269
Stream.of(NetworkACL.getName(), Gateway.getName()).anyMatch(s -> s.equalsIgnoreCase(service))) {
263270
serviceProviderMap.put(service, List.of(provider));
264271
}
@@ -268,7 +275,20 @@ else if (NetworkOffering.NetworkMode.NATTED.name().equalsIgnoreCase(getNetworkMo
268275
}
269276
}
270277

278+
@SuppressWarnings("unchecked")
271279
public Map<String, List<String>> getServiceCapabilityList() {
280+
// For Netris NATTED, Gateway service is excluded so the redundant-router capability
281+
// must reference SourceNat (not Gateway).
282+
if (serviceCapabilityList != null
283+
&& isNetrisNatted(getProvider(), getNetworkMode())) {
284+
for (Object capEntry : serviceCapabilityList.values()) {
285+
Map<String, String> cap = (Map<String, String>) capEntry;
286+
if (Network.Capability.RedundantRouter.getName().equalsIgnoreCase(cap.get("capabilitytype"))
287+
&& Gateway.getName().equalsIgnoreCase(cap.get("service"))) {
288+
cap.put("service", SourceNat.getName());
289+
}
290+
}
291+
}
272292
return serviceCapabilityList;
273293
}
274294

‎api/src/main/java/org/apache/cloudstack/api/command/utils/OfferingUtils.java‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ public class OfferingUtils {
2323
private OfferingUtils() {
2424
}
2525

26+
public static boolean isNetris(String provider) {
27+
return "Netris".equalsIgnoreCase(provider);
28+
}
29+
2630
public static boolean isNetrisNatted(String provider, String networkMode) {
27-
return "Netris".equalsIgnoreCase(provider) &&
31+
return isNetris(provider) &&
2832
NetworkOffering.NetworkMode.NATTED.name().equalsIgnoreCase(networkMode);
2933
}
3034

@@ -33,6 +37,6 @@ public static boolean isNsxWithoutLb(String provider, boolean nsxSupportsLbServi
3337
}
3438

3539
public static boolean isNetrisRouted(String provider, String networkMode) {
36-
return "Netris".equalsIgnoreCase(provider) && NetworkOffering.NetworkMode.ROUTED.name().equalsIgnoreCase(networkMode);
40+
return isNetris(provider) && NetworkOffering.NetworkMode.ROUTED.name().equalsIgnoreCase(networkMode);
3741
}
3842
}

‎api/src/main/java/org/apache/cloudstack/api/response/VpcOfferingResponse.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ public class VpcOfferingResponse extends BaseResponse {
6262
@Param(description = "Indicates if the VPC offering supports distributed router for one-hop forwarding", since = "4.4")
6363
private Boolean supportsDistributedRouter;
6464

65+
@SerializedName(ApiConstants.REDUNDANT_ROUTER)
66+
@Param(description = "Indicates if the VPC offering supports redundant routers")
67+
private Boolean redundantRouter;
68+
6569
@SerializedName((ApiConstants.SUPPORTS_REGION_LEVEL_VPC))
6670
@Param(description = "Indicated if the offering can support region level VPC", since = "4.4")
6771
private Boolean supportsRegionLevelVpc;
@@ -201,4 +205,8 @@ public String getRoutingMode() {
201205
public void setRoutingMode(String routingMode) {
202206
this.routingMode = routingMode;
203207
}
208+
209+
public void setRedundantRouter(Boolean redundantRouter) {
210+
this.redundantRouter = redundantRouter;
211+
}
204212
}

‎engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2302,6 +2302,11 @@ public void prepareNicForMigration(final VirtualMachineProfile vm, final DeployD
23022302
}
23032303
}
23042304

2305+
private boolean isReservedForExternalProvider(Long vlanId) {
2306+
VlanDetailsVO vlanDetail = vlanDetailsDao.findDetail(vlanId, ApiConstants.NETRIS_DETAIL_KEY);
2307+
return vlanDetail != null && BooleanUtils.toBoolean(vlanDetail.getValue());
2308+
}
2309+
23052310
/*
23062311
Prepare All Nics for migration including the nics dynamically created and not stored in DB
23072312
This is a temporary workaround work KVM migration
@@ -2350,6 +2355,10 @@ public void prepareAllNicsForMigration(final VirtualMachineProfile vm, final Dep
23502355
final List<IPAddressVO> publicIps = _ipAddressDao.listByAssociatedNetwork(guestNetworkId, null);
23512356
for (final IPAddressVO userIp : publicIps) {
23522357
final PublicIp publicIp = PublicIp.createFromAddrAndVlan(userIp, _vlanDao.findById(userIp.getVlanId()));
2358+
if (isReservedForExternalProvider(publicIp.getVlanId())) {
2359+
logger.debug("Skipping public IP {} for migration NIC profile: managed by external network provider", publicIp.getAddress());
2360+
continue;
2361+
}
23532362
final URI broadcastUri = BroadcastDomainType.Vlan.toUri(publicIp.getVlanTag());
23542363
final long ntwkId = publicIp.getNetworkId();
23552364
final Nic nic = _nicDao.findByNetworkIdInstanceIdAndBroadcastUri(ntwkId, vm.getId(),
@@ -3175,7 +3184,7 @@ private boolean hasGuestBypassVlanOverlapCheck(final boolean bypassVlanOverlapCh
31753184
/**
31763185
* Checks for L2 network offering services. Only 2 cases allowed:
31773186
* - No services
3178-
* - User Data service only, provided by ConfigDrive
3187+
* - UserData service only, provided by ConfigDrive
31793188
*
31803189
* @param ntwkOff network offering
31813190
*/

‎engine/schema/src/main/java/com/cloud/vm/dao/NicDao.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,6 @@ public interface NicDao extends GenericDao<NicVO, Long> {
105105

106106
NicVO findByIpAddressAndVmType(String ip, VirtualMachine.Type vmType);
107107

108-
List<NicVO> listByNetworkIdAndType(long networkId, VirtualMachine.Type vmType);
108+
List<NicVO> listNonPlaceholderNicsByNetworkIdAndType(long networkId, VirtualMachine.Type vmType);
109109
List<NicVO> searchRemovedByVms(List<Long> vmIds, Long batchSize);
110110
}

‎engine/schema/src/main/java/com/cloud/vm/dao/NicDaoImpl.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,10 +456,11 @@ public NicVO findByIpAddressAndVmType(String ip, VirtualMachine.Type vmType) {
456456
}
457457

458458
@Override
459-
public List<NicVO> listByNetworkIdAndType(long networkId, VirtualMachine.Type vmType) {
459+
public List<NicVO> listNonPlaceholderNicsByNetworkIdAndType(long networkId, VirtualMachine.Type vmType) {
460460
SearchCriteria<NicVO> sc = AllFieldsSearch.create();
461461
sc.setParameters("network", networkId);
462462
sc.setParameters("vmType", vmType);
463+
sc.setParameters("strategyNEQ", Nic.ReservationStrategy.PlaceHolder.toString());
463464
return listBy(sc);
464465
}
465466

‎engine/schema/src/main/resources/META-INF/db/schema-42210to42220.sql‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,11 @@
2323
-- per-VM volume usage records introduced in 4.22.1 can coexist. See #13399.
2424
CALL `cloud_usage`.`IDEMPOTENT_DROP_INDEX`('id', 'cloud_usage.usage_volume');
2525
CALL `cloud_usage`.`IDEMPOTENT_ADD_UNIQUE_INDEX`('cloud_usage.usage_volume', 'id', '(volume_id ASC, created ASC, vm_id ASC)');
26+
27+
-- Reclaim VNETs belonging to Netris deleted networks
28+
UPDATE op_dc_vnet_alloc a
29+
JOIN networks n ON n.broadcast_uri = CONCAT('netris://', a.vnet)
30+
SET a.account_id = NULL,
31+
a.reservation_id = NULL,
32+
a.taken = NULL
33+
WHERE n.removed IS NOT NULL;

0 commit comments

Comments
 (0)