Commit ced0bfc0 authored by Spiros Koulouzis's avatar Spiros Koulouzis

implement caller for new provisioner

parent 201f5ade
......@@ -69,7 +69,7 @@ class</p>
<dl class="dl-horizontal">
<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>
<table class="table datatype-properties">
......
......@@ -22,11 +22,11 @@ import java.util.concurrent.TimeoutException;
*
* @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);
}
}
/*
* 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;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -51,7 +50,6 @@ import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import nl.uva.sne.drip.api.dao.KeyPairDao;
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.ansible.AnsibleOutput;
import nl.uva.sne.drip.data.v1.external.ansible.AnsibleResult;
......
......@@ -63,7 +63,7 @@ public class PlannerService {
@Value("${message.broker.host}")
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)) {
Message plannerInvokationMessage = buildPlannerMessage(toscaId);
......@@ -84,7 +84,7 @@ public class PlannerService {
}
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();
topLevel.setTimestamp(System.currentTimeMillis());
topLevel.setLevel(0);
......
......@@ -65,7 +65,7 @@ public class PlannerController0 {
String yaml = plan0.file;
yaml = yaml.replaceAll("\\\\n", "\n");
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();
r.info = ("INFO");
......
......@@ -128,7 +128,7 @@ public class ProvisionController0 {
try {
ProvisionRequest req = provisionService.findOne(exc.action);
req = provisionService.provisionResources(req);
req = provisionService.provisionResources(req,0);
Map<String, Object> map = req.getKeyValue();
String yaml = Converter.map2YmlString(map);
yaml = yaml.replaceAll("\n", "\\\\n");
......
......@@ -51,7 +51,7 @@ import org.springframework.web.bind.annotation.RequestParam;
@ResponseCode(code = 401, condition = "Bad credentials")
})
public class PlannerController {
@Autowired
private PlannerService plannerService;
......@@ -67,7 +67,7 @@ public class PlannerController {
String plan(@PathVariable("tosca_id") String toscaId) {
try {
PlanResponse plan = plannerService.getPlan(toscaId);
PlanResponse plan = plannerService.getPlan(toscaId, "swarm");
if (plan == null) {
throw new NotFoundException("Could not make plan");
}
......
......@@ -137,7 +137,7 @@ public class ProvisionController {
throw new BadRequestException();
}
try {
req = provisionService.provisionResources(req);
req = provisionService.provisionResources(req, 1);
return req.getId();
......
......@@ -61,7 +61,7 @@ public class Converter {
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();
Map<String, Object> map = (Map<String, Object>) yaml.load(in);
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