|
102 | 102 | import com.cloud.network.Network; |
103 | 103 | import com.cloud.network.Network.Capability; |
104 | 104 | import com.cloud.network.Network.Service; |
| 105 | +import com.cloud.network.NetworkProfile; |
105 | 106 | import com.cloud.network.Networks.TrafficType; |
106 | 107 | import com.cloud.network.RemoteAccessVpn; |
107 | 108 | import com.cloud.network.VpnUser; |
|
150 | 151 | import com.cloud.vm.ConsoleProxyVO; |
151 | 152 | import com.cloud.vm.InstanceGroup; |
152 | 153 | import com.cloud.vm.InstanceGroupVO; |
153 | | -import com.cloud.vm.Nic; |
| 154 | +import com.cloud.vm.NicProfile; |
154 | 155 | import com.cloud.vm.SecondaryStorageVmVO; |
155 | 156 | import com.cloud.vm.SystemVm; |
156 | 157 | import com.cloud.vm.UserVmVO; |
@@ -1104,27 +1105,27 @@ public UserVmResponse createUserVmResponse(UserVm userVm) { |
1104 | 1105 | // network groups |
1105 | 1106 | userVmResponse.setSecurityGroupList(ApiDBUtils.getNetworkGroupsNamesForVm(userVm.getId())); |
1106 | 1107 |
|
1107 | | - List<? extends Nic> nics = ApiDBUtils.getNics(userVm); |
| 1108 | + List<NicProfile> nicProfiles = ApiDBUtils.getNics(userVm); |
1108 | 1109 | List<NicResponse> nicResponses = new ArrayList<NicResponse>(); |
1109 | | - for (Nic singleNic : nics) { |
| 1110 | + for (NicProfile singleNicProfile : nicProfiles) { |
1110 | 1111 | NicResponse nicResponse = new NicResponse(); |
1111 | | - nicResponse.setId(singleNic.getId()); |
1112 | | - nicResponse.setIpaddress(singleNic.getIp4Address()); |
1113 | | - nicResponse.setGateway(singleNic.getGateway()); |
1114 | | - nicResponse.setNetmask(singleNic.getNetmask()); |
1115 | | - nicResponse.setNetworkid(singleNic.getNetworkId()); |
| 1112 | + nicResponse.setId(singleNicProfile.getId()); |
| 1113 | + nicResponse.setIpaddress(singleNicProfile.getIp4Address()); |
| 1114 | + nicResponse.setGateway(singleNicProfile.getGateway()); |
| 1115 | + nicResponse.setNetmask(singleNicProfile.getNetmask()); |
| 1116 | + nicResponse.setNetworkid(singleNicProfile.getNetworkId()); |
1116 | 1117 | if (acct.getType() == Account.ACCOUNT_TYPE_ADMIN) { |
1117 | | - if (singleNic.getBroadcastUri() != null) { |
1118 | | - nicResponse.setBroadcastUri(singleNic.getBroadcastUri().toString()); |
| 1118 | + if (singleNicProfile.getBroadCastUri() != null) { |
| 1119 | + nicResponse.setBroadcastUri(singleNicProfile.getBroadCastUri().toString()); |
1119 | 1120 | } |
1120 | | - if (singleNic.getIsolationUri() != null) { |
1121 | | - nicResponse.setIsolationUri(singleNic.getIsolationUri().toString()); |
| 1121 | + if (singleNicProfile.getIsolationUri() != null) { |
| 1122 | + nicResponse.setIsolationUri(singleNicProfile.getIsolationUri().toString()); |
1122 | 1123 | } |
1123 | 1124 | } |
1124 | | - Network network = ApiDBUtils.findNetworkById(singleNic.getNetworkId()); |
| 1125 | + Network network = ApiDBUtils.findNetworkById(singleNicProfile.getNetworkId()); |
1125 | 1126 | nicResponse.setTrafficType(network.getTrafficType().toString()); |
1126 | 1127 | nicResponse.setType(network.getGuestType().toString()); |
1127 | | - nicResponse.setIsDefault(singleNic.isDefaultNic()); |
| 1128 | + nicResponse.setIsDefault(singleNicProfile.isDefaultNic()); |
1128 | 1129 |
|
1129 | 1130 | nicResponse.setObjectName("nic"); |
1130 | 1131 |
|
@@ -1159,23 +1160,23 @@ public DomainRouterResponse createDomainRouterResponse(VirtualRouter router) { |
1159 | 1160 | routerResponse.setDomainName(ApiDBUtils.findDomainById(accountTemp.getDomainId()).getName()); |
1160 | 1161 | } |
1161 | 1162 |
|
1162 | | - List<? extends Nic> nics = ApiDBUtils.getNics(router); |
1163 | | - for (Nic singleNic : nics) { |
1164 | | - Network network = ApiDBUtils.findNetworkById(singleNic.getNetworkId()); |
| 1163 | + List<NicProfile> nicProfiles = ApiDBUtils.getNics(router); |
| 1164 | + for (NicProfile singleNicProfile : nicProfiles) { |
| 1165 | + Network network = ApiDBUtils.findNetworkById(singleNicProfile.getNetworkId()); |
1165 | 1166 | if (network != null) { |
1166 | 1167 | if (network.getTrafficType() == TrafficType.Public) { |
1167 | | - routerResponse.setPublicIp(singleNic.getIp4Address()); |
1168 | | - routerResponse.setPublicMacAddress(singleNic.getMacAddress()); |
1169 | | - routerResponse.setPublicNetmask(singleNic.getNetmask()); |
1170 | | - routerResponse.setGateway(singleNic.getGateway()); |
| 1168 | + routerResponse.setPublicIp(singleNicProfile.getIp4Address()); |
| 1169 | + routerResponse.setPublicMacAddress(singleNicProfile.getMacAddress()); |
| 1170 | + routerResponse.setPublicNetmask(singleNicProfile.getNetmask()); |
| 1171 | + routerResponse.setGateway(singleNicProfile.getGateway()); |
1171 | 1172 | } else if (network.getTrafficType() == TrafficType.Control) { |
1172 | | - routerResponse.setPrivateIp(singleNic.getIp4Address()); |
1173 | | - routerResponse.setPrivateMacAddress(singleNic.getMacAddress()); |
1174 | | - routerResponse.setPrivateNetmask(singleNic.getNetmask()); |
| 1173 | + routerResponse.setPrivateIp(singleNicProfile.getIp4Address()); |
| 1174 | + routerResponse.setPrivateMacAddress(singleNicProfile.getMacAddress()); |
| 1175 | + routerResponse.setPrivateNetmask(singleNicProfile.getNetmask()); |
1175 | 1176 | } else if (network.getTrafficType() == TrafficType.Guest) { |
1176 | | - routerResponse.setGuestIpAddress(singleNic.getIp4Address()); |
1177 | | - routerResponse.setGuestMacAddress(singleNic.getMacAddress()); |
1178 | | - routerResponse.setGuestNetmask(singleNic.getNetmask()); |
| 1177 | + routerResponse.setGuestIpAddress(singleNicProfile.getIp4Address()); |
| 1178 | + routerResponse.setGuestMacAddress(singleNicProfile.getMacAddress()); |
| 1179 | + routerResponse.setGuestNetmask(singleNicProfile.getNetmask()); |
1179 | 1180 | } |
1180 | 1181 | } |
1181 | 1182 | } |
@@ -1238,22 +1239,22 @@ public SystemVmResponse createSystemVmResponse(VirtualMachine systemVM) { |
1238 | 1239 | vmResponse.setDns2(zone.getDns2()); |
1239 | 1240 | } |
1240 | 1241 |
|
1241 | | - List<? extends Nic> nics = ApiDBUtils.getNics(systemVM); |
1242 | | - for (Nic singleNic : nics) { |
1243 | | - Network network = ApiDBUtils.findNetworkById(singleNic.getNetworkId()); |
| 1242 | + List<NicProfile> nicProfiles = ApiDBUtils.getNics(systemVM); |
| 1243 | + for (NicProfile singleNicProfile : nicProfiles) { |
| 1244 | + Network network = ApiDBUtils.findNetworkById(singleNicProfile.getNetworkId()); |
1244 | 1245 | if (network != null) { |
1245 | 1246 | TrafficType trafficType = TrafficType.Public; |
1246 | 1247 | if(zone.getNetworkType() == NetworkType.Basic) { |
1247 | 1248 | trafficType = TrafficType.Guest; |
1248 | 1249 | } |
1249 | 1250 | if (network.getTrafficType() == trafficType) { |
1250 | | - vmResponse.setPublicIp(singleNic.getIp4Address()); |
1251 | | - vmResponse.setPublicMacAddress(singleNic.getMacAddress()); |
1252 | | - vmResponse.setPublicNetmask(singleNic.getNetmask()); |
| 1251 | + vmResponse.setPublicIp(singleNicProfile.getIp4Address()); |
| 1252 | + vmResponse.setPublicMacAddress(singleNicProfile.getMacAddress()); |
| 1253 | + vmResponse.setPublicNetmask(singleNicProfile.getNetmask()); |
1253 | 1254 | } else if (network.getTrafficType() == TrafficType.Control) { |
1254 | | - vmResponse.setPrivateIp(singleNic.getIp4Address()); |
1255 | | - vmResponse.setPrivateMacAddress(singleNic.getMacAddress()); |
1256 | | - vmResponse.setPrivateNetmask(singleNic.getNetmask()); |
| 1255 | + vmResponse.setPrivateIp(singleNicProfile.getIp4Address()); |
| 1256 | + vmResponse.setPrivateMacAddress(singleNicProfile.getMacAddress()); |
| 1257 | + vmResponse.setPrivateNetmask(singleNicProfile.getNetmask()); |
1257 | 1258 | } |
1258 | 1259 | } |
1259 | 1260 | } |
@@ -2237,6 +2238,8 @@ public NetworkOfferingResponse createNetworkOfferingResponse(NetworkOffering off |
2237 | 2238 |
|
2238 | 2239 | @Override |
2239 | 2240 | public NetworkResponse createNetworkResponse(Network network) { |
| 2241 | + NetworkProfile profile = ApiDBUtils.getNetworkProfile(network.getId()); |
| 2242 | + network = profile.getNetwork(); |
2240 | 2243 | NetworkResponse response = new NetworkResponse(); |
2241 | 2244 | response.setId(network.getId()); |
2242 | 2245 | response.setName(network.getName()); |
@@ -2285,10 +2288,11 @@ public NetworkResponse createNetworkResponse(Network network) { |
2285 | 2288 | response.setIsDefault(network.isDefault()); |
2286 | 2289 | response.setState(network.getState().toString()); |
2287 | 2290 | response.setRelated(network.getRelated()); |
2288 | | - response.setDns1(network.getDns1()); |
2289 | | - response.setDns2(network.getDns2()); |
2290 | 2291 | response.setNetworkDomain(network.getNetworkDomain()); |
2291 | 2292 |
|
| 2293 | + response.setDns1(profile.getDns1()); |
| 2294 | + response.setDns2(profile.getDns2()); |
| 2295 | + |
2292 | 2296 | //populate capability |
2293 | 2297 | Map<Service, Map<Capability, String>> serviceCapabilitiesMap = ApiDBUtils.getZoneCapabilities(network.getDataCenterId()); |
2294 | 2298 | List<ServiceResponse> serviceResponses = new ArrayList<ServiceResponse>(); |
|
0 commit comments