mirror of https://github.com/apache/cloudstack.git
Fixed listPublicIpAddresses for Direct guest network to return networkId associated with corresponding vlan (if null is returned, UI IP tab gives an error on listPublicIp)
Conflicts: server/src/com/cloud/api/ApiDBUtils.java server/src/com/cloud/api/ApiResponseHelper.java
This commit is contained in:
parent
dfaf7c4c5d
commit
3e089166bb
|
|
@ -32,10 +32,10 @@ import com.cloud.network.LoadBalancerVO;
|
|||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkRuleConfigVO;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.LoadBalancerDao;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
|
|
@ -43,7 +43,6 @@ import com.cloud.network.dao.NetworkRuleConfigDao;
|
|||
import com.cloud.network.security.SecurityGroup;
|
||||
import com.cloud.network.security.SecurityGroupManager;
|
||||
import com.cloud.network.security.dao.SecurityGroupDao;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
|
|
@ -538,5 +537,14 @@ public class ApiDBUtils {
|
|||
}
|
||||
return networks.get(0).getId();
|
||||
}
|
||||
|
||||
public static Long getVlanNetworkId(long vlanId) {
|
||||
VlanVO vlan = _vlanDao.findById(vlanId);
|
||||
if (vlan != null) {
|
||||
return vlan.getNetworkId();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -616,14 +616,27 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
ipResponse.setForVirtualNetwork(forVirtualNetworks);
|
||||
ipResponse.setStaticNat(ipAddress.isOneToOneNat());
|
||||
|
||||
//Network id the ip is associated with
|
||||
ipResponse.setAssociatedNetworkId(ipAddress.getAssociatedNetworkId());
|
||||
|
||||
//Network id the ip is associated withif associated networkId is null, try to get this information from vlan
|
||||
Long associatedNetworkId = ipAddress.getAssociatedNetworkId();
|
||||
Long vlanNetworkId = ApiDBUtils.getVlanNetworkId(ipAddress.getVlanId());
|
||||
if (associatedNetworkId == null) {
|
||||
associatedNetworkId = vlanNetworkId;
|
||||
}
|
||||
|
||||
ipResponse.setAssociatedNetworkId(associatedNetworkId);
|
||||
|
||||
//Network id the ip belongs to
|
||||
long networkId = ApiDBUtils.getPublicNetworkIdByZone(zoneId);
|
||||
Long networkId;
|
||||
if (vlanNetworkId != null) {
|
||||
networkId = vlanNetworkId;
|
||||
} else {
|
||||
networkId = ApiDBUtils.getPublicNetworkIdByZone(zoneId);
|
||||
}
|
||||
|
||||
ipResponse.setNetworkId(networkId);
|
||||
|
||||
|
||||
// show this info to admin only
|
||||
Account account = UserContext.current().getAccount();
|
||||
if ((account == null) || account.getType() == Account.ACCOUNT_TYPE_ADMIN) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue