diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties
index d2d52500ad1..53ca37c9eaa 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.
NOTE: You need to manually configure the newly-acquired secondary IP inside the virtual machine.
diff --git a/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
index f142048ec5e..8ea142ac909 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 implem
nicResponse.setType(userVm.getGuestType().toString());
}
nicResponse.setIsDefault(userVm.isDefaultNic());
+ List secondaryIps = ApiDBUtils.findNicSecondaryIps(userVm.getNicId());
+ if (secondaryIps != null) {
+ List ipList = new ArrayList();
+ 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);
}
diff --git a/ui/dictionary.jsp b/ui/dictionary.jsp
index e1c19f36e58..2d15c97f347 100644
--- a/ui/dictionary.jsp
+++ b/ui/dictionary.jsp
@@ -89,6 +89,8 @@ dictionary = {
'label.disk.iops.min': '',
'label.disk.iops.max': '',
'label.hypervisor.snapshot.reserve': '',
+'label.secondary.ips': '',
+'label.edit.secondary.ips': '',
'label.acquire.new.secondary.ip': '',
'label.view.secondary.ips': '',
'label.capacity.bytes': '',
diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js
index 15bc0d171bb..ee8ef0a70e9 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') + ')';
diff --git a/ui/scripts/network.js b/ui/scripts/network.js
index 7435961e3d5..0a46fa04392 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
}
}