From 2388bd8f82d4f6e598730a27ab13616ba26189eb Mon Sep 17 00:00:00 2001 From: Pranav Saxena Date: Tue, 31 Jul 2012 02:02:17 +0530 Subject: [PATCH] CS-15044:API changes to provide UI option to view the list of instances which are part of the guestnetwork is not availble --- .../com/cloud/api/response/NicResponse.java | 7 ++++ .../src/com/cloud/api/ApiResponseHelper.java | 1 + ui/scripts/instances.js | 33 ++++++++++++++----- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/api/src/com/cloud/api/response/NicResponse.java b/api/src/com/cloud/api/response/NicResponse.java index 53793f16c31..01d6d3b3740 100755 --- a/api/src/com/cloud/api/response/NicResponse.java +++ b/api/src/com/cloud/api/response/NicResponse.java @@ -26,6 +26,9 @@ public class NicResponse extends BaseResponse { @SerializedName("networkid") @Param(description="the ID of the corresponding network") private final IdentityProxy networkId = new IdentityProxy("networks"); + @SerializedName("networkname") @Param(description="the name of the corresponding network") + private String networkName ; + @SerializedName(ApiConstants.NETMASK) @Param(description="the netmask of the nic") private String netmask; @@ -65,6 +68,10 @@ public class NicResponse extends BaseResponse { this.networkId.setValue(networkid); } + public void setNetworkName(String networkname) { + this.networkName = networkname; + } + public void setNetmask(String netmask) { this.netmask = netmask; } diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index 175baa6dfeb..1e4f82626fd 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -1588,6 +1588,7 @@ public class ApiResponseHelper implements ResponseGenerator { nicResponse.setGateway(singleNicProfile.getGateway()); nicResponse.setNetmask(singleNicProfile.getNetmask()); nicResponse.setNetworkid(singleNicProfile.getNetworkId()); + nicResponse.setNetworkName(ApiDBUtils.findNetworkById(singleNicProfile.getNetworkId()).getName() ); if (acct.getType() == Account.ACCOUNT_TYPE_ADMIN) { if (singleNicProfile.getBroadCastUri() != null) { nicResponse.setBroadcastUri(singleNicProfile.getBroadCastUri().toString()); diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js index 04b83398ec4..e6bcbf7dbdd 100644 --- a/ui/scripts/instances.js +++ b/ui/scripts/instances.js @@ -1179,9 +1179,11 @@ nics: { title: 'label.nics', multiple: true, + cache:false, fields: [ { name: { label: 'label.name', header: true }, + networkname: {label: 'Network Name' }, ipaddress: { label: 'label.ip.address' }, type: { label: 'label.type' }, gateway: { label: 'label.gateway' }, @@ -1195,17 +1197,32 @@ } ], dataProvider: function(args) { - args.response.success({data: $.map(args.context.instances[0].nic, function(nic, index) { - var name = 'NIC ' + (index + 1); + + $.ajax({ + url:createURL("listVirtualMachines&details=nics&id=" + args.context.instances[0].id), + dataType: "json", + async:true, + success:function(json) { + + args.response.success({ + data: $.map(args.context.instances[0].nic, function(nic, index) { + var name = 'NIC ' + (index + 1); + var networkname = json.listvirtualmachinesresponse.virtualmachine[0].nic[index].networkname; + if (nic.isdefault) { + name += ' (' + _l('label.default') + ')'; + } + return $.extend(nic, { + name: name, + networkname: networkname + }); + }) + }); - if (nic.isdefault) { - name += ' (' + _l('label.default') + ')'; - } - return $.extend(nic, { - name: name + } }); - })}); + } + }, /**