Skip to content

Commit d04a3e8

Browse files
committed
CLOUDSTACK-9317: Update review comments and rule state column
1 parent 8ef5232 commit d04a3e8

4 files changed

Lines changed: 10 additions & 8 deletions

File tree

engine/schema/src/com/cloud/network/dao/IPAddressVO.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ public class IPAddressVO implements IpAddress {
117117
@Column(name = "display", updatable = true, nullable = false)
118118
protected boolean display = true;
119119

120+
//static nat rule state
120121
@Enumerated(value = EnumType.STRING)
121122
@Column(name = "rule_state")
122123
State ruleState;

plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1771,7 +1771,7 @@ protected ExecutionResult cleanupNetworkElementCommand(final IpAssocCommand cmd)
17711771
}
17721772
nicNum = broadcastUriAllocatedToVM.get(ip.getBroadcastUri());
17731773

1774-
if (lastIp != null && !ip.isAdd()) {
1774+
if (org.apache.commons.lang.StringUtils.equalsIgnoreCase(lastIp, "true") && !ip.isAdd()) {
17751775
// in isolated network eth2 is the default public interface. We don't want to delete it.
17761776
if (nicNum != 2) {
17771777
vifHotUnPlug(conn, routerName, ip.getVifMacAddress());

plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ protected ExecutionResult cleanupNetworkElementCommand(final IpAssocCommand cmd)
627627

628628
// there is only one ip in this public vlan and removing it, so
629629
// remove the nic
630-
if (lastIp != null && !ip.isAdd()) {
630+
if (org.apache.commons.lang.StringUtils.equalsIgnoreCase(lastIp, "true") && !ip.isAdd()) {
631631
final VIF correctVif = getCorrectVif(conn, router, network);
632632
// in isolated network eth2 is the default public interface. We don't want to delete it.
633633
if (correctVif != null && !correctVif.getDevice(conn).equals("2")) {

server/src/com/cloud/network/router/CommandSetupHelper.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,6 @@ public class CommandSetupHelper {
176176
@Inject
177177
private IPAddressDao _ipAddressDao;
178178
@Inject
179-
private FirewallRulesDao _firewallsDao;
180-
@Inject
181179
private GuestOSDao _guestOSDao;
182180

183181
@Inject
@@ -854,11 +852,12 @@ public int compare(final PublicIpAddress o1, final PublicIpAddress o2) {
854852
int ipsWithrules = 0;
855853
int ipsStaticNat = 0;
856854
for (IPAddressVO ip : userIps) {
857-
if ( _firewallsDao.countRulesByIpIdAndState(ip.getId(), FirewallRule.State.Active) > 0 ) {
855+
if ( _rulesDao.countRulesByIpIdAndState(ip.getId(), FirewallRule.State.Active) > 0){
858856
ipsWithrules++;
859857
}
860858

861-
// check onetoonenat and also check if the ip "add":false. If there are 2 PF remove 1 static nat add
859+
// check onetoonenat and also check if the ip "add":false. If there are 2 PF rules remove and
860+
// 1 static nat rule add
862861
if (ip.isOneToOneNat() && ip.getRuleState() == null) {
863862
ipsStaticNat++;
864863
}
@@ -871,10 +870,12 @@ public int compare(final PublicIpAddress o1, final PublicIpAddress o2) {
871870
final DataCenterVO dcVo = _dcDao.findById(router.getDataCenterId());
872871
cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
873872

874-
// if there 1 static nat then it will be checked for remove at the resource
875-
if (ipsWithrules == 0 && ipsStaticNat == 0 ) {
873+
// if there is 1 static nat then it will be checked for remove at the resource
874+
if (ipsWithrules == 0 && ipsStaticNat == 0) {
876875
// there is only one ip address for the network.
877876
cmd.setAccessDetail(NetworkElementCommand.NETWORK_PUB_LAST_IP, "true");
877+
} else {
878+
cmd.setAccessDetail(NetworkElementCommand.NETWORK_PUB_LAST_IP, "false");
878879
}
879880

880881
cmds.addCommand(ipAssocCommand, cmd);

0 commit comments

Comments
 (0)