Skip to content

Commit

Permalink
AV-186753: Added pagination support in vRO plugin. (#194)
Browse files Browse the repository at this point in the history
* AV-186753: Added pagination support in the plugin.

* Updated fetchObjectLists action version.
  • Loading branch information
mkhachane authored Sep 25, 2023
1 parent c336f3f commit 505a8d1
Show file tree
Hide file tree
Showing 15 changed files with 65 additions and 31 deletions.
6 changes: 3 additions & 3 deletions o11nplugin-vro-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>vro</artifactId>
<groupId>com.vmware.avi</groupId>
<version>22.1.4.RELEASE</version>
<version>22.1.4.1</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand All @@ -23,7 +23,7 @@
<dependency>
<groupId>com.vmware.avi.sdk</groupId>
<artifactId>avisdk</artifactId>
<version>22.1.4.RELEASE</version>
<version>22.1.4..1</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -189,4 +189,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -718,13 +718,47 @@ private void clearQueue() {
* @throws Exception
*/
@VsoMethod
public JSONArray get(String objectType, Map<String, String> params, String tenant) throws Exception {
public JSONObject get(String objectType, Map<String, String> params, String tenant) throws Exception {
AviApi session = getSession();
if ((null != objectType) && (!objectType.isEmpty())) {
HashMap<String, String> userHeader = this.getTenantHeader(tenant);
JSONObject data = session.get(objectType, params, userHeader);
logger.info("Existing data of " + objectType + " : " + data);
return (JSONArray) data.get("results");
return data;
} else {
logger.debug("ObjectType is empty");
throw new AviApiException("Please provide objectType");
}
}

/***
* Method for getting object data.
*
* @param objectType is the type of object.
* @param params is a map containing the key and values.
* @param tenant name of the Tenant
* @return the JSONArray of the response.
* @throws Exception
*/
@VsoMethod
public JSONArray getAllData(String objectType, Map<String, String> params, String tenant) throws Exception {
AviApi session = getSession();
if ((null != objectType) && (!objectType.isEmpty())) {
HashMap<String, String> userHeader = this.getTenantHeader(tenant);
JSONObject data = session.get(objectType, params, userHeader);
logger.info("Existing data of " + objectType + " : " + data);
JSONArray results = new JSONArray();
JSONArray response = (JSONArray) data.get("results");
for (int i = 0; i < response.length(); i++) {
results.put(response.getJSONObject(i));
}
if (data.has("next")) {
String pageNo = data.getString("next").split("=")[1];
Map<String, String> pageParams = new HashMap<>();
pageParams.put("page", pageNo);
results.putAll(this.getAllData(objectType, pageParams, tenant));
}
return results;
} else {
logger.debug("ObjectType is empty");
throw new AviApiException("Please provide objectType");
Expand Down Expand Up @@ -844,7 +878,7 @@ public AviRestResource getObjectByName(String objectType, String objectName) thr
@VsoMethod
public List<AviRestResource> getObject(String objectType, Map<String, String> params, String tenant)
throws Exception {
JSONArray array = this.get(objectType, params, tenant);
JSONArray array = this.getAllData(objectType, params, tenant);
List<AviRestResource> objectList = new ArrayList<AviRestResource>();
// ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(Include.NON_NULL);
Expand Down
2 changes: 1 addition & 1 deletion o11nplugin-vro-package/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>vro</artifactId>
<groupId>com.vmware.avi</groupId>
<version>22.1.4.RELEASE</version>
<version>22.1.4.1</version>
</parent>

<properties>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<dunes-script-module name="CreateSegmentPool"
result-type="string" api-version="6.0.0"
id="7ff776e4-4dac-4f62-94fc-a06edfe48b0b" version="0.0.1"
id="7ff776e4-4dac-4f62-94fc-a06edfe48b0b" version="0.0.2"
allowed-operations="vfe">
<description><![CDATA[This Action can ben used to create Network Segment Pools. This was designed for NSX-T Cloud Segments, but will work for any Cloud Segment.]]></description>
<param n="avivroClient" t="Avi:AviVroClient"><![CDATA[]]>
Expand All @@ -25,7 +25,7 @@ nsxtCloudURL = nsxtCloudURL.split('#')[0]
// Retrieve The Specified Segment
var tenant = avivroClient.cred.tenant
var network_seg = avivroClient.get("network", null, tenant)
var network_seg = avivroClient.getAllData("network", null, tenant)
// Parse the JSON Output
network_seg = JSON.parse(network_seg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function getUUIDOfObject(aviVroClientObj,objectType,name){
param.name=name;
var resultArray=aviVroClientObj.get(objectType,param);
resultArray=JSON.parse(resultArray);
var jsonObj=resultArray[0];
var jsonObj=resultArray.results[0];
var msg =objectType+" "+name+" Deleted successfully.";
msgArray.push(msg);
return jsonObj;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<dunes-script-module name="fetchNetworkSubnet" result-type="Array/Any" api-version="6.0.0" id="2824f3e4-44e3-457e-9382-34d3376a7b94" version="0.0.1" allowed-operations="vfe">
<dunes-script-module name="fetchNetworkSubnet" result-type="Array/Any" api-version="6.0.0" id="2824f3e4-44e3-457e-9382-34d3376a7b94" version="0.0.2" allowed-operations="vfe">
<param n="controller" t="string"><![CDATA[IP of the controller]]></param>
<param n="cloudName" t="string"><![CDATA[Add cloud name]]></param>
<param n="objectType" t="string"><![CDATA[Add object type]]></param>
Expand Down Expand Up @@ -82,7 +82,7 @@
}
function getObjectData(aviPlugin, objectType, params, tenantRef){
var result = aviPlugin.get(objectType, params, tenantRef);
var result = aviPlugin.getAllData(objectType, params, tenantRef);
var resultData = JSON.parse(result);
return resultData;
}]]></script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<dunes-script-module name="fetchObjectLists"
result-type="Any" api-version="6.0.0"
id="c8fdba15-adb3-4335-9a34-ec8e3825709c" version="0.0.6"
id="c8fdba15-adb3-4335-9a34-ec8e3825709c" version="0.0.7"
allowed-operations="vfe">
<param n="controller" t="string"><![CDATA[IP of the controller]]></param>
<param n="objectName" t="string"><![CDATA[Add object name]]></param>
Expand Down Expand Up @@ -35,7 +35,7 @@
}
var response = aviPlugin.get(objectType,params, clientTenant);
var objectData = JSON.parse(response);
var object =objectData[0];
var object = objectData.results[0];
if(object!=null){
if (field == "existingMembers"){
//var poolObject=objectData[0];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<dunes-script-module name="fetchObjectsNames"
result-type="Array/string" api-version="6.0.0"
id="aab1273f-20f0-4cef-ad2b-da6832d71030" version="1.0.1"
id="aab1273f-20f0-4cef-ad2b-da6832d71030" version="1.0.2"
allowed-operations="vfe">
<param n="controller" t="string"><![CDATA[IP of the controller]]></param>
<param n="objectType" t="string"><![CDATA[Add object type ]]></param>
Expand Down Expand Up @@ -32,7 +32,7 @@ try{
if (aviPlugin != null){
if(cloudName == "" || cloudName == null){
var objectList = new Array();
var response = aviPlugin.get(objectType,null, clientTenant);
var response = aviPlugin.getAllData(objectType,null, clientTenant);
var objectData = JSON.parse(response);
for each(index in objectData){
Expand All @@ -46,7 +46,7 @@ try{
cloudUuid = objectData.uuid;
cloudRef.cloud_uuid = cloudUuid;
var objectList = new Array();
var response = aviPlugin.get(objectType,cloudRef, clientTenant);
var response = aviPlugin.getAllData(objectType,cloudRef, clientTenant);
var objectData = JSON.parse(response);
for each(index in objectData){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<dunes-script-module name="getDNSProvider"
result-type="string" api-version="6.0.0"
id="0cfa03eb-cf20-45a3-800b-a6de844fff89" version="0.0.1"
id="0cfa03eb-cf20-45a3-800b-a6de844fff89" version="0.0.2"
allowed-operations="vfe">
<param n="controller" t="string"><![CDATA[Controller IP]]></param>
<param n="cloud" t="string"><![CDATA[Name of Cloud]]></param>
Expand All @@ -27,9 +27,9 @@
}
var param = new Object();
param.name=cloud;
var resultArray=aviVroClientObj.get("cloud",param, clientTenant);
resultArray=JSON.parse(resultArray);
var cloudObj=resultArray[0];
var resultObject=aviVroClientObj.get("cloud",param, clientTenant);
resultObject=JSON.parse(resultObject);
var cloudObj = resultObject.results[0];
var dnsProvider=cloudObj.dns_provider_ref;
var dnsProviderUUID = dnsProvider.substring(dnsProvider.indexOf("ipamdnsproviderprofile-"));
var dnsProviderObj=aviVroClientObj.getObjectDataByUUID("ipamdnsproviderprofile",dnsProviderUUID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<dunes-script-module
name="getExistingObjectsWithController" result-type="Array/string"
api-version="6.0.0" id="42556c6b-8b94-45fd-b1fd-feed30a097ca"
version="0.0.3" allowed-operations="vfe">
version="0.0.4" allowed-operations="vfe">
<param n="controller" t="string"><![CDATA[
]]></param>
<param n="objectType" t="string"><![CDATA[
Expand Down Expand Up @@ -30,7 +30,7 @@ try{
}
var objectList = new Array();
var response = aviVroClientObj.get(objectType, null, clientTenant);
var response = aviVroClientObj.getAllData(objectType, null, clientTenant);
var objectData = JSON.parse(response);
for each(index in objectData){
objectList.push(index.name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<dunes-script-module
name="remoteAuthenticationConfiguration" result-type="string"
api-version="6.0.0" id="66601741-2ca3-430c-a113-adab600fb325"
version="0.0.0" allowed-operations="vfe">
version="0.0.1" allowed-operations="vfe">
<description><![CDATA[This Action is used to configure the remote authentication of the Avi Cluster. It is able to configure SAML and LDAP authentication.]]></description>
<param n="aviVroClient" t="Avi:AviVroClient"><![CDATA[]]>
</param>
Expand Down Expand Up @@ -216,7 +216,7 @@ function tenanturl(str) {
//System.log("str "+str)
var tenantObject = aviVroClient.get("tenant")
var tenantObject = aviVroClient.getAllData("tenant")
tenantObject = JSON.parse(tenantObject)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<dunes-script-module name="updatePool"
result-type="void" api-version="6.0.0"
id="0164e6e8-7b7a-403f-8f8c-d9cdf8dbef9d" version="0.0.3"
id="0164e6e8-7b7a-403f-8f8c-d9cdf8dbef9d" version="0.0.4"
allowed-operations="vfe">
<param n="controller" t="string"><![CDATA[]]>
</param>
Expand Down Expand Up @@ -31,7 +31,7 @@
param.name=poolname;
var response = aviVroClientObj.get("pool",param, clientTenant);
response = JSON.parse(response);
var jsonData=response[0];
var jsonData = response.results[0];
jsonData.servers=[];
var updatedServers=[];
Expand Down
2 changes: 1 addition & 1 deletion o11nplugin-vro/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<artifactId>vro</artifactId>
<groupId>com.vmware.avi</groupId>
<version>22.1.4.RELEASE</version>
<version>22.1.4.1</version>
</parent>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.vmware.avi</groupId>
<artifactId>vro</artifactId>
<packaging>pom</packaging>
<version>22.1.4.RELEASE</version>
<version>22.1.4.1</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
4 changes: 2 additions & 2 deletions version.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
release_version=22.1.4
eng_version=30.1.2
release_version=22.1.4.1
eng_version=30.2.1

0 comments on commit 505a8d1

Please sign in to comment.