diff --git a/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfUtils.java b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfUtils.java index b6e3359d7e1..455535f5e28 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfUtils.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfUtils.java @@ -177,7 +177,7 @@ public class BigSwitchBcfUtils { // handle external network first, only if NAT service is enabled if(networks != null) { - if(!(networks.isEmpty()) && isNatEnabled()!=null && isNatEnabled()){ + if (!(networks.isEmpty()) && isNatEnabled()) { // get public net info - needed to set up source nat gateway NetworkVO pubNet = getPublicNetwork(physicalNetworkId); @@ -440,7 +440,7 @@ public class BigSwitchBcfUtils { public String syncTopologyToBcfHost(HostVO bigswitchBcfHost){ SyncBcfTopologyCommand syncCmd; - if(isNatEnabled()!=null && isNatEnabled()){ + if (isNatEnabled()) { syncCmd = new SyncBcfTopologyCommand(true, true); } else { syncCmd = new SyncBcfTopologyCommand(true, false); @@ -519,12 +519,12 @@ public class BigSwitchBcfUtils { }); } - public Boolean isNatEnabled(){ + public boolean isNatEnabled() { List devices = _bigswitchBcfDao.listAll(); if(devices != null && !devices.isEmpty()){ return devices.get(0).getNat(); } else { - return null; + return false; } } diff --git a/plugins/network-elements/bigswitch/src/com/cloud/network/element/BigSwitchBcfElement.java b/plugins/network-elements/bigswitch/src/com/cloud/network/element/BigSwitchBcfElement.java index 2de447efb80..37391a6eb9c 100644 --- a/plugins/network-elements/bigswitch/src/com/cloud/network/element/BigSwitchBcfElement.java +++ b/plugins/network-elements/bigswitch/src/com/cloud/network/element/BigSwitchBcfElement.java @@ -30,25 +30,26 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import org.apache.commons.net.util.SubnetUtils; import org.apache.log4j.Logger; import org.springframework.stereotype.Component; + import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice; -import org.apache.commons.net.util.SubnetUtils; import com.cloud.agent.AgentManager; import com.cloud.agent.api.BcfAnswer; -import com.cloud.agent.api.UpdateBcfRouterCommand; import com.cloud.agent.api.CreateBcfAttachmentCommand; import com.cloud.agent.api.CreateBcfStaticNatCommand; import com.cloud.agent.api.DeleteBcfAttachmentCommand; import com.cloud.agent.api.DeleteBcfStaticNatCommand; import com.cloud.agent.api.StartupBigSwitchBcfCommand; import com.cloud.agent.api.StartupCommand; +import com.cloud.agent.api.UpdateBcfRouterCommand; import com.cloud.api.ApiDBUtils; import com.cloud.api.commands.AddBigSwitchBcfDeviceCmd; +import com.cloud.api.commands.BcfConstants; import com.cloud.api.commands.DeleteBigSwitchBcfDeviceCmd; import com.cloud.api.commands.ListBigSwitchBcfDevicesCmd; -import com.cloud.api.commands.BcfConstants; import com.cloud.api.response.BigSwitchBcfDeviceResponse; import com.cloud.configuration.ConfigurationManager; import com.cloud.dc.DataCenterVO; @@ -451,8 +452,7 @@ NetworkACLServiceProvider, FirewallServiceProvider, ResourceStateAdapter { zoneName = String.valueOf(zoneId); } - Boolean natNow = _bcfUtils.isNatEnabled(); - if( natNow != null) + boolean natNow = _bcfUtils.isNatEnabled(); if (!nat && natNow){ throw new CloudRuntimeException("NAT is enabled in existing controller. Enable NAT for new controller or remove existing controller first."); } else if (nat && !natNow){