summaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils
diff options
context:
space:
mode:
authorSangalang, Felix <felix.sangalang@att.com>2019-06-14 09:40:04 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-06-14 09:40:10 -0400
commit89cedfabe33390fd4e31bdb918fb2dc98f160b3f (patch)
treed1d9082c9b7ea0ab12f8024eaacd904c671691b7 /adapters/mso-adapter-utils
parent1f8aa8ef6deade96a53fa57c28d1aacab6cf7e5e (diff)
adapter client will not retry on openstack failure
Utilized the original util method with boolean argument. inventory audit: adapter client should not retry on openstack failures. Change-Id: Ibdcec58c662f54ccef887e74f17634baa9df2457 Issue-ID: SO-2016 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'adapters/mso-adapter-utils')
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/CinderClientImpl.java4
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/GlanceClientImpl.java2
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java20
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java8
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java4
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NeutronClientImpl.java4
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java12
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoCommonUtilsTest.java4
8 files changed, 32 insertions, 26 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/CinderClientImpl.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/CinderClientImpl.java
index 567f849b36..b0c2d9430a 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/CinderClientImpl.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/CinderClientImpl.java
@@ -76,7 +76,7 @@ public class CinderClientImpl extends MsoCommonUtils {
// list is set to false, otherwise an invalid URL is appended
OpenStackRequest<Volumes> request =
cinderClient.volumes().list(false).queryParam("limit", limit).queryParam("marker", marker);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
} catch (MsoException e) {
logger.error("Error building Cinder Client", e);
throw new CinderClientException("Error building Cinder Client", e);
@@ -90,7 +90,7 @@ public class CinderClientImpl extends MsoCommonUtils {
Cinder cinderClient = getCinderClient(cloudSiteId, tenantId);
// list is set to false, otherwise an invalid URL is appended
OpenStackRequest<Volume> request = cinderClient.volumes().show(volumeId);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
} catch (MsoException e) {
logger.error("Error building Cinder Client", e);
throw new CinderClientException("Error building Cinder Client", e);
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/GlanceClientImpl.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/GlanceClientImpl.java
index 57faaac717..698b605be3 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/GlanceClientImpl.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/GlanceClientImpl.java
@@ -74,7 +74,7 @@ public class GlanceClientImpl extends MsoCommonUtils {
// list is set to false, otherwise an invalid URL is appended
OpenStackRequest<Images> request = glanceClient.images().list(false).queryParam("visibility", visibility)
.queryParam("limit", limit).queryParam("marker", marker).queryParam("name", name);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
} catch (MsoException e) {
logger.error("Error building Glance Client", e);
throw new GlanceClientException("Error building Glance Client", e);
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java
index 4ea205a8e1..576784ae3e 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java
@@ -98,19 +98,23 @@ public class MsoCommonUtils {
*/
protected <T> T executeAndRecordOpenstackRequest(OpenStackRequest<T> request) {
+ return executeAndRecordOpenstackRequest(request, true);
+ }
- String requestType;
- if (request.getClass().getEnclosingClass() != null) {
- requestType =
- request.getClass().getEnclosingClass().getSimpleName() + "." + request.getClass().getSimpleName();
- } else {
- requestType = request.getClass().getSimpleName();
- }
+ /*
+ * Method to execute an Openstack command and track its execution time. For the metrics log, a category of
+ * "Openstack" is used along with a sub-category that identifies the specific call (using the real
+ * openstack-java-sdk classname of the OpenStackRequest<T> parameter). boolean isNoRetry - true if No retry; and
+ * false if Retry.
+ */
+ protected <T> T executeAndRecordOpenstackRequest(OpenStackRequest<T> request, boolean shouldRetry) {
int retryDelay = poConfig.getRetryDelay();
int retryCount = poConfig.getRetryCount();
String retryCodes = poConfig.getRetryCodes();
-
+ if (!shouldRetry) {
+ retryCodes = null;
+ }
// Run the actual command. All exceptions will be propagated
while (true) {
try {
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
index c323bb699d..711fae94ae 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
@@ -1239,7 +1239,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
Heat heatClient = getHeatClient(cloudSiteId, tenantId);
OpenStackRequest<Resources> request =
heatClient.getResources().listResources(stackName).queryParam("nested_depth", nestedDepth);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
}
public Events queryStackEvents(String cloudSiteId, String tenantId, String stackName, String stackId,
@@ -1247,7 +1247,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
Heat heatClient = getHeatClient(cloudSiteId, tenantId);
OpenStackRequest<Events> request =
heatClient.getEvents().listEvents(stackName, stackId).queryParam("nested_depth", nestedDepth);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
}
public Stacks queryStacks(String cloudSiteId, String tenantId, int limit, String marker)
@@ -1261,14 +1261,14 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
}
OpenStackRequest<Stacks> request =
heatClient.getStacks().list().queryParam("limit", limit).queryParam("marker", marker);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
}
public <R> R executeHeatClientRequest(String url, String cloudSiteId, String tenantId, Class<R> returnType)
throws MsoException {
Heat heatClient = getHeatClient(cloudSiteId, tenantId);
OpenStackRequest<R> request = heatClient.get(url, returnType);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
}
protected void sleep(long time) {
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java
index 6f08afc55f..069c6c7c5b 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java
@@ -382,7 +382,7 @@ public class MsoNeutronUtils extends MsoCommonUtils {
Authentication credentials = authenticationMethodFactory.getAuthenticationFor(cloudIdentity);
OpenStackRequest<Access> request =
keystoneTenantClient.tokens().authenticate(credentials).withTenantId(tenantId);
- access = executeAndRecordOpenstackRequest(request);
+ access = executeAndRecordOpenstackRequest(request, true);
try {
@@ -499,7 +499,7 @@ public class MsoNeutronUtils extends MsoCommonUtils {
try {
OpenStackRequest<Port> request = neutronClient.ports().show(neutronPortId);
- Port port = executeAndRecordOpenstackRequest(request);
+ Port port = executeAndRecordOpenstackRequest(request, false);
return port;
} catch (OpenStackResponseException e) {
if (e.getStatus() == 404) {
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NeutronClientImpl.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NeutronClientImpl.java
index 93745de54a..938a888bbd 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NeutronClientImpl.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NeutronClientImpl.java
@@ -75,7 +75,7 @@ public class NeutronClientImpl extends MsoCommonUtils {
Quantum neutronClient = getNeutronClient(cloudSiteId, tenantId);
OpenStackRequest<Networks> request = neutronClient.networks().list().queryParam("id", id)
.queryParam("limit", limit).queryParam("marker", marker).queryParam("name", name);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
} catch (MsoException e) {
logger.error("Error building Neutron Client", e);
throw new NeutronClientException("Error building Neutron Client", e);
@@ -103,7 +103,7 @@ public class NeutronClientImpl extends MsoCommonUtils {
Quantum neutronClient = getNeutronClient(cloudSiteId, tenantId);
OpenStackRequest<Subnets> request = neutronClient.subnets().list().queryParam("id", id)
.queryParam("limit", limit).queryParam("marker", marker).queryParam("name", name);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
} catch (MsoException e) {
logger.error("Error building Neutron Client", e);
throw new NeutronClientException("Error building Neutron Client", e);
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java
index 6cd79de476..99e8b589b1 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java
@@ -78,7 +78,7 @@ public class NovaClientImpl extends MsoCommonUtils {
Nova novaClient = getNovaClient(cloudSiteId, tenantId);
OpenStackRequest<Flavors> request =
novaClient.flavors().list(false).queryParam("limit", limit).queryParam("marker", marker);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
} catch (MsoException e) {
logger.error("Error building Nova Client", e);
throw new NovaClientException("Error building Nova Client", e);
@@ -103,7 +103,7 @@ public class NovaClientImpl extends MsoCommonUtils {
Nova novaClient = getNovaClient(cloudSiteId, tenantId);
novaClient = getNovaClient(cloudSiteId, tenantId);
OpenStackRequest<Flavor> request = novaClient.flavors().show(id);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
} catch (MsoException e) {
logger.error("Error building Nova Client", e);
throw new NovaClientException("Error building Nova Client", e);
@@ -128,7 +128,7 @@ public class NovaClientImpl extends MsoCommonUtils {
Nova novaClient = getNovaClient(cloudSiteId, tenantId);
OpenStackRequest<HostAggregates> request =
novaClient.aggregates().list().queryParam("limit", limit).queryParam("marker", marker);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
} catch (MsoException e) {
logger.error("Error building Nova Client", e);
throw new NovaClientException("Error building Nova Client", e);
@@ -152,7 +152,7 @@ public class NovaClientImpl extends MsoCommonUtils {
try {
Nova novaClient = getNovaClient(cloudSiteId, tenantId);
OpenStackRequest<HostAggregate> request = novaClient.aggregates().showAggregate(id);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
} catch (MsoException e) {
logger.error("Error building Nova Client", e);
throw new NovaClientException("Error building Nova Client", e);
@@ -176,7 +176,7 @@ public class NovaClientImpl extends MsoCommonUtils {
try {
Nova novaClient = getNovaClient(cloudSiteId, tenantId);
OpenStackRequest<QuotaSet> request = novaClient.quotaSets().showQuota(tenantId);
- return executeAndRecordOpenstackRequest(request);
+ return executeAndRecordOpenstackRequest(request, false);
} catch (MsoException e) {
logger.error("Error building Nova Client", e);
throw new NovaClientException("Error building Nova Client", e);
@@ -198,7 +198,7 @@ public class NovaClientImpl extends MsoCommonUtils {
try {
Nova novaClient = getNovaClient(cloudSiteId, tenantId);
OpenStackRequest<Void> request = novaClient.keyPairs().delete(keyPairName);
- executeAndRecordOpenstackRequest(request);
+ executeAndRecordOpenstackRequest(request, false);
} catch (MsoException e) {
logger.error("Error building Nova Client", e);
throw new NovaClientException("Error building Nova Client", e);
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoCommonUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoCommonUtilsTest.java
index 5cf7c86522..622ad4f94f 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoCommonUtilsTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoCommonUtilsTest.java
@@ -69,6 +69,7 @@ public class MsoCommonUtilsTest extends BaseTest {
Mockito.when(openstackRequest.path()).thenReturn("/test");
// TODO:Must try a real connection
assertNull(commonUtils.executeAndRecordOpenstackRequest(openstackRequest));
+ assertNull(commonUtils.executeAndRecordOpenstackRequest(openstackRequest, true));
}
@Test
@@ -78,6 +79,7 @@ public class MsoCommonUtilsTest extends BaseTest {
doThrow(OpenStackResponseException.class).when(openstackRequest).execute();
commonUtils.executeAndRecordOpenstackRequest(openstackRequest);
+ commonUtils.executeAndRecordOpenstackRequest(openstackRequest, true);
}
@Test
@@ -86,7 +88,7 @@ public class MsoCommonUtilsTest extends BaseTest {
doThrow(OpenStackConnectException.class).when(openstackRequest).execute();
- commonUtils.executeAndRecordOpenstackRequest(openstackRequest);
+ commonUtils.executeAndRecordOpenstackRequest(openstackRequest, true);
}
@Test