Commit 4927b5ba authored by Spiros Koulouzis's avatar Spiros Koulouzis

Implemented user configure geni API v0

parent a147cca7
......@@ -32,6 +32,7 @@ import nl.uva.sne.drip.api.exception.NullKeyException;
import nl.uva.sne.drip.api.exception.NullKeyIDException;
import nl.uva.sne.drip.api.service.UserService;
import nl.uva.sne.drip.commons.v0.types.Configure;
import nl.uva.sne.drip.commons.v1.types.LoginKey;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -53,7 +54,7 @@ public class CloudConfigurationController0 {
@RequestMapping(value = "/ec2", method = RequestMethod.POST, consumes = MediaType.TEXT_XML_VALUE)
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
String postConf(@RequestBody Configure configure) {
String postEC2Conf(@RequestBody Configure configure) {
if (configure.key == null) {
throw new NullKeyException();
}
......@@ -80,4 +81,39 @@ public class CloudConfigurationController0 {
return "Success: " + cloudCredentials.getId();
}
@RequestMapping(value = "/geni", method = RequestMethod.POST, consumes = MediaType.TEXT_XML_VALUE)
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
String postGeniConf(@RequestBody Configure configure) {
if (configure.geniKey == null) {
throw new NullKeyException();
}
if (configure.geniKeyAlias == null) {
throw new NullKeyIDException();
}
CloudCredentials cloudCredentials = new CloudCredentials();
cloudCredentials.setKeyIdAlias(configure.geniKeyAlias);
cloudCredentials.setKey(configure.geniKey);
cloudCredentials.setKeyPass(configure.geniKeyPass);
List<nl.uva.sne.drip.commons.v1.types.LoginKey> loginKeys = new ArrayList<>();
for (nl.uva.sne.drip.commons.v0.types.LoginKey0 key0 : configure.loginPubKey) {
nl.uva.sne.drip.commons.v1.types.LoginKey key1 = new nl.uva.sne.drip.commons.v1.types.LoginKey();
key1.setKey(key0.content);
key1.setType(LoginKey.Type.PUBLIC);
loginKeys.add(key1);
}
for (nl.uva.sne.drip.commons.v0.types.LoginKey0 key0 : configure.loginPriKey) {
nl.uva.sne.drip.commons.v1.types.LoginKey key1 = new nl.uva.sne.drip.commons.v1.types.LoginKey();
key1.setKey(key0.content);
key1.setType(LoginKey.Type.PRIVATE);
loginKeys.add(key1);
}
cloudCredentials.setLogineKeys(loginKeys);
cloudCredentials.setCloudProviderName("geni");
cloudCredentialsDao.save(cloudCredentials);
return "Success: " + cloudCredentials.getId();
}
}
......@@ -33,5 +33,14 @@ public class Configure {
@XmlElement(name = "loginKey")
public List<LoginKey0> loginKey;
public String geniKey;
public String geniKeyAlias;
@XmlElement(name = "loginPubKey")
public List<LoginKey0> loginPubKey;
public String geniKeyPass;
@XmlElement(name = "loginPriKey")
public List<LoginKey0> loginPriKey;
}
......@@ -31,31 +31,27 @@ public class CloudCredentials {
@Id
private String id;
private String key;
private String keyIdAlias;
/**
* A list of login keys that can be used to log in to the deployed VMs. All
* new lines in the 'key' field have to be replaced with the '\n'
*/
private List<LoginKey> loginKeys;
private String cloudProviderName;
private String keypass;
public final String getId() {
return id;
}
public final void setId(final String id) {
this.id = id;
}
/**
* The key for the cloud provider.
*
* @return the key
*/
@DocumentationExample("6J7uo99ifrff45126Gsy5vgb3bmrtwY6hBxtYt9y")
......@@ -72,6 +68,7 @@ public class CloudCredentials {
/**
* The key id for the cloud provider or the key alias.
*
* @return the keyIdAlias
*/
@DocumentationExample("AKIAITY3K5ZUQ6M7YBSQ")
......@@ -88,6 +85,7 @@ public class CloudCredentials {
/**
* The login keys
*
* @return the loginKeys
*/
public List<LoginKey> getLoginKeys() {
......@@ -103,6 +101,7 @@ public class CloudCredentials {
/**
* The name of the cloud provider
*
* @return the cloudProviderName
*/
@DocumentationExample("ec2")
......@@ -116,4 +115,17 @@ public class CloudCredentials {
public void setCloudProviderName(String cloudProviderName) {
this.cloudProviderName = cloudProviderName;
}
public void setKeyPass(String keyPass) {
this.keypass = keyPass;
}
/**
* The password for key stores
* @return the keypass
*/
@DocumentationExample("123passwd")
public String getKeypass() {
return keypass;
}
}
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