CS-15044:API changes and UI changes to provide option to view the name of the guestnetwork a virtual machine belongs

This commit is contained in:
Pranav Saxena 2012-07-31 02:57:46 +05:30
parent 9ec89b9240
commit 36fc2bd9b5
3 changed files with 30 additions and 10 deletions

View File

@ -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;
}

View File

@ -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());

View File

@ -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
});
})
});
}
});
})});
}
}
},
/**