mirror of https://github.com/apache/cloudstack.git
[UI] show all secondary ips in VM NIC page
This commit is contained in:
parent
c3cbb7972e
commit
9b7ac9dfac
|
|
@ -31,6 +31,7 @@ import javax.inject.Inject;
|
|||
import org.apache.cloudstack.affinity.AffinityGroupResponse;
|
||||
import org.apache.cloudstack.api.ApiConstants.VMDetails;
|
||||
import org.apache.cloudstack.api.response.NicResponse;
|
||||
import org.apache.cloudstack.api.response.NicSecondaryIpResponse;
|
||||
import org.apache.cloudstack.api.response.SecurityGroupResponse;
|
||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
|
|
@ -52,7 +53,7 @@ import com.cloud.vm.VirtualMachine.State;
|
|||
import com.cloud.vm.VmDetailConstants;
|
||||
import com.cloud.vm.VmStats;
|
||||
import com.cloud.vm.dao.UserVmDetailsDao;
|
||||
|
||||
import com.cloud.vm.dao.NicSecondaryIpVO;
|
||||
|
||||
@Component
|
||||
@Local(value={UserVmJoinDao.class})
|
||||
|
|
@ -241,6 +242,17 @@ public class UserVmJoinDaoImpl extends GenericDaoBase<UserVmJoinVO, Long> implem
|
|||
nicResponse.setType(userVm.getGuestType().toString());
|
||||
}
|
||||
nicResponse.setIsDefault(userVm.isDefaultNic());
|
||||
List<NicSecondaryIpVO> secondaryIps = ApiDBUtils.findNicSecondaryIps(userVm.getNicId());
|
||||
if (secondaryIps != null) {
|
||||
List<NicSecondaryIpResponse> ipList = new ArrayList<NicSecondaryIpResponse>();
|
||||
for (NicSecondaryIpVO ip : secondaryIps) {
|
||||
NicSecondaryIpResponse ipRes = new NicSecondaryIpResponse();
|
||||
ipRes.setId(ip.getUuid());
|
||||
ipRes.setIpAddr(ip.getIp4Address());
|
||||
ipList.add(ipRes);
|
||||
}
|
||||
nicResponse.setSecondaryIps(ipList);
|
||||
}
|
||||
nicResponse.setObjectName("nic");
|
||||
userVmResponse.addNic(nicResponse);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2056,6 +2056,9 @@
|
|||
ipaddress: {
|
||||
label: 'label.ip.address'
|
||||
},
|
||||
secondaryips: {
|
||||
label: 'Secondary IPs'
|
||||
},
|
||||
gateway: {
|
||||
label: 'label.gateway'
|
||||
},
|
||||
|
|
@ -2082,8 +2085,8 @@
|
|||
}],
|
||||
viewAll: {
|
||||
path: 'network.secondaryNicIps',
|
||||
attachTo: 'ipaddress',
|
||||
label: 'label.view.secondary.ips',
|
||||
attachTo: 'secondaryips',
|
||||
label: 'Edit secondary IPs',
|
||||
title: function(args) {
|
||||
var title = _l('label.menu.ipaddresses') + ' - ' + args.context.nics[0].name;
|
||||
|
||||
|
|
@ -2106,6 +2109,19 @@
|
|||
}
|
||||
},
|
||||
data: $.map(json.listvirtualmachinesresponse.virtualmachine[0].nic, function(nic, index) {
|
||||
if (nic.secondaryip != null) {
|
||||
var secondaryips = "";
|
||||
for (var i = 0; i < nic.secondaryip.length; i++) {
|
||||
if (i == 0)
|
||||
secondaryips = nic.secondaryip[i].ipaddress;
|
||||
else
|
||||
secondaryips = secondaryips + " , " + nic.secondaryip[i].ipaddress;
|
||||
}
|
||||
$.extend(nic, {
|
||||
secondaryips: secondaryips
|
||||
})
|
||||
}
|
||||
|
||||
var name = 'NIC ' + (index + 1);
|
||||
if (nic.isdefault) {
|
||||
name += ' (' + _l('label.default') + ')';
|
||||
|
|
|
|||
Loading…
Reference in New Issue