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 {
// args.put("x-message-ttl", 60000);
// replyQueueName = channel.queueDeclare("myqueue", false, false, false, args).getQueue();
replyQueueName = channel.queueDeclare().getQueue();
}
}
......@@ -110,11 +110,19 @@ public class DRIPCaller implements AutoCloseable {
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
final String corrId = UUID.randomUUID().toString();
AMQP.BasicProperties props = new AMQP.BasicProperties.Builder()
.correlationId(corrId)
.expiration("10000")
.expiration(String.valueOf(timeOut*60000))
.replyTo(getReplyQueueName())
.build();
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 {
}
});
// 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);
Logger.getLogger(DRIPCaller.class.getName()).log(Level.INFO, "Got: {0}", resp);
if (resp == null) {
......
......@@ -162,14 +162,21 @@ public class DRIPService {
public String delete(String id, List<String> nodeNames) throws NotFoundException, IOException, JsonProcessingException, ApiException, TypeExeption, TimeoutException, InterruptedException {
ToscaTemplate toscaTemplate = initExecution(id);
boolean nothingToDelete = true;
//If no nodes are specified delete all the infrastructure
if (nodeNames == null || nodeNames.isEmpty()) {
List<NodeTemplateMap> vmTopologies = helper.getVMTopologyTemplates();
if (vmTopologies != null) {
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;
} 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