Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import org.zstack.network.service.NetworkServiceManager;
import org.zstack.network.service.NetworkServiceProviderLookup;
import org.zstack.network.service.flat.IpStatisticConstants.VmType;
import org.zstack.network.service.userdata.UserdataConstant;
import org.zstack.network.service.vip.VipVO;
import org.zstack.header.network.service.SdnControllerDhcp;
import org.zstack.sdnController.SdnControllerManager;
Expand Down Expand Up @@ -2855,27 +2856,41 @@ public void disableNetworkService(L3NetworkVO l3VO, Completion completion) {
return;
}

flushDhcpConfig(L3NetworkInventory.valueOf(l3VO), new Completion(completion) {
@Override
public void success() {
Map<String, String> dhcpServerMap = getExistingDhcpServerIp(l3VO.getUuid(), IPv6Constants.DUAL_STACK);
if (dhcpServerMap.isEmpty()) {
// If userdata service is also enabled on this L3 network, the namespace is shared,
// so only flush DHCP config. Otherwise, delete the namespace and dnsmasq entirely.
String userdataProviderType = new NetworkProviderFinder().getNetworkProviderTypeByNetworkServiceType(
l3VO.getUuid(), UserdataConstant.USERDATA_TYPE_STRING);
boolean userdataEnabled = userdataProviderType != null;

if (userdataEnabled) {
flushDhcpConfig(L3NetworkInventory.valueOf(l3VO), new Completion(completion) {
@Override
public void success() {
Map<String, String> dhcpServerMap = getExistingDhcpServerIp(l3VO.getUuid(), IPv6Constants.DUAL_STACK);
if (dhcpServerMap.isEmpty()) {
completion.success();
return;
}

for (Map.Entry<String, String> e : dhcpServerMap.entrySet()) {
deleteDhcpServerIp(l3VO.getUuid(), e.getKey(), e.getValue());
}

completion.success();
return;
}

for (Map.Entry<String, String> e : dhcpServerMap.entrySet()) {
deleteDhcpServerIp(l3VO.getUuid(), e.getKey(), e.getValue());
@Override
public void fail(ErrorCode errorCode) {
completion.fail(errorCode);
}

completion.success();
}

@Override
public void fail(ErrorCode errorCode) {
completion.fail(errorCode);
});
} else {
Map<String, String> dhcpServerMap = getExistingDhcpServerIp(l3VO.getUuid(), IPv6Constants.DUAL_STACK);
for (Map.Entry<String, String> e : dhcpServerMap.entrySet()) {
deleteDhcpServerIp(l3VO.getUuid(), e.getKey(), e.getValue());
}
});
deleteNameSpace(L3NetworkInventory.valueOf(l3VO), completion);
}
}

private void doArpingOnHost(CheckIpAvailabilityMsg msg, HostInventory host, L2NetworkInventory l2Inv, ReturnValueCompletion<List<String>> completion) {
Expand Down