You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ad...@apache.org on 2014/10/24 06:05:18 UTC
[1/3] git commit: Update to latest Azure Compute api version.
Repository: jclouds-labs
Updated Branches:
refs/heads/master 1f907d2a7 -> 7f307e859
Update to latest Azure Compute api version.
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/3b4c6526
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/3b4c6526
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/3b4c6526
Branch: refs/heads/master
Commit: 3b4c6526a221a68bba4fccc97c4dfee1b18dc544
Parents: 1f907d2
Author: Adrian Cole <ac...@twitter.com>
Authored: Wed Oct 22 20:51:34 2014 -0700
Committer: Adrian Cole <ad...@apache.org>
Committed: Thu Oct 23 21:05:08 2014 -0700
----------------------------------------------------------------------
azurecompute/pom.xml | 2 +-
.../java/org/jclouds/azurecompute/AzureManagementApiMetadata.java | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/3b4c6526/azurecompute/pom.xml
----------------------------------------------------------------------
diff --git a/azurecompute/pom.xml b/azurecompute/pom.xml
index 7cba08d..22431e8 100644
--- a/azurecompute/pom.xml
+++ b/azurecompute/pom.xml
@@ -35,7 +35,7 @@
<test.jclouds.azurecompute.subscription-id>FIXME_subscription-id</test.jclouds.azurecompute.subscription-id>
<!-- note that there's no prefix of "test." in the url. This is to ensure that jclouds inteprets the value, as opposed to maven -->
<test.azurecompute.endpoint>https://management.core.windows.net/${jclouds.azurecompute.subscription-id}</test.azurecompute.endpoint>
- <test.azurecompute.api-version>2012-03-01</test.azurecompute.api-version>
+ <test.azurecompute.api-version>2014-06-01</test.azurecompute.api-version>
<test.azurecompute.build-version />
<test.azurecompute.identity>/path/to/cert.p12</test.azurecompute.identity>
<test.azurecompute.credential>password to cert</test.azurecompute.credential>
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/3b4c6526/azurecompute/src/main/java/org/jclouds/azurecompute/AzureManagementApiMetadata.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/AzureManagementApiMetadata.java b/azurecompute/src/main/java/org/jclouds/azurecompute/AzureManagementApiMetadata.java
index e941dfa..762261c 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/AzureManagementApiMetadata.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/AzureManagementApiMetadata.java
@@ -55,7 +55,7 @@ public class AzureManagementApiMetadata extends BaseHttpApiMetadata<AzureCompute
protected Builder() {
id("azurecompute")
.name("Microsoft Azure Service Management Service API")
- .version("2012-03-01")
+ .version("2014-06-01")
.identityName("Path to Management Certificate .p12 file, or PEM string")
.credentialName("Password to Management Certificate")
.defaultEndpoint("https://management.core.windows.net/${" + SUBSCRIPTION_ID + "}")
[2/3] In latest Azure api, there are both OS images and Disk images.
Posted by ad...@apache.org.
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListOSImagesHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListOSImagesHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListOSImagesHandler.java
new file mode 100644
index 0000000..a3b8819
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListOSImagesHandler.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.jclouds.azurecompute.xml;
+
+import java.util.List;
+
+import org.jclouds.azurecompute.domain.OSImage;
+import org.jclouds.http.functions.ParseSax;
+import org.xml.sax.Attributes;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableList.Builder;
+
+public final class ListOSImagesHandler extends ParseSax.HandlerForGeneratedRequestWithResult<List<OSImage>> {
+ private boolean inOSImage;
+ private final OSImageHandler OSImageHandler = new OSImageHandler();
+ private final Builder<OSImage> images = ImmutableList.builder();
+
+ @Override
+ public List<OSImage> getResult() {
+ return images.build();
+ }
+
+ @Override
+ public void startElement(String url, String name, String qName, Attributes attributes) {
+ if (qName.equals("OSImage")) {
+ inOSImage = true;
+ }
+ }
+
+ @Override
+ public void endElement(String uri, String name, String qName) {
+ if (qName.equals("OSImage")) {
+ inOSImage = false;
+ images.add(OSImageHandler.getResult());
+ } else if (inOSImage) {
+ OSImageHandler.endElement(uri, name, qName);
+ }
+ }
+
+ @Override
+ public void characters(char ch[], int start, int length) {
+ if (inOSImage) {
+ OSImageHandler.characters(ch, start, length);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OSImageHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OSImageHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OSImageHandler.java
new file mode 100644
index 0000000..c64b69f
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OSImageHandler.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.jclouds.azurecompute.xml;
+
+import static com.google.common.base.Strings.emptyToNull;
+import static org.jclouds.util.SaxUtils.currentOrNull;
+
+import java.net.URI;
+import java.util.List;
+
+import org.jclouds.azurecompute.domain.OSImage;
+import org.jclouds.http.functions.ParseSax;
+
+import com.google.common.base.Splitter;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+
+/**
+ * @see <a href="http://msdn.microsoft.com/en-us/library/jj157191" >api</a>
+ */
+final class OSImageHandler extends ParseSax.HandlerForGeneratedRequestWithResult<OSImage> {
+ private String name;
+ private final List<String> locations = Lists.newArrayList();
+ private String affinityGroup;
+ private String label;
+ private String category;
+ private String description;
+ private OSImage.Type os;
+ private URI mediaLink;
+ private Integer logicalSizeInGB;
+ private final List<String> eulas = Lists.newArrayList();
+
+ private final StringBuilder currentText = new StringBuilder();
+
+ @Override public OSImage getResult() {
+ OSImage result = OSImage
+ .create(name, ImmutableList.copyOf(locations), affinityGroup, label, description, category, os, mediaLink,
+ logicalSizeInGB, ImmutableList.copyOf(eulas));
+ resetState(); // handler is called in a loop.
+ return result;
+ }
+
+ private void resetState() {
+ name = affinityGroup = label = description = category = null;
+ os = null;
+ mediaLink = null;
+ logicalSizeInGB = null;
+ eulas.clear();
+ locations.clear();
+ }
+
+ @Override public void endElement(String ignoredUri, String ignoredName, String qName) {
+ if (qName.equals("OS")) {
+ String osText = currentOrNull(currentText);
+ if (osText != null) {
+ os = OSImage.Type.valueOf(currentOrNull(currentText).toUpperCase());
+ }
+ } else if (qName.equals("Name")) {
+ name = currentOrNull(currentText);
+ } else if (qName.equals("LogicalSizeInGB")) {
+ String gb = currentOrNull(currentText);
+ if (gb != null) {
+ logicalSizeInGB = Integer.parseInt(gb);
+ }
+ } else if (qName.equals("Description")) {
+ description = currentOrNull(currentText);
+ } else if (qName.equals("Category")) {
+ category = currentOrNull(currentText);
+ } else if (qName.equals("Location")) {
+ String locationField = currentOrNull(currentText);
+ if (locationField != null) {
+ locations.addAll(Splitter.on(';').splitToList(locationField));
+ }
+ } else if (qName.equals("AffinityGroup")) {
+ affinityGroup = currentOrNull(currentText);
+ } else if (qName.equals("MediaLink")) {
+ String link = currentOrNull(currentText);
+ if (link != null) {
+ mediaLink = URI.create(link);
+ }
+ } else if (qName.equals("Eula")) {
+ String eulaField = currentOrNull(currentText);
+ if (eulaField != null) {
+ for (String eula : Splitter.on(';').split(eulaField)) {
+ if ((eula = emptyToNull(eula.trim())) != null) { // Dirty data in RightScale eulas field.
+ eulas.add(eula);
+ }
+ }
+ }
+ } else if (qName.equals("Label")) {
+ label = currentOrNull(currentText);
+ }
+ currentText.setLength(0);
+ }
+
+ @Override public void characters(char ch[], int start, int length) {
+ currentText.append(ch, start, length);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
index e6662ac..a469df3 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
@@ -22,11 +22,11 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull;
import org.jclouds.azurecompute.domain.DeploymentParams;
-import org.jclouds.azurecompute.domain.Image;
+import org.jclouds.azurecompute.domain.OSImage;
import org.jclouds.azurecompute.domain.RoleSize;
import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest;
import org.jclouds.azurecompute.xml.DeploymentHandlerTest;
-import org.jclouds.azurecompute.xml.ListImagesHandlerTest;
+import org.jclouds.azurecompute.xml.ListOSImagesHandlerTest;
import org.testng.annotations.Test;
import com.squareup.okhttp.mockwebserver.MockResponse;
@@ -42,12 +42,12 @@ public class DeploymentApiMockTest extends BaseAzureComputeApiMockTest {
try {
DeploymentApi api = api(server.getUrl("/")).getDeploymentApiForService("myservice");
- Image image = ListImagesHandlerTest.expected().get(5); // CentOS
+ OSImage OSImage = ListOSImagesHandlerTest.expected().get(5); // CentOS
DeploymentParams params = DeploymentParams.builder()
.name("mydeployment")
.size(RoleSize.MEDIUM)
- .sourceImageName(image.name()).mediaLink(image.mediaLink()).os(image.os())
+ .sourceImageName(OSImage.name()).mediaLink(OSImage.mediaLink()).os(OSImage.os())
.username("username").password("testpwd")
.externalEndpoint(inboundTcpToLocalPort(80, 8080))
.externalEndpoint(inboundUdpToLocalPort(53, 53)).build();
@@ -67,12 +67,12 @@ public class DeploymentApiMockTest extends BaseAzureComputeApiMockTest {
try {
DeploymentApi api = api(server.getUrl("/")).getDeploymentApiForService("myservice");
- Image image = ListImagesHandlerTest.expected().get(1); // Windows
+ OSImage OSImage = ListOSImagesHandlerTest.expected().get(1); // Windows
DeploymentParams params = DeploymentParams.builder()
.name("mydeployment")
.size(RoleSize.MEDIUM)
- .sourceImageName(image.name()).mediaLink(image.mediaLink()).os(image.os())
+ .sourceImageName(OSImage.name()).mediaLink(OSImage.mediaLink()).os(OSImage.os())
.username("username").password("testpwd")
.externalEndpoint(inboundTcpToLocalPort(80, 8080))
.externalEndpoint(inboundUdpToLocalPort(53, 53)).build();
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
index 0f54641..2f9499e 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
@@ -21,8 +21,8 @@ import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import org.jclouds.azurecompute.domain.Disk;
-import org.jclouds.azurecompute.domain.Image;
import org.jclouds.azurecompute.domain.Location;
+import org.jclouds.azurecompute.domain.OSImage;
import org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -46,8 +46,8 @@ public class DiskApiLiveTest extends BaseAzureComputeApiLiveTest {
return in.name();
}
}));
- images = ImmutableSet.copyOf(transform(api.getImageApi().list(), new Function<Image, String>() {
- public String apply(Image in) {
+ images = ImmutableSet.copyOf(transform(api.getOSImageApi().list(), new Function<OSImage, String>() {
+ public String apply(OSImage in) {
return in.name();
}
}));
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java
deleted file mode 100644
index c4b36e4..0000000
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.jclouds.azurecompute.features;
-
-import static com.google.common.collect.Iterables.transform;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import org.jclouds.azurecompute.domain.Image;
-import org.jclouds.azurecompute.domain.Location;
-import org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Function;
-import com.google.common.collect.ImmutableSet;
-
-@Test(groups = "live", testName = "ImageApiLiveTest")
-public class ImageApiLiveTest extends BaseAzureComputeApiLiveTest {
-
- private ImmutableSet<String> locations;
-
- @BeforeClass(groups = { "integration", "live" })
- public void setup() {
- super.setup();
-
- locations = ImmutableSet.copyOf(transform(api.getLocationApi().list(), new Function<Location, String>() {
- public String apply(Location in) {
- return in.name();
- }
- }));
- }
-
- public void testList() {
- for (Image image : api().list()) {
- checkOSImage(image);
- }
- }
-
- private void checkOSImage(Image image) {
- assertNotNull(image.label(), "Label cannot be null for " + image);
- assertNotNull(image.name(), "Name cannot be null for " + image);
- assertNotNull(image.os(), "OS cannot be null for " + image);
- assertTrue(image.logicalSizeInGB() > 0, "LogicalSizeInGB should be positive, if set" + image);
-
- if (image.category() != null) {
- assertNotEquals("", image.category().trim(), "Invalid Category for " + image);
- }
-
- if (image.mediaLink() != null) {
- assertTrue(ImmutableSet.of("http", "https").contains(image.mediaLink().getScheme()),
- "MediaLink should be an http(s) url" + image);
- }
- if (image.location() != null) {
- assertTrue(locations.contains(image.location()), "Location not in " + locations + " :" + image);
- }
-
- // Ex. Dirty data in RightScale eula field comes out as an empty string.
- assertFalse(image.eula().contains(""));
- if (image.affinityGroup() != null) {
- // TODO: list getAffinityGroups and check if there
- }
- }
-
- private ImageApi api() {
- return api.getImageApi();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiMockTest.java
deleted file mode 100644
index 4e05102..0000000
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiMockTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.jclouds.azurecompute.features;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-
-import java.net.URI;
-
-import org.jclouds.azurecompute.domain.Image.OSType;
-import org.jclouds.azurecompute.domain.ImageParams;
-import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest;
-import org.jclouds.azurecompute.xml.ListImagesHandlerTest;
-import org.testng.annotations.Test;
-
-import com.squareup.okhttp.mockwebserver.MockResponse;
-import com.squareup.okhttp.mockwebserver.MockWebServer;
-
-@Test(groups = "unit", testName = "ImageApiMockTest")
-public class ImageApiMockTest extends BaseAzureComputeApiMockTest {
-
- public void listWhenFound() throws Exception {
- MockWebServer server = mockAzureManagementServer();
- server.enqueue(xmlResponse("/images.xml"));
-
- try {
- ImageApi api = api(server.getUrl("/")).getImageApi();
-
- assertEquals(api.list(), ListImagesHandlerTest.expected());
-
- assertSent(server, "GET", "/services/images");
- } finally {
- server.shutdown();
- }
- }
-
- public void listWhenNotFound() throws Exception {
- MockWebServer server = mockAzureManagementServer();
- server.enqueue(new MockResponse().setResponseCode(404));
-
- try {
- ImageApi api = api(server.getUrl("/")).getImageApi();
-
- assertTrue(api.list().isEmpty());
-
- assertSent(server, "GET", "/services/images");
- } finally {
- server.shutdown();
- }
- }
-
- public void add() throws Exception {
- MockWebServer server = mockAzureManagementServer();
- server.enqueue(requestIdResponse("request-1"));
-
- try {
- ImageApi api = api(server.getUrl("/")).getImageApi();
-
- ImageParams params = ImageParams.builder().name("myimage").label("foo").os(OSType.LINUX)
- .mediaLink(URI.create("http://example.blob.core.windows.net/disks/mydisk.vhd")).build();
-
- assertEquals(api.add(params), "request-1");
-
- assertSent(server, "POST", "/services/images", "/imageparams.xml");
- } finally {
- server.shutdown();
- }
- }
-
- public void update() throws Exception {
- MockWebServer server = mockAzureManagementServer();
- server.enqueue(requestIdResponse("request-1"));
-
- try {
- ImageApi api = api(server.getUrl("/")).getImageApi();
-
- ImageParams params = ImageParams.builder().name("myimage").label("foo").os(OSType.LINUX)
- .mediaLink(URI.create("http://example.blob.core.windows.net/disks/mydisk.vhd")).build();
-
- assertEquals(api.update(params), "request-1");
-
- assertSent(server, "PUT", "/services/images/myimage", "/imageparams.xml");
- } finally {
- server.shutdown();
- }
- }
-
- public void deleteWhenFound() throws Exception {
- MockWebServer server = mockAzureManagementServer();
- server.enqueue(requestIdResponse("request-1"));
-
- try {
- ImageApi api = api(server.getUrl("/")).getImageApi();
-
- assertEquals(api.delete("myimage"), "request-1");
-
- assertSent(server, "DELETE", "/services/images/myimage");
- } finally {
- server.shutdown();
- }
- }
-
- public void deleteWhenNotFound() throws Exception {
- MockWebServer server = mockAzureManagementServer();
- server.enqueue(new MockResponse().setResponseCode(404));
-
- try {
- ImageApi api = api(server.getUrl("/")).getImageApi();
-
- assertNull(api.delete("myimage"));
-
- assertSent(server, "DELETE", "/services/images/myimage");
- } finally {
- server.shutdown();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiMockTest.java
index b476ed1..9360cb0 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiMockTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiMockTest.java
@@ -16,13 +16,14 @@
*/
package org.jclouds.azurecompute.features;
-import com.squareup.okhttp.mockwebserver.MockResponse;
-import com.squareup.okhttp.mockwebserver.MockWebServer;
+import static org.assertj.core.api.Assertions.assertThat;
+
import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest;
import org.jclouds.azurecompute.xml.ListLocationsHandlerTest;
import org.testng.annotations.Test;
-import static org.assertj.core.api.Assertions.assertThat;
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
@Test(groups = "unit", testName = "LocationApiMockTest")
public class LocationApiMockTest extends BaseAzureComputeApiMockTest {
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiLiveTest.java
new file mode 100644
index 0000000..785a5a1
--- /dev/null
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiLiveTest.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.jclouds.azurecompute.features;
+
+import static com.google.common.collect.Iterables.transform;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import org.jclouds.azurecompute.domain.Location;
+import org.jclouds.azurecompute.domain.OSImage;
+import org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableSet;
+
+@Test(groups = "live", testName = "OSImageApiLiveTest")
+public class OSImageApiLiveTest extends BaseAzureComputeApiLiveTest {
+
+ private ImmutableSet<String> locations;
+
+ @BeforeClass(groups = { "integration", "live" })
+ public void setup() {
+ super.setup();
+
+ locations = ImmutableSet.copyOf(transform(api.getLocationApi().list(), new Function<Location, String>() {
+ public String apply(Location in) {
+ return in.name();
+ }
+ }));
+ }
+
+ public void testList() {
+ for (OSImage OSImage : api().list()) {
+ checkOSImage(OSImage);
+ }
+ }
+
+ private void checkOSImage(OSImage OSImage) {
+ assertNotNull(OSImage.label(), "Label cannot be null for " + OSImage);
+ assertNotNull(OSImage.name(), "Name cannot be null for " + OSImage);
+ assertNotNull(OSImage.os(), "OS cannot be null for " + OSImage);
+ assertTrue(OSImage.logicalSizeInGB() > 0, "LogicalSizeInGB should be positive, if set" + OSImage);
+
+ if (OSImage.category() != null) {
+ assertNotEquals("", OSImage.category().trim(), "Invalid Category for " + OSImage);
+ }
+
+ if (OSImage.mediaLink() != null) {
+ assertTrue(ImmutableSet.of("http", "https").contains(OSImage.mediaLink().getScheme()),
+ "MediaLink should be an http(s) url" + OSImage);
+ }
+
+ assertTrue(locations.containsAll(OSImage.locations()), "Locations not in " + locations + " :" + OSImage);
+
+ // Ex. Dirty data in RightScale eula field comes out as an empty string.
+ assertFalse(OSImage.eula().contains(""));
+ if (OSImage.affinityGroup() != null) {
+ // TODO: list getAffinityGroups and check if there
+ }
+ }
+
+ private OSImageApi api() {
+ return api.getOSImageApi();
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiMockTest.java
new file mode 100644
index 0000000..70c5ec6
--- /dev/null
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiMockTest.java
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.jclouds.azurecompute.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+
+import org.jclouds.azurecompute.domain.OSImage;
+import org.jclouds.azurecompute.domain.OSImageParams;
+import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest;
+import org.jclouds.azurecompute.xml.ListOSImagesHandlerTest;
+import org.testng.annotations.Test;
+
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
+
+@Test(groups = "unit", testName = "OSImageApiMockTest")
+public class OSImageApiMockTest extends BaseAzureComputeApiMockTest {
+
+ public void listWhenFound() throws Exception {
+ MockWebServer server = mockAzureManagementServer();
+ server.enqueue(xmlResponse("/images.xml"));
+
+ try {
+ OSImageApi api = api(server.getUrl("/")).getOSImageApi();
+
+ assertEquals(api.list(), ListOSImagesHandlerTest.expected());
+
+ assertSent(server, "GET", "/services/images");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void listWhenNotFound() throws Exception {
+ MockWebServer server = mockAzureManagementServer();
+ server.enqueue(new MockResponse().setResponseCode(404));
+
+ try {
+ OSImageApi api = api(server.getUrl("/")).getOSImageApi();
+
+ assertTrue(api.list().isEmpty());
+
+ assertSent(server, "GET", "/services/images");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void add() throws Exception {
+ MockWebServer server = mockAzureManagementServer();
+ server.enqueue(requestIdResponse("request-1"));
+
+ try {
+ OSImageApi api = api(server.getUrl("/")).getOSImageApi();
+
+ OSImageParams params = OSImageParams.builder().name("myimage").label("foo").os(OSImage.Type.LINUX)
+ .mediaLink(URI.create("http://example.blob.core.windows.net/disks/mydisk.vhd")).build();
+
+ assertEquals(api.add(params), "request-1");
+
+ assertSent(server, "POST", "/services/images", "/imageparams.xml");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void update() throws Exception {
+ MockWebServer server = mockAzureManagementServer();
+ server.enqueue(requestIdResponse("request-1"));
+
+ try {
+ OSImageApi api = api(server.getUrl("/")).getOSImageApi();
+
+ OSImageParams params = OSImageParams.builder().name("myimage").label("foo").os(OSImage.Type.LINUX)
+ .mediaLink(URI.create("http://example.blob.core.windows.net/disks/mydisk.vhd")).build();
+
+ assertEquals(api.update(params), "request-1");
+
+ assertSent(server, "PUT", "/services/images/myimage", "/imageparams.xml");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void deleteWhenFound() throws Exception {
+ MockWebServer server = mockAzureManagementServer();
+ server.enqueue(requestIdResponse("request-1"));
+
+ try {
+ OSImageApi api = api(server.getUrl("/")).getOSImageApi();
+
+ assertEquals(api.delete("myimage"), "request-1");
+
+ assertSent(server, "DELETE", "/services/images/myimage");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void deleteWhenNotFound() throws Exception {
+ MockWebServer server = mockAzureManagementServer();
+ server.enqueue(new MockResponse().setResponseCode(404));
+
+ try {
+ OSImageApi api = api(server.getUrl("/")).getOSImageApi();
+
+ assertNull(api.delete("myimage"));
+
+ assertSent(server, "DELETE", "/services/images/myimage");
+ } finally {
+ server.shutdown();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/test/java/org/jclouds/azurecompute/features/VirtualMachineApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/VirtualMachineApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/VirtualMachineApiMockTest.java
index 7e3ce5a..41cce90 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/VirtualMachineApiMockTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/VirtualMachineApiMockTest.java
@@ -16,13 +16,14 @@
*/
package org.jclouds.azurecompute.features;
-import com.squareup.okhttp.mockwebserver.MockWebServer;
+import static org.assertj.core.api.Assertions.assertThat;
+
import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest;
import org.testng.annotations.Test;
-import static org.assertj.core.api.Assertions.assertThat;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
-@Test(groups = "unit", testName = "ApiMockTest")
+@Test(groups = "unit", testName = "VirtualMachineApiMockTest")
public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest {
public void start() throws Exception {
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiLiveTest.java
index 5e3fea4..a05d421 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiLiveTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiLiveTest.java
@@ -16,12 +16,13 @@
*/
package org.jclouds.azurecompute.internal;
+import static org.jclouds.azurecompute.config.AzureComputeProperties.SUBSCRIPTION_ID;
+
import java.util.Properties;
+
import org.jclouds.apis.BaseApiLiveTest;
import org.jclouds.azurecompute.AzureComputeApi;
-import static org.jclouds.azurecompute.config.AzureComputeProperties.SUBSCRIPTION_ID;
-
public class BaseAzureComputeApiLiveTest extends BaseApiLiveTest<AzureComputeApi> {
protected String subscriptionId;
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiMockTest.java
index 0ecba9d..e991331 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiMockTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiMockTest.java
@@ -16,23 +16,25 @@
*/
package org.jclouds.azurecompute.internal;
-import com.google.common.base.Throwables;
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.Module;
-import com.squareup.okhttp.mockwebserver.MockResponse;
-import com.squareup.okhttp.mockwebserver.MockWebServer;
-import com.squareup.okhttp.mockwebserver.RecordedRequest;
+import static com.google.common.base.Charsets.UTF_8;
+import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService;
+import static org.assertj.core.api.Assertions.assertThat;
+
import java.io.IOException;
import java.net.URL;
import java.util.Set;
+
import org.jclouds.ContextBuilder;
import org.jclouds.azurecompute.AzureComputeApi;
import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.util.Strings2;
-import static com.google.common.base.Charsets.UTF_8;
-import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService;
-import static org.assertj.core.api.Assertions.assertThat;
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Module;
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
+import com.squareup.okhttp.mockwebserver.RecordedRequest;
public class BaseAzureComputeApiMockTest {
private final Set<Module> modules = ImmutableSet
@@ -81,7 +83,7 @@ public class BaseAzureComputeApiMockTest {
RecordedRequest request = server.takeRequest();
assertThat(request.getMethod()).isEqualTo(method);
assertThat(request.getPath()).isEqualTo(path);
- assertThat(request.getHeader("x-ms-version")).isEqualTo("2012-03-01");
+ assertThat(request.getHeader("x-ms-version")).isEqualTo("2014-06-01");
assertThat(request.getHeader("Accept")).isEqualTo("application/xml");
return request;
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java
index 320c405..491653b 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java
@@ -24,7 +24,7 @@ import java.util.List;
import org.jclouds.azurecompute.domain.Disk;
import org.jclouds.azurecompute.domain.Disk.Attachment;
-import org.jclouds.azurecompute.domain.Image.OSType;
+import org.jclouds.azurecompute.domain.OSImage;
import org.jclouds.http.functions.BaseHandlerTest;
import org.testng.annotations.Test;
@@ -47,7 +47,7 @@ public class ListDisksHandlerTest extends BaseHandlerTest {
"West Europe", // location
null, // affinityGroup
null, //description
- OSType.LINUX, // os
+ OSImage.Type.LINUX, // os
URI.create("http://blobs/vhds/testimage2-testimage2-2012-08-17.vhd"), // mediaLink
30, // logicalSizeInGB
null, // attachedTo
@@ -57,7 +57,7 @@ public class ListDisksHandlerTest extends BaseHandlerTest {
"West Europe", // location
null, // affinityGroup
null, //description
- OSType.WINDOWS, // os
+ OSImage.Type.WINDOWS, // os
URI.create("http://blobs/disks/neotysss/MSFT__Win2K8R2SP1-ABCD-en-us-30GB.vhd"), // mediaLink
30, // logicalSizeInGB
Attachment.create("neotysss", "neotysss", "neotysss"), // attachedTo
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListImagesHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListImagesHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListImagesHandlerTest.java
deleted file mode 100644
index ffd3de3..0000000
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListImagesHandlerTest.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.jclouds.azurecompute.xml;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.InputStream;
-import java.net.URI;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import org.jclouds.azurecompute.domain.Image;
-import org.jclouds.azurecompute.domain.Image.OSType;
-import org.jclouds.http.functions.BaseHandlerTest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-
-@Test(groups = "unit", testName = "ListImagesHandlerTest")
-public class ListImagesHandlerTest extends BaseHandlerTest {
-
- public void test() {
- InputStream is = getClass().getResourceAsStream("/images.xml");
- List<Image> result = factory.create(new ListImagesHandler()).parse(is);
-
- assertEquals(result, expected());
- }
-
- public static List<Image> expected() {
- return ImmutableList.of( //
- Image.create( //
- "CANONICAL__Canonical-Ubuntu-12-04-amd64-server-20120528.1.3-en-us-30GB.vhd", // name
- null, // location
- null, // affinityGroup
- "Ubuntu Server 12.04 LTS", // label
- "Ubuntu Server 12.04 LTS amd64 20120528 Cloud Image", //description
- "Canonical", // category
- OSType.LINUX, // os
- null, // mediaLink
- 30, // logicalSizeInGB
- Arrays.asList("http://www.ubuntu.com/project/about-ubuntu/licensing") // eula
- ),
- Image.create( //
- "MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd", // name
- null, // location
- null, // affinityGroup
- "Windows Server 2008 R2 SP1, June 2012", // label
- "Windows Server 2008 R2 is a multi-purpose server.", //description
- "Microsoft", // category
- OSType.WINDOWS, // os
- URI.create("http://blobs/disks/mydeployment/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd"), // mediaLink
- 30, // logicalSizeInGB
- Collections.<String>emptyList() // eula
- ),
- Image.create( //
- "MSFT__Sql-Server-11EVAL-11.0.2215.0-05152012-en-us-30GB.vhd", // name
- null, // location
- null, // affinityGroup
- "Microsoft SQL Server 2012 Evaluation Edition", // label
- "SQL Server 2012 Evaluation Edition (64-bit).", //description
- "Microsoft", // category
- OSType.WINDOWS, // os
- null, // mediaLink
- 30, // logicalSizeInGB
- Arrays.asList("http://go.microsoft.com/fwlink/?LinkID=251820",
- "http://go.microsoft.com/fwlink/?LinkID=131004") // eula
- ),
- Image.create( //
- "MSFT__Win2K12RC-Datacenter-201207.02-en.us-30GB.vhd", // name
- null, // location
- null, // affinityGroup
- "Windows Server 2012 Release Candidate, July 2012", // label
- "Windows Server 2012 incorporates Microsoft's experience building.", //description
- "Microsoft", // category
- OSType.WINDOWS, // os
- null, // mediaLink
- 30, // logicalSizeInGB
- Collections.<String>emptyList() // eula
- ),
- Image.create( //
- "MSFT__Win2K8R2SP1-Datacenter-201207.01-en.us-30GB.vhd", // name
- null, // location
- null, // affinityGroup
- "Windows Server 2008 R2 SP1, July 2012", // label
- "Windows Server 2008 R2 is a multi-purpose server.", //description
- "Microsoft", // category
- OSType.WINDOWS, // os
- null, // mediaLink
- 30, // logicalSizeInGB
- Collections.<String>emptyList() // eula
- ),
- Image.create( //
- "OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd", // name
- null, // location
- null, // affinityGroup
- "OpenLogic CentOS 6.2", // label
- "This distribution of Linux is based on CentOS.", //description
- "OpenLogic", // category
- OSType.LINUX, // os
- URI.create("http://blobs/disks/mydeployment/OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd"), // mediaLink
- 30, // logicalSizeInGB
- Arrays.asList("http://www.openlogic.com/azure/service-agreement/") // eula
- ),
- Image.create( //
- "SUSE__openSUSE-12-1-20120603-en-us-30GB.vhd", // name
- null, // location
- null, // affinityGroup
- "openSUSE 12.1", // label
- "openSUSE is a free and Linux-based operating system!", //description
- "SUSE", // category
- OSType.LINUX, // os
- null, // mediaLink
- 30, // logicalSizeInGB
- Arrays.asList("http://opensuse.org/") // eula
- ),
- Image.create( //
- "SUSE__SUSE-Linux-Enterprise-Server-11SP2-20120601-en-us-30GB.vhd", // name
- null, // location
- null, // affinityGroup
- "SUSE Linux Enterprise Server", // label
- "SUSE Linux Enterprise Server is a highly reliable value.", //description
- "SUSE", // category
- OSType.LINUX, // os
- null, // mediaLink
- 30, // logicalSizeInGB
- Arrays.asList("http://www.novell.com/licensing/eula/") // eula
- ),
- Image.create( //
- "0b11de9248dd4d87b18621318e037d37__RightImage-CentOS-6.4-x64-v13.4", // name
- null, // location
- null, // affinityGroup
- "RightImage-CentOS-6.4-x64-v13.4", // label
- null, //description
- "RightScale with Linux", // category
- OSType.LINUX, // os
- null, // mediaLink
- 10, // logicalSizeInGB
- Collections.<String>emptyList() // No EULA, as RightScale stuffed ';' into the field.
- )
- );
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListOSImagesHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListOSImagesHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListOSImagesHandlerTest.java
new file mode 100644
index 0000000..3809440
--- /dev/null
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListOSImagesHandlerTest.java
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.jclouds.azurecompute.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.jclouds.azurecompute.domain.OSImage;
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+
+@Test(groups = "unit", testName = "ListImagesHandlerTest")
+public class ListOSImagesHandlerTest extends BaseHandlerTest {
+
+ public void test() {
+ InputStream is = getClass().getResourceAsStream("/images.xml");
+ List<OSImage> result = factory.create(new ListOSImagesHandler()).parse(is);
+
+ assertEquals(result, expected());
+ }
+
+ public static List<OSImage> expected() {
+ return ImmutableList.of( //
+ OSImage.create( //
+ "CANONICAL__Canonical-Ubuntu-12-04-amd64-server-20120528.1.3-en-us-30GB.vhd", // name
+ Collections.<String>emptyList(), // locations
+ null, // affinityGroup
+ "Ubuntu Server 12.04 LTS", // label
+ "Ubuntu Server 12.04 LTS amd64 20120528 Cloud Image", //description
+ "Canonical", // category
+ OSImage.Type.LINUX, // os
+ null, // mediaLink
+ 30, // logicalSizeInGB
+ Arrays.asList("http://www.ubuntu.com/project/about-ubuntu/licensing") // eula
+ ),
+ OSImage.create( //
+ "MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd", // name
+ Arrays.asList("East Asia", "Southeast Asia", "North Europe"), // locations
+ null, // affinityGroup
+ "Windows Server 2008 R2 SP1, June 2012", // label
+ "Windows Server 2008 R2 is a multi-purpose server.", //description
+ "Microsoft", // category
+ OSImage.Type.WINDOWS, // os
+ URI.create("http://blobs/disks/mydeployment/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd"),
+ // mediaLink
+ 30, // logicalSizeInGB
+ Collections.<String>emptyList() // eula
+ ),
+ OSImage.create( //
+ "MSFT__Sql-Server-11EVAL-11.0.2215.0-05152012-en-us-30GB.vhd", // name
+ Collections.<String>emptyList(), // locations
+ null, // affinityGroup
+ "Microsoft SQL Server 2012 Evaluation Edition", // label
+ "SQL Server 2012 Evaluation Edition (64-bit).", //description
+ "Microsoft", // category
+ OSImage.Type.WINDOWS, // os
+ null, // mediaLink
+ 30, // logicalSizeInGB
+ Arrays.asList("http://go.microsoft.com/fwlink/?LinkID=251820",
+ "http://go.microsoft.com/fwlink/?LinkID=131004") // eula
+ ),
+ OSImage.create( //
+ "MSFT__Win2K12RC-Datacenter-201207.02-en.us-30GB.vhd", // name
+ Collections.<String>emptyList(), // locations
+ null, // affinityGroup
+ "Windows Server 2012 Release Candidate, July 2012", // label
+ "Windows Server 2012 incorporates Microsoft's experience building.", //description
+ "Microsoft", // category
+ OSImage.Type.WINDOWS, // os
+ null, // mediaLink
+ 30, // logicalSizeInGB
+ Collections.<String>emptyList() // eula
+ ),
+ OSImage.create( //
+ "MSFT__Win2K8R2SP1-Datacenter-201207.01-en.us-30GB.vhd", // name
+ Collections.<String>emptyList(), // locations
+ null, // affinityGroup
+ "Windows Server 2008 R2 SP1, July 2012", // label
+ "Windows Server 2008 R2 is a multi-purpose server.", //description
+ "Microsoft", // category
+ OSImage.Type.WINDOWS, // os
+ null, // mediaLink
+ 30, // logicalSizeInGB
+ Collections.<String>emptyList() // eula
+ ),
+ OSImage.create( //
+ "OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd", // name
+ Collections.<String>emptyList(), // locations
+ null, // affinityGroup
+ "OpenLogic CentOS 6.2", // label
+ "This distribution of Linux is based on CentOS.", //description
+ "OpenLogic", // category
+ OSImage.Type.LINUX, // os
+ URI.create("http://blobs/disks/mydeployment/OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd"),
+ // mediaLink
+ 30, // logicalSizeInGB
+ Arrays.asList("http://www.openlogic.com/azure/service-agreement/") // eula
+ ),
+ OSImage.create( //
+ "SUSE__openSUSE-12-1-20120603-en-us-30GB.vhd", // name
+ Collections.<String>emptyList(), // locations
+ null, // affinityGroup
+ "openSUSE 12.1", // label
+ "openSUSE is a free and Linux-based operating system!", //description
+ "SUSE", // category
+ OSImage.Type.LINUX, // os
+ null, // mediaLink
+ 30, // logicalSizeInGB
+ Arrays.asList("http://opensuse.org/") // eula
+ ),
+ OSImage.create( //
+ "SUSE__SUSE-Linux-Enterprise-Server-11SP2-20120601-en-us-30GB.vhd", // name
+ Collections.<String>emptyList(), // locations
+ null, // affinityGroup
+ "SUSE Linux Enterprise Server", // label
+ "SUSE Linux Enterprise Server is a highly reliable value.", //description
+ "SUSE", // category
+ OSImage.Type.LINUX, // os
+ null, // mediaLink
+ 30, // logicalSizeInGB
+ Arrays.asList("http://www.novell.com/licensing/eula/") // eula
+ ),
+ OSImage.create( //
+ "0b11de9248dd4d87b18621318e037d37__RightImage-CentOS-6.4-x64-v13.4", // name
+ Collections.<String>emptyList(), // locations
+ null, // affinityGroup
+ "RightImage-CentOS-6.4-x64-v13.4", // label
+ null, //description
+ "RightScale with Linux", // category
+ OSImage.Type.LINUX, // os
+ null, // mediaLink
+ 10, // logicalSizeInGB
+ Collections.<String>emptyList() // No EULA, as RightScale stuffed ';' into the field.
+ )
+ );
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/test/resources/capturerolepayload.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/capturerolepayload.xml b/azurecompute/src/test/resources/capturerolepayload.xml
index 9414c52..36396ff 100644
--- a/azurecompute/src/test/resources/capturerolepayload.xml
+++ b/azurecompute/src/test/resources/capturerolepayload.xml
@@ -1 +1 @@
-<CaptureRoleOperation xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><OperationType>CaptureRoleOperation</OperationType><PostCaptureAction>Delete</PostCaptureAction><TargetImageLabel>myImageLabel</TargetImageLabel><TargetImageName>myImageName</TargetImageName></CaptureRoleOperation>
\ No newline at end of file
+<CaptureRoleOperation xmlns="http://schemas.microsoft.com/windowsazure"><OperationType>CaptureRoleOperation</OperationType><PostCaptureAction>Delete</PostCaptureAction><TargetImageLabel>myImageLabel</TargetImageLabel><TargetImageName>myImageName</TargetImageName></CaptureRoleOperation>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/test/resources/images.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/images.xml b/azurecompute/src/test/resources/images.xml
index 8c01393..e72370e 100644
--- a/azurecompute/src/test/resources/images.xml
+++ b/azurecompute/src/test/resources/images.xml
@@ -11,6 +11,7 @@
<OSImage>
<Category>Microsoft</Category>
<Label>Windows Server 2008 R2 SP1, June 2012</Label>
+ <Location>East Asia;Southeast Asia;North Europe</Location>
<LogicalSizeInGB>30</LogicalSizeInGB>
<Name>MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd</Name>
<MediaLink>http://blobs/disks/mydeployment/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd</MediaLink>
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/test/resources/restartrolepayload.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/restartrolepayload.xml b/azurecompute/src/test/resources/restartrolepayload.xml
index 4eca508..54ccf84 100644
--- a/azurecompute/src/test/resources/restartrolepayload.xml
+++ b/azurecompute/src/test/resources/restartrolepayload.xml
@@ -1 +1 @@
-<RestartRoleOperation xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><OperationType>RestartRoleOperation</OperationType></RestartRoleOperation>
\ No newline at end of file
+<RestartRoleOperation xmlns="http://schemas.microsoft.com/windowsazure"><OperationType>RestartRoleOperation</OperationType></RestartRoleOperation>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/test/resources/shutdownrolepayload.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/shutdownrolepayload.xml b/azurecompute/src/test/resources/shutdownrolepayload.xml
index 27beee8..5048ca3 100644
--- a/azurecompute/src/test/resources/shutdownrolepayload.xml
+++ b/azurecompute/src/test/resources/shutdownrolepayload.xml
@@ -1 +1 @@
-<ShutdownRoleOperation xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><OperationType>ShutdownRoleOperation</OperationType></ShutdownRoleOperation>
\ No newline at end of file
+<ShutdownRoleOperation xmlns="http://schemas.microsoft.com/windowsazure"><OperationType>ShutdownRoleOperation</OperationType></ShutdownRoleOperation>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/test/resources/startrolepayload.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/startrolepayload.xml b/azurecompute/src/test/resources/startrolepayload.xml
index 4e82022..6b6d7a3 100644
--- a/azurecompute/src/test/resources/startrolepayload.xml
+++ b/azurecompute/src/test/resources/startrolepayload.xml
@@ -1 +1 @@
-<StartRoleOperation xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><OperationType>StartRoleOperation</OperationType></StartRoleOperation>
\ No newline at end of file
+<StartRoleOperation xmlns="http://schemas.microsoft.com/windowsazure"><OperationType>StartRoleOperation</OperationType></StartRoleOperation>
\ No newline at end of file
[3/3] git commit: In latest Azure api,
there are both OS images and Disk images.
Posted by ad...@apache.org.
In latest Azure api, there are both OS images and Disk images.
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/7f307e85
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/7f307e85
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/7f307e85
Branch: refs/heads/master
Commit: 7f307e85982383202bf8b53a8ae18e14bc52207e
Parents: 3b4c652
Author: Adrian Cole <ac...@twitter.com>
Authored: Wed Oct 22 21:03:10 2014 -0700
Committer: Adrian Cole <ad...@apache.org>
Committed: Thu Oct 23 21:05:09 2014 -0700
----------------------------------------------------------------------
.../jclouds/azurecompute/AzureComputeApi.java | 5 +-
.../AzureComputeProviderMetadata.java | 5 +-
.../AzureManagementApiMetadata.java | 8 +-
.../binders/DeploymentParamsToXML.java | 8 +-
.../azurecompute/binders/ImageParamsToXML.java | 43 -----
.../binders/OSImageParamsToXML.java | 43 +++++
.../compute/AzureComputeServiceAdapter.java | 9 +-
.../AzureComputeServiceContextModule.java | 17 +-
.../compute/functions/AzureImageToImage.java | 29 ---
.../functions/DeploymentToNodeMetadata.java | 3 +-
.../compute/functions/OSImageToImage.java | 30 +++
.../compute/functions/RoleSizeToHardware.java | 3 +-
.../config/AzureComputeHttpApiModule.java | 7 +-
.../azurecompute/domain/DeploymentParams.java | 20 +-
.../org/jclouds/azurecompute/domain/Disk.java | 9 +-
.../org/jclouds/azurecompute/domain/Image.java | 183 -------------------
.../azurecompute/domain/ImageParams.java | 141 --------------
.../jclouds/azurecompute/domain/OSImage.java | 176 ++++++++++++++++++
.../azurecompute/domain/OSImageParams.java | 139 ++++++++++++++
.../jclouds/azurecompute/features/DiskApi.java | 8 +-
.../jclouds/azurecompute/features/ImageApi.java | 101 ----------
.../azurecompute/features/LocationApi.java | 6 +-
.../azurecompute/features/OSImageApi.java | 101 ++++++++++
.../azurecompute/features/OperationApi.java | 5 +-
.../features/VirtualMachineApi.java | 9 +-
.../azurecompute/functions/ImageParamsName.java | 27 ---
.../functions/OSImageParamsName.java | 27 +++
.../functions/ParseRequestIdHeader.java | 6 +-
.../suppliers/KeyStoreSupplier.java | 13 +-
.../suppliers/SSLContextWithKeysSupplier.java | 9 +-
.../jclouds/azurecompute/xml/DiskHandler.java | 6 +-
.../jclouds/azurecompute/xml/ImageHandler.java | 109 -----------
.../azurecompute/xml/ListImagesHandler.java | 61 -------
.../azurecompute/xml/ListOSImagesHandler.java | 61 +++++++
.../azurecompute/xml/OSImageHandler.java | 113 ++++++++++++
.../features/DeploymentApiMockTest.java | 12 +-
.../azurecompute/features/DiskApiLiveTest.java | 6 +-
.../azurecompute/features/ImageApiLiveTest.java | 84 ---------
.../azurecompute/features/ImageApiMockTest.java | 132 -------------
.../features/LocationApiMockTest.java | 7 +-
.../features/OSImageApiLiveTest.java | 83 +++++++++
.../features/OSImageApiMockTest.java | 132 +++++++++++++
.../features/VirtualMachineApiMockTest.java | 7 +-
.../internal/BaseAzureComputeApiLiveTest.java | 5 +-
.../internal/BaseAzureComputeApiMockTest.java | 22 ++-
.../azurecompute/xml/ListDisksHandlerTest.java | 6 +-
.../azurecompute/xml/ListImagesHandlerTest.java | 157 ----------------
.../xml/ListOSImagesHandlerTest.java | 158 ++++++++++++++++
.../src/test/resources/capturerolepayload.xml | 2 +-
azurecompute/src/test/resources/images.xml | 1 +
.../src/test/resources/restartrolepayload.xml | 2 +-
.../src/test/resources/shutdownrolepayload.xml | 2 +-
.../src/test/resources/startrolepayload.xml | 2 +-
53 files changed, 1192 insertions(+), 1168 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeApi.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeApi.java
index ec037a3..5946838 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeApi.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeApi.java
@@ -17,13 +17,14 @@
package org.jclouds.azurecompute;
import java.io.Closeable;
+
import javax.ws.rs.PathParam;
import org.jclouds.azurecompute.features.CloudServiceApi;
import org.jclouds.azurecompute.features.DeploymentApi;
import org.jclouds.azurecompute.features.DiskApi;
-import org.jclouds.azurecompute.features.ImageApi;
import org.jclouds.azurecompute.features.LocationApi;
+import org.jclouds.azurecompute.features.OSImageApi;
import org.jclouds.azurecompute.features.OperationApi;
import org.jclouds.azurecompute.features.VirtualMachineApi;
import org.jclouds.rest.annotations.Delegate;
@@ -81,7 +82,7 @@ public interface AzureComputeApi extends Closeable {
* @see <a href="http://msdn.microsoft.com/en-us/library/jj157175">docs</a>
*/
@Delegate
- ImageApi getImageApi();
+ OSImageApi getOSImageApi();
/**
* The Service Management API includes operations for Tracking Asynchronous Service Management
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeProviderMetadata.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeProviderMetadata.java b/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeProviderMetadata.java
index 8fcb560..9c811ce 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeProviderMetadata.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeProviderMetadata.java
@@ -16,13 +16,14 @@
*/
package org.jclouds.azurecompute;
+import static org.jclouds.azurecompute.config.AzureComputeProperties.SUBSCRIPTION_ID;
+
import java.net.URI;
import java.util.Properties;
+
import org.jclouds.providers.ProviderMetadata;
import org.jclouds.providers.internal.BaseProviderMetadata;
-import static org.jclouds.azurecompute.config.AzureComputeProperties.SUBSCRIPTION_ID;
-
/**
* Implementation of {@link ProviderMetadata} for Microsoft Azure Service Management Service.
*/
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/AzureManagementApiMetadata.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/AzureManagementApiMetadata.java b/azurecompute/src/main/java/org/jclouds/azurecompute/AzureManagementApiMetadata.java
index 762261c..0caad94 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/AzureManagementApiMetadata.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/AzureManagementApiMetadata.java
@@ -16,16 +16,18 @@
*/
package org.jclouds.azurecompute;
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.Module;
+import static org.jclouds.azurecompute.config.AzureComputeProperties.SUBSCRIPTION_ID;
+
import java.net.URI;
import java.util.Properties;
+
import org.jclouds.apis.ApiMetadata;
import org.jclouds.azurecompute.compute.config.AzureComputeServiceContextModule;
import org.jclouds.azurecompute.config.AzureComputeHttpApiModule;
import org.jclouds.rest.internal.BaseHttpApiMetadata;
-import static org.jclouds.azurecompute.config.AzureComputeProperties.SUBSCRIPTION_ID;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Module;
/**
* Implementation of {@link ApiMetadata} for Microsoft Service Management Service API
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/binders/DeploymentParamsToXML.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/DeploymentParamsToXML.java b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/DeploymentParamsToXML.java
index c493c90..26301d6 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/DeploymentParamsToXML.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/DeploymentParamsToXML.java
@@ -19,10 +19,10 @@ package org.jclouds.azurecompute.binders;
import static com.google.common.base.CaseFormat.UPPER_CAMEL;
import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
import static com.google.common.base.Throwables.propagate;
-import static org.jclouds.azurecompute.domain.Image.OSType.LINUX;
+import static org.jclouds.azurecompute.domain.OSImage.Type.LINUX;
import org.jclouds.azurecompute.domain.DeploymentParams;
-import org.jclouds.azurecompute.domain.Image.OSType;
+import org.jclouds.azurecompute.domain.OSImage;
import org.jclouds.http.HttpRequest;
import org.jclouds.rest.Binder;
@@ -44,7 +44,7 @@ public final class DeploymentParamsToXML implements Binder {
.e("RoleType").t("PersistentVMRole").up()
.e("ConfigurationSets");
- if (params.os() == OSType.WINDOWS) {
+ if (params.os() == OSImage.Type.WINDOWS) {
XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Windows
configBuilder.e("ConfigurationSetType").t("WindowsProvisioningConfiguration").up()
.e("ComputerName").t(params.name()).up()
@@ -61,7 +61,7 @@ public final class DeploymentParamsToXML implements Binder {
.up() // Domain Join
.e("StoredCertificateSettings").up()
.up(); // Windows ConfigurationSet
- } else if (params.os() == OSType.LINUX) {
+ } else if (params.os() == OSImage.Type.LINUX) {
XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Linux
configBuilder.e("ConfigurationSetType").t("LinuxProvisioningConfiguration").up()
.e("HostName").t(params.name()).up()
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/binders/ImageParamsToXML.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/ImageParamsToXML.java b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/ImageParamsToXML.java
deleted file mode 100644
index 040184b..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/ImageParamsToXML.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.jclouds.azurecompute.binders;
-
-import static com.google.common.base.Throwables.propagate;
-import static org.jclouds.azurecompute.domain.Image.OSType.LINUX;
-
-import org.jclouds.azurecompute.domain.ImageParams;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.rest.Binder;
-
-import com.jamesmurty.utils.XMLBuilder;
-
-public final class ImageParamsToXML implements Binder {
- @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) {
- ImageParams params = ImageParams.class.cast(input);
- try {
- String xml = XMLBuilder.create("OSImage", "http://schemas.microsoft.com/windowsazure")
- .e("Label").t(params.label()).up()
- .e("MediaLink").t(params.mediaLink().toASCIIString()).up()
- .e("Name").t(params.name()).up()
- .e("OS").t(params.os() == LINUX ? "Linux" : "Windows").up()
- .up().asString();
- return (R) request.toBuilder().payload(xml).build();
- } catch (Exception e) {
- throw propagate(e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/binders/OSImageParamsToXML.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/OSImageParamsToXML.java b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/OSImageParamsToXML.java
new file mode 100644
index 0000000..3d87c8f
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/OSImageParamsToXML.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.jclouds.azurecompute.binders;
+
+import static com.google.common.base.Throwables.propagate;
+import static org.jclouds.azurecompute.domain.OSImage.Type.LINUX;
+
+import org.jclouds.azurecompute.domain.OSImageParams;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.Binder;
+
+import com.jamesmurty.utils.XMLBuilder;
+
+public final class OSImageParamsToXML implements Binder {
+ @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ OSImageParams params = OSImageParams.class.cast(input);
+ try {
+ String xml = XMLBuilder.create("OSImage", "http://schemas.microsoft.com/windowsazure")
+ .e("Label").t(params.label()).up()
+ .e("MediaLink").t(params.mediaLink().toASCIIString()).up()
+ .e("Name").t(params.name()).up()
+ .e("OS").t(params.os() == LINUX ? "Linux" : "Windows").up()
+ .up().asString();
+ return (R) request.toBuilder().payload(xml).build();
+ } catch (Exception e) {
+ throw propagate(e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/compute/AzureComputeServiceAdapter.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/AzureComputeServiceAdapter.java b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/AzureComputeServiceAdapter.java
index 4ce0ee4..9663a75 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/AzureComputeServiceAdapter.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/AzureComputeServiceAdapter.java
@@ -17,9 +17,10 @@
package org.jclouds.azurecompute.compute;
import javax.inject.Singleton;
+
import org.jclouds.azurecompute.AzureComputeApi;
import org.jclouds.azurecompute.domain.Deployment;
-import org.jclouds.azurecompute.domain.Image;
+import org.jclouds.azurecompute.domain.OSImage;
import org.jclouds.azurecompute.domain.RoleSize;
import org.jclouds.compute.ComputeServiceAdapter;
import org.jclouds.compute.domain.Template;
@@ -29,7 +30,7 @@ import org.jclouds.compute.domain.Template;
* jclouds {@link org.jclouds.compute.ComputeService}
*/
@Singleton
-public class AzureComputeServiceAdapter implements ComputeServiceAdapter<Deployment, RoleSize, Image, String> {
+public class AzureComputeServiceAdapter implements ComputeServiceAdapter<Deployment, RoleSize, OSImage, String> {
@Override
public NodeAndInitialCredentials<Deployment> createNodeWithGroupEncodedIntoName(
@@ -45,13 +46,13 @@ public class AzureComputeServiceAdapter implements ComputeServiceAdapter<Deploym
}
@Override
- public Iterable<Image> listImages() {
+ public Iterable<OSImage> listImages() {
// TODO Auto-generated method stub
return null;
}
@Override
- public Image getImage(String id) {
+ public OSImage getImage(String id) {
// TODO Auto-generated method stub
return null;
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/compute/config/AzureComputeServiceContextModule.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/config/AzureComputeServiceContextModule.java b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/config/AzureComputeServiceContextModule.java
index 2edd8a0..b09b867 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/config/AzureComputeServiceContextModule.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/config/AzureComputeServiceContextModule.java
@@ -16,30 +16,31 @@
*/
package org.jclouds.azurecompute.compute.config;
-import com.google.common.base.Function;
-import com.google.inject.TypeLiteral;
import org.jclouds.azurecompute.compute.AzureComputeServiceAdapter;
-import org.jclouds.azurecompute.compute.functions.AzureImageToImage;
import org.jclouds.azurecompute.compute.functions.DeploymentToNodeMetadata;
+import org.jclouds.azurecompute.compute.functions.OSImageToImage;
import org.jclouds.azurecompute.compute.functions.RoleSizeToHardware;
import org.jclouds.azurecompute.domain.Deployment;
-import org.jclouds.azurecompute.domain.Image;
+import org.jclouds.azurecompute.domain.OSImage;
import org.jclouds.azurecompute.domain.RoleSize;
import org.jclouds.compute.ComputeServiceAdapter;
import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.NodeMetadata;
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+
public class AzureComputeServiceContextModule
- extends ComputeServiceAdapterContextModule<Deployment, RoleSize, Image, String> {
+ extends ComputeServiceAdapterContextModule<Deployment, RoleSize, OSImage, String> {
@Override
protected void configure() {
super.configure();
- bind(new TypeLiteral<ComputeServiceAdapter<Deployment, RoleSize, Image, String>>() {
+ bind(new TypeLiteral<ComputeServiceAdapter<Deployment, RoleSize, OSImage, String>>() {
}).to(AzureComputeServiceAdapter.class);
- bind(new TypeLiteral<Function<Image, org.jclouds.compute.domain.Image>>() {
- }).to(AzureImageToImage.class);
+ bind(new TypeLiteral<Function<OSImage, org.jclouds.compute.domain.Image>>() {
+ }).to(OSImageToImage.class);
bind(new TypeLiteral<Function<RoleSize, Hardware>>() {
}).to(RoleSizeToHardware.class);
bind(new TypeLiteral<Function<Deployment, NodeMetadata>>() {
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/AzureImageToImage.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/AzureImageToImage.java b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/AzureImageToImage.java
deleted file mode 100644
index 4da1c34..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/AzureImageToImage.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.jclouds.azurecompute.compute.functions;
-
-import com.google.common.base.Function;
-import org.jclouds.azurecompute.domain.Image;
-
-public class AzureImageToImage implements Function<Image, org.jclouds.compute.domain.Image> {
-
- @Override
- public org.jclouds.compute.domain.Image apply(Image input) {
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/DeploymentToNodeMetadata.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/DeploymentToNodeMetadata.java b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/DeploymentToNodeMetadata.java
index 7e02ee6..127ea02 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/DeploymentToNodeMetadata.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/DeploymentToNodeMetadata.java
@@ -16,10 +16,11 @@
*/
package org.jclouds.azurecompute.compute.functions;
-import com.google.common.base.Function;
import org.jclouds.azurecompute.domain.Deployment;
import org.jclouds.compute.domain.NodeMetadata;
+import com.google.common.base.Function;
+
public class DeploymentToNodeMetadata implements Function<Deployment, NodeMetadata> {
@Override
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/OSImageToImage.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/OSImageToImage.java b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/OSImageToImage.java
new file mode 100644
index 0000000..9cd1e70
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/OSImageToImage.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.jclouds.azurecompute.compute.functions;
+
+import org.jclouds.azurecompute.domain.OSImage;
+import org.jclouds.compute.domain.Image;
+
+import com.google.common.base.Function;
+
+public class OSImageToImage implements Function<OSImage, Image> {
+
+ @Override
+ public Image apply(OSImage input) {
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/RoleSizeToHardware.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/RoleSizeToHardware.java b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/RoleSizeToHardware.java
index 09dbf78..97a9b2c 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/RoleSizeToHardware.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/RoleSizeToHardware.java
@@ -16,10 +16,11 @@
*/
package org.jclouds.azurecompute.compute.functions;
-import com.google.common.base.Function;
import org.jclouds.azurecompute.domain.RoleSize;
import org.jclouds.compute.domain.Hardware;
+import com.google.common.base.Function;
+
public class RoleSizeToHardware implements Function<RoleSize, Hardware> {
@Override
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeHttpApiModule.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeHttpApiModule.java b/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeHttpApiModule.java
index 8c85c0a..2d07471 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeHttpApiModule.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeHttpApiModule.java
@@ -16,16 +16,19 @@
*/
package org.jclouds.azurecompute.config;
-import com.google.common.base.Supplier;
-import com.google.inject.TypeLiteral;
import java.security.KeyStore;
+
import javax.net.ssl.SSLContext;
+
import org.jclouds.azurecompute.AzureComputeApi;
import org.jclouds.azurecompute.suppliers.KeyStoreSupplier;
import org.jclouds.azurecompute.suppliers.SSLContextWithKeysSupplier;
import org.jclouds.rest.ConfiguresHttpApi;
import org.jclouds.rest.config.HttpApiModule;
+import com.google.common.base.Supplier;
+import com.google.inject.TypeLiteral;
+
@ConfiguresHttpApi
public class AzureComputeHttpApiModule extends HttpApiModule<AzureComputeApi> {
@Override
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
index ac06305..e75fa19 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java
@@ -24,8 +24,6 @@ import java.net.URI;
import java.util.Collection;
import java.util.List;
-import org.jclouds.azurecompute.domain.Image.OSType;
-
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
@@ -134,18 +132,18 @@ public final class DeploymentParams {
return password;
}
- /** {@link Image#name() name} of the user or platform image. */
+ /** {@link OSImage#name() name} of the user or platform image. */
public String sourceImageName() {
return sourceImageName;
}
- /** Indicates the {@link Image#mediaLink() location} when {@link #sourceImageName() source} is a platform image. */
+ /** Indicates the {@link OSImage#mediaLink() location} when {@link #sourceImageName() source} is a platform image. */
public URI mediaLink() {
return mediaLink;
}
- /** {@link Image#os() Os type} of the {@link #sourceImageName() source image}. */
- public OSType os() {
+ /** {@link OSImage#os() Os type} of the {@link #sourceImageName() source image}. */
+ public OSImage.Type os() {
return os;
}
@@ -168,7 +166,7 @@ public final class DeploymentParams {
private String password;
private String sourceImageName;
private URI mediaLink;
- private OSType os;
+ private OSImage.Type os;
private List<ExternalEndpoint> externalEndpoints = Lists.newArrayList();
public Builder name(String name) {
@@ -201,7 +199,7 @@ public final class DeploymentParams {
return this;
}
- public Builder os(OSType os) {
+ public Builder os(OSImage.Type os) {
this.os = os;
return this;
}
@@ -234,13 +232,13 @@ public final class DeploymentParams {
}
private static DeploymentParams create(String name, RoleSize size, String username, String password, String sourceImageName,
- URI mediaLink, OSType os, List<ExternalEndpoint> externalEndpoints) {
+ URI mediaLink, OSImage.Type os, List<ExternalEndpoint> externalEndpoints) {
return new DeploymentParams(name, size, username, password, sourceImageName, mediaLink, os, externalEndpoints);
}
// TODO: Remove from here down with @AutoValue.
private DeploymentParams(String name, RoleSize size, String username, String password, String sourceImageName, URI mediaLink,
- OSType os, List<ExternalEndpoint> externalEndpoints) {
+ OSImage.Type os, List<ExternalEndpoint> externalEndpoints) {
this.name = checkNotNull(name, "name");
this.size = checkNotNull(size, "size");
this.username = checkNotNull(username, "username");
@@ -257,7 +255,7 @@ public final class DeploymentParams {
private final String password;
private final String sourceImageName;
private final URI mediaLink;
- private final OSType os;
+ private final OSImage.Type os;
private final List<ExternalEndpoint> externalEndpoints;
@Override public int hashCode() {
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java
index 07ebf56..888e9af 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java
@@ -22,7 +22,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
-import org.jclouds.azurecompute.domain.Image.OSType;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
@@ -126,7 +125,7 @@ public final class Disk {
}
/** The operating system type of the OS image, or null if a data disk. */
- @Nullable public OSType os() {
+ @Nullable public OSImage.Type os() {
return os;
}
@@ -165,13 +164,13 @@ public final class Disk {
}
public static Disk create(String name, String location, String affinityGroup, String description,
- OSType os, URI mediaLink, Integer logicalSizeInGB, Attachment attachedTo, String sourceImage) {
+ OSImage.Type os, URI mediaLink, Integer logicalSizeInGB, Attachment attachedTo, String sourceImage) {
return new Disk(name, location, affinityGroup, description, os, mediaLink, logicalSizeInGB, attachedTo,
sourceImage);
}
// TODO: Remove from here down with @AutoValue.
- private Disk(String name, String location, String affinityGroup, String description, OSType os, URI mediaLink,
+ private Disk(String name, String location, String affinityGroup, String description, OSImage.Type os, URI mediaLink,
Integer logicalSizeInGB, Attachment attachedTo, String sourceImage) {
this.name = checkNotNull(name, "name");
this.location = location;
@@ -188,7 +187,7 @@ public final class Disk {
private final String location;
private final String affinityGroup;
private final String description;
- private final OSType os;
+ private final OSImage.Type os;
private final URI mediaLink;
private final Integer logicalSizeInGB;
private final Attachment attachedTo;
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Image.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Image.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Image.java
deleted file mode 100644
index d533c41..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Image.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.jclouds.azurecompute.domain;
-
-import static com.google.common.base.Objects.equal;
-import static com.google.common.base.Objects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.net.URI;
-import java.util.List;
-
-import org.jclouds.javax.annotation.Nullable;
-
-import com.google.common.base.Objects;
-
-/**
- * OS image from the image repository
- *
- * @see <a href="http://msdn.microsoft.com/en-us/library/jj157191" >api</a>
- */
-public final class Image {
- public enum OSType {
- LINUX, WINDOWS;
- }
-
- public String name() {
- return name;
- }
-
- /**
- * The geo-location of the image in Windows Azure, if the image is not
- * associated with an affinity group. If a location has been specified, the AffinityGroup element
- * is not returned.
- */
- @Nullable public String location() {
- return location;
- }
-
- /**
- * The affinity group with which this image is associated, if any. If the service is
- * associated with an affinity group, the Location element is not returned.
- */
- @Nullable public String affinityGroup() {
- return affinityGroup;
- }
-
- /**
- * The name can be up to 100 characters in length. The name can be used identify the storage account for your
- * tracking purposes.
- */
- public String label() {
- return label;
- }
-
- @Nullable public String description() {
- return description;
- }
-
- /**
- * The repository classification of image. All user images have the category "User", but
- * categories for other images could be, for example "Canonical"
- */
- @Nullable public String category() {
- return category;
- }
-
- /** The operating system type of the OS image. */
- public OSType os() {
- return os;
- }
-
- /**
- * The location of the blob in the blob store in which the media for the image is located. The
- * blob location belongs to a storage account in the subscription specified by the
- * <subscription-id> value in the operation call.
- *
- * Example:
- *
- * http://example.blob.core.windows.net/disks/myimage.vhd
- */
- @Nullable public URI mediaLink() {
- return mediaLink;
- }
-
- public int logicalSizeInGB() {
- return logicalSizeInGB;
- }
-
- /** The eulas for the image, if available. */
- // Not URI as some providers put non-uri data in, such as riverbed.
- public List<String> eula() {
- return eula;
- }
-
- public static Image create(String name, String location, String affinityGroup, String label, String description,
- String category, OSType os, URI mediaLink, int logicalSizeInGB, List<String> eula) {
- return new Image(name, location, affinityGroup, label, description, category, os, mediaLink, logicalSizeInGB,
- eula);
- }
-
- // TODO: Remove from here down with @AutoValue.
- private Image(String name, String location, String affinityGroup, String label, String description, String category,
- OSType os, URI mediaLink, int logicalSizeInGB, List<String> eula) {
- this.name = checkNotNull(name, "name");
- this.location = location;
- this.affinityGroup = affinityGroup;
- this.label = checkNotNull(label, "label");
- this.description = description;
- this.category = category;
- this.os = checkNotNull(os, "os");
- this.mediaLink = mediaLink;
- this.logicalSizeInGB = logicalSizeInGB;
- this.eula = checkNotNull(eula, "eula");
- }
-
- private final String name;
- private final String location;
- private final String affinityGroup;
- private final String label;
- private final String category;
- private final String description;
- private final OSType os;
- private final URI mediaLink;
- private final int logicalSizeInGB;
- private final List<String> eula;
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof Image) {
- Image that = Image.class.cast(object);
- return equal(name, that.name)
- && equal(location, that.location)
- && equal(affinityGroup, that.affinityGroup)
- && equal(label, that.label)
- && equal(description, that.description)
- && equal(category, that.category)
- && equal(os, that.os)
- && equal(mediaLink, that.mediaLink)
- && equal(logicalSizeInGB, that.logicalSizeInGB)
- && equal(eula, that.eula);
- } else {
- return false;
- }
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(name, location, affinityGroup, label, description, category, os, mediaLink,
- logicalSizeInGB, eula);
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add("name", name)
- .add("location", location)
- .add("affinityGroup", affinityGroup)
- .add("label", label)
- .add("description", description)
- .add("category", category)
- .add("os", os)
- .add("mediaLink", mediaLink)
- .add("logicalSizeInGB", logicalSizeInGB)
- .add("eula", eula).toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ImageParams.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ImageParams.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ImageParams.java
deleted file mode 100644
index ed72936..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ImageParams.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.jclouds.azurecompute.domain;
-
-import static com.google.common.base.Objects.equal;
-import static com.google.common.base.Objects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.net.URI;
-
-import org.jclouds.azurecompute.domain.Image.OSType;
-
-import com.google.common.base.Objects;
-
-/** To create a new operating system image. */
-public final class ImageParams {
-
- /** Specifies a name that is used to identify the image when you create a Virtual Machine. */
- public String name() {
- return name;
- }
-
- /** Specifies the friendly name of the image. */
- public String label() {
- return label;
- }
-
- /** Specifies the location of the vhd file for the image. */
- public URI mediaLink() {
- return mediaLink;
- }
-
- /** {@link Image#os() Os type} of the image. */
- public OSType os() {
- return os;
- }
-
- public Builder toBuilder() {
- return builder().fromImageParams(this);
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static final class Builder {
- private String name;
- private String label;
- private URI mediaLink;
- private OSType os;
-
- public Builder name(String name) {
- this.name = name;
- return this;
- }
-
- public Builder label(String label) {
- this.label = label;
- return this;
- }
-
- public Builder mediaLink(URI mediaLink) {
- this.mediaLink = mediaLink;
- return this;
- }
-
- public Builder os(OSType os) {
- this.os = os;
- return this;
- }
-
- public ImageParams build() {
- return ImageParams.create(name, label, mediaLink, os);
- }
-
- public Builder fromImageParams(ImageParams in) {
- return name(in.name())
- .label(in.label())
- .mediaLink(in.mediaLink())
- .os(in.os());
- }
- }
-
- private static ImageParams create(String name, String label, URI mediaLink, OSType os) {
- return new ImageParams(name, label, mediaLink, os);
- }
-
- // TODO: Remove from here down with @AutoValue.
- private ImageParams(String name, String label, URI mediaLink, OSType os) {
- this.name = checkNotNull(name, "name");
- this.label = checkNotNull(label, "label");
- this.mediaLink = checkNotNull(mediaLink, "mediaLink");
- this.os = checkNotNull(os, "os");
- }
-
- private final String name;
- private final String label;
- private final URI mediaLink;
- private final OSType os;
-
- @Override public int hashCode() {
- return Objects.hashCode(name, label, mediaLink, os);
- }
-
- @Override public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof ImageParams) {
- ImageParams that = ImageParams.class.cast(object);
- return equal(name, that.name)
- && equal(label, that.label)
- && equal(mediaLink, that.mediaLink)
- && equal(os, that.os);
- } else {
- return false;
- }
- }
-
- @Override public String toString() {
- return toStringHelper(this)
- .add("name", name)
- .add("label", label)
- .add("mediaLink", mediaLink)
- .add("os", os).toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSImage.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSImage.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSImage.java
new file mode 100644
index 0000000..5d1947c
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSImage.java
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.jclouds.azurecompute.domain;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.List;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+
+/**
+ * OS image from the image repository
+ *
+ * @see <a href="http://msdn.microsoft.com/en-us/library/jj157191" >api</a>
+ */
+public final class OSImage {
+ public enum Type {
+ LINUX, WINDOWS;
+ }
+
+ public String name() {
+ return name;
+ }
+
+ /** The geo-locations of the image, if the image is not associated with an affinity group. */
+ public List<String> locations() {
+ return locations;
+ }
+
+ /** The affinity group with which this image is associated, if any. */
+ @Nullable public String affinityGroup() {
+ return affinityGroup;
+ }
+
+ /**
+ * The name can be up to 100 characters in length. The name can be used identify the storage account for your
+ * tracking purposes.
+ */
+ public String label() {
+ return label;
+ }
+
+ @Nullable public String description() {
+ return description;
+ }
+
+ /**
+ * The repository classification of image. All user images have the category "User", but
+ * categories for other images could be, for example "Canonical"
+ */
+ @Nullable public String category() {
+ return category;
+ }
+
+ /** The operating system type of the OS image. */
+ public Type os() {
+ return os;
+ }
+
+ /**
+ * The locations of the blob in the blob store in which the media for the image is located. The
+ * blob locations belongs to a storage account in the subscription specified by the
+ * <subscription-id> value in the operation call.
+ *
+ * Example:
+ *
+ * http://example.blob.core.windows.net/disks/myimage.vhd
+ */
+ @Nullable public URI mediaLink() {
+ return mediaLink;
+ }
+
+ public int logicalSizeInGB() {
+ return logicalSizeInGB;
+ }
+
+ /** The eulas for the image, if available. */
+ // Not URI as some providers put non-uri data in, such as riverbed.
+ public List<String> eula() {
+ return eula;
+ }
+
+ public static OSImage create(String name, List<String> locations, String affinityGroup, String label,
+ String description, String category, Type os, URI mediaLink, int logicalSizeInGB, List<String> eula) {
+ return new OSImage(name, locations, affinityGroup, label, description, category, os, mediaLink, logicalSizeInGB,
+ eula);
+ }
+
+ // TODO: Remove from here down with @AutoValue.
+ private OSImage(String name, List<String> locations, String affinityGroup, String label, String description,
+ String category, Type os, URI mediaLink, int logicalSizeInGB, List<String> eula) {
+ this.name = checkNotNull(name, "name");
+ this.locations = locations;
+ this.affinityGroup = affinityGroup;
+ this.label = checkNotNull(label, "label");
+ this.description = description;
+ this.category = category;
+ this.os = checkNotNull(os, "os");
+ this.mediaLink = mediaLink;
+ this.logicalSizeInGB = logicalSizeInGB;
+ this.eula = checkNotNull(eula, "eula");
+ }
+
+ private final String name;
+ private final List<String> locations;
+ private final String affinityGroup;
+ private final String label;
+ private final String category;
+ private final String description;
+ private final Type os;
+ private final URI mediaLink;
+ private final int logicalSizeInGB;
+ private final List<String> eula;
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof OSImage) {
+ OSImage that = OSImage.class.cast(object);
+ return equal(name, that.name)
+ && equal(locations, that.locations)
+ && equal(affinityGroup, that.affinityGroup)
+ && equal(label, that.label)
+ && equal(description, that.description)
+ && equal(category, that.category)
+ && equal(os, that.os)
+ && equal(mediaLink, that.mediaLink)
+ && equal(logicalSizeInGB, that.logicalSizeInGB)
+ && equal(eula, that.eula);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(name, locations, affinityGroup, label, description, category, os, mediaLink,
+ logicalSizeInGB, eula);
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("name", name)
+ .add("locations", locations)
+ .add("affinityGroup", affinityGroup)
+ .add("label", label)
+ .add("description", description)
+ .add("category", category)
+ .add("os", os)
+ .add("mediaLink", mediaLink)
+ .add("logicalSizeInGB", logicalSizeInGB)
+ .add("eula", eula).toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSImageParams.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSImageParams.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSImageParams.java
new file mode 100644
index 0000000..8f3c237
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSImageParams.java
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.jclouds.azurecompute.domain;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+
+import com.google.common.base.Objects;
+
+/** To create a new operating system image. */
+public final class OSImageParams {
+
+ /** Specifies a name that is used to identify the image when you create a Virtual Machine. */
+ public String name() {
+ return name;
+ }
+
+ /** Specifies the friendly name of the image. */
+ public String label() {
+ return label;
+ }
+
+ /** Specifies the location of the vhd file for the image. */
+ public URI mediaLink() {
+ return mediaLink;
+ }
+
+ /** {@link OSImage#os() Os type} of the image. */
+ public OSImage.Type os() {
+ return os;
+ }
+
+ public Builder toBuilder() {
+ return builder().fromImageParams(this);
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static final class Builder {
+ private String name;
+ private String label;
+ private URI mediaLink;
+ private OSImage.Type os;
+
+ public Builder name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ public Builder label(String label) {
+ this.label = label;
+ return this;
+ }
+
+ public Builder mediaLink(URI mediaLink) {
+ this.mediaLink = mediaLink;
+ return this;
+ }
+
+ public Builder os(OSImage.Type os) {
+ this.os = os;
+ return this;
+ }
+
+ public OSImageParams build() {
+ return OSImageParams.create(name, label, mediaLink, os);
+ }
+
+ public Builder fromImageParams(OSImageParams in) {
+ return name(in.name())
+ .label(in.label())
+ .mediaLink(in.mediaLink())
+ .os(in.os());
+ }
+ }
+
+ private static OSImageParams create(String name, String label, URI mediaLink, OSImage.Type os) {
+ return new OSImageParams(name, label, mediaLink, os);
+ }
+
+ // TODO: Remove from here down with @AutoValue.
+ private OSImageParams(String name, String label, URI mediaLink, OSImage.Type os) {
+ this.name = checkNotNull(name, "name");
+ this.label = checkNotNull(label, "label");
+ this.mediaLink = checkNotNull(mediaLink, "mediaLink");
+ this.os = checkNotNull(os, "os");
+ }
+
+ private final String name;
+ private final String label;
+ private final URI mediaLink;
+ private final OSImage.Type os;
+
+ @Override public int hashCode() {
+ return Objects.hashCode(name, label, mediaLink, os);
+ }
+
+ @Override public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof OSImageParams) {
+ OSImageParams that = OSImageParams.class.cast(object);
+ return equal(name, that.name)
+ && equal(label, that.label)
+ && equal(mediaLink, that.mediaLink)
+ && equal(os, that.os);
+ } else {
+ return false;
+ }
+ }
+
+ @Override public String toString() {
+ return toStringHelper(this)
+ .add("name", name)
+ .add("label", label)
+ .add("mediaLink", mediaLink)
+ .add("os", os).toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/features/DiskApi.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/DiskApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/DiskApi.java
index 1d43707..4390524 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/DiskApi.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/features/DiskApi.java
@@ -16,7 +16,11 @@
*/
package org.jclouds.azurecompute.features;
+import static org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
+import static org.jclouds.Fallbacks.NullOnNotFoundOr404;
+
import java.util.List;
+
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
@@ -24,6 +28,7 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
+
import org.jclouds.azurecompute.domain.Disk;
import org.jclouds.azurecompute.functions.ParseRequestIdHeader;
import org.jclouds.azurecompute.xml.ListDisksHandler;
@@ -32,9 +37,6 @@ import org.jclouds.rest.annotations.Headers;
import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.XMLResponseParser;
-import static org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
-import static org.jclouds.Fallbacks.NullOnNotFoundOr404;
-
/**
* The Service Management API includes operations for managing the disks in your subscription.
*
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/features/ImageApi.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/ImageApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/ImageApi.java
deleted file mode 100644
index 3ca54c3..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/ImageApi.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.jclouds.azurecompute.features;
-
-import static javax.ws.rs.core.MediaType.APPLICATION_XML;
-import static org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
-import static org.jclouds.Fallbacks.NullOnNotFoundOr404;
-
-import java.util.List;
-
-import javax.inject.Named;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-
-import org.jclouds.azurecompute.binders.ImageParamsToXML;
-import org.jclouds.azurecompute.domain.Image;
-import org.jclouds.azurecompute.domain.ImageParams;
-import org.jclouds.azurecompute.functions.ImageParamsName;
-import org.jclouds.azurecompute.functions.ParseRequestIdHeader;
-import org.jclouds.azurecompute.xml.ListImagesHandler;
-import org.jclouds.rest.annotations.BinderParam;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.Headers;
-import org.jclouds.rest.annotations.ParamParser;
-import org.jclouds.rest.annotations.ResponseParser;
-import org.jclouds.rest.annotations.XMLResponseParser;
-
-/**
- * The Service Management API includes operations for managing the OS images in your subscription.
- *
- * @see <a href="http://msdn.microsoft.com/en-us/library/jj157175">docs</a>
- */
-@Path("/services/images")
-@Headers(keys = "x-ms-version", values = "{jclouds.api-version}")
-@Consumes(APPLICATION_XML)
-public interface ImageApi {
-
- /**
- * The List Cloud Services operation lists the cloud services available under the current
- * subscription.
- */
- @Named("ListImages")
- @GET
- @XMLResponseParser(ListImagesHandler.class)
- @Fallback(EmptyListOnNotFoundOr404.class)
- List<Image> list();
-
- /**
- * The Add OS Image operation adds an OS image that is currently stored in a storage account in your subscription to
- * the image repository.
- */
- @Named("AddImage")
- @POST
- @Produces(APPLICATION_XML)
- @ResponseParser(ParseRequestIdHeader.class)
- String add(@BinderParam(ImageParamsToXML.class) ImageParams params);
-
- /**
- * The Update OS Image operation updates an OS image that in your image repository.
- */
- @Named("UpdateImage")
- @PUT
- @Path("/{imageName}")
- @Produces(APPLICATION_XML)
- @ResponseParser(ParseRequestIdHeader.class)
- String update(@PathParam("imageName") @ParamParser(ImageParamsName.class)
- @BinderParam(ImageParamsToXML.class) ImageParams params);
-
- /**
- * The Delete Cloud Service operation deletes the specified cloud service from Windows Azure.
- *
- * @param imageName
- * the unique DNS Prefix value in the Windows Azure Management Portal
- */
- @Named("DeleteImage")
- @DELETE
- @Path("/{imageName}")
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(ParseRequestIdHeader.class)
- String delete(@PathParam("imageName") String imageName);
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/features/LocationApi.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/LocationApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/LocationApi.java
index 2a77e68..0ef5ee0 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/LocationApi.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/features/LocationApi.java
@@ -16,20 +16,22 @@
*/
package org.jclouds.azurecompute.features;
+import static org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
+
import java.util.List;
+
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType;
+
import org.jclouds.azurecompute.domain.Location;
import org.jclouds.azurecompute.xml.ListLocationsHandler;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.Headers;
import org.jclouds.rest.annotations.XMLResponseParser;
-import static org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
-
/**
* The Service Management API includes operations for listing the available data center locations
* for a cloud service in your subscription.
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/features/OSImageApi.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/OSImageApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/OSImageApi.java
new file mode 100644
index 0000000..42c58a0
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/features/OSImageApi.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.jclouds.azurecompute.features;
+
+import static javax.ws.rs.core.MediaType.APPLICATION_XML;
+import static org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
+import static org.jclouds.Fallbacks.NullOnNotFoundOr404;
+
+import java.util.List;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+
+import org.jclouds.azurecompute.binders.OSImageParamsToXML;
+import org.jclouds.azurecompute.domain.OSImage;
+import org.jclouds.azurecompute.domain.OSImageParams;
+import org.jclouds.azurecompute.functions.OSImageParamsName;
+import org.jclouds.azurecompute.functions.ParseRequestIdHeader;
+import org.jclouds.azurecompute.xml.ListOSImagesHandler;
+import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.Headers;
+import org.jclouds.rest.annotations.ParamParser;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.XMLResponseParser;
+
+/**
+ * The Service Management API includes operations for managing the OS images in your subscription.
+ *
+ * @see <a href="http://msdn.microsoft.com/en-us/library/jj157175">docs</a>
+ */
+@Path("/services/images")
+@Headers(keys = "x-ms-version", values = "{jclouds.api-version}")
+@Consumes(APPLICATION_XML)
+public interface OSImageApi {
+
+ /**
+ * The List Cloud Services operation lists the cloud services available under the current
+ * subscription.
+ */
+ @Named("ListImages")
+ @GET
+ @XMLResponseParser(ListOSImagesHandler.class)
+ @Fallback(EmptyListOnNotFoundOr404.class)
+ List<OSImage> list();
+
+ /**
+ * The Add OS Image operation adds an OS image that is currently stored in a storage account in your subscription to
+ * the image repository.
+ */
+ @Named("AddImage")
+ @POST
+ @Produces(APPLICATION_XML)
+ @ResponseParser(ParseRequestIdHeader.class)
+ String add(@BinderParam(OSImageParamsToXML.class) OSImageParams params);
+
+ /**
+ * The Update OS Image operation updates an OS image that in your image repository.
+ */
+ @Named("UpdateImage")
+ @PUT
+ @Path("/{imageName}")
+ @Produces(APPLICATION_XML)
+ @ResponseParser(ParseRequestIdHeader.class)
+ String update(@PathParam("imageName") @ParamParser(OSImageParamsName.class)
+ @BinderParam(OSImageParamsToXML.class) OSImageParams params);
+
+ /**
+ * The Delete Cloud Service operation deletes the specified cloud service from Windows Azure.
+ *
+ * @param imageName
+ * the unique DNS Prefix value in the Windows Azure Management Portal
+ */
+ @Named("DeleteImage")
+ @DELETE
+ @Path("/{imageName}")
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(ParseRequestIdHeader.class)
+ String delete(@PathParam("imageName") String imageName);
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/features/OperationApi.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/OperationApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/OperationApi.java
index 5ee97a6..ac4092b 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/OperationApi.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/features/OperationApi.java
@@ -16,20 +16,21 @@
*/
package org.jclouds.azurecompute.features;
+import static org.jclouds.Fallbacks.NullOnNotFoundOr404;
+
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
+
import org.jclouds.azurecompute.domain.Operation;
import org.jclouds.azurecompute.xml.OperationHandler;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.Headers;
import org.jclouds.rest.annotations.XMLResponseParser;
-import static org.jclouds.Fallbacks.NullOnNotFoundOr404;
-
/**
* The Service Management API includes one operation for tracking the progress of asynchronous requests.
*
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/features/VirtualMachineApi.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/VirtualMachineApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/VirtualMachineApi.java
index 5067029..9f54ed0 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/VirtualMachineApi.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/features/VirtualMachineApi.java
@@ -23,6 +23,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
+
import org.jclouds.azurecompute.functions.ParseRequestIdHeader;
import org.jclouds.rest.annotations.Headers;
import org.jclouds.rest.annotations.Payload;
@@ -48,7 +49,7 @@ public interface VirtualMachineApi {
@Path("/{name}/Operations")
@Produces(MediaType.APPLICATION_XML)
@ResponseParser(ParseRequestIdHeader.class)
- @Payload(value = "<RestartRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><OperationType>RestartRoleOperation</OperationType></RestartRoleOperation>")
+ @Payload(value = "<RestartRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\"><OperationType>RestartRoleOperation</OperationType></RestartRoleOperation>")
String restart(@PathParam("name") String name);
/**
@@ -59,7 +60,7 @@ public interface VirtualMachineApi {
@Path("/{name}/Operations")
@Produces(MediaType.APPLICATION_XML)
@ResponseParser(ParseRequestIdHeader.class)
- @Payload(value = "<CaptureRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><OperationType>CaptureRoleOperation</OperationType><PostCaptureAction>Delete</PostCaptureAction><TargetImageLabel>{imageLabel}</TargetImageLabel><TargetImageName>{imageName}</TargetImageName></CaptureRoleOperation>")
+ @Payload(value = "<CaptureRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\"><OperationType>CaptureRoleOperation</OperationType><PostCaptureAction>Delete</PostCaptureAction><TargetImageLabel>{imageLabel}</TargetImageLabel><TargetImageName>{imageName}</TargetImageName></CaptureRoleOperation>")
String capture(@PathParam("name") String name, @PayloadParam("imageName") String imageName,
@PayloadParam("imageLabel") String imageLabel);
@@ -71,7 +72,7 @@ public interface VirtualMachineApi {
@Path("/{name}/Operations")
@Produces(MediaType.APPLICATION_XML)
@ResponseParser(ParseRequestIdHeader.class)
- @Payload(value = "<ShutdownRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><OperationType>ShutdownRoleOperation</OperationType></ShutdownRoleOperation>")
+ @Payload(value = "<ShutdownRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\"><OperationType>ShutdownRoleOperation</OperationType></ShutdownRoleOperation>")
String shutdown(@PathParam("name") String name);
/**
@@ -82,6 +83,6 @@ public interface VirtualMachineApi {
@Path("/{name}/Operations")
@Produces(MediaType.APPLICATION_XML)
@ResponseParser(ParseRequestIdHeader.class)
- @Payload(value = "<StartRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><OperationType>StartRoleOperation</OperationType></StartRoleOperation>")
+ @Payload(value = "<StartRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\"><OperationType>StartRoleOperation</OperationType></StartRoleOperation>")
String start(@PathParam("name") String name);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ImageParamsName.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ImageParamsName.java b/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ImageParamsName.java
deleted file mode 100644
index 3b2c458..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ImageParamsName.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.jclouds.azurecompute.functions;
-
-import org.jclouds.azurecompute.domain.ImageParams;
-
-import com.google.common.base.Function;
-
-public class ImageParamsName implements Function<Object, String> {
- @Override public String apply(Object input) {
- return ImageParams.class.cast(input).name();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/functions/OSImageParamsName.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/functions/OSImageParamsName.java b/azurecompute/src/main/java/org/jclouds/azurecompute/functions/OSImageParamsName.java
new file mode 100644
index 0000000..7b962e7
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/functions/OSImageParamsName.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.jclouds.azurecompute.functions;
+
+import org.jclouds.azurecompute.domain.OSImageParams;
+
+import com.google.common.base.Function;
+
+public class OSImageParamsName implements Function<Object, String> {
+ @Override public String apply(Object input) {
+ return OSImageParams.class.cast(input).name();
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ParseRequestIdHeader.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ParseRequestIdHeader.java b/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ParseRequestIdHeader.java
index 2a0d5aa..db229be 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ParseRequestIdHeader.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ParseRequestIdHeader.java
@@ -16,11 +16,13 @@
*/
package org.jclouds.azurecompute.functions;
-import com.google.common.base.Function;
+import static org.jclouds.http.HttpUtils.releasePayload;
+
import javax.inject.Singleton;
+
import org.jclouds.http.HttpResponse;
-import static org.jclouds.http.HttpUtils.releasePayload;
+import com.google.common.base.Function;
/**
* Parses an x-ms-request-id the header
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/KeyStoreSupplier.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/KeyStoreSupplier.java b/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/KeyStoreSupplier.java
index d4955e1..d90bd16 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/KeyStoreSupplier.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/KeyStoreSupplier.java
@@ -16,9 +16,9 @@
*/
package org.jclouds.azurecompute.suppliers;
-import com.google.common.base.Charsets;
-import com.google.common.base.Supplier;
-import com.google.common.io.ByteSource;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Throwables.propagate;
+
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -34,15 +34,18 @@ import java.security.cert.CertificateFactory;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;
import java.util.Collection;
+
import javax.inject.Inject;
import javax.inject.Singleton;
+
import org.jclouds.crypto.Crypto;
import org.jclouds.crypto.Pems;
import org.jclouds.domain.Credentials;
import org.jclouds.location.Provider;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Throwables.propagate;
+import com.google.common.base.Charsets;
+import com.google.common.base.Supplier;
+import com.google.common.io.ByteSource;
/**
* TODO this code needs to be completely refactored. It needs to stop using KeyStore of at all possible and definitely
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/SSLContextWithKeysSupplier.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/SSLContextWithKeysSupplier.java b/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/SSLContextWithKeysSupplier.java
index 1936bf8..da9a2a3 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/SSLContextWithKeysSupplier.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/SSLContextWithKeysSupplier.java
@@ -16,25 +16,28 @@
*/
package org.jclouds.azurecompute.suppliers;
-import com.google.common.base.Supplier;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Throwables.propagate;
+
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.UnrecoverableKeyException;
+
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
+
import org.jclouds.domain.Credentials;
import org.jclouds.http.HttpUtils;
import org.jclouds.http.config.SSLModule.TrustAllCerts;
import org.jclouds.location.Provider;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Throwables.propagate;
+import com.google.common.base.Supplier;
/**
* TODO this code needs to be completely refactored. It needs to stop using KeyStore of at all possible and definitely
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DiskHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DiskHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DiskHandler.java
index 3792527..b3ae8c2 100644
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DiskHandler.java
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DiskHandler.java
@@ -22,7 +22,7 @@ import java.net.URI;
import org.jclouds.azurecompute.domain.Disk;
import org.jclouds.azurecompute.domain.Disk.Attachment;
-import org.jclouds.azurecompute.domain.Image.OSType;
+import org.jclouds.azurecompute.domain.OSImage;
import org.jclouds.http.functions.ParseSax;
import org.xml.sax.Attributes;
@@ -34,7 +34,7 @@ final class DiskHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Di
private String location;
private String affinityGroup;
private String description;
- private OSType os;
+ private OSImage.Type os;
private URI mediaLink;
private Integer logicalSizeInGB;
private Attachment attachedTo;
@@ -74,7 +74,7 @@ final class DiskHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Di
} else if (qName.equals("OS")) {
String osText = currentOrNull(currentText);
if (osText != null) {
- os = OSType.valueOf(currentOrNull(currentText).toUpperCase());
+ os = OSImage.Type.valueOf(currentOrNull(currentText).toUpperCase());
}
} else if (qName.equals("Name")) {
name = currentOrNull(currentText);
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ImageHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ImageHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ImageHandler.java
deleted file mode 100644
index f13dd5d..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ImageHandler.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.jclouds.azurecompute.xml;
-
-import static com.google.common.base.Strings.emptyToNull;
-import static org.jclouds.util.SaxUtils.currentOrNull;
-
-import java.net.URI;
-import java.util.List;
-
-import org.jclouds.azurecompute.domain.Image;
-import org.jclouds.azurecompute.domain.Image.OSType;
-import org.jclouds.http.functions.ParseSax;
-
-import com.google.common.base.Splitter;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-
-/**
- * @see <a href="http://msdn.microsoft.com/en-us/library/jj157191" >api</a>
- */
-final class ImageHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Image> {
- private String name;
- private String location;
- private String affinityGroup;
- private String label;
- private String category;
- private String description;
- private OSType os;
- private URI mediaLink;
- private Integer logicalSizeInGB;
- private final List<String> eula = Lists.newArrayList();
-
- private final StringBuilder currentText = new StringBuilder();
-
- @Override public Image getResult() {
- Image result = Image.create(name, location, affinityGroup, label, description, category, os, mediaLink,
- logicalSizeInGB, ImmutableList.copyOf(eula));
- resetState(); // handler is called in a loop.
- return result;
- }
-
- private void resetState() {
- name = location = affinityGroup = label = description = category = null;
- os = null;
- mediaLink = null;
- logicalSizeInGB = null;
- eula.clear();
- }
-
- @Override public void endElement(String ignoredUri, String ignoredName, String qName) {
- if (qName.equals("OS")) {
- String osText = currentOrNull(currentText);
- if (osText != null) {
- os = OSType.valueOf(currentOrNull(currentText).toUpperCase());
- }
- } else if (qName.equals("Name")) {
- name = currentOrNull(currentText);
- } else if (qName.equals("LogicalSizeInGB")) {
- String gb = currentOrNull(currentText);
- if (gb != null) {
- logicalSizeInGB = Integer.parseInt(gb);
- }
- } else if (qName.equals("Description")) {
- description = currentOrNull(currentText);
- } else if (qName.equals("Category")) {
- category = currentOrNull(currentText);
- } else if (qName.equals("Location")) {
- location = currentOrNull(currentText);
- } else if (qName.equals("AffinityGroup")) {
- affinityGroup = currentOrNull(currentText);
- } else if (qName.equals("MediaLink")) {
- String link = currentOrNull(currentText);
- if (link != null) {
- mediaLink = URI.create(link);
- }
- } else if (qName.equals("Eula")) {
- String eulaField = currentOrNull(currentText);
- if (eulaField != null) {
- for (String eula : Splitter.on(';').split(eulaField)) {
- if ((eula = emptyToNull(eula.trim())) != null) { // Dirty data in RightScale eula field.
- this.eula.add(eula);
- }
- }
- }
- } else if (qName.equals("Label")) {
- label = currentOrNull(currentText);
- }
- currentText.setLength(0);
- }
-
- @Override public void characters(char ch[], int start, int length) {
- currentText.append(ch, start, length);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7f307e85/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListImagesHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListImagesHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListImagesHandler.java
deleted file mode 100644
index f220f8c..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListImagesHandler.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.jclouds.azurecompute.xml;
-
-import java.util.List;
-
-import org.jclouds.azurecompute.domain.Image;
-import org.jclouds.http.functions.ParseSax;
-import org.xml.sax.Attributes;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableList.Builder;
-
-public final class ListImagesHandler extends ParseSax.HandlerForGeneratedRequestWithResult<List<Image>> {
- private boolean inOSImage;
- private final ImageHandler imageHandler = new ImageHandler();
- private final Builder<Image> images = ImmutableList.builder();
-
- @Override
- public List<Image> getResult() {
- return images.build();
- }
-
- @Override
- public void startElement(String url, String name, String qName, Attributes attributes) {
- if (qName.equals("OSImage")) {
- inOSImage = true;
- }
- }
-
- @Override
- public void endElement(String uri, String name, String qName) {
- if (qName.equals("OSImage")) {
- inOSImage = false;
- images.add(imageHandler.getResult());
- } else if (inOSImage) {
- imageHandler.endElement(uri, name, qName);
- }
- }
-
- @Override
- public void characters(char ch[], int start, int length) {
- if (inOSImage) {
- imageHandler.characters(ch, start, length);
- }
- }
-}