Fixed instance logic
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/commit/feff6cd3 Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/tree/feff6cd3 Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/diff/feff6cd3 Branch: refs/heads/jclouds-393 Commit: feff6cd312c8534d602ff26d39b76bfab3d948ef Parents: 3b5e98b Author: Andrew Bayer <[email protected]> Authored: Tue Dec 3 18:21:54 2013 -0800 Committer: Andrew Bayer <[email protected]> Committed: Tue Dec 3 18:21:54 2013 -0800 ---------------------------------------------------------------------- .../config/GoogleComputeEngineParserModule.java | 6 ++--- .../googlecomputeengine/domain/Instance.java | 24 ++------------------ .../GoogleComputeEngineServiceExpectTest.java | 4 ++++ .../features/InstanceApiExpectTest.java | 3 --- .../parse/ParseInstanceTest.java | 6 ++--- .../src/test/resources/instance_get.json | 1 - .../src/test/resources/instance_insert.json | 2 +- .../test/resources/instance_insert_simple.json | 2 +- .../src/test/resources/instance_list.json | 7 ++++-- 9 files changed, 19 insertions(+), 36 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/feff6cd3/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineParserModule.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineParserModule.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineParserModule.java index a0874a8..2f5f644 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineParserModule.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineParserModule.java @@ -208,14 +208,14 @@ public class GoogleComputeEngineParserModule extends AbstractModule { private static class InstanceInternal extends Instance { @ConstructorProperties({ - "id", "creationTimestamp", "selfLink", "name", "description", "tags", "image", "machineType", + "id", "creationTimestamp", "selfLink", "name", "description", "tags", "machineType", "status", "statusMessage", "zone", "networkInterfaces", "metadata", "serviceAccounts" }) private InstanceInternal(String id, Date creationTimestamp, URI selfLink, String name, String description, - Tags tags, URI image, URI machineType, Status status, String statusMessage, + Tags tags, URI machineType, Status status, String statusMessage, URI zone, Set<NetworkInterface> networkInterfaces, Metadata metadata, Set<ServiceAccount> serviceAccounts) { - super(id, creationTimestamp, selfLink, name, description, tags, image, machineType, + super(id, creationTimestamp, selfLink, name, description, tags, machineType, status, statusMessage, zone, networkInterfaces, null, metadata, serviceAccounts); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/feff6cd3/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Instance.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Instance.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Instance.java index bd58fee..7f65176 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Instance.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Instance.java @@ -54,7 +54,6 @@ public class Instance extends Resource { } protected final Tags tags; - protected final URI image; protected final URI machineType; protected final Status status; protected final Optional<String> statusMessage; @@ -65,12 +64,11 @@ public class Instance extends Resource { protected final Set<ServiceAccount> serviceAccounts; protected Instance(String id, Date creationTimestamp, URI selfLink, String name, String description, - Tags tags, URI image, URI machineType, Status status, String statusMessage, + Tags tags, URI machineType, Status status, String statusMessage, URI zone, Set<NetworkInterface> networkInterfaces, Set<AttachedDisk> disks, Metadata metadata, Set<ServiceAccount> serviceAccounts) { super(Kind.INSTANCE, id, creationTimestamp, selfLink, name, description); this.tags = checkNotNull(tags, "tags"); - this.image = checkNotNull(image, "image"); this.machineType = checkNotNull(machineType, "machineType of %s", name); this.status = checkNotNull(status, "status"); this.statusMessage = fromNullable(statusMessage); @@ -92,13 +90,6 @@ public class Instance extends Resource { } /** - * @return the URL of the disk image resource to be to be installed on this instance. - */ - public URI getImage() { - return image; - } - - /** * @return URL of the machine type resource describing which machine type to use to host the instance. */ public URI getMachineType() { @@ -180,7 +171,6 @@ public class Instance extends Resource { return super.string() .omitNullValues() .add("items", tags) - .add("image", image) .add("machineType", machineType) .add("status", status) .add("statusMessage", statusMessage.orNull()) @@ -210,7 +200,6 @@ public class Instance extends Resource { public static final class Builder extends Resource.Builder<Builder> { private Tags tags; - private URI image; private URI machineType; private Status status; private String statusMessage; @@ -230,14 +219,6 @@ public class Instance extends Resource { } /** - * @see Instance#getImage() - */ - public Builder image(URI image) { - this.image = image; - return this; - } - - /** * @see Instance#getMachineType() */ public Builder machineType(URI machineType) { @@ -333,14 +314,13 @@ public class Instance extends Resource { public Instance build() { return new Instance(super.id, super.creationTimestamp, super.selfLink, super.name, - super.description, tags, image, machineType, status, statusMessage, zone, + super.description, tags, machineType, status, statusMessage, zone, networkInterfaces.build(), disks.build(), metadata, serviceAccounts.build()); } public Builder fromInstance(Instance in) { return super.fromResource(in) .tags(in.getTags()) - .image(in.getImage()) .machineType(in.getMachineType()) .status(in.getStatus()) .statusMessage(in.getStatusMessage().orNull()) http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/feff6cd3/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceExpectTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceExpectTest.java index cb1a971..3ce5316 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceExpectTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceExpectTest.java @@ -486,6 +486,8 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin .add(GET_GLOBAL_OPERATION_REQUEST) .add(LIST_INSTANCES_REQUEST) .add(LIST_MACHINE_TYPES_REQUEST) + .add(LIST_PROJECT_IMAGES_REQUEST) + .add(LIST_GOOGLE_IMAGES_REQUEST) .add(createDiskRequestForInstance("test-1")) .add(GET_ZONE_OPERATION_REQUEST) .add(getDiskRequestForInstance("test-1")) @@ -520,6 +522,8 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin .add(GET_GLOBAL_OPERATION_RESPONSE) .add(LIST_INSTANCES_RESPONSE) .add(LIST_MACHINE_TYPES_RESPONSE) + .add(LIST_PROJECT_IMAGES_RESPONSE) + .add(LIST_GOOGLE_IMAGES_RESPONSE) .add(SUCESSFULL_OPERATION_RESPONSE) .add(GET_ZONE_OPERATION_RESPONSE) .add(getDiskResponseForInstance("test-1")) http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/feff6cd3/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiExpectTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiExpectTest.java index 1af5ef7..2107c3c 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiExpectTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiExpectTest.java @@ -144,7 +144,6 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest CREATE_INSTANCE_RESPONSE)).getInstanceApiForProject("myproject"); InstanceTemplate options = InstanceTemplate.builder().forMachineType("us-central1-a/n1-standard-1") - .image(URI.create("https://www.googleapis.com/compute/v1/projects/google/global/images/gcel-12-04-v20121106")) .addNetworkInterface(URI.create("https://www.googleapis" + ".com/compute/v1/projects/myproject/global/networks/default")); @@ -173,8 +172,6 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest .addNetworkInterface(URI.create("https://www.googleapis" + ".com/compute/v1/projects/myproject/global/networks/default"), Instance.NetworkInterface.AccessConfig.Type.ONE_TO_ONE_NAT) .description("desc") - .image(URI.create("https://www.googleapis" + - ".com/compute/v1/projects/google/global/images/gcel-12-04-v20121106")) .addDisk(InstanceTemplate.PersistentDisk.Mode.READ_WRITE, create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/test")) .addServiceAccount(Instance.ServiceAccount.builder().email("default").addScopes("myscope").build()) http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/feff6cd3/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseInstanceTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseInstanceTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseInstanceTest.java index d8287e4..e2d8905 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseInstanceTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseInstanceTest.java @@ -48,8 +48,6 @@ public class ParseInstanceTest extends BaseGoogleComputeEngineParseTest<Instance ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-0")) .description("desc") .name("test-0") - .image(URI.create("https://www.googleapis" + - ".com/compute/v1/projects/google/global/images/gcel-12-04-v20121106")) .machineType(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1" + "-standard-1")) .status(Instance.Status.RUNNING) @@ -73,7 +71,9 @@ public class ParseInstanceTest extends BaseGoogleComputeEngineParseTest<Instance ) .tags(Instance.Tags.builder().fingerprint("abcd").addItem("aTag").build()) .metadata(Metadata.builder() - .items(ImmutableMap.of("aKey", "aValue")) + .items(ImmutableMap.of("aKey", "aValue", + "jclouds-image", + "https://www.googleapis.com/compute/v1/projects/google/global/images/gcel-12-04-v20121106")) .fingerprint("efgh") .build()) .addServiceAccount(Instance.ServiceAccount.builder().email("default").addScopes("myscope").build()) http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/feff6cd3/google-compute-engine/src/test/resources/instance_get.json ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/resources/instance_get.json b/google-compute-engine/src/test/resources/instance_get.json index 158e869..9fdf1cc 100644 --- a/google-compute-engine/src/test/resources/instance_get.json +++ b/google-compute-engine/src/test/resources/instance_get.json @@ -5,7 +5,6 @@ "creationTimestamp": "2012-11-25T23:48:20.758", "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-0", "name": "test-0", - "image": "https://www.googleapis.com/compute/v1/projects/google/global/images/gcel-12-04-v20121106", "machineType": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-1", "status": "RUNNING", "zone": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a", http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/feff6cd3/google-compute-engine/src/test/resources/instance_insert.json ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/resources/instance_insert.json b/google-compute-engine/src/test/resources/instance_insert.json index 7866de6..bfb07eb 100644 --- a/google-compute-engine/src/test/resources/instance_insert.json +++ b/google-compute-engine/src/test/resources/instance_insert.json @@ -1 +1 @@ -{"name":"test-0","description":"desc","machineType":"https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-1","image":"https://www.googleapis.com/compute/v1/projects/google/global/images/gcel-12-04-v20121106","serviceAccounts":[{"email":"default","scopes":["myscope"]}],"networkInterfaces":[{"network":"https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default","accessConfigs":[{"type":"ONE_TO_ONE_NAT"}]}],"disks":[{"mode":"READ_WRITE","source":"https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/test","type":"PERSISTENT"}],"metadata":{"kind":"compute#metadata","items":[{"key":"aKey","value":"aValue"}]}} \ No newline at end of file +{"name":"test-0","description":"desc","machineType":"https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-1","serviceAccounts":[{"email":"default","scopes":["myscope"]}],"networkInterfaces":[{"network":"https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default","accessConfigs":[{"type":"ONE_TO_ONE_NAT"}]}],"disks":[{"mode":"READ_WRITE","source":"https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/test","boot":false,"type":"PERSISTENT"}],"metadata":{"kind":"compute#metadata","items":[{"key":"aKey","value":"aValue"}]}} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/feff6cd3/google-compute-engine/src/test/resources/instance_insert_simple.json ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/resources/instance_insert_simple.json b/google-compute-engine/src/test/resources/instance_insert_simple.json index b879416..038e7f8 100644 --- a/google-compute-engine/src/test/resources/instance_insert_simple.json +++ b/google-compute-engine/src/test/resources/instance_insert_simple.json @@ -1 +1 @@ -{"name":"test-1","machineType":"https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-1","image":"https://www.googleapis.com/compute/v1/projects/google/global/images/gcel-12-04-v20121106","serviceAccounts":[],"networkInterfaces":[{"network":"https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default","accessConfigs":[]}]} \ No newline at end of file +{"name":"test-1","machineType":"https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-1","serviceAccounts":[],"networkInterfaces":[{"network":"https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default","accessConfigs":[]}]} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/feff6cd3/google-compute-engine/src/test/resources/instance_list.json ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/resources/instance_list.json b/google-compute-engine/src/test/resources/instance_list.json index a6c2369..6502389 100644 --- a/google-compute-engine/src/test/resources/instance_list.json +++ b/google-compute-engine/src/test/resources/instance_list.json @@ -10,7 +10,6 @@ "creationTimestamp": "2012-11-25T23:48:20.758", "selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-0", "name": "test-0", - "image": "https://www.googleapis.com/compute/v1/projects/google/global/images/gcel-12-04-v20121106", "machineType": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-1", "status": "RUNNING", "zone": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a", @@ -46,7 +45,11 @@ { "key": "aKey", "value": "aValue" - } + }, + { + "key": "jclouds-image", + "value": "https://www.googleapis.com/compute/v1/projects/google/global/images/gcel-12-04-v20121106" + } ], "fingerprint": "efgh" },
