Bläddra i källkod

Add sizes

pull/4/head
Svitlana 4 år sedan
förälder
incheckning
6f2435a162
3 ändrade filer med 20 tillägg och 7 borttagningar
  1. +10
    -5
      bubble-server/src/main/java/bubble/cloud/compute/ec2/AmazonEC2Driver.java
  2. +5
    -1
      bubble-server/src/main/resources/models/defaults/cloudService.json
  3. +5
    -1
      bubble-server/src/test/resources/models/system/cloudService.json

+ 10
- 5
bubble-server/src/main/java/bubble/cloud/compute/ec2/AmazonEC2Driver.java Visa fil

@@ -4,6 +4,7 @@
*/
package bubble.cloud.compute.ec2;

import bubble.cloud.compute.ComputeNodeSize;
import bubble.cloud.compute.ComputeServiceDriverBase;
import bubble.cloud.shared.aws.BubbleAwsCredentialsProvider;
import bubble.model.cloud.BubbleNode;
@@ -15,6 +16,7 @@ import com.amazonaws.services.ec2.AmazonEC2;
import com.amazonaws.services.ec2.AmazonEC2ClientBuilder;
import com.amazonaws.services.ec2.model.*;
import lombok.Getter;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.cobbzilla.util.http.HttpRequestBean;
import org.cobbzilla.util.http.HttpResponseBean;
@@ -88,10 +90,11 @@ public class AmazonEC2Driver extends ComputeServiceDriverBase {
return nodes;
}

@Override public BubbleNode start(BubbleNode node) throws Exception {
@Override public BubbleNode start(@NonNull BubbleNode node) throws Exception {
final ComputeNodeSize size = config.getSize(node.getSize());

RunInstancesRequest runInstancesRequest = new RunInstancesRequest().withImageId(config.getConfig("imageId"))
.withInstanceType(config.getConfig("instanceType"))
.withInstanceType(size.getInternalName())
.withMinCount(MIN_COUNT)
.withMaxCount(MAX_COUNT)
.withKeyName(node.getUuid())
@@ -135,12 +138,14 @@ public class AmazonEC2Driver extends ComputeServiceDriverBase {
return node;
}

@Override public BubbleNode cleanupStart(BubbleNode node) throws Exception {
@Override public BubbleNode cleanupStart(@NonNull BubbleNode node) throws Exception {
deleteEC2KeyPair(node);
return node;
}

@Override public BubbleNode stop(BubbleNode node) throws Exception {
deleteEC2KeyPair(node); // just in case

if (!node.hasTag(TAG_INSTANCE_ID)) {
throw notFoundEx(node.id());
}
@@ -160,7 +165,7 @@ public class AmazonEC2Driver extends ComputeServiceDriverBase {
return node;
}

@Override public BubbleNode status(BubbleNode node) throws Exception {
@Override public BubbleNode status(@NonNull BubbleNode node) throws Exception {
final List<BubbleNode> found = listNodes();
if (found.isEmpty()) {
return node.setState(BubbleNodeState.stopped);
@@ -178,7 +183,7 @@ public class AmazonEC2Driver extends ComputeServiceDriverBase {
return node;
}

private void deleteEC2KeyPair(BubbleNode node) throws Exception {
private void deleteEC2KeyPair(@NonNull BubbleNode node) throws Exception {
if (node.hasTag(TAG_SSH_KEY_ID)) {
DeleteKeyPairRequest request = new DeleteKeyPairRequest()
.withKeyName(node.getUuid());


+ 5
- 1
bubble-server/src/main/resources/models/defaults/cloudService.json Visa fil

@@ -275,8 +275,12 @@
"name": "us-east-1", "description": "US East (N. Virginia)",
"location": {"country": "US", "lat": "37.926868", "lon": "-78.024902"}
}],
"sizes": [
{"name": "small", "type": "small", "internalName": "t2.micro", "vcpu": 1, "memoryMB": 1024, "ssdGB": 0},
{"name": "medium", "type": "medium", "internalName": "t2.small", "vcpu": 1, "memoryMB": 2048, "ssdGB": 0},
{"name": "large", "type": "large", "internalName": "t2.medium", "vcpu": 2, "memoryMB": 4096, "ssdGB": 80}
],
"config": [
{"name": "instanceType", "value": "{{INSTANCE_TYPE}}"},
{"name": "imageId", "value": "{{IMAGE_ID}}"},
{"name": "group", "value": "{{EC2_GROUP}}"}
]


+ 5
- 1
bubble-server/src/test/resources/models/system/cloudService.json Visa fil

@@ -243,8 +243,12 @@
"name": "us-east-1", "description": "US East (N. Virginia)",
"location": {"country": "US", "lat": "37.926868", "lon": "-78.024902"}
}],
"sizes": [
{"name": "small", "type": "small", "internalName": "t2.micro", "vcpu": 1, "memoryMB": 1024, "ssdGB": 0},
{"name": "medium", "type": "medium", "internalName": "t2.small", "vcpu": 1, "memoryMB": 2048, "ssdGB": 0},
{"name": "large", "type": "large", "internalName": "t2.medium", "vcpu": 2, "memoryMB": 4096, "ssdGB": 80}
],
"config": [
{"name": "instanceType", "value": "t2.micro"},
{"name": "imageId", "value": "ami-0080e4c5bc078760e"},
{"name": "group", "value": "sg-id"}
]},


Laddar…
Avbryt
Spara