Skip to content

Commit

Permalink
Static: remove allocated IPv4 subnet when delete a network or vpc
Browse files Browse the repository at this point in the history
  • Loading branch information
weizhouapache committed Aug 28, 2024
1 parent d25dc5e commit 943a4eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -480,17 +480,7 @@ public void releaseIpv4SubnetForVpc(long vpcId) {
}

private void releaseIpv4SubnetForGuestNetworkOrVpcInternal(Ipv4GuestSubnetNetworkMapVO mapVO) {
if (mapVO.getParentId() == null) {
// if parent_id is NULL, remove it
ipv4GuestSubnetNetworkMapDao.remove(mapVO.getId());
} else {
// otherwise, release it
mapVO.setAllocated(null);
mapVO.setVpcId(null);
mapVO.setNetworkId(null);
mapVO.setState(State.Free);
ipv4GuestSubnetNetworkMapDao.update(mapVO.getId(), mapVO);
}
ipv4GuestSubnetNetworkMapDao.remove(mapVO.getId());
}

@Override
Expand Down
10 changes: 4 additions & 6 deletions test/integration/smoke/test_ipv4_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,10 +684,9 @@ def test_04_create_isolated_network_routed_mode_with_cidrsize(self):
subnet=network_cidr
)
self.assertEqual(
isinstance(subnets, list) and len(subnets) == 1
and not subnets[0].networkid and subnets[0].state == "Free",
not isinstance(subnets, list) or len(subnets) == 0,
True,
"The subnet should be created for isolated_network %s" % isolated_network.name
"The subnet should be removed for isolated_network %s" % isolated_network.name
)

@attr(tags=['advanced'], required_hardware=False)
Expand Down Expand Up @@ -735,10 +734,9 @@ def test_05_create_vpc_routed_mode_with_cidrsize(self):
subnet=vpc_cidr
)
self.assertEqual(
isinstance(subnets, list) and len(subnets) == 1
and not subnets[0].vpcid and subnets[0].state == "Free",
not isinstance(subnets, list) or len(subnets) == 0,
True,
"The subnet should be created for vpc %s" % vpc.name
"The subnet should be removed for vpc %s" % vpc.name
)

@attr(tags=['advanced'], required_hardware=False)
Expand Down

0 comments on commit 943a4eb

Please sign in to comment.