Repository: cloudstack Updated Branches: refs/heads/master 528bc80b4 -> dcb7fcc6d
CLOUDSTACK-8063: list secondary Ips information in VM response Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/dcb7fcc6 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/dcb7fcc6 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/dcb7fcc6 Branch: refs/heads/master Commit: dcb7fcc6df6137b143e6809e67429ed24a0ae19e Parents: 528bc80 Author: Wei Zhou <[email protected]> Authored: Fri Dec 12 09:47:27 2014 +0100 Committer: Wei Zhou <[email protected]> Committed: Fri Dec 12 09:47:27 2014 +0100 ---------------------------------------------------------------------- .../classes/resources/messages.properties | 2 ++ .../cloud/api/query/dao/UserVmJoinDaoImpl.java | 13 +++++++++++++ ui/dictionary.jsp | 2 ++ ui/scripts/instances.js | 20 ++++++++++++++++++-- ui/scripts/network.js | 1 + 5 files changed, 36 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dcb7fcc6/client/WEB-INF/classes/resources/messages.properties ---------------------------------------------------------------------- diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties index d2d5250..53ca37c 100644 --- a/client/WEB-INF/classes/resources/messages.properties +++ b/client/WEB-INF/classes/resources/messages.properties @@ -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. http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dcb7fcc6/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java index f142048..8ea142a 100644 --- a/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java +++ b/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java @@ -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); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dcb7fcc6/ui/dictionary.jsp ---------------------------------------------------------------------- diff --git a/ui/dictionary.jsp b/ui/dictionary.jsp index e1c19f3..2d15c97 100644 --- a/ui/dictionary.jsp +++ b/ui/dictionary.jsp @@ -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" />', http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dcb7fcc6/ui/scripts/instances.js ---------------------------------------------------------------------- diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js index 15bc0d1..ee8ef0a 100644 --- a/ui/scripts/instances.js +++ b/ui/scripts/instances.js @@ -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') + ')'; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dcb7fcc6/ui/scripts/network.js ---------------------------------------------------------------------- diff --git a/ui/scripts/network.js b/ui/scripts/network.js index 7435961..0a46fa0 100755 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -1864,6 +1864,7 @@ ipaddress: { label: 'label.ip.address', validation: { + required: false, ipv4: true } }
