Remove group for segment before removing segment

This commit is contained in:
nvazquez 2023-11-12 22:55:17 -03:00
parent 28b4fee6c2
commit bd9be1239c
No known key found for this signature in database
GPG Key ID: 656E1BCC8CB54F84
1 changed files with 6 additions and 0 deletions

View File

@ -384,6 +384,7 @@ public class NsxApiClient {
public void deleteSegment(long zoneId, long domainId, long accountId, Long vpcId, long networkId, String segmentName) {
try {
Segments segmentService = (Segments) nsxService.apply(Segments.class);
removeGroupForSegment(segmentName);
LOGGER.debug(String.format("Removing the segment with ID %s", segmentName));
segmentService.delete(segmentName);
DhcpRelayConfigs dhcpRelayConfig = (DhcpRelayConfigs) nsxService.apply(DhcpRelayConfigs.class);
@ -739,4 +740,9 @@ public class NsxApiClient {
service.patch(DEFAULT_DOMAIN, segmentName, group);
}
private void removeGroupForSegment(String segmentName) {
LOGGER.info(String.format("Removing Group for Segment %s", segmentName));
Groups service = (Groups) nsxService.apply(Groups.class);
service.delete(DEFAULT_DOMAIN, segmentName, true, false);
}
}