Commit ced0bfc0 authored by Spiros Koulouzis's avatar Spiros Koulouzis

implement caller for new provisioner

parent 201f5ade
...@@ -69,7 +69,7 @@ class</p> ...@@ -69,7 +69,7 @@ class</p>
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>Subtypes</dt> <dt>Subtypes</dt>
<dd><a href="json_DeployRequest.html">DeployRequest</a>, <a href="json_KeyPair.html">KeyPair</a>, <a href="json_ProvisionRequest.html">ProvisionRequest</a>, <a href="json_AnsibleOutput.html">AnsibleOutput</a>, <a href="json_PlanResponse.html">PlanResponse</a>, <a href="json_KeyValueHolder.html">KeyValueHolder</a>, <a href="json_SysbenchCPUBenchmark.html">SysbenchCPUBenchmark</a>, <a href="json_PlaybookRepresentation.html">PlaybookRepresentation</a>, <a href="json_ProvisionResponse.html">ProvisionResponse</a>, <a href="json_Script.html">Script</a>, <a href="json_DeployResponse.html">DeployResponse</a>, <a href="json_BenchmarkResult.html">BenchmarkResult</a>, <a href="json_ToscaRepresentation.html">ToscaRepresentation</a>, <a href="json_CloudCredentials.html">CloudCredentials</a></dd> <dd><a href="json_DeployRequest.html">DeployRequest</a>, <a href="json_ProvisionRequest.html">ProvisionRequest</a>, <a href="json_KeyPair.html">KeyPair</a>, <a href="json_AnsibleOutput.html">AnsibleOutput</a>, <a href="json_PlanResponse.html">PlanResponse</a>, <a href="json_KeyValueHolder.html">KeyValueHolder</a>, <a href="json_SysbenchCPUBenchmark.html">SysbenchCPUBenchmark</a>, <a href="json_PlaybookRepresentation.html">PlaybookRepresentation</a>, <a href="json_ProvisionResponse.html">ProvisionResponse</a>, <a href="json_Script.html">Script</a>, <a href="json_DeployResponse.html">DeployResponse</a>, <a href="json_BenchmarkResult.html">BenchmarkResult</a>, <a href="json_ToscaRepresentation.html">ToscaRepresentation</a>, <a href="json_CloudCredentials.html">CloudCredentials</a></dd>
</dl> </dl>
<table class="table datatype-properties"> <table class="table datatype-properties">
......
...@@ -22,11 +22,11 @@ import java.util.concurrent.TimeoutException; ...@@ -22,11 +22,11 @@ import java.util.concurrent.TimeoutException;
* *
* @author S. Koulouzis * @author S. Koulouzis
*/ */
public class ProvisionerCaller extends DRIPCaller { public class ProvisionerCaller0 extends DRIPCaller {
private static final String REQUEST_QUEUE_NAME = "provisioner_queue"; private static final String REQUEST_QUEUE_NAME = "provisioner_queue_v0";
public ProvisionerCaller(String messageBrokerHost) throws IOException, TimeoutException { public ProvisionerCaller0(String messageBrokerHost) throws IOException, TimeoutException {
super(messageBrokerHost, REQUEST_QUEUE_NAME); super(messageBrokerHost, REQUEST_QUEUE_NAME);
} }
} }
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.api.rpc;
import java.io.IOException;
import java.util.concurrent.TimeoutException;
/**
*
* @author S. Koulouzis
*/
public class ProvisionerCaller1 extends DRIPCaller {
private static final String REQUEST_QUEUE_NAME = "provisioner_queue_v1";
public ProvisionerCaller1(String messageBrokerHost) throws IOException, TimeoutException {
super(messageBrokerHost, REQUEST_QUEUE_NAME);
}
}
...@@ -18,7 +18,6 @@ package nl.uva.sne.drip.api.service; ...@@ -18,7 +18,6 @@ package nl.uva.sne.drip.api.service;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
...@@ -51,7 +50,6 @@ import org.springframework.security.core.context.SecurityContextHolder; ...@@ -51,7 +50,6 @@ import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import nl.uva.sne.drip.api.dao.KeyPairDao; import nl.uva.sne.drip.api.dao.KeyPairDao;
import nl.uva.sne.drip.api.exception.KeyException; import nl.uva.sne.drip.api.exception.KeyException;
import nl.uva.sne.drip.commons.utils.MessageGenerator;
import nl.uva.sne.drip.data.v1.external.KeyPair; import nl.uva.sne.drip.data.v1.external.KeyPair;
import nl.uva.sne.drip.data.v1.external.ansible.AnsibleOutput; import nl.uva.sne.drip.data.v1.external.ansible.AnsibleOutput;
import nl.uva.sne.drip.data.v1.external.ansible.AnsibleResult; import nl.uva.sne.drip.data.v1.external.ansible.AnsibleResult;
......
...@@ -63,7 +63,7 @@ public class PlannerService { ...@@ -63,7 +63,7 @@ public class PlannerService {
@Value("${message.broker.host}") @Value("${message.broker.host}")
private String messageBrokerHost; private String messageBrokerHost;
public PlanResponse getPlan(String toscaId) throws JSONException, UnsupportedEncodingException, IOException, TimeoutException, InterruptedException { public PlanResponse getPlan(String toscaId, String clusterType) throws JSONException, UnsupportedEncodingException, IOException, TimeoutException, InterruptedException {
try (PlannerCaller planner = new PlannerCaller(messageBrokerHost)) { try (PlannerCaller planner = new PlannerCaller(messageBrokerHost)) {
Message plannerInvokationMessage = buildPlannerMessage(toscaId); Message plannerInvokationMessage = buildPlannerMessage(toscaId);
...@@ -84,7 +84,7 @@ public class PlannerService { ...@@ -84,7 +84,7 @@ public class PlannerService {
} }
jsonArrayString.append("]"); jsonArrayString.append("]");
SimplePlanContainer simplePlan = P2PConverter.convert(jsonArrayString.toString(), "vm_user", "Ubuntu 16.04", "swarm"); SimplePlanContainer simplePlan = P2PConverter.convert(jsonArrayString.toString(), "vm_user", "Ubuntu 16.04", clusterType);
PlanResponse topLevel = new PlanResponse(); PlanResponse topLevel = new PlanResponse();
topLevel.setTimestamp(System.currentTimeMillis()); topLevel.setTimestamp(System.currentTimeMillis());
topLevel.setLevel(0); topLevel.setLevel(0);
......
...@@ -65,7 +65,7 @@ public class PlannerController0 { ...@@ -65,7 +65,7 @@ public class PlannerController0 {
String yaml = plan0.file; String yaml = plan0.file;
yaml = yaml.replaceAll("\\\\n", "\n"); yaml = yaml.replaceAll("\\\\n", "\n");
String id = toscaService.saveYamlString(yaml, null); String id = toscaService.saveYamlString(yaml, null);
nl.uva.sne.drip.data.v1.external.PlanResponse plan1 = plannerService.getPlan(id); nl.uva.sne.drip.data.v1.external.PlanResponse plan1 = plannerService.getPlan(id,"swarm");
Result r = new Result(); Result r = new Result();
r.info = ("INFO"); r.info = ("INFO");
......
...@@ -128,7 +128,7 @@ public class ProvisionController0 { ...@@ -128,7 +128,7 @@ public class ProvisionController0 {
try { try {
ProvisionRequest req = provisionService.findOne(exc.action); ProvisionRequest req = provisionService.findOne(exc.action);
req = provisionService.provisionResources(req); req = provisionService.provisionResources(req,0);
Map<String, Object> map = req.getKeyValue(); Map<String, Object> map = req.getKeyValue();
String yaml = Converter.map2YmlString(map); String yaml = Converter.map2YmlString(map);
yaml = yaml.replaceAll("\n", "\\\\n"); yaml = yaml.replaceAll("\n", "\\\\n");
......
...@@ -67,7 +67,7 @@ public class PlannerController { ...@@ -67,7 +67,7 @@ public class PlannerController {
String plan(@PathVariable("tosca_id") String toscaId) { String plan(@PathVariable("tosca_id") String toscaId) {
try { try {
PlanResponse plan = plannerService.getPlan(toscaId); PlanResponse plan = plannerService.getPlan(toscaId, "swarm");
if (plan == null) { if (plan == null) {
throw new NotFoundException("Could not make plan"); throw new NotFoundException("Could not make plan");
} }
......
...@@ -137,7 +137,7 @@ public class ProvisionController { ...@@ -137,7 +137,7 @@ public class ProvisionController {
throw new BadRequestException(); throw new BadRequestException();
} }
try { try {
req = provisionService.provisionResources(req); req = provisionService.provisionResources(req, 1);
return req.getId(); return req.getId();
......
...@@ -61,7 +61,7 @@ public class Converter { ...@@ -61,7 +61,7 @@ public class Converter {
return (Map<String, Object>) object; return (Map<String, Object>) object;
} }
public static Map<String, Object> ymlString2Map(InputStream in) { public static Map<String, Object> ymlStream2Map(InputStream in) {
Yaml yaml = new Yaml(); Yaml yaml = new Yaml();
Map<String, Object> map = (Map<String, Object>) yaml.load(in); Map<String, Object> map = (Map<String, Object>) yaml.load(in);
return map; return map;
......
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