From 143b8110640a1760f6265a012fabee40d3a890b9 Mon Sep 17 00:00:00 2001 From: Remi Bergsma Date: Fri, 6 Apr 2018 10:48:08 +0200 Subject: [PATCH 1/2] Add extra responses to prevent looking up names --- .../api/src/main/java/com/cloud/api/ApiConstants.java | 1 + .../java/com/cloud/api/response/IPAddressResponse.java | 8 ++++++++ .../main/java/com/cloud/api/response/NetworkResponse.java | 8 ++++++++ .../src/main/java/com/cloud/api/ApiResponseHelper.java | 3 +++ 4 files changed, 20 insertions(+) diff --git a/cosmic-core/api/src/main/java/com/cloud/api/ApiConstants.java b/cosmic-core/api/src/main/java/com/cloud/api/ApiConstants.java index 00bb6daf26..292ec00a54 100644 --- a/cosmic-core/api/src/main/java/com/cloud/api/ApiConstants.java +++ b/cosmic-core/api/src/main/java/com/cloud/api/ApiConstants.java @@ -534,6 +534,7 @@ public class ApiConstants { public static final String AFFINITY_GROUP_NAME = "affinitygroupname"; public static final String DEPLOYMENT_PLANNER = "deploymentplanner"; public static final String ACL_ID = "aclid"; + public static final String ACL_NAME = "aclname"; public static final String NUMBER = "number"; public static final String IS_DYNAMICALLY_SCALABLE = "isdynamicallyscalable"; public static final String ROUTING = "isrouting"; diff --git a/cosmic-core/api/src/main/java/com/cloud/api/response/IPAddressResponse.java b/cosmic-core/api/src/main/java/com/cloud/api/response/IPAddressResponse.java index cb551c2614..5af182889b 100644 --- a/cosmic-core/api/src/main/java/com/cloud/api/response/IPAddressResponse.java +++ b/cosmic-core/api/src/main/java/com/cloud/api/response/IPAddressResponse.java @@ -110,6 +110,10 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR @Param(description = "the ID of the ACL applied to this IP") private String aclId; + @SerializedName(ApiConstants.ACL_NAME) + @Param(description = "the name of the ACL applied to this IP") + private String aclName; + @SerializedName(ApiConstants.STATE) @Param(description = "State of the ip address. Can be: Allocatin, Allocated and Releasing") private String state; @@ -272,4 +276,8 @@ public void setAssociatedNetworkName(final String associatedNetworkName) { public void setForDisplay(final Boolean forDisplay) { this.forDisplay = forDisplay; } + + public void setAclName(final String aclName) { + this.aclName = aclName; + } } diff --git a/cosmic-core/api/src/main/java/com/cloud/api/response/NetworkResponse.java b/cosmic-core/api/src/main/java/com/cloud/api/response/NetworkResponse.java index af63824a65..b853f14ef6 100644 --- a/cosmic-core/api/src/main/java/com/cloud/api/response/NetworkResponse.java +++ b/cosmic-core/api/src/main/java/com/cloud/api/response/NetworkResponse.java @@ -208,6 +208,10 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes @Param(description = "ACL Id associated with the VPC network") private String aclId; + @SerializedName(ApiConstants.ACL_NAME) + @Param(description = "the name of the ACL applied to this IP") + private String aclName; + @SerializedName(ApiConstants.STRECHED_L2_SUBNET) @Param(description = "true if network can span multiple zones", since = "4.4") private Boolean strechedL2Subnet; @@ -428,4 +432,8 @@ public void setStrechedL2Subnet(final Boolean strechedL2Subnet) { public void setNetworkSpannedZones(final Set networkSpannedZones) { this.networkSpannedZones = networkSpannedZones; } + + public void setAclName(final String aclName) { + this.aclName = aclName; + } } diff --git a/cosmic-core/server/src/main/java/com/cloud/api/ApiResponseHelper.java b/cosmic-core/server/src/main/java/com/cloud/api/ApiResponseHelper.java index 4cb2e1082b..6dca0151c8 100644 --- a/cosmic-core/server/src/main/java/com/cloud/api/ApiResponseHelper.java +++ b/cosmic-core/server/src/main/java/com/cloud/api/ApiResponseHelper.java @@ -783,6 +783,7 @@ public IPAddressResponse createIPAddressResponse(final ResponseView view, final final NetworkVO nw = ApiDBUtils.findNetworkById(networkId); if (nw != null) { ipResponse.setNetworkId(nw.getUuid()); + ipResponse.setAssociatedNetworkName(nw.getName()); } } ipResponse.setState(ipAddr.getState().toString()); @@ -790,6 +791,7 @@ public IPAddressResponse createIPAddressResponse(final ResponseView view, final final NetworkACL acl = ApiDBUtils.findByNetworkACLId(ipAddr.getIpACLId()); if (acl != null) { ipResponse.setAclId(acl.getUuid()); + ipResponse.setAclName(acl.getName()); } if (ipAddr.getPhysicalNetworkId() != null) { @@ -1910,6 +1912,7 @@ public NetworkResponse createNetworkResponse(final ResponseView view, final Netw final NetworkACL acl = ApiDBUtils.findByNetworkACLId(network.getNetworkACLId()); if (acl != null) { response.setAclId(acl.getUuid()); + response.setAclName(acl.getName()); } } From a650e065c1ca9248b9c94841417d765b0e84122d Mon Sep 17 00:00:00 2001 From: Alexander Verhaar Date: Fri, 6 Apr 2018 13:30:20 +0200 Subject: [PATCH 2/2] Removed extra API call and added missing fields --- .../src/main/webapp/scripts/network.js | 37 ++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/cosmic-client/src/main/webapp/scripts/network.js b/cosmic-client/src/main/webapp/scripts/network.js index c2748f60c8..71a3db62a3 100755 --- a/cosmic-client/src/main/webapp/scripts/network.js +++ b/cosmic-client/src/main/webapp/scripts/network.js @@ -3668,20 +3668,15 @@ title: 'label.details', preFilter: function (args) { var hiddenFields = []; - var zoneObj; - $.ajax({ - url: createURL("listZones&id=" + args.context.ipAddresses[0].zoneid), - dataType: "json", - async: false, - success: function (json) { - zoneObj = json.listzonesresponse.zone[0]; - } - }); - if (zoneObj.networktype == "Advanced") { - hiddenFields.push("issystem"); - hiddenFields.push("purpose"); + if (typeof args.context.ipAddresses[0].vmipaddress == "undefined") { + hiddenFields.push("vmipaddress"); + } + if (typeof args.context.ipAddresses[0].virtualmachinedisplayname == "undefined") { + hiddenFields.push("virtualmachinedisplayname"); + } + if (typeof args.context.ipAddresses[0].associatednetworkid == "undefined") { + hiddenFields.push("associatednetworkid") } - if (!isAdmin()) { hiddenFields.push("vlanname"); } @@ -3707,6 +3702,9 @@ aclid: { label: 'label.acl.id' }, + aclname: { + label: 'label.acl.name' + }, networkid: { label: 'label.network.id' }, @@ -3721,13 +3719,6 @@ vmipaddress: { label: 'label.vm.ip' }, - issystem: { - label: 'label.is.system', - converter: cloudStack.converters.toBooleanText - }, //(basic zone only) - purpose: { - label: 'label.purpose' - }, //(basic zone only) When an IP is system-generated, the purpose it serves can be Lb or static nat. virtualmachinedisplayname: { label: 'label.vm.name' }, @@ -6326,7 +6317,11 @@ var data = []; $(algorithms).each(function () { - data.push({id: this.valueOf(), name: this.valueOf(), description: _l('label.lb.algorithm.' + this.valueOf())}); + data.push({ + id: this.valueOf(), + name: this.valueOf(), + description: _l('label.lb.algorithm.' + this.valueOf()) + }); }); return data;