aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils/src/main/java
diff options
context:
space:
mode:
authorSmokowski, Steven <steve.smokowski@att.com>2019-06-18 17:46:20 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-06-18 17:46:25 -0400
commit6e770a765b4f313a8d2499d0d3c3f56ff316cc2f (patch)
tree941db07407cc8631d1fe5145a1be3e3a30bd174e /adapters/mso-adapter-utils/src/main/java
parent7c69f07593a8c7474bd7a69a65979dc0635f1526 (diff)
Use Regex to find the name on failure scenario
Use Regex to find the keypair name on failure scenario Change-Id: Ibf2167283d90407def7750fab4538f5443e57092 Issue-ID: SO-2037 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'adapters/mso-adapter-utils/src/main/java')
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java21
1 files changed, 9 insertions, 12 deletions
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 7174bc0e31..28d4f3f9b4 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
@@ -31,8 +31,8 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import java.util.stream.Collectors;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.adapters.vdu.CloudInfo;
import org.onap.so.adapters.vdu.PluginAction;
@@ -79,7 +79,6 @@ import com.woorea.openstack.base.client.OpenStackResponseException;
import com.woorea.openstack.heat.Heat;
import com.woorea.openstack.heat.model.CreateStackParam;
import com.woorea.openstack.heat.model.Events;
-import com.woorea.openstack.heat.model.Resource;
import com.woorea.openstack.heat.model.Resources;
import com.woorea.openstack.heat.model.Stack;
import com.woorea.openstack.heat.model.Stack.Output;
@@ -405,17 +404,15 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
protected Stack handleKeyPairConflict(String cloudSiteId, String tenantId, CreateStackParam stackCreate,
int timeoutMinutes, boolean backout, Stack stack) throws MsoException {
logger.info("Keypair conflict found on stack, attempting to clean up");
-
- Resources resources = queryStackResources(cloudSiteId, tenantId, stackCreate.getStackName(), 2);
- List<Resource> keyPairs = resources.getList().stream()
- .filter(p -> "OS::Nova::KeyPair".equalsIgnoreCase(p.getType())).collect(Collectors.toList());
- keyPairs.stream().forEach(keyPair -> {
- try {
- novaClient.deleteKeyPair(cloudSiteId, tenantId, keyPair.getLogicalResourceId());
- } catch (MsoCloudSiteNotFound | NovaClientException e) {
- logger.warn("Could not delete keypair", e);
+ try {
+ Matcher m = Pattern.compile("'([^']+?)'").matcher(stack.getStackStatusReason());
+ if (m.find()) {
+ novaClient.deleteKeyPair(cloudSiteId, tenantId, m.group(1));
}
- });
+ } catch (NovaClientException e) {
+ logger.warn("Could not delete keypair", e);
+ }
+
handleUnknownCreateStackFailure(stack, timeoutMinutes, cloudSiteId, tenantId);
Stack newStack = createStack(stackCreate, cloudSiteId, tenantId);
newStack.setStackName(stackCreate.getStackName());