Commit 0472a4af authored by Spiros Koulouzis's avatar Spiros Koulouzis

deploy kubernetes with API v0.0 works

parent c36da2cd
/*
* 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.service;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
import nl.uva.sne.drip.api.dao.ClusterCredentialsDao;
import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.api.rpc.DRIPCaller;
import nl.uva.sne.drip.api.rpc.DeployerCaller;
import nl.uva.sne.drip.api.v1.rest.DeployController;
import nl.uva.sne.drip.commons.v1.types.CloudCredentials;
import nl.uva.sne.drip.commons.v1.types.ClusterCredentials;
import nl.uva.sne.drip.commons.v1.types.DeployParameter;
import nl.uva.sne.drip.commons.v1.types.LoginKey;
import nl.uva.sne.drip.commons.v1.types.Message;
import nl.uva.sne.drip.commons.v1.types.MessageParameter;
import nl.uva.sne.drip.commons.v1.types.ProvisionInfo;
import nl.uva.sne.drip.commons.v1.types.User;
import org.json.JSONException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
/**
*
* @author S. Koulouzis
*/
@Service
@PreAuthorize("isAuthenticated()")
public class DeployClusterService {
@Autowired
private ClusterCredentialsDao dao;
@Value("${message.broker.host}")
private String messageBrokerHost;
@Autowired
private CloudCredentialsService cloudCredentialsService;
@Autowired
private ProvisionService provisionService;
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public ClusterCredentials findOne(String id) {
return dao.findOne(id);
}
@PostFilter("(filterObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public List<ClusterCredentials> findAll() {
return dao.findAll();
}
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public ClusterCredentials delete(String id) {
ClusterCredentials cred = dao.findOne(id);
dao.delete(cred);
return cred;
}
public ClusterCredentials save(ClusterCredentials clusterCred) {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String owner = user.getUsername();
clusterCred.setOwner(owner);
return dao.save(clusterCred);
}
public ClusterCredentials deployCluster(String provisionID, String clusterType) {
try (DRIPCaller deployer = new DeployerCaller(messageBrokerHost);) {
Message deployerInvokationMessage = buildDeployerMessage(provisionID, clusterType.toLowerCase());
Message response = (deployer.call(deployerInvokationMessage));
// Message response = generateFakeResponse();
List<MessageParameter> params = response.getParameters();
ClusterCredentials clusterCred = new ClusterCredentials();
for (MessageParameter p : params) {
String name = p.getName();
if (name.equals("credential")) {
String value = p.getValue();
clusterCred.setKey(value);
save(clusterCred);
return clusterCred;
}
}
} catch (IOException | TimeoutException | JSONException | InterruptedException ex) {
Logger.getLogger(DeployController.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
private Message buildDeployerMessage(String provisionID, String clusterType) {
ProvisionInfo pro = provisionService.findOne(provisionID);
if (pro == null) {
throw new NotFoundException();
}
String cloudConfID = pro.getCloudcloudCredentialsID();
CloudCredentials cCred = cloudCredentialsService.findOne(cloudConfID);
List<LoginKey> loginKeys = cCred.getLoginKeys();
List<DeployParameter> deployParams = pro.getDeployParameters();
List<MessageParameter> parameters = new ArrayList<>();
for (DeployParameter dp : deployParams) {
String cName = dp.getCloudCertificateName();
MessageParameter messageParameter = new MessageParameter();
messageParameter.setName("credential");
messageParameter.setEncoding("UTF-8");
String key = null;
for (LoginKey lk : loginKeys) {
String lkName = lk.getName();
if (lkName == null) {
lkName = lk.getAttributes().get("domain_name");
}
if (lkName.equals(cName)) {
key = lk.getKey();
break;
}
}
messageParameter.setValue(key);
Map<String, String> attributes = new HashMap<>();
attributes.put("IP", dp.getIP());
attributes.put("role", dp.getRole());
attributes.put("user", dp.getUser());
messageParameter.setAttributes(attributes);
parameters.add(messageParameter);
}
MessageParameter clusterTypeParameter = new MessageParameter();
clusterTypeParameter.setName("cluster");
clusterTypeParameter.setEncoding("UTF-8");
clusterTypeParameter.setValue(clusterType);
parameters.add(clusterTypeParameter);
Message deployInvokationMessage = new Message();
deployInvokationMessage.setParameters(parameters);
deployInvokationMessage.setCreationDate(System.currentTimeMillis());
return deployInvokationMessage;
}
private Message generateFakeResponse() throws IOException, TimeoutException, InterruptedException, JSONException {
String strResponse = "{'creationDate': 1488453891505, 'parameters': "
+ "[{'url': 'null', 'attributes': 'null', 'name': 'credential', "
+ "'value': 'apiVersion: v1\\nclusters:\\n- cluster:\\n "
+ "certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tL"
+ "S0tCk1JSUN5RENDQWJDZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBRE"
+ "FWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRFM01ETXdNakV"
+ "4TWpNek9Gb1hEVEkzTURJeU9ERXhNak16T0Zvd0ZURVRNQkVHQTFVRQpBeE1L"
+ "YTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBR"
+ "ENDQVFvQ2dnRUJBTGV4CitSS2p4SjR3WXJacTc5bHU1dExCc0JZbWtCTi9xZl"
+ "AzUXRUeXV6RW5nWmFYaHpQWnNYbGlGK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QgQ0VSVElGSUNBVEUtLS0tLQo=\\n server: https://52.201.84.116:6443\\n name: kubernetes\\ncontexts:\\n- context:\\n cluster: kubernetes\\n user: admin\\n name: admin@kubernetes\\n- context:\\n cluster: kubernetes\\n user: kubelet\\n name: kubelet@kubernetes\\ncurrent-context: admin@kubernetes\\nkind: Config\\npreferences: {}\\nusers:\\n- name: admin\\n user:\\n client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM0ekNDQWN1Z0F3SUJBZ0lJWlR0eVhaRWNRUTh3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB4TnpBek1ESXhNVEl6TXpoYUZ3MHhPREF6TURJeE1USXpOREJhTUJzeApHVEFYQmdOVkJBTVRFR3QxWW1WeWJtVjBaWE10WVdSdGFXNHdnZ0VpTUEwR0NTcUdTSWIzRFFFQkFRVUFBNElCCkR3QXdnZ0VLQW9JQkFRRFFkOWdJK0liTVhDWlB6d244cGZuK1Vxd0RldXRKZjY5YWFCNFI4ZjZsSHl0dVRyNTkKZWJoZm43Uk5Od0UyTjZmeUdpOXpMdXdrcllpdU1zK3MvcTlDNVBmUXZiWTNaR2xTQk1KWXhTTGx6eFZ0UW1xdApKb1djWTBucUgwa2xjVnlZaFNKaEtKU25MdGx5UHBNZ0lkSWZBM1VDNXY4RVVzTzd0bFU5eGFZc0dkdDRmUDloCllxdDRZQndjOFY1VjgzNm5nTlFmNDdKZXJlMXR4RDRNV3JvM2pOZnp2NE9MVS9qTjlxdTdLWGpXZGZmenJiblIKQ2l3b1lhQ094aEV4Z3pvYkQvT01XZm1EcktRZlJZV3E2aUlWSmgvL0FoZi9KVGR6K3NoV2NndG96Q21KZDFXWgoyaEJnMTIwNE8zNTFLemVvZnp4MjJZc012NDdjVldIVjZ1QWhBZ01CQUFHak1UQXZNQTRHQTFVZER3RUIvd1FFCkF3SUZvREFkQmdOVkhTVUVGakFV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hCLzJCWURHaTdUWFdyTjkwRmVGZFlPVVRXWEpQaHNwQwpQRXVET2hGSHBMZTN6Smxyck9ySG1Ebm5aOFdtWU4rdGZzNnVuVHVsSXZPQWFKd01xVlZ4Ci0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0tCg==\\n', "
+ "'encoding': 'UTF-8'}]}";
strResponse = strResponse.replaceAll("'null'", "null").replaceAll("\'", "\"").replaceAll(" ", "");
ObjectMapper mapper = new ObjectMapper();
mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
return mapper.readValue(strResponse, Message.class);
}
}
......@@ -120,11 +120,11 @@ public class ProvisionService {
try (DRIPCaller provisioner = new ProvisionerCaller(messageBrokerHost);) {
Message provisionerInvokationMessage = buildProvisionerMessage(req);
Message response = (provisioner.call(provisionerInvokationMessage));
// Message response = generateFakeResponse(System.getProperty("user.home")
// + File.separator + "workspace" + File.separator + "DRIP"
// + File.separator + "doc" + File.separator + "json_samples" +
// File.separator + "ec2_provisioner_provisoned2.json");
// Message response = (provisioner.call(provisionerInvokationMessage));
Message response = generateFakeResponse(System.getProperty("user.home")
+ File.separator + "workspace" + File.separator + "DRIP"
+ File.separator + "doc" + File.separator + "json_samples"
+ File.separator + "ec2_provisioner_provisoned2.json");
List<MessageParameter> params = response.getParameters();
for (MessageParameter p : params) {
......
......@@ -13,51 +13,69 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.api.service;
package nl.uva.sne.drip.api.v0.rest;
import java.util.ArrayList;
import java.util.List;
import nl.uva.sne.drip.api.dao.ClusterCredentialsDao;
import nl.uva.sne.drip.commons.v1.types.ClusterCredentials;
import nl.uva.sne.drip.commons.v1.types.User;
import javax.annotation.security.RolesAllowed;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PostFilter;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import nl.uva.sne.drip.api.service.DeployClusterService;
import nl.uva.sne.drip.api.service.UserService;
import nl.uva.sne.drip.commons.v0.types.Deploy;
import nl.uva.sne.drip.commons.v0.types.File;
import nl.uva.sne.drip.commons.v0.types.Result;
import nl.uva.sne.drip.commons.v1.types.ClusterCredentials;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
/**
* This controller is responsible for deploying a cluster on provisoned
* resources.
*
* @author S. Koulouzis
*/
@Service
@RestController
@RequestMapping("/user/v0.0/switch/deploy/")
@Component
@PreAuthorize("isAuthenticated()")
public class ClusterCredentialService {
public class DeployController0 {
@Autowired
private ClusterCredentialsDao dao;
private DeployClusterService deployService;
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public ClusterCredentials findOne(String id) {
return dao.findOne(id);
@RequestMapping(value = "/kubernetes", method = RequestMethod.POST, consumes = MediaType.TEXT_XML_VALUE)
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
Result deployKubernetes(@RequestBody Deploy deploy) {
return deploy(deploy, "kubernetes");
}
@PostFilter("(filterObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public List<ClusterCredentials> findAll() {
return dao.findAll();
@RequestMapping(value = "/swarm", method = RequestMethod.POST, consumes = MediaType.TEXT_XML_VALUE)
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
Result deploySwarm(@RequestBody Deploy deploy) {
return deploy(deploy, "swarm");
}
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public ClusterCredentials delete(String id) {
ClusterCredentials cred = dao.findOne(id);
dao.delete(cred);
return cred;
}
private Result deploy(Deploy deploy, String clusterType) {
String provisionID = deploy.action;
ClusterCredentials clusterCred = deployService.deployCluster(provisionID, clusterType);
public ClusterCredentials save(ClusterCredentials clusterCred) {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String owner = user.getUsername();
clusterCred.setOwner(owner);
return dao.save(clusterCred);
Result res = new Result();
res.info = "INFO";
res.status = "Success";
List<File> files = new ArrayList<>();
File e = new File();
e.content = clusterCred.getKey();
files.add(e);
res.file = files;
return res;
}
}
......@@ -79,26 +79,7 @@ public class ProvisionController0 {
@Autowired
private PlannerService planService;
@RequestMapping(value = "/get", method = RequestMethod.GET, produces = MediaType.TEXT_XML_VALUE)
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
Upload provision() {
try {
Upload up = new Upload();
up.user = "user";
up.pwd = "123";
List<File> files = new ArrayList<>();
Plan plan1 = planService.findAll().get(0);
File f = Converter.plan1toFile(plan1);
files.add(f);
up.file = files;
return up;
} catch (JSONException ex) {
Logger.getLogger(ProvisionController0.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
@RequestMapping(value = "/upload", method = RequestMethod.POST, consumes = MediaType.TEXT_XML_VALUE)
@RolesAllowed({UserService.USER, UserService.ADMIN})
......
......@@ -40,7 +40,7 @@ import org.springframework.web.bind.annotation.RestController;
import nl.uva.sne.drip.api.rpc.DRIPCaller;
import nl.uva.sne.drip.api.rpc.DeployerCaller;
import nl.uva.sne.drip.api.service.CloudCredentialsService;
import nl.uva.sne.drip.api.service.ClusterCredentialService;
import nl.uva.sne.drip.api.service.DeployClusterService;
import nl.uva.sne.drip.api.service.ProvisionService;
import nl.uva.sne.drip.api.service.UserService;
import nl.uva.sne.drip.commons.v1.types.CloudCredentials;
......@@ -63,17 +63,10 @@ import org.springframework.web.bind.annotation.RequestParam;
@Controller
public class DeployController {
@Value("${message.broker.host}")
private String messageBrokerHost;
@Autowired
private CloudCredentialsService cloudCredentialsService;
@Autowired
private ProvisionService provisionService;
@Autowired
private ClusterCredentialService clusterCredentialService;
private DeployClusterService deployService;
/**
* Deploys a cluster on a provisioned resources.
......@@ -87,28 +80,9 @@ public class DeployController {
public @ResponseBody
String deploy(@PathVariable("id") String provisionID, @RequestParam(value = "cluster") String clusterType) {
checkClusterType(clusterType);
try (DRIPCaller deployer = new DeployerCaller(messageBrokerHost);) {
Message deployerInvokationMessage = buildDeployerMessage(provisionID, clusterType.toLowerCase());
Message response = (deployer.call(deployerInvokationMessage));
// Message response = generateFakeResponse();
List<MessageParameter> params = response.getParameters();
ClusterCredentials clusterCred = new ClusterCredentials();
for (MessageParameter p : params) {
String name = p.getName();
if (name.equals("credential")) {
String value = p.getValue();
clusterCred.setContents(value);
clusterCredentialService.save(clusterCred);
ClusterCredentials clusterCred = deployService.deployCluster(provisionID, clusterType);
return clusterCred.getId();
}
}
} catch (IOException | TimeoutException | JSONException | InterruptedException ex) {
Logger.getLogger(DeployController.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
/**
* Gets the cluster credentials.
......@@ -120,7 +94,7 @@ public class DeployController {
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
ClusterCredentials get(@PathVariable("id") String id) {
ClusterCredentials clusterC = clusterCredentialService.findOne(id);
ClusterCredentials clusterC = deployService.findOne(id);
if (clusterC == null) {
throw new NotFoundException();
}
......@@ -136,7 +110,7 @@ public class DeployController {
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
List<String> getIds() {
List<ClusterCredentials> all = clusterCredentialService.findAll();
List<ClusterCredentials> all = deployService.findAll();
List<String> ids = new ArrayList<>(all.size());
for (ClusterCredentials pi : all) {
ids.add(pi.getId());
......@@ -154,94 +128,15 @@ public class DeployController {
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
String delete(@PathVariable("id") String id) {
ClusterCredentials cred = clusterCredentialService.findOne(id);
ClusterCredentials cred = deployService.findOne(id);
if (cred != null) {
clusterCredentialService.delete(id);
deployService.delete(id);
return "Deleted : " + id;
}
throw new NotFoundException();
}
private Message buildDeployerMessage(String provisionID, String clusterType) {
ProvisionInfo pro = provisionService.findOne(provisionID);
if (pro == null) {
throw new NotFoundException();
}
String cloudConfID = pro.getCloudcloudCredentialsID();
CloudCredentials cCred = cloudCredentialsService.findOne(cloudConfID);
List<LoginKey> loginKeys = cCred.getLoginKeys();
List<DeployParameter> deployParams = pro.getDeployParameters();
List<MessageParameter> parameters = new ArrayList<>();
for (DeployParameter dp : deployParams) {
String cName = dp.getCloudCertificateName();
MessageParameter messageParameter = new MessageParameter();
messageParameter.setName("credential");
messageParameter.setEncoding("UTF-8");
String key = null;
for (LoginKey lk : loginKeys) {
String lkName = lk.getName();
if (lkName == null) {
lkName = lk.getAttributes().get("domain_name");
}
if (lkName.equals(cName)) {
key = lk.getKey();
break;
}
}
messageParameter.setValue(key);
Map<String, String> attributes = new HashMap<>();
attributes.put("IP", dp.getIP());
attributes.put("role", dp.getRole());
attributes.put("user", dp.getUser());
messageParameter.setAttributes(attributes);
parameters.add(messageParameter);
}
MessageParameter clusterTypeParameter = new MessageParameter();
clusterTypeParameter.setName("cluster");
clusterTypeParameter.setEncoding("UTF-8");
clusterTypeParameter.setValue(clusterType);
parameters.add(clusterTypeParameter);
Message deployInvokationMessage = new Message();
deployInvokationMessage.setParameters(parameters);
deployInvokationMessage.setCreationDate(System.currentTimeMillis());
return deployInvokationMessage;
}
private Message generateFakeResponse() throws IOException, TimeoutException, InterruptedException, JSONException {
String strResponse = "{'creationDate': 1488453891505, 'parameters': "
+ "[{'url': 'null', 'attributes': 'null', 'name': 'credential', "
+ "'value': 'apiVersion: v1\\nclusters:\\n- cluster:\\n "
+ "certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tL"
+ "S0tCk1JSUN5RENDQWJDZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBRE"
+ "FWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRFM01ETXdNakV"
+ "4TWpNek9Gb1hEVEkzTURJeU9ERXhNak16T0Zvd0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sRjA2Sk8KMElXSVhDam1NYXppaG1hNGVHQTRHO"
+ "XZ6R2lMMVlyZGIxVDdYbFd3Zm5iOTg1QmVUWEZvV1JjMUo3RjFvQ3BaVwp2OTN3cko5L01uUzZxN3p2NkdNaUE0Rm5VanZiUDB4OHhWVXpsYjVvVG5HenFycSt2MXJLQklGSlFXdz0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=\\n server: https://52.201.84.116:6443\\n name: kubernetes\\ncontexts:\\n- context:\\n cluster: kubernetes\\n user: admin\\n name: admin@kubernetes\\n- context:\\n cluster: kubernetes\\n user: kubelet\\n name: kubelet@kubernetes\\ncurrent-context: admin@kubernetes\\nkind: Config\\npreferences: {}\\nusers:\\n- name: admin\\n user:\\n client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM0ekNDQWN1Z0F3SUJBZ0lJWlR0eVhaRWNRUTh3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB4TnpBek1ESXhNVEl6TXpoYUZ3MHhPREF6TURJeE1USXpOREJhTUJzeApHVEFYQmdOVkJBTVRFR3QxWW1WeWJtVjBaWE10WVdSdGFXNHdnZ0VpTUEwR0NTcUdTSWIzRFFFQkFRVUFBNElCCkR3QXdnZ0VLQW9JQkFRRFFkOWdJK0liTVhDWlB6d244cGZuK1Vxd0RldXRKZjY5YWFCNFI4ZjZsSHl0dVRyNTkKZWJoZm43Uk5Od0UyTjZmeUdpOXpMdXdrcllpdU1zK3MvcTlDNVBmUXZiWTNaR2xTQk1KWXhTTGx6eFZ0UW1xdApKb1djWTBucUgwa2xjVnlZaFNKaEtKU25MdGx5UHBNZ0lkSWZBM1VDNXY4RVVzTzd0bFU5eGFZc0dkdDRmUDloCllxdDRZQndjOFY1VjgzNm5nTlFmNDdKZXJlMXR4RDRNV3JvM2pOZnp2NE9MVS9qTjlxdTdLWGpXZGZmenJiblIKQ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F4bVZWL2Mvd1h0dXYySWVJeWlnUnRzZ1dtNmFScElFS1lXRXJlV2pkCmlPZ0JjUUtCZ0ZZeTJYMmRubHVnUUI5TDhDWVRYMDZ2Q3ZNM3BsOWIwZXN3MFcxTzljVGJEbmViYXRUdW1lUy8KMEtpUHh5b2tBS1pCM3NDTUl3ZC9ZbTdtbEdjRU9aNEhCLzJCWURHaTdUWFdyTjkwRmVGZFlPVVRXWEpQaHNwQwpQRXVET2hGSHBMZTN6Smxyck9ySG1Ebm5aOFdtWU4rdGZzNnVuVHVsSXZPQWFKd01xVlZ4Ci0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0tCg==\\n', "
+ "'encoding': 'UTF-8'}]}";
strResponse = strResponse.replaceAll("'null'", "null").replaceAll("\'", "\"").replaceAll(" ", "");
ObjectMapper mapper = new ObjectMapper();
mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
return mapper.readValue(strResponse, Message.class);
}
private void checkClusterType(String clusterType) {
switch (clusterType.toLowerCase()) {
......
/*
* 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.commons.v0.types;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author S. Koulouzis
*/
@XmlRootElement
public class Deploy extends Execute {
}
......@@ -19,12 +19,12 @@ import com.webcohesion.enunciate.metadata.DocumentationExample;
import org.springframework.data.annotation.Id;
/**
This class represents the cluster credentials for a cloud. They can used to
* This class represents the cluster credentials for a cloud. They can used to
* login to the cluster created by the deployer
*
* @author S. Koulouzis
*/
public class ClusterCredentials extends OwnedObject{
public class ClusterCredentials extends OwnedObject {
@Id
private String id;
......@@ -44,6 +44,7 @@ public class ClusterCredentials extends OwnedObject{
/**
* The key of the login key.
*
* @return the key
*/
@DocumentationExample("BEGINRSAPRIVATEKEY-----\\nMIIEogIBAAKCAQEAm6AALYxkJFNzD3fVJ4+hMY5j0/kqM9CURLKXMlYuAysnvoG8wZKx9Bedefm\\neNSse4zTg798ZA2kDMZFIrwp1AseTwtj8DDu5fhG5DjyI3g6iJltS5zFQdMXneDlHXBX8cncSzNY\\nRx0NdjEMAe7YttvI8FNlxL0VnMFli/HB/ftzYMe5+AmkSROncVGHiwoiUpj+vtobCFOYtXsCf6ri\\nd4lgWA5wv6DZT/JKCYymiBqgSXu3ueFcEzw5SAukARWVjn1xccjZkokFfBbO/FpYY00TrUTBw9S6\\nD3iM+gj8RT6EKILOmhrt71D21S95WAWIT7h2YBsy1KAvMixhNf9VaQIDAQABAoIBAHhVYK3Xl3tr\\nN1Xm0ctJTQg3ijxhR2qsUBgGUokqezpdOoD2zbbOz7XvTYsX1GLr967U9pwxzUpELexexwiTvDgk\\nnLv8D7ui6qbRsmc4DSsWBRSophVIVFKQmftO8Xow6x+fuYJAYmsicM1KIYHBILtL+PSzV8anenWq\\nKQ3r0tfCiQhEzKEk4b1uT3SJWQyHE++JAhVkO7lIeb6S9Dg1jAaAeMnJ/NiMxTarpPRnxe6hsTsH\\ngG1iKWo+Skcl4SknOc+CMEfyDjG4FL7MGhKduahsO8vMUrgGsDD7EH3NiX/FweB8La6qpDYAwFpC\\nycrooyhiyzw8Wb5gGaYnmvr9l70CgYEAx74O8JleXaHpxEAmh4h7VbLmJ3mOylfBmOdzcHeedJQw\\nack2SAv65WBI9S9MEQ7J/vFuyw5HNk3C/mcWgzDQXSNIhHLvl/Z9sux/Qpm3SQWLz0RBxKV3dJ4r\\nwcAxzVA93+/L1Nee+VOKnlyRumvVa6+XLsLagpap2AVcTqlerMcCgYEAx3T2pXtqkCE9eU/ov22r\\npdaKjgHoGOUg1CMEfWi/Ch6sYIIRyrHz6dhy+yR1pXNgPbLWdrn8l88F3+IsmbaMupMgRmqwEC3G\\n9Y2FglGIVvRdZaagvRxLzRCcvcN4v6OYs9ST4o1xlv7Qxphld+0XDKv7VSCv/rASuK8BqlFL3E8C\\ngYArMXJRnRjG7qh6g9TRIjZphdI3XxX9s5Rt2D8iZvuhAhqmBZjzY4PR7kxYmO2+EpCjzNnEl0XW\\n/GHaWbiIjhnAykx4N9KP7gGom3O5lzwHUme1XnFKcO2wDjQwJbufRmba8iQF1srN577mF+Z7ha4V\\nJ1duCTzvWF1KFX6sk/uhKQKBgAcDFai7rgNjJ8YcCRKxyFcMM9LKPl6hr4XFtWKzTAQPEABUkkuN\\n9gVClsg9f+VRKRECOIf0Ae1UWeCFEwxUXp4wjfHrzkTDVztKvmbWdvSXorDwKrZ7SC7tZpVFSfly\\nxuuLjadpUZT9YFmbAfY1X5oSccOMYqORjRbxEB3svb4BAoGAGTgFuq9Zojh/KIqY8b4HpEfmh6CQ\\nhLVfD98Nqd6GDbxgvIM0v4mFXE92x2jn35Ia0JdFyh3B8Vkl7sqQZfxDFXI9O9pte2mPJxY9ICaY\\n55+X/SN1pd53BH+gaPZJy/R+Vpvs5MN48howjUKy5UKpoFeUWrS5QArjtvNCm4SGlXw=\\n-----ENDRSAPRIVATEKEY-----\\n")
......@@ -52,10 +53,10 @@ public class ClusterCredentials extends OwnedObject{
}
/**
* @param contents the key to set
* @param key the key to set
*/
public void setContents(String contents) {
this.key = contents;
public void setKey(String key) {
this.key = key;
}
}
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