|
104 | 104 | import com.cloud.network.vpc.StaticRouteProfile; |
105 | 105 | import com.cloud.network.vpc.Vpc; |
106 | 106 | import com.cloud.network.vpc.VpcGateway; |
107 | | -import com.cloud.network.vpc.VpcGatewayVO; |
108 | 107 | import com.cloud.network.vpc.dao.VpcDao; |
109 | | -import com.cloud.network.vpc.dao.VpcGatewayDao; |
110 | 108 | import com.cloud.offering.NetworkOffering; |
111 | 109 | import com.cloud.offerings.NetworkOfferingVO; |
112 | 110 | import com.cloud.offerings.dao.NetworkOfferingDao; |
@@ -172,8 +170,6 @@ public class CommandSetupHelper { |
172 | 170 | @Inject |
173 | 171 | private VpcDao _vpcDao; |
174 | 172 | @Inject |
175 | | - private VpcGatewayDao _vpcGatewayDao; |
176 | | - @Inject |
177 | 173 | private VlanDao _vlanDao; |
178 | 174 | @Inject |
179 | 175 | private IPAddressDao _ipAddressDao; |
@@ -726,8 +722,7 @@ public int compare(final PublicIpAddress o1, final PublicIpAddress o2) { |
726 | 722 | final IpAddressTO ip = new IpAddressTO(ipAddr.getAccountId(), ipAddr.getAddress().addr(), add, firstIP, sourceNat, BroadcastDomainType.fromString(ipAddr.getVlanTag()).toString(), ipAddr.getGateway(), |
727 | 723 | ipAddr.getNetmask(), macAddress, networkRate, ipAddr.isOneToOneNat()); |
728 | 724 |
|
729 | | - ip.setTrafficType(getNetworkTrafficType(network)); |
730 | | - ip.setNetworkName(_networkModel.getNetworkTag(router.getHypervisorType(), network)); |
| 725 | + setIpAddressNetworkParams(ip, network, router); |
731 | 726 | ipsToSend[i++] = ip; |
732 | 727 | if (ipAddr.isSourceNat()) { |
733 | 728 | sourceNatIpAdd = new Pair<IpAddressTO, Long>(ip, ipAddr.getNetworkId()); |
@@ -851,8 +846,7 @@ public int compare(final PublicIpAddress o1, final PublicIpAddress o2) { |
851 | 846 | final IpAddressTO ip = new IpAddressTO(ipAddr.getAccountId(), ipAddr.getAddress().addr(), add, firstIP, sourceNat, vlanId, vlanGateway, vlanNetmask, |
852 | 847 | vifMacAddress, networkRate, ipAddr.isOneToOneNat()); |
853 | 848 |
|
854 | | - ip.setTrafficType(getNetworkTrafficType(network)); |
855 | | - ip.setNetworkName(_networkModel.getNetworkTag(router.getHypervisorType(), network)); |
| 849 | + setIpAddressNetworkParams(ip, network, router); |
856 | 850 | ipsToSend[i++] = ip; |
857 | 851 | /* |
858 | 852 | * send the firstIP = true for the first Add, this is to create |
@@ -979,8 +973,7 @@ public void createVpcAssociatePrivateIPCommands(final VirtualRouter router, fina |
979 | 973 | final IpAddressTO ip = new IpAddressTO(Account.ACCOUNT_ID_SYSTEM, ipAddr.getIpAddress(), add, false, ipAddr.getSourceNat(), ipAddr.getBroadcastUri(), |
980 | 974 | ipAddr.getGateway(), ipAddr.getNetmask(), ipAddr.getMacAddress(), null, false); |
981 | 975 |
|
982 | | - ip.setTrafficType(getNetworkTrafficType(network)); |
983 | | - ip.setNetworkName(_networkModel.getNetworkTag(router.getHypervisorType(), network)); |
| 976 | + setIpAddressNetworkParams(ip, network, router); |
984 | 977 | ipsToSend[i++] = ip; |
985 | 978 |
|
986 | 979 | } |
@@ -1136,13 +1129,16 @@ protected String getGuestDhcpRange(final NicProfile guestNic, final Network gues |
1136 | 1129 | return dhcpRange; |
1137 | 1130 | } |
1138 | 1131 |
|
1139 | | - private TrafficType getNetworkTrafficType(Network network) { |
1140 | | - final VpcGatewayVO gateway = _vpcGatewayDao.getVpcGatewayByNetworkId(network.getId()); |
1141 | | - if (gateway != null) { |
| 1132 | + private void setIpAddressNetworkParams(IpAddressTO ipAddress, final Network network, final VirtualRouter router) { |
| 1133 | + if (_networkModel.isPrivateGateway(network.getId())) { |
1142 | 1134 | s_logger.debug("network " + network.getId() + " (name: " + network.getName() + " ) is a vpc private gateway, set traffic type to Public"); |
1143 | | - return TrafficType.Public; |
| 1135 | + ipAddress.setTrafficType(TrafficType.Public); |
| 1136 | + ipAddress.setPrivateGateway(true); |
1144 | 1137 | } else { |
1145 | | - return network.getTrafficType(); |
| 1138 | + ipAddress.setTrafficType(network.getTrafficType()); |
| 1139 | + ipAddress.setPrivateGateway(false); |
1146 | 1140 | } |
| 1141 | + ipAddress.setNetworkName(_networkModel.getNetworkTag(router.getHypervisorType(), network)); |
1147 | 1142 | } |
| 1143 | + |
1148 | 1144 | } |
0 commit comments