Updated Branches: refs/heads/master 9ec89b924 -> 36fc2bd9b
CS-15044:API changes and UI changes to provide option to view the name of the guestnetwork a virtual machine belongs Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/36fc2bd9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/36fc2bd9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/36fc2bd9 Branch: refs/heads/master Commit: 36fc2bd9b5e2768a27287deaee381c0afc6734a0 Parents: 9ec89b9 Author: Pranav Saxena <[email protected]> Authored: Tue Jul 31 02:57:46 2012 +0530 Committer: Pranav Saxena <[email protected]> Committed: Tue Jul 31 02:57:46 2012 +0530 ---------------------------------------------------------------------- api/src/com/cloud/api/response/NicResponse.java | 7 ++++ server/src/com/cloud/api/ApiResponseHelper.java | 1 + ui/scripts/instances.js | 32 ++++++++++++----- 3 files changed, 30 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/36fc2bd9/api/src/com/cloud/api/response/NicResponse.java ---------------------------------------------------------------------- diff --git a/api/src/com/cloud/api/response/NicResponse.java b/api/src/com/cloud/api/response/NicResponse.java index 010cf49..69d5c31 100755 --- a/api/src/com/cloud/api/response/NicResponse.java +++ b/api/src/com/cloud/api/response/NicResponse.java @@ -29,6 +29,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; @@ -69,6 +72,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; } http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/36fc2bd9/server/src/com/cloud/api/ApiResponseHelper.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index 433d263..399a816 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -1566,6 +1566,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()); http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/36fc2bd9/ui/scripts/instances.js ---------------------------------------------------------------------- diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js index bca405b..ede22e1 100644 --- a/ui/scripts/instances.js +++ b/ui/scripts/instances.js @@ -1185,6 +1185,7 @@ fields: [ { name: { label: 'label.name', header: true }, + networkname: {label: 'Network Name' }, ipaddress: { label: 'label.ip.address' }, type: { label: 'label.type' }, gateway: { label: 'label.gateway' }, @@ -1198,17 +1199,28 @@ } ], dataProvider: function(args) { - args.response.success({data: $.map(args.context.instances[0].nic, function(nic, index) { - var name = 'NIC ' + (index + 1); - - if (nic.isdefault) { - name += ' (' + _l('label.default') + ')'; - } - return $.extend(nic, { - name: name + $.ajax({ + url:createURL("listVirtualMachines&details=nics&id=" + args.context.instances[0].id), + dataType: "json", + async:true, + success:function(json) { + // Handling the display of network name for a VM under the NICS tabs + 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 + }); + }) + }); + } }); - })}); - } + } }, /**
