CLOUDSTACK-8063: list secondary Ips information in VM response

This commit is contained in:
Wei Zhou 2014-12-12 09:47:27 +01:00
parent 528bc80b4c
commit dcb7fcc6df
5 changed files with 36 additions and 2 deletions

View File

@ -62,6 +62,8 @@ label.disk.iops.min=Min IOPS
label.disk.iops.max=Max IOPS
label.disk.iops.total=IOPS Total
label.hypervisor.snapshot.reserve=Hypervisor Snapshot Reserve
label.secondary.ips=Secondary IPs
label.edit.secondary.ips=Edit secondary IPs
label.view.secondary.ips=View secondary IPs
message.validate.invalid.characters=Invalid characters found; please correct.
message.acquire.ip.nic=Please confirm that you would like to acquire a new secondary IP for this NIC.<br/>NOTE: You need to manually configure the newly-acquired secondary IP inside the virtual machine.

View File

@ -35,6 +35,7 @@ import org.apache.cloudstack.affinity.AffinityGroupResponse;
import org.apache.cloudstack.api.ApiConstants.VMDetails;
import org.apache.cloudstack.api.ResponseObject.ResponseView;
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;
@ -55,6 +56,7 @@ import com.cloud.vm.UserVmDetailVO;
import com.cloud.vm.VirtualMachine.State;
import com.cloud.vm.VmDetailConstants;
import com.cloud.vm.VmStats;
import com.cloud.vm.dao.NicSecondaryIpVO;
import com.cloud.vm.dao.UserVmDetailsDao;
@Component
@ -255,6 +257,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);
}

View File

@ -89,6 +89,8 @@ dictionary = {
'label.disk.iops.min': '<fmt:message key="label.disk.iops.min" />',
'label.disk.iops.max': '<fmt:message key="label.disk.iops.max" />',
'label.hypervisor.snapshot.reserve': '<fmt:message key="label.hypervisor.snapshot.reserve" />',
'label.secondary.ips': '<fmt:message key="label.secondary.ips" />',
'label.edit.secondary.ips': '<fmt:message key="label.edit.secondary.ips" />',
'label.acquire.new.secondary.ip': '<fmt:message key="label.acquire.new.secondary.ip" />',
'label.view.secondary.ips': '<fmt:message key="label.view.secondary.ips" />',
'label.capacity.bytes': '<fmt:message key="label.capacity.bytes" />',

View File

@ -2143,6 +2143,9 @@
ipaddress: {
label: 'label.ip.address'
},
secondaryips: {
label: 'label.secondary.ips'
},
gateway: {
label: 'label.gateway'
},
@ -2169,8 +2172,8 @@
}],
viewAll: {
path: 'network.secondaryNicIps',
attachTo: 'ipaddress',
label: 'label.view.secondary.ips',
attachTo: 'secondaryips',
label: 'label.edit.secondary.ips',
title: function(args) {
var title = _l('label.menu.ipaddresses') + ' - ' + args.context.nics[0].name;
@ -2193,6 +2196,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') + ')';

View File

@ -1864,6 +1864,7 @@
ipaddress: {
label: 'label.ip.address',
validation: {
required: false,
ipv4: true
}
}