|
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; |
107 | 108 | import com.cloud.network.vpc.dao.VpcDao;
|
| 109 | +import com.cloud.network.vpc.dao.VpcGatewayDao; |
108 | 110 | import com.cloud.offering.NetworkOffering;
|
109 | 111 | import com.cloud.offerings.NetworkOfferingVO;
|
110 | 112 | import com.cloud.offerings.dao.NetworkOfferingDao;
|
@@ -170,6 +172,8 @@ public class CommandSetupHelper {
|
170 | 172 | @Inject
|
171 | 173 | private VpcDao _vpcDao;
|
172 | 174 | @Inject
|
| 175 | + private VpcGatewayDao _vpcGatewayDao; |
| 176 | + @Inject |
173 | 177 | private VlanDao _vlanDao;
|
174 | 178 | @Inject
|
175 | 179 | private IPAddressDao _ipAddressDao;
|
@@ -707,7 +711,7 @@ public int compare(final PublicIpAddress o1, final PublicIpAddress o2) {
|
707 | 711 | final IpAddressTO ip = new IpAddressTO(ipAddr.getAccountId(), ipAddr.getAddress().addr(), add, firstIP, sourceNat, BroadcastDomainType.fromString(ipAddr.getVlanTag()).toString(), ipAddr.getGateway(),
|
708 | 712 | ipAddr.getNetmask(), macAddress, networkRate, ipAddr.isOneToOneNat());
|
709 | 713 |
|
710 |
| - ip.setTrafficType(network.getTrafficType()); |
| 714 | + ip.setTrafficType(getNetworkTrafficType(network)); |
711 | 715 | ip.setNetworkName(_networkModel.getNetworkTag(router.getHypervisorType(), network));
|
712 | 716 | ipsToSend[i++] = ip;
|
713 | 717 | if (ipAddr.isSourceNat()) {
|
@@ -823,7 +827,7 @@ public int compare(final PublicIpAddress o1, final PublicIpAddress o2) {
|
823 | 827 | final IpAddressTO ip = new IpAddressTO(ipAddr.getAccountId(), ipAddr.getAddress().addr(), add, firstIP, sourceNat, vlanId, vlanGateway, vlanNetmask,
|
824 | 828 | vifMacAddress, networkRate, ipAddr.isOneToOneNat());
|
825 | 829 |
|
826 |
| - ip.setTrafficType(network.getTrafficType()); |
| 830 | + ip.setTrafficType(getNetworkTrafficType(network)); |
827 | 831 | ip.setNetworkName(_networkModel.getNetworkTag(router.getHypervisorType(), network));
|
828 | 832 | ipsToSend[i++] = ip;
|
829 | 833 | /*
|
@@ -948,7 +952,7 @@ public void createVpcAssociatePrivateIPCommands(final VirtualRouter router, fina
|
948 | 952 | final IpAddressTO ip = new IpAddressTO(Account.ACCOUNT_ID_SYSTEM, ipAddr.getIpAddress(), add, false, ipAddr.getSourceNat(), ipAddr.getBroadcastUri(),
|
949 | 953 | ipAddr.getGateway(), ipAddr.getNetmask(), ipAddr.getMacAddress(), null, false);
|
950 | 954 |
|
951 |
| - ip.setTrafficType(network.getTrafficType()); |
| 955 | + ip.setTrafficType(getNetworkTrafficType(network)); |
952 | 956 | ip.setNetworkName(_networkModel.getNetworkTag(router.getHypervisorType(), network));
|
953 | 957 | ipsToSend[i++] = ip;
|
954 | 958 |
|
@@ -1101,4 +1105,14 @@ protected String getGuestDhcpRange(final NicProfile guestNic, final Network gues
|
1101 | 1105 | }
|
1102 | 1106 | return dhcpRange;
|
1103 | 1107 | }
|
| 1108 | + |
| 1109 | + private TrafficType getNetworkTrafficType(Network network) { |
| 1110 | + final VpcGatewayVO gateway = _vpcGatewayDao.getVpcGatewayByNetworkId(network.getId()); |
| 1111 | + if (gateway != null) { |
| 1112 | + s_logger.debug("network " + network.getId() + " (name: " + network.getName() + " ) is a vpc private gateway, set traffic type to Public"); |
| 1113 | + return TrafficType.Public; |
| 1114 | + } else { |
| 1115 | + return network.getTrafficType(); |
| 1116 | + } |
| 1117 | + } |
1104 | 1118 | }
|
0 commit comments