Skip to content

Commit dcb7fcc

Browse files
committed
CLOUDSTACK-8063: list secondary Ips information in VM response
1 parent 528bc80 commit dcb7fcc

5 files changed

Lines changed: 36 additions & 2 deletions

File tree

client/WEB-INF/classes/resources/messages.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ label.disk.iops.min=Min IOPS
6262
label.disk.iops.max=Max IOPS
6363
label.disk.iops.total=IOPS Total
6464
label.hypervisor.snapshot.reserve=Hypervisor Snapshot Reserve
65+
label.secondary.ips=Secondary IPs
66+
label.edit.secondary.ips=Edit secondary IPs
6567
label.view.secondary.ips=View secondary IPs
6668
message.validate.invalid.characters=Invalid characters found; please correct.
6769
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.

server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.apache.cloudstack.api.ApiConstants.VMDetails;
3636
import org.apache.cloudstack.api.ResponseObject.ResponseView;
3737
import org.apache.cloudstack.api.response.NicResponse;
38+
import org.apache.cloudstack.api.response.NicSecondaryIpResponse;
3839
import org.apache.cloudstack.api.response.SecurityGroupResponse;
3940
import org.apache.cloudstack.api.response.UserVmResponse;
4041
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
@@ -55,6 +56,7 @@
5556
import com.cloud.vm.VirtualMachine.State;
5657
import com.cloud.vm.VmDetailConstants;
5758
import com.cloud.vm.VmStats;
59+
import com.cloud.vm.dao.NicSecondaryIpVO;
5860
import com.cloud.vm.dao.UserVmDetailsDao;
5961

6062
@Component
@@ -255,6 +257,17 @@ public UserVmResponse newUserVmResponse(ResponseView view, String objectName, Us
255257
nicResponse.setType(userVm.getGuestType().toString());
256258
}
257259
nicResponse.setIsDefault(userVm.isDefaultNic());
260+
List<NicSecondaryIpVO> secondaryIps = ApiDBUtils.findNicSecondaryIps(userVm.getNicId());
261+
if (secondaryIps != null) {
262+
List<NicSecondaryIpResponse> ipList = new ArrayList<NicSecondaryIpResponse>();
263+
for (NicSecondaryIpVO ip : secondaryIps) {
264+
NicSecondaryIpResponse ipRes = new NicSecondaryIpResponse();
265+
ipRes.setId(ip.getUuid());
266+
ipRes.setIpAddr(ip.getIp4Address());
267+
ipList.add(ipRes);
268+
}
269+
nicResponse.setSecondaryIps(ipList);
270+
}
258271
nicResponse.setObjectName("nic");
259272
userVmResponse.addNic(nicResponse);
260273
}

ui/dictionary.jsp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ dictionary = {
8989
'label.disk.iops.min': '<fmt:message key="label.disk.iops.min" />',
9090
'label.disk.iops.max': '<fmt:message key="label.disk.iops.max" />',
9191
'label.hypervisor.snapshot.reserve': '<fmt:message key="label.hypervisor.snapshot.reserve" />',
92+
'label.secondary.ips': '<fmt:message key="label.secondary.ips" />',
93+
'label.edit.secondary.ips': '<fmt:message key="label.edit.secondary.ips" />',
9294
'label.acquire.new.secondary.ip': '<fmt:message key="label.acquire.new.secondary.ip" />',
9395
'label.view.secondary.ips': '<fmt:message key="label.view.secondary.ips" />',
9496
'label.capacity.bytes': '<fmt:message key="label.capacity.bytes" />',

ui/scripts/instances.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2143,6 +2143,9 @@
21432143
ipaddress: {
21442144
label: 'label.ip.address'
21452145
},
2146+
secondaryips: {
2147+
label: 'label.secondary.ips'
2148+
},
21462149
gateway: {
21472150
label: 'label.gateway'
21482151
},
@@ -2169,8 +2172,8 @@
21692172
}],
21702173
viewAll: {
21712174
path: 'network.secondaryNicIps',
2172-
attachTo: 'ipaddress',
2173-
label: 'label.view.secondary.ips',
2175+
attachTo: 'secondaryips',
2176+
label: 'label.edit.secondary.ips',
21742177
title: function(args) {
21752178
var title = _l('label.menu.ipaddresses') + ' - ' + args.context.nics[0].name;
21762179

@@ -2193,6 +2196,19 @@
21932196
}
21942197
},
21952198
data: $.map(json.listvirtualmachinesresponse.virtualmachine[0].nic, function(nic, index) {
2199+
if (nic.secondaryip != null) {
2200+
var secondaryips = "";
2201+
for (var i = 0; i < nic.secondaryip.length; i++) {
2202+
if (i == 0)
2203+
secondaryips = nic.secondaryip[i].ipaddress;
2204+
else
2205+
secondaryips = secondaryips + " , " + nic.secondaryip[i].ipaddress;
2206+
}
2207+
$.extend(nic, {
2208+
secondaryips: secondaryips
2209+
})
2210+
}
2211+
21962212
var name = 'NIC ' + (index + 1);
21972213
if (nic.isdefault) {
21982214
name += ' (' + _l('label.default') + ')';

ui/scripts/network.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,6 +1864,7 @@
18641864
ipaddress: {
18651865
label: 'label.ip.address',
18661866
validation: {
1867+
required: false,
18671868
ipv4: true
18681869
}
18691870
}

0 commit comments

Comments
 (0)