Commit 6da20c5e authored by Spiros Koulouzis's avatar Spiros Koulouzis

delete all provisioned topologies

parent dc281aeb
...@@ -71,7 +71,7 @@ public class DRIPCaller implements AutoCloseable { ...@@ -71,7 +71,7 @@ public class DRIPCaller implements AutoCloseable {
// args.put("x-message-ttl", 60000); // args.put("x-message-ttl", 60000);
// replyQueueName = channel.queueDeclare("myqueue", false, false, false, args).getQueue(); // replyQueueName = channel.queueDeclare("myqueue", false, false, false, args).getQueue();
replyQueueName = channel.queueDeclare().getQueue(); replyQueueName = channel.queueDeclare().getQueue();
} }
} }
...@@ -110,11 +110,19 @@ public class DRIPCaller implements AutoCloseable { ...@@ -110,11 +110,19 @@ public class DRIPCaller implements AutoCloseable {
String jsonInString = mapper.writeValueAsString(r); String jsonInString = mapper.writeValueAsString(r);
int timeOut = 25;
if (getRequestQeueName().equals("planner")) {
timeOut = 5;
}
if (getRequestQeueName().equals("provisioner")) {
timeOut = 10;
}
//Build a correlation ID to distinguish responds //Build a correlation ID to distinguish responds
final String corrId = UUID.randomUUID().toString(); final String corrId = UUID.randomUUID().toString();
AMQP.BasicProperties props = new AMQP.BasicProperties.Builder() AMQP.BasicProperties props = new AMQP.BasicProperties.Builder()
.correlationId(corrId) .correlationId(corrId)
.expiration("10000") .expiration(String.valueOf(timeOut*60000))
.replyTo(getReplyQueueName()) .replyTo(getReplyQueueName())
.build(); .build();
Logger.getLogger(DRIPCaller.class.getName()).log(Level.INFO, "Sending: {0} to queue: {1}", new Object[]{jsonInString, getRequestQeueName()}); Logger.getLogger(DRIPCaller.class.getName()).log(Level.INFO, "Sending: {0} to queue: {1}", new Object[]{jsonInString, getRequestQeueName()});
...@@ -132,14 +140,7 @@ public class DRIPCaller implements AutoCloseable { ...@@ -132,14 +140,7 @@ public class DRIPCaller implements AutoCloseable {
} }
}); });
// String resp = response.take(); // String resp = response.take();
int timeOut = 25;
if (getRequestQeueName().equals("planner")) {
timeOut = 5;
}
if (getRequestQeueName().equals("provisioner")) {
timeOut = 10;
}
String resp = response.poll(timeOut, TimeUnit.MINUTES); String resp = response.poll(timeOut, TimeUnit.MINUTES);
Logger.getLogger(DRIPCaller.class.getName()).log(Level.INFO, "Got: {0}", resp); Logger.getLogger(DRIPCaller.class.getName()).log(Level.INFO, "Got: {0}", resp);
if (resp == null) { if (resp == null) {
......
...@@ -162,14 +162,21 @@ public class DRIPService { ...@@ -162,14 +162,21 @@ public class DRIPService {
public String delete(String id, List<String> nodeNames) throws NotFoundException, IOException, JsonProcessingException, ApiException, TypeExeption, TimeoutException, InterruptedException { public String delete(String id, List<String> nodeNames) throws NotFoundException, IOException, JsonProcessingException, ApiException, TypeExeption, TimeoutException, InterruptedException {
ToscaTemplate toscaTemplate = initExecution(id); ToscaTemplate toscaTemplate = initExecution(id);
boolean nothingToDelete = true;
//If no nodes are specified delete all the infrastructure //If no nodes are specified delete all the infrastructure
if (nodeNames == null || nodeNames.isEmpty()) { if (nodeNames == null || nodeNames.isEmpty()) {
List<NodeTemplateMap> vmTopologies = helper.getVMTopologyTemplates(); List<NodeTemplateMap> vmTopologies = helper.getVMTopologyTemplates();
if (vmTopologies != null) { if (vmTopologies != null) {
for (NodeTemplateMap vmTopology : vmTopologies) { for (NodeTemplateMap vmTopology : vmTopologies) {
toscaTemplate = setDesieredSate(toscaTemplate, vmTopology, NODE_STATES.DELETED); NODE_STATES currentState = helper.getNodeCurrentState(vmTopology);
if (currentState != null && currentState != NODE_STATES.DELETED) {
nothingToDelete = false;
toscaTemplate = setDesieredSate(toscaTemplate, vmTopology, NODE_STATES.DELETED);
}
}
if (!nothingToDelete) {
return execute(toscaTemplate, provisionerQueueName);
} }
return execute(toscaTemplate, provisionerQueueName);
} }
return id; return id;
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment